From: Eric Botcazou Date: Sun, 17 Apr 2011 10:22:40 +0000 (+0000) Subject: decl.c (gnat_to_gnu_entity): Declare the padded type built for the return type if... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=51c5169c60be01c229b8637d11283d843bc6e126;p=gcc.git decl.c (gnat_to_gnu_entity): Declare the padded type built for the return type if it is unconstrained. * gcc-interface/decl.c (gnat_to_gnu_entity) : Declare the padded type built for the return type if it is unconstrained. From-SVN: r172608 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 3e8595940d7..8f52d5a50b1 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2011-04-17 Eric Botcazou + + * gcc-interface/decl.c (gnat_to_gnu_entity) : Declare the + padded type built for the return type if it is unconstrained. + 2011-04-14 Nathan Froyd * gcc-interface/utils.c (gnat_poplevel): Use block_chainon. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index bc6b9cc7bf3..185df85af32 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ac7833b5953..8e258482f18 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-04-17 Eric Botcazou + + * 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 PR tree-optimization/48622 diff --git a/gcc/testsuite/gnat.dg/discr27.adb b/gcc/testsuite/gnat.dg/discr27.adb index cfaba34c2f9..875fe435b66 100644 --- a/gcc/testsuite/gnat.dg/discr27.adb +++ b/gcc/testsuite/gnat.dg/discr27.adb @@ -1,3 +1,5 @@ +-- { dg-do compile } + package body Discr27 is subtype Index is Positive range 1..4096; diff --git a/gcc/testsuite/gnat.dg/discr27.ads b/gcc/testsuite/gnat.dg/discr27.ads index db1914accc3..247134a9916 100644 --- a/gcc/testsuite/gnat.dg/discr27.ads +++ b/gcc/testsuite/gnat.dg/discr27.ads @@ -1,5 +1,3 @@ --- { dg-do compile } - package Discr27 is procedure Proc; diff --git a/gcc/testsuite/gnat.dg/discr28.adb b/gcc/testsuite/gnat.dg/discr28.adb new file mode 100644 index 00000000000..97ca8cd68b7 --- /dev/null +++ b/gcc/testsuite/gnat.dg/discr28.adb @@ -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 index 00000000000..3288b52bfcb --- /dev/null +++ b/gcc/testsuite/gnat.dg/discr28.ads @@ -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 index 00000000000..f6be834eedc --- /dev/null +++ b/gcc/testsuite/gnat.dg/discr28_pkg.ads @@ -0,0 +1,5 @@ +package Discr28_Pkg is + + function N return Natural; + +end Discr28_Pkg;