Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > b5e52bbfb4bb11a6cbed452927fba979 > files > 98

gcc-4.1.2-50.el5.src.rpm

2009-08-28  Cary Coutant  <ccoutant@google.com>

	PR debug/41063
	* dwarf2out.c (gen_type_die_with_usage): Use proper context for
	struct/union/enum types local to a function.

	* g++.dg/debug/pr41063.C: New test.

--- gcc/dwarf2out.c	(revision 151184)
+++ gcc/dwarf2out.c	(revision 151187)
@@ -15573,6 +15573,15 @@ gen_type_die_with_usage (tree type, dw_d
 	  context_die = lookup_type_die (TYPE_CONTEXT (type));
 	  need_pop = 1;
 	}
+      else if (TYPE_CONTEXT (type) != NULL_TREE
+	       && (TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL))
+	{
+	  /* If this type is local to a function that hasn't been written
+	     out yet, use a NULL context for now; it will be fixed up in
+	     decls_for_scope.  */
+	  context_die = lookup_decl_die (TYPE_CONTEXT (type));
+	  need_pop = 0;
+	}
       else
 	{
 	  context_die = declare_in_namespace (type, context_die);
--- gcc/testsuite/g++.dg/debug/pr41063.C	(revision 0)
+++ gcc/testsuite/g++.dg/debug/pr41063.C	(revision 151187)
@@ -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;
+}