This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Fix incomplete debug info for atomic enum type


This patch is aimed at fixing a problem with STABS debug info: for

   type Data_T is (One, Two, Three);
   pragma Atomic (Data_T);

a cross-reference to a missing type (the naked Data_T) is emitted.

Fixed thusly, tested on i586-suse-linux, applied on the mainline


2008-04-06  Eric Botcazou  <ebotcazou@adacore.com>

	* decl.c (rest_of_type_decl_compilation_no_defer): New local function
	used to process all the variants of the specified type.
	(gnat_to_gnu_entity): Invoke rest_of_type_decl_compilation for enumeral
	types too.  Call rest_of_type_decl_compilation_no_defer if undeferring.
	(rest_of_type_decl_compilation): Likewise.
	* utils.c (gnat_pushdecl): Propagate the name to all variants of a type.


-- 
Eric Botcazou
Index: decl.c
===================================================================
--- decl.c	(revision 133936)
+++ decl.c	(working copy)
@@ -119,7 +119,8 @@ static tree make_type_from_size (tree, t
 static unsigned int validate_alignment (Uint, Entity_Id, unsigned int);
 static unsigned int ceil_alignment (unsigned HOST_WIDE_INT);
 static void check_ok_for_atomic (tree, Entity_Id, bool);
-static int  compatible_signatures_p (tree ftype1, tree ftype2);
+static int compatible_signatures_p (tree ftype1, tree ftype2);
+static void rest_of_type_decl_compilation_no_defer (tree);
 
 /* Given GNAT_ENTITY, an entity in the incoming GNAT tree, return a
    GCC type corresponding to that entity.  GNAT_ENTITY is assumed to
@@ -4417,12 +4418,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 
       if (TREE_CODE (gnu_scalar_type) == ENUMERAL_TYPE)
 	{
-	  TYPE_STUB_DECL (gnu_scalar_type) = gnu_decl;
-
 	  /* Since this has both a typedef and a tag, avoid outputting
 	     the name twice.  */
 	  DECL_ARTIFICIAL (gnu_decl) = 1;
-	  rest_of_type_compilation (gnu_scalar_type, global_bindings_p ());
+	  rest_of_type_decl_compilation (gnu_decl);
 	}
     }
 
@@ -4462,12 +4461,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	 now proceed with the finalization of the deferred types.  */
       if (defer_finalize_level == 0 && defer_finalize_list)
 	{
-	  int toplev = global_bindings_p ();
 	  unsigned int i;
 	  tree t;
 
 	  for (i = 0; VEC_iterate (tree, defer_finalize_list, i, t); i++)
-	    rest_of_decl_compilation (t, toplev, 0);
+	    rest_of_type_decl_compilation_no_defer (t);
 
 	  VEC_free (tree, heap, defer_finalize_list);
 	}
@@ -4514,17 +4512,46 @@ gnat_to_gnu_field_decl (Entity_Id gnat_e
   return gnu_field;
 }
 
-/* Wrap up compilation of T, a TYPE_DECL, possibly deferring it.  */
+/* Wrap up compilation of DECL, a TYPE_DECL, possibly deferring it.
+   Every TYPE_DECL generated for a type definition must be passed
+   to this function once everything else has been done for it.  */
 
 void
-rest_of_type_decl_compilation (tree t)
+rest_of_type_decl_compilation (tree decl)
 {
   /* We need to defer finalizing the type if incomplete types
      are being deferred or if they are being processed.  */
   if (defer_incomplete_level || defer_finalize_level)
-    VEC_safe_push (tree, heap, defer_finalize_list, t);
+    VEC_safe_push (tree, heap, defer_finalize_list, decl);
   else
-    rest_of_decl_compilation (t, global_bindings_p (), 0);
+    rest_of_type_decl_compilation_no_defer (decl);
+}
+
+/* Same as above but without deferring the compilation.  This
+   function should not be invoked directly on a TYPE_DECL.  */
+
+static void
+rest_of_type_decl_compilation_no_defer (tree decl)
+{
+  const int toplev = global_bindings_p ();
+  tree t = TREE_TYPE (decl);
+
+  rest_of_decl_compilation (decl, toplev, 0);
+
+  /* Now process all the variants.  This is needed for STABS.  */
+  for (t = TYPE_MAIN_VARIANT (t); t; t = TYPE_NEXT_VARIANT (t))
+    {
+      if (t == TREE_TYPE (decl))
+	continue;
+
+      if (!TYPE_STUB_DECL (t))
+	{
+	  TYPE_STUB_DECL (t) = build_decl (TYPE_DECL, DECL_NAME (decl), t);
+	  DECL_ARTIFICIAL (TYPE_STUB_DECL (t)) = 1;
+	}
+
+      rest_of_type_compilation (t, toplev);
+    }
 }
 
 /* Finalize any From_With_Type incomplete types.  We do this after processing
Index: utils.c
===================================================================
--- utils.c	(revision 133936)
+++ utils.c	(working copy)
@@ -447,7 +447,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_n
       tree t = TREE_TYPE (decl);
 
       if (!TYPE_NAME (t) || TREE_CODE (TYPE_NAME (t)) == IDENTIFIER_NODE)
-	TYPE_NAME (t) = decl;
+	;
       else if (TYPE_FAT_POINTER_P (t))
 	{
 	  tree tt = build_variant_type_copy (t);
@@ -455,9 +455,18 @@ gnat_pushdecl (tree decl, Node_Id gnat_n
 	  TREE_USED (tt) = TREE_USED (t);
 	  TREE_TYPE (decl) = tt;
 	  DECL_ORIGINAL_TYPE (decl) = t;
+	  t = NULL_TREE;
 	}
       else if (DECL_ARTIFICIAL (TYPE_NAME (t)) && !DECL_ARTIFICIAL (decl))
-	TYPE_NAME (t) = decl;
+	;
+      else
+	t = NULL_TREE;
+
+      /* Propagate the name to all the variants.  This is needed for
+	 the type qualifiers machinery to work properly.  */
+      if (t)
+	for (t = TYPE_MAIN_VARIANT (t); t; t = TYPE_NEXT_VARIANT (t))
+	  TYPE_NAME (t) = decl;
     }
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]