[RFA][PR 41063] ICE in output_die

Cary Coutant ccoutant@google.com
Sat Aug 15 00:41:00 GMT 2009


Here's an updated patch, with test case. I moved get_context_die to a
point earlier in the file to silence a warning about being declared
inline after it was used.

Bootstrapped and tested on x86_64-linux-gnu. Is this OK for trunk?

-cary


gcc/ChangeLog:

	PR debug/41063
	* dwarf2out.c (get_context_die): Moved.
	(gen_type_die_with_usage): Use proper context for basis types
	of pointer and reference types.
	(force_decl_die): Add case for TRANSLATION_UNIT_DECL.

gcc/testsuite/ChangeLog:

	PR debug/41063
	* g++.dg/debug/dwarf2/pr41063.C: New test.
-------------- next part --------------
Index: testsuite/g++.dg/debug/dwarf2/pr41063.C
===================================================================
--- testsuite/g++.dg/debug/dwarf2/pr41063.C	(revision 0)
+++ testsuite/g++.dg/debug/dwarf2/pr41063.C	(revision 0)
@@ -0,0 +1,20 @@
+// Contributed by Cary Coutant <ccoutant@google.com>
+// Origin: PR debug/41063
+// { dg-do compile }
+
+struct A {
+  virtual void run();
+};
+
+void test() {
+  struct B : public A {
+    void run() {
+      struct C : public A {
+	C() { }
+	B *b_;
+      };
+      C c;
+    }
+  };
+  B b;
+}
Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 150727)
+++ dwarf2out.c	(working copy)
@@ -13602,6 +13602,22 @@ decl_start_label (tree decl)
   return fnname;
 }
 #endif
+
+/* Returns the DIE for a context.  */
+
+static inline dw_die_ref
+get_context_die (tree context)
+{
+  if (context)
+    {
+      /* Find die that represents this context.  */
+      if (TYPE_P (context))
+	return force_type_die (context);
+      else
+	return force_decl_die (context);
+    }
+  return comp_unit_die;
+}
 

 /* These routines generate the internal representation of the DIE's for
    the compilation unit.  Debugging information is collected by walking
@@ -15486,6 +15502,17 @@ gen_type_die_with_usage (tree type, dw_d
 	 statement.  */
       TREE_ASM_WRITTEN (type) = 1;
 
+      /* Figure out the proper context for the basis type.  If it is
+         local to a function, use NULL for now; it will be fixed up
+         in decls_for_scope.  */
+      if (TYPE_STUB_DECL (TREE_TYPE (type)) != NULL_TREE)
+        {
+          if (decl_function_context (TYPE_STUB_DECL (TREE_TYPE (type))))
+            context_die = NULL;
+          else
+            context_die = get_context_die (TYPE_CONTEXT (TREE_TYPE (type)));
+	}
+
       /* For these types, all that is required is that we output a DIE (or a
 	 set of DIEs) to represent the "basis" type.  */
       gen_type_die_with_usage (TREE_TYPE (type), context_die,
@@ -15758,22 +15785,6 @@ is_redundant_typedef (const_tree decl)
   return 0;
 }
 
-/* Returns the DIE for a context.  */
-
-static inline dw_die_ref
-get_context_die (tree context)
-{
-  if (context)
-    {
-      /* Find die that represents this context.  */
-      if (TYPE_P (context))
-	return force_type_die (context);
-      else
-	return force_decl_die (context);
-    }
-  return comp_unit_die;
-}
-
 /* Returns the DIE for decl.  A DIE will always be returned.  */
 
 static dw_die_ref
@@ -15816,6 +15827,10 @@ force_decl_die (tree decl)
 	  dwarf2out_decl (decl);
 	  break;
 
+	case TRANSLATION_UNIT_DECL:
+	  decl_die = comp_unit_die;
+	  break;
+
 	default:
 	  gcc_unreachable ();
 	}


More information about the Gcc-patches mailing list