aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/dwarf2out.c34
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C34
4 files changed, 75 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c4335a6..eb352d6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2010-06-22 Cary Coutant <ccoutant@google.com>
+
+ * dwarf2out.c (is_nested_in_subprogram): New function.
+ (should_move_die_to_comdat): Use it.
+ (copy_ancestor_tree): Don't mark DIEs here.
+ (copy_decls_walk): Start walk from root of newly-added tree;
+ mark DIEs here instead.
+
2010-06-22 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/i386.md (unit): Also check sseishft1.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 701d792..5c4999d 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -9630,6 +9630,18 @@ is_declaration_die (dw_die_ref die)
return 0;
}
+/* Return non-zero if this DIE is nested inside a subprogram. */
+
+static int
+is_nested_in_subprogram (dw_die_ref die)
+{
+ dw_die_ref decl = get_AT_ref (die, DW_AT_specification);
+
+ if (decl == NULL)
+ decl = die;
+ return local_scope_p (decl);
+}
+
/* Return non-zero if this is a type DIE that should be moved to a
COMDAT .debug_types section. */
@@ -9642,8 +9654,11 @@ should_move_die_to_comdat (dw_die_ref die)
case DW_TAG_structure_type:
case DW_TAG_enumeration_type:
case DW_TAG_union_type:
- /* Don't move declarations or inlined instances. */
- if (is_declaration_die (die) || get_AT (die, DW_AT_abstract_origin))
+ /* Don't move declarations, inlined instances, or types nested in a
+ subprogram. */
+ if (is_declaration_die (die)
+ || get_AT (die, DW_AT_abstract_origin)
+ || is_nested_in_subprogram (die))
return 0;
return 1;
case DW_TAG_array_type:
@@ -10055,8 +10070,6 @@ copy_ancestor_tree (dw_die_ref unit, dw_die_ref die, htab_t decl_table)
if (decl_table != NULL)
{
- /* Make sure the copy is marked as part of the type unit. */
- copy->die_mark = 1;
/* Record the pointer to the copy. */
entry->copy = copy;
}
@@ -10130,7 +10143,18 @@ copy_decls_walk (dw_die_ref unit, dw_die_ref die, htab_t decl_table)
installed in a previously-added context, it won't
get visited otherwise. */
if (parent != unit)
- copy_decls_walk (unit, parent, decl_table);
+ {
+ /* Find the highest point of the newly-added tree,
+ mark each node along the way, and walk from there. */
+ parent->die_mark = 1;
+ while (parent->die_parent
+ && parent->die_parent->die_mark == 0)
+ {
+ parent = parent->die_parent;
+ parent->die_mark = 1;
+ }
+ copy_decls_walk (unit, parent, decl_table);
+ }
}
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 326f2bc..056fd96 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2010-06-22 Cary Coutant <ccoutant@google.com>
+
+ * g++.dg/debug/dwarf2/dwarf4-typedef.C: New test.
+
2010-06-22 Janus Weil <janus@gcc.gnu.org>
PR fortran/44616
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C
new file mode 100644
index 0000000..c5520fa
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf4-typedef.C
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-gdwarf-4" } */
+
+/* Regression test for an ICE in output_die when using -gdwarf-4. */
+
+namespace {
+
+struct A {
+ virtual ~A();
+};
+
+struct B : public A {
+ template <typename A>
+ bool foo(A x[2]) { }
+};
+
+template <typename T>
+struct C {
+ T v[2];
+};
+
+template <typename T>
+bool X(T &b) {
+ typedef C<int> D;
+ D x[2];
+ return b.foo(x);
+}
+
+void f() {
+ B b;
+ X<B>(b);
+}
+
+}