Patchwork Fix PR ada/46192

login
register
mail settings
Submitter Eric Botcazou
Date Jan. 21, 2012, 3:02 p.m.
Message ID <201201211602.17915.ebotcazou@adacore.com>
Download mbox | patch
Permalink /patch/137191/
State New
Headers show

Comments

Eric Botcazou - Jan. 21, 2012, 3:02 p.m.
This is a regression present since the 4.5.x series at least.  We generate 
wrong code (infinite loop for the testcase) for the renaming of a volatile 
packed array with an address clause.

Tested on i586-suse-linux, applied on the trunk, 4.6 and 4.5 branches.


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-21  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/renaming5.ad[sb]: New test.

Patch

Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c	(revision 183348)
+++ gcc-interface/decl.c	(working copy)
@@ -1051,6 +1051,14 @@  gnat_to_gnu_entity (Entity_Id gnat_entit
 		   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;