From: Eric Botcazou Date: Sat, 21 Jan 2012 15:04:25 +0000 (+0000) Subject: re PR ada/46192 (wrong code for renaming of volatile packed array with address clause) X-Git-Tag: releases/gcc-4.5.4~258 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1845b7cc02ec35915febb2232a795fc2e66a7f52;p=thirdparty%2Fgcc.git re PR ada/46192 (wrong code for renaming of volatile packed array with address clause) PR ada/46192 * gcc-interface/decl.c (gnat_to_gnu_entity) : In the case of a renaming, preserve the volatileness through the indirection, if any. From-SVN: r183367 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index c9bca727e143..d80ac672a290 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2012-01-21 Eric Botcazou + + PR ada/46192 + * gcc-interface/decl.c (gnat_to_gnu_entity) : In the case of a + renaming, preserve the volatileness through the indirection, if any. + 2012-01-09 Eric Botcazou * gcc-interface/trans.c (addressable_p) : Fix thinko. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 6d7fa13fde1b..b9971248cb0f 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -942,6 +942,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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b7e0e69e9511..b606a2604b00 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2012-01-21 Eric Botcazou + + * gnat.dg/renaming5.ad[sb]: New test. + 2012-01-20 Kai Tietz * g++.dg/torture/pr51344.C: Fix typo. diff --git a/gcc/testsuite/gnat.dg/renaming5.adb b/gcc/testsuite/gnat.dg/renaming5.adb new file mode 100644 index 000000000000..25374fe895c9 --- /dev/null +++ b/gcc/testsuite/gnat.dg/renaming5.adb @@ -0,0 +1,30 @@ +-- PR ada/46192 +-- Testcase by Rolf Ebert + +-- { 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 index 000000000000..2b39663ad42c --- /dev/null +++ b/gcc/testsuite/gnat.dg/renaming5.ads @@ -0,0 +1,5 @@ +package Renaming5 is + + procedure Proc; + +end Renaming5;