Commit babf697a by Eric Botcazou Committed by Eric Botcazou

trans.c (pos_to_constructor): Skip conversions to an unconstrained array type.

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

From-SVN: r251691
parent 02e637d8
2017-09-05 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (pos_to_constructor): Skip conversions to an
unconstrained array type.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
......
......@@ -9826,7 +9826,14 @@ pos_to_constructor (Node_Id gnat_expr, tree gnu_array_type,
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. */
......
2017-09-05 Eric Botcazou <ebotcazou@adacore.com>
* testsuite/gnat.dg/array29.ad[sb]: New test.
2017-09-05 Martin Liska <mliska@suse.cz>
PR tree-optimization/82032
......
-- { dg-do compile }
-- { dg-options "-O" }
package body Array29 is
procedure Copy (Src : in Matrix; Dst : out Matrix) is
begin
for I in Src'Range (1) loop
for J in Src'Range (2) loop
Dst (I, J) := Src (I, J);
end loop;
end loop;
end;
procedure Proc is
N : constant := 2;
FM1 : constant Matrix (1 .. N, 1 .. N) := ((1.0, 2.0), (3.0, 4.0));
FM2 : constant Matrix (1 .. N, 1 .. N) := ((1.0, 2.0), (3.0, 4.0));
A : constant array (1 .. 2) of Matrix (1 .. N, 1 .. N)
:= (Matrix (FM1), Matrix (FM2));
Final : Matrix (1 .. N, 1 .. N);
begin
Copy (Src => A (1), Dst => Final);
end;
end Array29;
package Array29 is
type Matrix is array (Integer range <>, Integer range <>) of Long_Float;
procedure Proc;
end Array29;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment