From ad1d36bafd1f18e33bd03169af788c6467f09c4d Mon Sep 17 00:00:00 2001
From: Eric Botcazou <ebotcazou@adacore.com>
Date: Sun, 25 Sep 2011 20:40:10 +0000
Subject: ada-tree.h (TREE_THIS_NOTRAP): Redefine.

	* gcc-interface/ada-tree.h (TREE_THIS_NOTRAP): Redefine.
	* gcc-interface/trans.c (Identifier_to_gnu): Factor out common code in
	the by-ref case.  Do not set TREE_READONLY on a renamed object.  Set
	TREE_THIS_NOTRAP on UNCONSTRAINED_ARRAY_REF nodes.
	(Attribute_to_gnu) <Attr_Length>: Expand the use of the parameter cache
	to the indirect case.
	* gcc-interface/utils.c (convert) <UNCONSTRAINED_ARRAY_REF>: Preserve
	the TREE_THIS_NOTRAP flag.

From-SVN: r179171
---
 gcc/ada/gcc-interface/utils.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

(limited to 'gcc/ada/gcc-interface/utils.c')

diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 0176c3e..de9256a 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -3947,17 +3947,21 @@ convert (tree type, tree expr)
       break;
 
     case UNCONSTRAINED_ARRAY_REF:
-      /* Convert this to the type of the inner array by getting the address of
-	 the array from the template.  */
-      expr = TREE_OPERAND (expr, 0);
-      expr = build_unary_op (INDIRECT_REF, NULL_TREE,
-			     build_component_ref (expr, NULL_TREE,
-						  TYPE_FIELDS
-						  (TREE_TYPE (expr)),
-						  false));
-      etype = TREE_TYPE (expr);
-      ecode = TREE_CODE (etype);
-      break;
+      {
+	/* Convert this to the type of the inner array by getting the address
+	   of the array from the template.  */
+	const bool no_trap = TREE_THIS_NOTRAP (expr);
+	expr = TREE_OPERAND (expr, 0);
+	expr = build_unary_op (INDIRECT_REF, NULL_TREE,
+			       build_component_ref (expr, NULL_TREE,
+						    TYPE_FIELDS
+						    (TREE_TYPE (expr)),
+						    false));
+	TREE_THIS_NOTRAP (expr) = no_trap;
+	etype = TREE_TYPE (expr);
+	ecode = TREE_CODE (etype);
+	break;
+      }
 
     case VIEW_CONVERT_EXPR:
       {
@@ -3992,8 +3996,9 @@ convert (tree type, tree expr)
 		     && !TYPE_IS_FAT_POINTER_P (etype))
 	      return convert (type, op0);
 	  }
+
+	break;
       }
-      break;
 
     default:
       break;
-- 
cgit v1.1