commit 302f9976c53aa09e431bd54f37dbfeaa2c6b2acc Author: Aldy Hernandez Date: Wed Jun 24 20:04:09 2015 -0700 PR debug/66653 * cgraphunit.c (analyze_functions): Do not call debug_hooks->late_global_decl when decl_type_context. diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 066a155..d2974ad 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1149,7 +1149,8 @@ analyze_functions (bool first_time) at looking at optimized away DECLs, since late_global_decl will subsequently be called from the contents of the now pruned symbol table. */ - if (!decl_function_context (node->decl)) + if (!decl_function_context (node->decl) + && !decl_type_context (node->decl)) (*debug_hooks->late_global_decl) (node->decl); node->remove (); diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr66653.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr66653.C new file mode 100644 index 0000000..bcaaf88 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr66653.C @@ -0,0 +1,8 @@ +// PR debug/54508 +// { dg-do compile } +// { dg-options "-g" } + +template class A +{ + static __thread T a; +};