From: ebotcazou Date: Sun, 16 May 2010 09:11:39 +0000 (+0000) Subject: * gcc-interface/gigi.h (enum standard_datatypes): Add new value X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=0fff241f8cdba09dca53c3340b8efa45a621b5be;ds=sidebyside * gcc-interface/gigi.h (enum standard_datatypes): Add new value ADT_exception_data_name_id. (exception_data_name_id): New define. * gcc-interface/trans.c (gigi): Initialize it. * gcc-interface/decl.c (gnat_to_gnu_entity) : Use the standard exception type for standard exception definitions. Do not make them volatile. : Equate fields of types associated with an exception definition to those of the standard exception type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159452 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index aa2e4626dec..b70056b77a8 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,15 @@ +2010-05-16 Eric Botcazou + + * gcc-interface/gigi.h (enum standard_datatypes): Add new value + ADT_exception_data_name_id. + (exception_data_name_id): New define. + * gcc-interface/trans.c (gigi): Initialize it. + * gcc-interface/decl.c (gnat_to_gnu_entity) : Use the standard + exception type for standard exception definitions. Do not make them + volatile. + : Equate fields of types associated with an exception + definition to those of the standard exception type. + 2010-05-13 Andreas Schwab * tracebak.c (__gnat_backtrace): Mark top_stack with ATTRIBUTE_UNUSED. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 49a06fbfd7d..137d523ddbf 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -582,6 +582,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) /* Get the type after elaborating the renamed object. */ gnu_type = gnat_to_gnu_type (Etype (gnat_entity)); + /* If this is a standard exception definition, then use the standard + exception type. This is necessary to make sure that imported and + exported views of exceptions are properly merged in LTO mode. */ + if (TREE_CODE (TYPE_NAME (gnu_type)) == TYPE_DECL + && DECL_NAME (TYPE_NAME (gnu_type)) == exception_data_name_id) + gnu_type = except_type_node; + /* For a debug renaming declaration, build a pure debug entity. */ if (Present (Debug_Renaming_Link (gnat_entity))) { @@ -1000,6 +1007,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) and disallow any optimizations for such a non-constant object. */ if ((Treat_As_Volatile (gnat_entity) || (!const_flag + && gnu_type != except_type_node && (Is_Exported (gnat_entity) || imported_p || Present (Address_Clause (gnat_entity))))) @@ -2922,6 +2930,21 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) && Is_Itype (Etype (gnat_temp)) && !present_gnu_tree (gnat_temp)) gnat_to_gnu_entity (Etype (gnat_temp), NULL_TREE, 0); + + /* If this is a record type associated with an exception definition, + equate its fields to those of the standard exception type. This + will make it possible to convert between them. */ + if (gnu_entity_name == exception_data_name_id) + { + tree gnu_std_field; + for (gnu_field = TYPE_FIELDS (gnu_type), + gnu_std_field = TYPE_FIELDS (except_type_node); + gnu_field; + gnu_field = TREE_CHAIN (gnu_field), + gnu_std_field = TREE_CHAIN (gnu_std_field)) + SET_DECL_ORIGINAL_FIELD_TO_FIELD (gnu_field, gnu_std_field); + gcc_assert (!gnu_std_field); + } } break; diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index f3a0bdd3499..ce8fc8a7a7f 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -342,6 +342,9 @@ enum standard_datatypes /* Identifier for the name of the _Parent field in tagged record types. */ ADT_parent_name_id, + /* Identifier for the name of the Exception_Data type. */ + ADT_exception_data_name_id, + /* Types and decls used by our temporary exception mechanism. See init_gigi_decls for details. */ ADT_jmpbuf_type, @@ -376,6 +379,7 @@ extern GTY(()) tree gnat_raise_decls[(int) LAST_REASON_CODE + 1]; #define free_decl gnat_std_decls[(int) ADT_free_decl] #define mulv64_decl gnat_std_decls[(int) ADT_mulv64_decl] #define parent_name_id gnat_std_decls[(int) ADT_parent_name_id] +#define exception_data_name_id gnat_std_decls[(int) ADT_exception_data_name_id] #define jmpbuf_type gnat_std_decls[(int) ADT_jmpbuf_type] #define jmpbuf_ptr_type gnat_std_decls[(int) ADT_jmpbuf_ptr_type] #define get_jmpbuf_decl gnat_std_decls[(int) ADT_get_jmpbuf_decl] diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index c6bad4351e7..68b496ea690 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -401,6 +401,10 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED, /* Name of the _Parent field in tagged record types. */ parent_name_id = get_identifier (Get_Name_String (Name_uParent)); + /* Name of the Exception_Data type defined in System.Standard_Library. */ + exception_data_name_id + = get_identifier ("system__standard_library__exception_data"); + /* Make the types and functions used for exception processing. */ jmpbuf_type = build_array_type (gnat_type_for_mode (Pmode, 0),