From 8c44fc0f2305f051c9631b4ab3f46417bfe0d644 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 27 Oct 2014 11:19:41 +0000 Subject: [PATCH] decl.c (gnat_to_gnu_entity): Apply special treatment of derived packed array types to constrained subtypes only. * 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 | 5 +++++ gcc/ada/gcc-interface/decl.c | 4 +++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gnat.dg/specs/pack10.ads | 14 ++++++++++++++ gcc/testsuite/gnat.dg/specs/pack10_pkg.adb | 5 +++++ gcc/testsuite/gnat.dg/specs/pack10_pkg.ads | 9 +++++++++ 6 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gnat.dg/specs/pack10.ads create mode 100644 gcc/testsuite/gnat.dg/specs/pack10_pkg.adb create mode 100644 gcc/testsuite/gnat.dg/specs/pack10_pkg.ads diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index bb092c81c66..f8bcb2e97ea 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2014-10-27 Eric Botcazou + + * 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 * gcc-interface/decl.c (gnat_to_gnu_entity) : Remove diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 97fd3b5a854..626f09a7b69 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -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), diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 89d8d8edb88..a6e6d030258 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-10-27 Eric Botcazou + + * gnat.dg/specs/pack10.ads: New test. + * gnat.dg/specs/pack10_pkg.ad[sb]: New helper. + 2014-10-27 Eric Botcazou * 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 index 00000000000..0138e09775e --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/pack10.ads @@ -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 index 00000000000..af81776544a --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/pack10_pkg.adb @@ -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 index 00000000000..76d99fbbf37 --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/pack10_pkg.ads @@ -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; -- 2.30.2