decl.c (gnat_to_gnu_entity): Apply special treatment of derived packed array types...
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 27 Oct 2014 11:19:41 +0000 (11:19 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 27 Oct 2014 11:19:41 +0000 (11:19 +0000)
* gcc-interface/decl.c (gnat_to_gnu_entity): Apply special treatment
of derived packed array types to constrained subtypes only.

From-SVN: r216727

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/specs/pack10.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/pack10_pkg.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/specs/pack10_pkg.ads [new file with mode: 0644]

index bb092c81c666db1e9948bffce8308927f2a9c21c..f8bcb2e97ea223a33025fb5ba098864fb638e580 100644 (file)
@@ -1,3 +1,8 @@
+2014-10-27  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_entity): Apply special treatment
+       of derived packed array types to constrained subtypes only.
+
 2014-10-27  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Remove
index 97fd3b5a854252341c134fc70079a6f279fd880f..626f09a7b6934d41959a99f7cf431b72aadeb471 100644 (file)
@@ -5083,8 +5083,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
       if (Is_Derived_Type (gnat_entity) && !type_annotate_only)
        {
          Entity_Id gnat_parent_type = Underlying_Type (Etype (gnat_entity));
-         /* For packed array subtypes, the implementation type is used.  */
+         /* For constrained packed array subtypes, the implementation type is
+            used instead of the nominal type.  */
          if (kind == E_Array_Subtype
+             && Is_Constrained (gnat_entity)
              && Present (Packed_Array_Impl_Type (gnat_parent_type)))
            gnat_parent_type = Packed_Array_Impl_Type (gnat_parent_type);
          relate_alias_sets (gnu_type, gnat_to_gnu_type (gnat_parent_type),
index 89d8d8edb886a560547417cefb9f0233a9017325..a6e6d03025828199f459555c9647fa08e3de84eb 100644 (file)
@@ -1,3 +1,8 @@
+2014-10-27  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/specs/pack10.ads: New test.
+       * gnat.dg/specs/pack10_pkg.ad[sb]: New helper.
+
 2014-10-27  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/entry_queues2.adb: New test.
diff --git a/gcc/testsuite/gnat.dg/specs/pack10.ads b/gcc/testsuite/gnat.dg/specs/pack10.ads
new file mode 100644 (file)
index 0000000..0138e09
--- /dev/null
@@ -0,0 +1,14 @@
+-- { dg-do compile }
+
+with Pack10_Pkg; use Pack10_Pkg;
+
+package Pack10 is
+
+   type Boolean_Vector is array (Positive range <>) of Boolean;
+
+   type Packed_Boolean_Vector is new Boolean_Vector;
+   pragma Pack (Packed_Boolean_Vector);
+
+   procedure My_Proc is new Proc (Packed_Boolean_Vector);
+
+end Pack10;
diff --git a/gcc/testsuite/gnat.dg/specs/pack10_pkg.adb b/gcc/testsuite/gnat.dg/specs/pack10_pkg.adb
new file mode 100644 (file)
index 0000000..af81776
--- /dev/null
@@ -0,0 +1,5 @@
+package body Pack10_Pkg is
+
+   procedure Proc is begin null; end;
+
+end Pack10_Pkg;
diff --git a/gcc/testsuite/gnat.dg/specs/pack10_pkg.ads b/gcc/testsuite/gnat.dg/specs/pack10_pkg.ads
new file mode 100644 (file)
index 0000000..76d99fb
--- /dev/null
@@ -0,0 +1,9 @@
+-- { dg-excess-errors "cannot generate code" }
+
+package Pack10_Pkg is
+
+   generic
+      type Vector_Type (<>) is private;
+   procedure Proc;
+
+end Pack10_Pkg;