diff mbox

[Ada] Fix ICE on array type with aggregate component as bound

Message ID 201104082221.43317.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou April 8, 2011, 8:21 p.m. UTC
The compiler aborts on the declaration of an array type whose upper bound is a
component of an aggregate whose nominal subtype is a discriminated record type 
which contains a component whose nominal subtype is a volatile discriminated 
record type with a variant part and a size clause.

Tested on i586-suse-linux, applied on the mainline.


2011-04-08  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (Identifier_to_gnu): Do not return initializers
	of aggregate types that contain a placeholder.


2011-04-08  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/aggr17.adb: New test.
	* gnat.dg/aggr18.adb: Likewise.
diff mbox

Patch

Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 172166)
+++ gcc-interface/trans.c	(working copy)
@@ -1058,10 +1058,14 @@  Identifier_to_gnu (Node_Id gnat_node, tr
 
   /* If we have a constant declaration and its initializer, try to return the
      latter to avoid the need to call fold in lots of places and the need for
-     elaboration code if this identifier is used as an initializer itself.  */
+     elaboration code if this identifier is used as an initializer itself.
+     Don't do it for aggregate types that contain a placeholder since their
+     initializers cannot be manipulated easily.  */
   if (TREE_CONSTANT (gnu_result)
       && DECL_P (gnu_result)
-      && DECL_INITIAL (gnu_result))
+      && DECL_INITIAL (gnu_result)
+      && !(AGGREGATE_TYPE_P (TREE_TYPE (gnu_result))
+	   && type_contains_placeholder_p (TREE_TYPE (gnu_result))))
     {
       bool constant_only = (TREE_CODE (gnu_result) == CONST_DECL
 			    && !DECL_CONST_CORRESPONDING_VAR (gnu_result));