decl.c (gnat_to_gnu_entity): Always take into account the Esize if it is known.
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 21 Dec 2017 22:02:45 +0000 (22:02 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 21 Dec 2017 22:02:45 +0000 (22:02 +0000)
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Always take
into account the Esize if it is known.

From-SVN: r255958

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/atomic9.adb [new file with mode: 0644]

index 13a0c80e43171238489f6c2aa02177cf2748021b..c95d1fc3cae2df0dca270be19680d744eb569c1b 100644 (file)
@@ -1,3 +1,8 @@
+2017-12-21  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Always take
+       into account the Esize if it is known.
+
 2017-12-21  Richard Sandiford  <richard.sandiford@linaro.org>
            Alan Hayward  <alan.hayward@arm.com>
            David Sherwood  <david.sherwood@arm.com>
index 20d35f3a5dc1bfa3e8447d100f9d83ad5dd56423..ab5fb0e1a5581e9dea7940970380bbc17b6c0a72 100644 (file)
@@ -723,7 +723,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
                                      TYPE_ALIGN (gnu_type));
 
        /* Likewise, if a size is specified, use it if valid.  */
-       if (Known_Esize (gnat_entity) && No (Address_Clause (gnat_entity)))
+       if (Known_Esize (gnat_entity))
          gnu_size
            = validate_size (Esize (gnat_entity), gnu_type, gnat_entity,
                             VAR_DECL, false, Has_Size_Clause (gnat_entity));
index 35752574666d6846cdeec66ca4017ed91dc202e7..a93c0ddf292ceaf7b56d2dfb066853a189547ee5 100644 (file)
@@ -1,3 +1,7 @@
+2017-12-21  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/atomic9.adb: New test.
+
 2017-12-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/80747
diff --git a/gcc/testsuite/gnat.dg/atomic9.adb b/gcc/testsuite/gnat.dg/atomic9.adb
new file mode 100644 (file)
index 0000000..1dab33c
--- /dev/null
@@ -0,0 +1,29 @@
+-- { dg-do compile }
+-- { dg-options "-fdump-tree-gimple" }
+
+with Interfaces;
+
+procedure Atomic9 is
+
+   Register : Interfaces.Unsigned_32;
+
+   type Interrupt_ID is range 0 .. 44;
+
+   procedure Trigger_Interrupt (IRQ : Interrupt_ID) is
+      NVIC_STIR : Interrupt_ID
+      with
+        Import,
+        Atomic,
+        Size    => 32,
+        Address => Register'Address;
+
+   begin
+      NVIC_STIR := IRQ;
+   end Trigger_Interrupt;
+
+begin
+   Register := 16#ffff_ffff#;
+   Trigger_Interrupt (1);
+end;
+
+-- { dg-final { scan-tree-dump "atomic_store_4" "gimple" } }