utils2.c (build_allocator): In the unconstrained array type case...
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 2 Apr 2011 09:38:22 +0000 (09:38 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 2 Apr 2011 09:38:22 +0000 (09:38 +0000)
* gcc-interface/utils2.c (build_allocator): In the unconstrained array
type case, do not strip a padding type around the array type.

From-SVN: r171888

gcc/ada/ChangeLog
gcc/ada/gcc-interface/utils2.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/specs/aggr2.ads [new file with mode: 0644]

index 2a1eba4a9e0160ca73be71c903f0f282c59c08c5..8f164e542d289704bd74d948baca1cfbc863609e 100644 (file)
@@ -1,3 +1,8 @@
+2011-04-02  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * 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  <ebotcazou@adacore.com>
 
        * gcc-interface/utils.c (update_pointer_to): Finalize named pointer
index 78f5fd94c336d63940568200306321f84814601a..240d3459d107a2e331359bd714fcd75c8226f38a 100644 (file)
@@ -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,
index 7f19c13ece114297cc09bc141e7b5b6af6249b1b..dff95d8fdd3ea06d8f53d5660ce5d3344c0cd93c 100644 (file)
@@ -1,3 +1,7 @@
+2011-04-02  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/specs/aggr2.ads: New test.
+
 2011-04-02  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/debug2.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 (file)
index 0000000..8f7ea87
--- /dev/null
@@ -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;