OSDN Git Service

* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Create TYPE_DECL
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 26 Mar 2011 10:18:54 +0000 (10:18 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 26 Mar 2011 10:18:54 +0000 (10:18 +0000)
for the padded type built to support a specified size or alignment.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171554 138bc75d-0d04-0410-961f-82ee72b054a4

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

index a4d45a5..91725e4 100644 (file)
@@ -1,5 +1,10 @@
 2011-03-26  Eric Botcazou  <ebotcazou@adacore.com>
 
+       * gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Create TYPE_DECL
+       for the padded type built to support a specified size or alignment.
+
+2011-03-26  Eric Botcazou  <ebotcazou@adacore.com>
+
        * gcc-interface/gigi.h (finalize_from_with_types): Adjust comment.
        * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Access_Type>: Defer
        unconditionally to the end of the unit when the designated type is
index d3d2b96..cea8d3d 100644 (file)
@@ -911,9 +911,20 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
           size of the object.  */
        gnu_object_size = gnu_size ? gnu_size : TYPE_SIZE (gnu_type);
        if (gnu_size || align > 0)
-         gnu_type = maybe_pad_type (gnu_type, gnu_size, align, gnat_entity,
-                                    false, false, definition,
-                                    gnu_size ? true : false);
+         {
+           tree orig_type = gnu_type;
+
+           gnu_type = maybe_pad_type (gnu_type, gnu_size, align, gnat_entity,
+                                      false, false, definition,
+                                      gnu_size ? true : false);
+
+           /* If a padding record was made, declare it now since it will
+              never be declared otherwise.  This is necessary to ensure
+              that its subtrees are properly marked.  */
+           if (gnu_type != orig_type && !DECL_P (TYPE_NAME (gnu_type)))
+             create_type_decl (TYPE_NAME (gnu_type), gnu_type, NULL, true,
+                               debug_info_p, gnat_entity);
+         }
 
        /* If this is a renaming, avoid as much as possible to create a new
           object.  However, in several cases, creating it is required.
index 4f1fa8a..28ab5b9 100644 (file)
@@ -1,5 +1,9 @@
 2011-03-26  Eric Botcazou  <ebotcazou@adacore.com>
 
+       * gnat.dg/discr27.ad[sb]: New test.
+
+2011-03-26  Eric Botcazou  <ebotcazou@adacore.com>
+
        * gnat.dg/limited_with2.ad[sb]: New test.
        * gnat.dg/limited_with2_pkg1.ads: New helper.
        * gnat.dg/imited_with2_pkg2.ads: Likewise.
diff --git a/gcc/testsuite/gnat.dg/discr27.adb b/gcc/testsuite/gnat.dg/discr27.adb
new file mode 100644 (file)
index 0000000..cfaba34
--- /dev/null
@@ -0,0 +1,31 @@
+package body Discr27 is\r
+\r
+   subtype Index is Positive range 1..4096;\r
+\r
+   function F return String is\r
+      S : String(1..1) := (others =>'w');\r
+   begin\r
+      return S;\r
+   end;\r
+\r
+   type Enum is (One, Two);\r
+\r
+   type Rec (D : Enum  := One; Len : Index := 1) is record\r
+      case D is\r
+          when One => I : Integer;\r
+          when Two => A : String(1..Len);\r
+      end case;\r
+   end record;\r
+\r
+   procedure Nothing is\r
+      M : constant String := F;\r
+      C : constant Rec := (Two, M'Length, M);\r
+   begin\r
+      null;\r
+   end;\r
+\r
+   procedure Proc is begin\r
+      null;\r
+   end;\r
+\r
+end Discr27;\r
diff --git a/gcc/testsuite/gnat.dg/discr27.ads b/gcc/testsuite/gnat.dg/discr27.ads
new file mode 100644 (file)
index 0000000..db1914a
--- /dev/null
@@ -0,0 +1,7 @@
+-- { dg-do compile }\r
+\r
+package Discr27 is\r
+\r
+   procedure Proc;\r
+\r
+end Discr27;\r