decl.c (gnat_to_gnu_entity): Reuse dummy fat type for gnu_ptr_template and gnu_templa...
authorTristan Gingold <gingold@adacore.com>
Mon, 27 Feb 2012 17:25:28 +0000 (17:25 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 27 Feb 2012 17:25:28 +0000 (17:25 +0000)
* gcc-interface/decl.c (gnat_to_gnu_entity) [E_String_Type,
E_Array_Type]: Reuse dummy fat type for gnu_ptr_template and
gnu_template_type.

From-SVN: r184605

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

index 38d58f3..b0b51ee 100644 (file)
@@ -1,3 +1,9 @@
+2012-02-27  Tristan Gingold  <gingold@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_entity) [E_String_Type,
+       E_Array_Type]: Reuse dummy fat type for gnu_ptr_template and
+       gnu_template_type.
+
 2012-02-27  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/ada-tree.h (TYPE_PACKED_ARRAY_TYPE_P): Add checking.
index e47aca4..80ad5a3 100644 (file)
@@ -2003,8 +2003,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
        const bool convention_fortran_p
          = (Convention (gnat_entity) == Convention_Fortran);
        const int ndim = Number_Dimensions (gnat_entity);
-       tree gnu_template_type = make_node (RECORD_TYPE);
-       tree gnu_ptr_template = build_pointer_type (gnu_template_type);
+       tree gnu_template_type;
+       tree gnu_ptr_template;
        tree gnu_template_reference, gnu_template_fields, gnu_fat_type;
        tree *gnu_index_types = XALLOCAVEC (tree, ndim);
        tree *gnu_temp_fields = XALLOCAVEC (tree, ndim);
@@ -2035,9 +2035,16 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
            TYPE_NAME (gnu_fat_type) = NULL_TREE;
            /* Save the contents of the dummy type for update_pointer_to.  */
            TYPE_POINTER_TO (gnu_type) = copy_type (gnu_fat_type);
+           gnu_ptr_template =
+             TREE_TYPE (TREE_CHAIN (TYPE_FIELDS (gnu_fat_type)));
+           gnu_template_type = TREE_TYPE (gnu_ptr_template);
          }
        else
-         gnu_fat_type = make_node (RECORD_TYPE);
+         {
+           gnu_fat_type = make_node (RECORD_TYPE);
+           gnu_template_type = make_node (RECORD_TYPE);
+           gnu_ptr_template = build_pointer_type (gnu_template_type);
+         }
 
        /* Make a node for the array.  If we are not defining the array
           suppress expanding incomplete types.  */
index 5c9f70c..a267742 100644 (file)
@@ -1,3 +1,7 @@
+2012-02-27  Tristan Gingold  <gingold@adacore.com>
+
+       * gnat.dg/array20.ad[sb]: New test.
+
 2012-02-27  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/52375
diff --git a/gcc/testsuite/gnat.dg/array20.adb b/gcc/testsuite/gnat.dg/array20.adb
new file mode 100644 (file)
index 0000000..86eb61b
--- /dev/null
@@ -0,0 +1,13 @@
+-- { dg-do assemble }
+
+package body Array20 is
+
+   type Arr is array (Positive range <>) of Integer;
+
+   type P_Arr is access Arr;
+
+   N : constant P_Arr := null;
+
+   Table : P_Arr := N;
+
+end Array20;
diff --git a/gcc/testsuite/gnat.dg/array20.ads b/gcc/testsuite/gnat.dg/array20.ads
new file mode 100644 (file)
index 0000000..b132b27
--- /dev/null
@@ -0,0 +1,5 @@
+package Array20 is
+
+   pragma Elaborate_Body;
+
+end array20;