From e99c3ccc40fac2b63c005b2bdc7ef3a18e74cb07 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sat, 24 Oct 2009 11:12:21 +0000 Subject: [PATCH] decl.c (gnat_to_gnu_entity): When processing the parent type... * gcc-interface/decl.c (gnat_to_gnu_entity) : When processing the parent type, build the COMPONENT_REF for a discriminant with the proper type. From-SVN: r153528 --- gcc/ada/ChangeLog | 6 ++++++ gcc/ada/gcc-interface/decl.c | 19 ++++++++++--------- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/specs/pack4.ads | 12 ++++++++++++ 4 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/specs/pack4.ads diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 231de304090..dae8d315f49 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2009-10-24 Eric Botcazou + + * gcc-interface/decl.c (gnat_to_gnu_entity) : When + processing the parent type, build the COMPONENT_REF for a discriminant + with the proper type. + 2009-10-24 Eric Botcazou * init.c (__gnat_adjust_context_for_raise): Mention _Unwind_GetIPInfo. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index d0b52f2e745..6abb366bd07 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -2729,15 +2729,16 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) Present (gnat_field); gnat_field = Next_Stored_Discriminant (gnat_field)) if (Present (Corresponding_Discriminant (gnat_field))) - save_gnu_tree - (gnat_field, - build3 (COMPONENT_REF, - get_unpadded_type (Etype (gnat_field)), - gnu_get_parent, - gnat_to_gnu_field_decl (Corresponding_Discriminant - (gnat_field)), - NULL_TREE), - true); + { + tree gnu_field + = gnat_to_gnu_field_decl (Corresponding_Discriminant + (gnat_field)); + save_gnu_tree + (gnat_field, + build3 (COMPONENT_REF, TREE_TYPE (gnu_field), + gnu_get_parent, gnu_field, NULL_TREE), + true); + } /* Then we build the parent subtype. If it has discriminants but the type itself has unknown discriminants, this means that it diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 73d8d6bf8e0..178af56dde0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2009-10-24 Eric Botcazou + + * gnat.dg/specs/pack4.ads: New test. + 2009-10-24 Eric Botcazou * gnat.dg/null_pointer_deref1.adb: New test. diff --git a/gcc/testsuite/gnat.dg/specs/pack4.ads b/gcc/testsuite/gnat.dg/specs/pack4.ads new file mode 100644 index 00000000000..82b76d2f457 --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/pack4.ads @@ -0,0 +1,12 @@ +package Pack4 is + + type Buffer is array (Natural range <>) of Boolean; + + type Root (Size : Natural) is tagged record + Data : Buffer (1..Size); + end record; + pragma Pack (Root); + + type Derived is new Root with null record; + +end Pack4; -- 2.30.2