From: ebotcazou Date: Sat, 8 May 2010 11:50:18 +0000 (+0000) Subject: * exp_disp.adb (Make_Tags): Mark the imported view of dispatch tables. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7640ed3d8a38f4eedd02419fb353ac66320fc78e;p=thirdparty%2Fgcc.git * exp_disp.adb (Make_Tags): Mark the imported view of dispatch tables. * gcc-interface/decl.c (gnat_to_gnu_entity) : Make imported constants really constant. : Strip the suffix for dispatch table entities. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159184 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 3878ccd41493..68a92668c2a0 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2010-05-08 Eric Botcazou + + * exp_disp.adb (Make_Tags): Mark the imported view of dispatch tables. + * gcc-interface/decl.c (gnat_to_gnu_entity) : Make imported + constants really constant. + : Strip the suffix for dispatch table entities. + 2010-05-08 Eric Botcazou * gcc-interface/decl.c (make_aligning_type): Declare the type. diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index 11ae6dff5c78..f21b8d270043 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -6241,7 +6241,7 @@ package body Exp_Disp is Tname : constant Name_Id := Chars (Typ); AI_Tag_Comp : Elmt_Id; - DT : Node_Id; + DT : Node_Id := Empty; DT_Ptr : Node_Id; Predef_Prims_Ptr : Node_Id; Iface_DT : Node_Id; @@ -6562,6 +6562,14 @@ package body Exp_Disp is end; end if; + -- Mark entities of dispatch table. Required by the back end to + -- handle them properly. + + if Present (DT) then + Set_Is_Dispatch_Table_Entity (DT); + Set_Is_Dispatch_Table_Entity (Etype (DT)); + end if; + Set_Ekind (DT_Ptr, E_Constant); Set_Is_Tag (DT_Ptr); Set_Related_Type (DT_Ptr, Typ); diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 6df79fb878ed..fba552bc0e06 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -560,7 +560,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) && (((Nkind (Declaration_Node (gnat_entity)) == N_Object_Declaration) && Present (Expression (Declaration_Node (gnat_entity)))) - || Present (Renamed_Object (gnat_entity)))); + || Present (Renamed_Object (gnat_entity)) + || Is_Imported (gnat_entity))); bool inner_const_flag = const_flag; bool static_p = Is_Statically_Allocated (gnat_entity); bool mutable_p = false; @@ -2975,6 +2976,20 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) break; } + /* If this is a record subtype associated with a dispatch table, + strip the suffix. This is necessary to make sure 2 different + subtypes associated with the imported and exported views of a + dispatch table are properly merged in LTO mode. */ + if (Is_Dispatch_Table_Entity (gnat_entity)) + { + char *p; + Get_Encoded_Name (gnat_entity); + p = strrchr (Name_Buffer, '_'); + gcc_assert (p); + strcpy (p+1, "dtS"); + gnu_entity_name = get_identifier (Name_Buffer); + } + /* When the subtype has discriminants and these discriminants affect the initial shape it has inherited, factor them in. But for an Unchecked_Union (it must be an Itype), just return the type. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 08266b1d434c..85dd6b9d8568 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-05-08 Eric Botcazou + + * gnat.dg/lto5.adb: New test. + * gnat.dg/lto5_pkg.ad[sb]: New helper. + 2010-05-08 Eric Botcazou * gnat.dg/lto4.ad[sb]: New test. diff --git a/gcc/testsuite/gnat.dg/lto5.adb b/gcc/testsuite/gnat.dg/lto5.adb new file mode 100644 index 000000000000..c36aae8fe5ee --- /dev/null +++ b/gcc/testsuite/gnat.dg/lto5.adb @@ -0,0 +1,9 @@ +-- { dg-do run } +-- { dg-options "-flto" } + +with Lto5_Pkg; + +procedure Lto5 is +begin + null; +end; diff --git a/gcc/testsuite/gnat.dg/lto5_pkg.adb b/gcc/testsuite/gnat.dg/lto5_pkg.adb new file mode 100644 index 000000000000..b5bf68ab9423 --- /dev/null +++ b/gcc/testsuite/gnat.dg/lto5_pkg.adb @@ -0,0 +1,6 @@ +package body Lto5_Pkg is + procedure d (a : t) is + begin + null; + end; +end; diff --git a/gcc/testsuite/gnat.dg/lto5_pkg.ads b/gcc/testsuite/gnat.dg/lto5_pkg.ads new file mode 100644 index 000000000000..34d34926ea46 --- /dev/null +++ b/gcc/testsuite/gnat.dg/lto5_pkg.ads @@ -0,0 +1,6 @@ +pragma Eliminate (p, d); + +package Lto5_Pkg is + type t is tagged null record; + procedure d (a : t); +end;