gigi.h (enum standard_datatypes): Add new value ADT_exception_data_name_id.

* 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) <object>: Use the standard
	exception type for standard exception definitions.  Do not make them
	volatile.
	<E_Record_Type>: Equate fields of types associated with an exception
	definition to those of the standard exception type.

From-SVN: r159452
This commit is contained in:
Eric Botcazou 2010-05-16 09:11:39 +00:00 committed by Eric Botcazou
parent 1d4c5fe99b
commit 871fda0ab0
4 changed files with 43 additions and 0 deletions

View File

@ -1,3 +1,15 @@
2010-05-16 Eric Botcazou <ebotcazou@adacore.com>
* 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) <object>: Use the standard
exception type for standard exception definitions. Do not make them
volatile.
<E_Record_Type>: Equate fields of types associated with an exception
definition to those of the standard exception type.
2010-05-13 Andreas Schwab <schwab@linux-m68k.org>
* tracebak.c (__gnat_backtrace): Mark top_stack with ATTRIBUTE_UNUSED.

View File

@ -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;

View File

@ -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]

View File

@ -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),