From 19c1e4a9cc508838ba8d9ce44c16234191dad7e4 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Sat, 2 Apr 2011 09:38:22 +0000 Subject: [PATCH] * gcc-interface/utils2.c (build_allocator): In the unconstrained array type case, do not strip a padding type around the array type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171888 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/gcc-interface/utils2.c | 15 +++------------ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/specs/aggr2.ads | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/specs/aggr2.ads diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 2a1eba4a9e0..8f164e542d2 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,10 @@ 2011-04-02 Eric Botcazou + * gcc-interface/utils2.c (build_allocator): In the unconstrained array + type case, do not strip a padding type around the array type. + +2011-04-02 Eric Botcazou + * gcc-interface/utils.c (update_pointer_to): Finalize named pointer types. diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index 78f5fd94c33..240d3459d10 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -2135,17 +2135,9 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, gnat_proc, gnat_pool, gnat_node); storage = convert (storage_ptr_type, gnat_protect_expr (storage)); - if (TYPE_IS_PADDING_P (type)) - { - type = TREE_TYPE (TYPE_FIELDS (type)); - if (init) - init = convert (type, init); - } - - /* If there is an initializing expression, make a constructor for - the entire object including the bounds and copy it into the - object. If there is no initializing expression, just set the - bounds. */ + /* If there is an initializing expression, then make a constructor for + the entire object including the bounds and copy it into the object. + If there is no initializing expression, just set the bounds. */ if (init) { VEC(constructor_elt,gc) *v = VEC_alloc (constructor_elt, gc, 2); @@ -2154,7 +2146,6 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, build_template (template_type, type, init)); CONSTRUCTOR_APPEND_ELT (v, DECL_CHAIN (TYPE_FIELDS (storage_type)), init); - return convert (result_type, build2 (COMPOUND_EXPR, storage_ptr_type, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7f19c13ece1..dff95d8fdd3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2011-04-02 Eric Botcazou + * gnat.dg/specs/aggr2.ads: New test. + +2011-04-02 Eric Botcazou + * gnat.dg/debug2.ad[sb]: New test. * gnat.dg/debug2_pkg.ads: New helper. * gnat.dg/debug3.ad[sb]: New test. diff --git a/gcc/testsuite/gnat.dg/specs/aggr2.ads b/gcc/testsuite/gnat.dg/specs/aggr2.ads new file mode 100644 index 00000000000..8f7ea871733 --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/aggr2.ads @@ -0,0 +1,14 @@ +-- { dg-do compile } + +package Aggr2 is + + type Buffer is array (Positive range <>) of Boolean; + for Buffer'Alignment use 4; + + type Buffer_Ptr is access Buffer; + + subtype My_Buffer is Buffer (1 .. 2); + + P : Buffer_Ptr := new My_Buffer'(Others => False); + +end Aggr2; -- 2.11.4.GIT