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 <[email protected]>
* 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.
--
Eric Botcazou
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;
}