From 9be1353919ef0b9c7319e44fb1e80aad908b3fea Mon Sep 17 00:00:00 2001 From: dodji Date: Thu, 1 Apr 2010 18:54:30 +0000 Subject: [PATCH] Fix for PR debug/43325 gcc/ChangeLog: PR debug/43325 * dwarf2out.c (gen_variable_die): Allow debug info for variable re-declaration when it happens in a function. gcc/testsuite/ChangeLog: PR debug/43325 * c-c++-common/dwarf2/redeclaration-1.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157928 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/dwarf2out.c | 6 +++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/dwarf2/redeclaration-1.C | 18 ++++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/dwarf2/redeclaration-1.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e5fc45e43b7..e78624faf63 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2010-04-01 Dodji Seketeli + + PR debug/43325 + * dwarf2out.c (gen_variable_die): Allow debug info for variable + re-declaration when it happens in a function. + 2010-04-01 Aldy Hernandez * cgraph.c (cgraph_add_function_insertion_hook): Update comment. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 86ae89b6964..5faa58c6c76 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -18283,9 +18283,9 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die) /* If the compiler emitted a definition for the DECL declaration and if we already emitted a DIE for it, don't emit a second - DIE for it again. */ - if (old_die - && declaration) + DIE for it again. Allow re-declarations of DECLs that are + inside functions, though. */ + if (old_die && declaration && !local_scope_p (context_die)) return; /* For static data members, the declaration in the class is supposed diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9eef0b06a14..8cefbf4125a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-04-01 Dodji Seketeli + + PR debug/43325 + * c-c++-common/dwarf2/redeclaration-1.C: New test. + 2010-04-01 Jason Merrill * g++.dg/cpp0x/initlist12.C: Adjust expected errors. diff --git a/gcc/testsuite/c-c++-common/dwarf2/redeclaration-1.C b/gcc/testsuite/c-c++-common/dwarf2/redeclaration-1.C new file mode 100644 index 00000000000..8aaff8ef2ea --- /dev/null +++ b/gcc/testsuite/c-c++-common/dwarf2/redeclaration-1.C @@ -0,0 +1,18 @@ +// Origin: PR debug/43325 +// { dg-options "-g -dA" } +// { dg-do compile } + +// { dg-final { scan-assembler-times "\[^\n\r\]*\\(DIE \[^\n\r\]*DW_TAG_lexical_block\\)\[\n\r\]{1,2}\[^\n\r\]*DW_AT_low_pc\[\n\r\]{1,2}\[^\n\r\]*DW_AT_high_pc\[\n\r\]{1,2}\[^\n\r\]*\\(DIE \[^\n\r\]*DW_TAG_variable\\)\[\n\r\]{1,2}\[^\n\r\]*DW_AT_name" 2 } } + +namespace S +{ + int + f() + { + int i = 42; + { + extern int i; + return i; + } + } +} -- 2.11.0