Patchwork [Ada] Do not set TREE_THIS_NOTRAP with address clause

login
register
mail settings
Submitter Eric Botcazou
Date June 18, 2011, 10:24 a.m.
Message ID <201106181224.06904.ebotcazou@adacore.com>
Download mbox | patch
Permalink /patch/100912/
State New
Headers show

Comments

Eric Botcazou - June 18, 2011, 10:24 a.m.
If an object has an address clause, it is handled indirectly, i.e. replaced 
with a pointer initialized to the address.  We were putting TREE_THIS_NOTRAP 
on the dereferences built to retrieve the real object from the pointer, but 
this is problematic if the address is invalid, as this means that we cannot 
properly raise the exception.

Tested on i586-suse-linux, applied on the mainline and 4.6 branch.


2011-06-18  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (Identifier_to_gnu): Don't set TREE_THIS_NOTRAP
	on a dereference built for a by-ref object if it has an address clause.

Patch

Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 175171)
+++ gcc-interface/trans.c	(working copy)
@@ -1018,7 +1018,8 @@  Identifier_to_gnu (Node_Id gnat_node, tr
       else
 	{
 	  gnu_result = build_unary_op (INDIRECT_REF, NULL_TREE, gnu_result);
-	  if (TREE_CODE (gnu_result) == INDIRECT_REF)
+	  if (TREE_CODE (gnu_result) == INDIRECT_REF
+	      && No (Address_Clause (gnat_temp)))
 	    TREE_THIS_NOTRAP (gnu_result) = 1;
 	}