From f3ac6d2c51d007e000f92db06043f0f4683695bc Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 4 Apr 2018 14:11:39 +0000 Subject: [PATCH] re PR debug/85176 (ICE in force_decl_die, at dwarf2out.c:25910) 2018-04-04 Richard Biener PR lto/85176 * dwarf2out.c (dwarf2out_register_external_die): Peel namespaces from contexts for DINFO_LEVEL_TERSE and below. * g++.dg/lto/pr85176_0.C: New testcase. From-SVN: r259080 --- gcc/ChangeLog | 6 ++++++ gcc/dwarf2out.c | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/lto/pr85176_0.C | 10 ++++++++++ 4 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/g++.dg/lto/pr85176_0.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bd0c1b12156..c24c3dc090f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-04-04 Richard Biener + + PR lto/85176 + * dwarf2out.c (dwarf2out_register_external_die): Peel namespaces + from contexts for DINFO_LEVEL_TERSE and below. + 2018-04-04 Kito Cheng * config/nds32/nds32-doubleword.md (move_): Require diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 049be713391..793305484df 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -5903,8 +5903,13 @@ dwarf2out_register_external_die (tree decl, const char *sym, } else ctx = DECL_CONTEXT (decl); + /* Peel types in the context stack. */ while (ctx && TYPE_P (ctx)) ctx = TYPE_CONTEXT (ctx); + /* Likewise namespaces in case we do not want to emit DIEs for them. */ + if (debug_info_level <= DINFO_LEVEL_TERSE) + while (ctx && TREE_CODE (ctx) == NAMESPACE_DECL) + ctx = DECL_CONTEXT (ctx); if (ctx) { if (TREE_CODE (ctx) == BLOCK) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index af3e374c510..e9c9475830d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-04-04 Richard Biener + + PR lto/85176 + * g++.dg/lto/pr85176_0.C: New testcase. + 2018-04-04 Richard Biener PR testsuite/85191 diff --git a/gcc/testsuite/g++.dg/lto/pr85176_0.C b/gcc/testsuite/g++.dg/lto/pr85176_0.C new file mode 100644 index 00000000000..73767ce42ea --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr85176_0.C @@ -0,0 +1,10 @@ +// { dg-lto-do link } +// { dg-lto-options { { -flto -g1 } } } +// { dg-extra-ld-options "-r -nostdlib" } +namespace a { + template class c; + template void e(c &); + void operator<<(c &f, const char *) { e(f); } + extern c cout; +} +int main() { a::cout << ""; } -- 2.30.2