re PR ada/46192 (wrong code for renaming of volatile packed array with address clause)
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 21 Jan 2012 14:58:33 +0000 (14:58 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 21 Jan 2012 14:58:33 +0000 (14:58 +0000)
PR ada/46192
* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: In the case of a
renaming, preserve the volatileness through the indirection, if any.

From-SVN: r183365

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

index 1960e1a7185819e07a1ef47c1ddbb9a15c981096..a961439b0dff62a10443000632bbe02f156fddd6 100644 (file)
@@ -1,3 +1,9 @@
+2012-01-21  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR ada/46192
+       * gcc-interface/decl.c (gnat_to_gnu_entity) <object>: In the case of a
+       renaming, preserve the volatileness through the indirection, if any.
+
 2012-01-14  Andreas Schwab  <schwab@linux-m68k.org>
 
        * gcc-interface/Makefile.in (OSCONS_EXTRACT): Add
index 89a6a2ea2cc236a5af6db2f3922054d9d48cc87f..9d81ade1fe1c63787390d4f17975b89122c61936 100644 (file)
@@ -1051,6 +1051,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
                   entity is always accessed indirectly through it.  */
                else
                  {
+                   /* We need to preserve the volatileness of the renamed
+                      object through the indirection.  */
+                   if (TREE_THIS_VOLATILE (gnu_expr)
+                       && !TYPE_VOLATILE (gnu_type))
+                     gnu_type
+                       = build_qualified_type (gnu_type,
+                                               (TYPE_QUALS (gnu_type)
+                                                | TYPE_QUAL_VOLATILE));
                    gnu_type = build_reference_type (gnu_type);
                    inner_const_flag = TREE_READONLY (gnu_expr);
                    const_flag = true;
index dee0f804126ecf9c58e949d324a7f7935040fd26..7d3d095905320b80be8d45641c1bf0af39d6ddc6 100644 (file)
@@ -1,3 +1,7 @@
+2012-01-21  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/renaming5.ad[sb]: New test.
+
 2012-01-20  Jason Merrill  <jason@redhat.com>
 
        PR c++/51919
diff --git a/gcc/testsuite/gnat.dg/renaming5.adb b/gcc/testsuite/gnat.dg/renaming5.adb
new file mode 100644 (file)
index 0000000..25374fe
--- /dev/null
@@ -0,0 +1,30 @@
+-- PR ada/46192
+-- Testcase by Rolf Ebert <rolf.ebert.gcc@gmx.de>
+
+-- { dg-do compile }
+-- { dg-options "-O2 -fdump-tree-optimized" }
+
+with System; use System;
+
+package body Renaming5 is
+
+   type Bits_In_Byte is array (0 .. 7) of Boolean;
+   pragma Pack (Bits_In_Byte);
+
+   A : Bits_In_Byte;
+   for A'Address use System'To_Address(16#c0#);
+   pragma Volatile (A);
+
+   B : Bits_In_Byte renames A;
+
+   procedure Proc is
+   begin
+      while B (0) = False loop
+         null;
+      end loop;
+   end;
+
+end Renaming5;
+
+-- { dg-final { scan-tree-dump-times "goto" 2 "optimized" } }
+-- { dg-final { cleanup-tree-dump "optimized" } }
diff --git a/gcc/testsuite/gnat.dg/renaming5.ads b/gcc/testsuite/gnat.dg/renaming5.ads
new file mode 100644 (file)
index 0000000..2b39663
--- /dev/null
@@ -0,0 +1,5 @@
+package Renaming5 is
+
+   procedure Proc;
+
+end Renaming5;