decl.c (gnat_to_gnu_entity): Declare the padded type built for the return type if...
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 17 Apr 2011 10:22:40 +0000 (10:22 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sun, 17 Apr 2011 10:22:40 +0000 (10:22 +0000)
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Function>: Declare the
padded type built for the return type if it is unconstrained.

From-SVN: r172608

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

index 3e8595940d7b5d86ea4c597eb35ffffcc5d349d1..8f52d5a50b1d5f78cbe8406dee7aad5f60851ac4 100644 (file)
@@ -1,3 +1,8 @@
+2011-04-17  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Function>: Declare the
+       padded type built for the return type if it is unconstrained.
+
 2011-04-14  Nathan Froyd  <froydnj@codesourcery.com>
 
        * gcc-interface/utils.c (gnat_poplevel): Use block_chainon.
index bc6b9cc7bf3457f866732afc31250fa04646e651..185df85af32449ddefe508534a901859e8205a4a 100644 (file)
@@ -4068,6 +4068,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
                                    max_size (TYPE_SIZE (gnu_return_type),
                                              true),
                                    0, gnat_entity, false, false, false, true);
+
+               /* Declare it now since it will never be declared otherwise.
+                  This is necessary to ensure that its subtrees are properly
+                  marked.  */
+               create_type_decl (TYPE_NAME (gnu_return_type), gnu_return_type,
+                                 NULL, true, debug_info_p, gnat_entity);
+
                return_by_invisi_ref_p = true;
              }
 
index ac7833b5953571e1b81e95f46029654d7b9d2dc1..8e258482f18f8254dc2560440f8434249c18cf39 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-17  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/discr27.ad[sb]: Move dg directive.
+       * gnat.dg/discr28.ad[sb]: New test.
+       * gnat.dg/discr28_pkg.ads: New helper.
+
 2011-04-17  Michael Matz  <matz@suse.de>
 
        PR tree-optimization/48622
index cfaba34c2f90e7c5d816b58d33883c5c2b34e864..875fe435b668f855a551d01515b2cb141604c680 100644 (file)
@@ -1,3 +1,5 @@
+-- { dg-do compile }\r
+\r
 package body Discr27 is\r
 \r
    subtype Index is Positive range 1..4096;\r
index db1914accc30d8fbecd9900f06c58c8536f2ac1c..247134a991673f770df607b413edd100a63f8188 100644 (file)
@@ -1,5 +1,3 @@
--- { dg-do compile }\r
-\r
 package Discr27 is\r
 \r
    procedure Proc;\r
diff --git a/gcc/testsuite/gnat.dg/discr28.adb b/gcc/testsuite/gnat.dg/discr28.adb
new file mode 100644 (file)
index 0000000..97ca8cd
--- /dev/null
@@ -0,0 +1,25 @@
+-- { dg-do compile }
+
+package body Discr28 is
+
+   procedure Dummy (E : Rec) is
+   begin
+     null;
+   end;
+
+   function F return Rec is
+   begin
+      return Default_Rec;
+   end;
+
+   procedure Proc1 is
+   begin
+      Dummy (F);
+   end;
+
+   procedure Proc2 is
+   begin
+      Dummy (F);
+   end;
+
+end Discr28;
diff --git a/gcc/testsuite/gnat.dg/discr28.ads b/gcc/testsuite/gnat.dg/discr28.ads
new file mode 100644 (file)
index 0000000..3288b52
--- /dev/null
@@ -0,0 +1,19 @@
+with Discr28_Pkg;
+
+package Discr28 is
+
+   type Enum is (One, Two);
+
+   type Rec (D : Enum := One) is record
+      case D is
+         when One => null;
+         when Two => S : String (1 .. Discr28_Pkg.N);
+      end case;
+   end record;
+
+   Default_Rec : constant Rec := (D => One);
+
+   procedure Proc1;
+   procedure Proc2;
+
+end Discr28;
diff --git a/gcc/testsuite/gnat.dg/discr28_pkg.ads b/gcc/testsuite/gnat.dg/discr28_pkg.ads
new file mode 100644 (file)
index 0000000..f6be834
--- /dev/null
@@ -0,0 +1,5 @@
+package Discr28_Pkg is
+
+  function N return Natural;
+
+end Discr28_Pkg;