OSDN Git Service

* gcc-interface/gigi.h (enum standard_datatypes): Add new value
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 16 May 2010 09:11:39 +0000 (09:11 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 16 May 2010 09:11:39 +0000 (09:11 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159452 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/ada/gcc-interface/gigi.h
gcc/ada/gcc-interface/trans.c

index aa2e462..b70056b 100644 (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.
index 49a06fb..137d523 100644 (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;
 
index f3a0bdd..ce8fc8a 100644 (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]
index c6bad43..68b496e 100644 (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),