]> gcc.gnu.org Git - gcc.git/commitdiff
[Ada] Plug small loophole with pathological packed array type
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 11 Dec 2018 11:11:37 +0000 (11:11 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 11 Dec 2018 11:11:37 +0000 (11:11 +0000)
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

gcc/ada/ChangeLog
gcc/ada/exp_aggr.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/packed_array.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/packed_array.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/packed_array_pkg.ads [new file with mode: 0644]

index d56897b4fed8f1a5da20d81eb0badfe9d2986b23..c2305be2ec2113b170822c38a2caf257e0e2e1b4 100644 (file)
@@ -1,3 +1,8 @@
+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.
index 1b644e1d74bfa32cd6860537cd0d9e7e93f2dabf..37b9fa8378377ee15c5e31dca7afc9362f6189aa 100644 (file)
@@ -7893,9 +7893,7 @@ package body Exp_Aggr is
          return False;
       end if;
 
-      if not Is_Scalar_Type (Component_Type (Typ))
-        and then Has_Non_Standard_Rep (Component_Type (Typ))
-      then
+      if not Is_Scalar_Type (Ctyp) then
          return False;
       end if;
 
index bdc7eb443608f56805754dffceeba228ce13dcf1..7a71ed1bc55455b8d216719f8990ac216ed6b365 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * gnat.dg/ghost3.adb, gnat.dg/ghost3.ads: New testcase.
diff --git a/gcc/testsuite/gnat.dg/packed_array.adb b/gcc/testsuite/gnat.dg/packed_array.adb
new file mode 100644 (file)
index 0000000..5faba40
--- /dev/null
@@ -0,0 +1,5 @@
+package body Packed_Array is
+
+  procedure Dummy is null;
+
+end;
diff --git a/gcc/testsuite/gnat.dg/packed_array.ads b/gcc/testsuite/gnat.dg/packed_array.ads
new file mode 100644 (file)
index 0000000..957a321
--- /dev/null
@@ -0,0 +1,9 @@
+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;
diff --git a/gcc/testsuite/gnat.dg/packed_array_pkg.ads b/gcc/testsuite/gnat.dg/packed_array_pkg.ads
new file mode 100644 (file)
index 0000000..d116f3c
--- /dev/null
@@ -0,0 +1,20 @@
+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;
This page took 0.106866 seconds and 5 git commands to generate.