Commit 78326189 by Eric Botcazou Committed by Pierre-Marie de Rodat

[Ada] Plug small loophole with pathological packed array type

This fixes a crash in gigi on a pathological packed array type, whose
component type is a record type without representation clause or packing
but with a clause that bumps its size to a non-multiple value of the
storage unit.  In this case, the front-end fails to detect that calls
to the packing manpulation routines of the run time are necessary.

The fix doesn't change anything for non-pathological cases, i.e. when
the component type has a representation clause or is packed.

2018-12-11  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* exp_aggr.adb (Packed_Array_Aggregate_Handled): Bail out for
	any non-scalar type as component type of the array.

gcc/testsuite/

	* gnat.dg/packed_array.adb, gnat.dg/packed_array.ads,
	gnat.dg/packed_array_pkg.ads: New testcase.

From-SVN: r267006
parent 6186a6ef
2018-12-11 Eric Botcazou <ebotcazou@adacore.com> 2018-12-11 Eric Botcazou <ebotcazou@adacore.com>
* exp_aggr.adb (Packed_Array_Aggregate_Handled): Bail out for
any non-scalar type as component type of the array.
2018-12-11 Eric Botcazou <ebotcazou@adacore.com>
* einfo.ads (Is_Bit_Packed_Array): Fix values of component size. * einfo.ads (Is_Bit_Packed_Array): Fix values of component size.
(Is_Packed): Likewise. (Is_Packed): Likewise.
* gcc-interface/utils.c (convert): Do not extract the value of a * gcc-interface/utils.c (convert): Do not extract the value of a
......
...@@ -7893,9 +7893,7 @@ package body Exp_Aggr is ...@@ -7893,9 +7893,7 @@ package body Exp_Aggr is
return False; return False;
end if; end if;
if not Is_Scalar_Type (Component_Type (Typ)) if not Is_Scalar_Type (Ctyp) then
and then Has_Non_Standard_Rep (Component_Type (Typ))
then
return False; return False;
end if; end if;
......
2018-12-11 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/packed_array.adb, gnat.dg/packed_array.ads,
gnat.dg/packed_array_pkg.ads: New testcase.
2018-12-11 Hristian Kirtchev <kirtchev@adacore.com> 2018-12-11 Hristian Kirtchev <kirtchev@adacore.com>
* gnat.dg/ghost3.adb, gnat.dg/ghost3.ads: New testcase. * gnat.dg/ghost3.adb, gnat.dg/ghost3.ads: New testcase.
......
package body Packed_Array is
procedure Dummy is null;
end;
with Packed_Array_Pkg; use Packed_Array_Pkg;
package Packed_Array is
C : constant Small_Rec2 := (Lo => 1, Hi => Max, A => (1 => (2, 3)));
procedure Dummy;
end;
package Packed_Array_Pkg is
type Rec1 is record
I : Integer;
S : Short_Integer;
end record;
for Rec1'Size use 49;
type Arr is array (Positive range <>) of Rec1;
for Arr'Component_Size use 49;
type Rec2 (Lo, Hi : Positive) is record
A : Arr (Lo .. Hi);
end record;
Max : Positive := 1;
subtype Small_Rec2 is Rec2 (1, Max);
end;
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