OSDN Git Service

* gcc-interface/gigi.h (record_builtin_type): Add ARTIFICIAL_P param.
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 2 Apr 2011 08:28:21 +0000 (08:28 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 2 Apr 2011 08:28:21 +0000 (08:28 +0000)
* gcc-interface/utils.c (gnat_pushdecl): If this is a non-artificial
declaration of an array type, then set DECL_ORIGINAL_TYPE to a distinct
copy.
(record_builtin_type): Add ARTIFICIAL_P parameter.  Set DECL_ARTIFICIAL
flag of the type accordingly.
* gcc-interface/trans.c (gigi): Adjust calls to record_builtin_type.

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

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

index e4928c4..4e109b4 100644 (file)
@@ -1,5 +1,15 @@
 2011-04-02  Eric Botcazou  <ebotcazou@adacore.com>
 
+       * gcc-interface/gigi.h (record_builtin_type): Add ARTIFICIAL_P param.
+       * gcc-interface/utils.c (gnat_pushdecl): If this is a non-artificial
+       declaration of an array type, then set DECL_ORIGINAL_TYPE to a distinct
+       copy.
+       (record_builtin_type): Add ARTIFICIAL_P parameter.  Set DECL_ARTIFICIAL
+       flag of the type accordingly.
+       * gcc-interface/trans.c (gigi): Adjust calls to record_builtin_type.
+
+2011-04-02  Eric Botcazou  <ebotcazou@adacore.com>
+
        * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Access_Type>: Defer
        finalizing types when updating the pointers to the designated type.
        <all>: Finalize the deferred types even if we didn't defer processing
index a50010c..fbf8a0b 100644 (file)
@@ -504,8 +504,10 @@ extern void init_dummy_type (void);
 /* Make a dummy type corresponding to GNAT_TYPE.  */
 extern tree make_dummy_type (Entity_Id gnat_type);
 
-/* Record TYPE as a builtin type for Ada.  NAME is the name of the type.  */
-extern void record_builtin_type (const char *name, tree type);
+/* Record TYPE as a builtin type for Ada.  NAME is the name of the type.
+   ARTIFICIAL_P is true if it's a type that was generated by the compiler.  */
+extern void record_builtin_type (const char *name, tree type,
+                                bool artificial_p);
 
 /* Given a record type RECORD_TYPE and a list of FIELD_DECL nodes FIELD_LIST,
    finish constructing the record or union type.  If REP_LEVEL is zero, this
index 332f715..cca9523 100644 (file)
@@ -308,10 +308,10 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED,
 
   /* Record the builtin types.  Define `integer' and `character' first so that
      dbx will output them first.  */
-  record_builtin_type ("integer", integer_type_node);
-  record_builtin_type ("character", unsigned_char_type_node);
-  record_builtin_type ("boolean", boolean_type_node);
-  record_builtin_type ("void", void_type_node);
+  record_builtin_type ("integer", integer_type_node, false);
+  record_builtin_type ("character", unsigned_char_type_node, false);
+  record_builtin_type ("boolean", boolean_type_node, false);
+  record_builtin_type ("void", void_type_node, false);
 
   /* Save the type we made for integer as the type for Standard.Integer.  */
   save_gnu_tree (Base_Type (standard_integer),
@@ -397,7 +397,7 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED,
   jmpbuf_type
     = build_array_type (gnat_type_for_mode (Pmode, 0),
                        build_index_type (size_int (5)));
-  record_builtin_type ("JMPBUF_T", jmpbuf_type);
+  record_builtin_type ("JMPBUF_T", jmpbuf_type, true);
   jmpbuf_ptr_type = build_pointer_type (jmpbuf_type);
 
   /* Functions to get and set the jumpbuf pointer for the current thread.  */
@@ -552,7 +552,7 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED,
        }
 
       finish_record_type (fdesc_type_node, nreverse (field_list), 0, false);
-      record_builtin_type ("descriptor", fdesc_type_node);
+      record_builtin_type ("descriptor", fdesc_type_node, true);
       null_fdesc_node = gnat_build_constructor (fdesc_type_node, null_vec);
     }
 
@@ -566,7 +566,8 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name ATTRIBUTE_UNUSED,
       longest_float_type_node = make_node (REAL_TYPE);
       TYPE_PRECISION (longest_float_type_node) = LONG_DOUBLE_TYPE_SIZE;
       layout_type (longest_float_type_node);
-      record_builtin_type ("longest float type", longest_float_type_node);
+      record_builtin_type ("longest float type", longest_float_type_node,
+                          false);
     }
   else
     longest_float_type_node = TREE_TYPE (long_long_float_type);
index 2cfd1ce..78d5506 100644 (file)
@@ -508,7 +508,18 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
       tree t = TREE_TYPE (decl);
 
       if (!(TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL))
-       ;
+       {
+         /* Array types aren't tagged types in the C sense so we force the
+            type to be associated with its typedef in the DWARF back-end,
+            in order to make sure that the latter is always preserved.  */
+         if (!DECL_ARTIFICIAL (decl) && TREE_CODE (t) == ARRAY_TYPE)
+           {
+             tree tt = build_distinct_type_copy (t);
+             TYPE_NAME (tt) = DECL_NAME (decl);
+             TYPE_STUB_DECL (tt) = TYPE_STUB_DECL (t);
+             DECL_ORIGINAL_TYPE (decl) = tt;
+           }
+       }
       else if (TYPE_IS_FAT_POINTER_P (t))
        {
          tree tt = build_variant_type_copy (t);
@@ -535,14 +546,15 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
     }
 }
 \f
-/* Record TYPE as a builtin type for Ada.  NAME is the name of the type.  */
+/* Record TYPE as a builtin type for Ada.  NAME is the name of the type.
+   ARTIFICIAL_P is true if it's a type that was generated by the compiler.  */
 
 void
-record_builtin_type (const char *name, tree type)
+record_builtin_type (const char *name, tree type, bool artificial_p)
 {
   tree type_decl = build_decl (input_location,
                               TYPE_DECL, get_identifier (name), type);
-
+  DECL_ARTIFICIAL (type_decl) = artificial_p;
   gnat_pushdecl (type_decl, Empty);
 
   if (debug_hooks->type_decl)