From be3d4a8262c8ce221fddae01c9117348f6aedd44 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 3 Dec 2010 16:56:53 +0000 Subject: [PATCH] PR debug/46123 * dwarf2out.c (gen_tagged_type_die): Don't put local types in a declaration DIE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167436 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++ gcc/dwarf2out.c | 4 +++ gcc/testsuite/ChangeLog | 6 ++++ gcc/testsuite/g++.dg/debug/dwarf2/pr46123.C | 47 +++++++++++++++++++++++++++++ gcc/testsuite/g++.dg/debug/pr46123.C | 47 +++++++++++++++++++++++++++++ 5 files changed, 110 insertions(+) create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/pr46123.C create mode 100644 gcc/testsuite/g++.dg/debug/pr46123.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5fb26ae..338e324 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-12-03 Jason Merrill + + PR debug/46123 + * dwarf2out.c (gen_tagged_type_die): Don't put local types in + a declaration DIE. + 2010-12-03 Nathan Froyd * config/arm/arm.c (arm_legitimate_index_p): Split diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 75faec5..acb70ed 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -20212,6 +20212,10 @@ gen_tagged_type_die (tree type, 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)); + /* A declaration DIE doesn't count; nested types need to go in the + specification. */ + if (context_die && is_declaration_die (context_die)) + context_die = NULL; need_pop = 0; } else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e70cf6a..f46c555 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2010-12-03 Jakub Jelinek + + PR debug/46123 + * g++.dg/debug/pr46123.C: New test. + * g++.dg/debug/dwarf2/pr46123.C: New test. + 2010-12-03 Jason Merrill PR c++/46058 diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr46123.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr46123.C new file mode 100644 index 0000000..eee192c --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr46123.C @@ -0,0 +1,47 @@ +// PR debug/46123 +// { dg-do compile } +// { dg-options "-gdwarf-4" } + +struct foo +{ + static int bar () + { + int i; + static int baz = 1; + { + static int baz = 2; + i = baz++; + } + { + struct baz + { + static int m () + { + static int n; + return n += 10; + } + }; + baz a; + i += a.m (); + } + { + static int baz = 3; + i += baz; + baz += 30; + } + i += baz; + baz += 60; + return i; + } +}; + +int main () +{ + foo x; + + if (x.bar () != 16) + return 1; + if (x.bar() != 117) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.dg/debug/pr46123.C b/gcc/testsuite/g++.dg/debug/pr46123.C new file mode 100644 index 0000000..9e115cd --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/pr46123.C @@ -0,0 +1,47 @@ +// PR debug/46123 +// { dg-do compile } +// { dg-options "-g -feliminate-dwarf2-dups" } + +struct foo +{ + static int bar () + { + int i; + static int baz = 1; + { + static int baz = 2; + i = baz++; + } + { + struct baz + { + static int m () + { + static int n; + return n += 10; + } + }; + baz a; + i += a.m (); + } + { + static int baz = 3; + i += baz; + baz += 30; + } + i += baz; + baz += 60; + return i; + } +}; + +int main () +{ + foo x; + + if (x.bar () != 16) + return 1; + if (x.bar() != 117) + return 1; + return 0; +} -- 2.7.4