diff mbox series

[Ada] Fix ICE on multi-dimensional array

Message ID 8455722.vByhrAPZx7@polaris
State New
Headers show
Series [Ada] Fix ICE on multi-dimensional array | expand

Commit Message

Eric Botcazou Sept. 5, 2017, 8:22 a.m. UTC
This is a regression present on the mainline, 7 and 6 branches, in the form of 
an ICE during tree-sra, which is confused by an unconstrained array type.

Tested on x86_64-suse-linux, applied on mainline, 7 and 6 branches.


2017-09-05  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (pos_to_constructor): Skip conversions to an
	unconstrained array type.


2017-09-05  Eric Botcazou  <ebotcazou@adacore.com>

	* testsuite/gnat.dg/array29.ad[sb]: New test.
diff mbox series

Patch

Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 251553)
+++ gcc-interface/trans.c	(working copy)
@@ -9826,7 +9826,14 @@  pos_to_constructor (Node_Id gnat_expr, t
 				       gnat_component_type);
       else
 	{
-	  gnu_expr = gnat_to_gnu (gnat_expr);
+	  /* If the expression is a conversion to an unconstrained array type,
+	     skip it to avoid spilling to memory.  */
+	  if (Nkind (gnat_expr) == N_Type_Conversion
+	      && Is_Array_Type (Etype (gnat_expr))
+	      && !Is_Constrained (Etype (gnat_expr)))
+	    gnu_expr = gnat_to_gnu (Expression (gnat_expr));
+	  else
+	    gnu_expr = gnat_to_gnu (gnat_expr);
 
 	  /* Before assigning the element to the array, make sure it is
 	     in range.  */