From 0589be0c59767cf4cbb0ef0e7d918cf6aa3d606c Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 13 Apr 2021 20:32:13 -0400 Subject: [PATCH] c++: DWARF ICE with defaulted specialization [PR90674] Here when we merged the specialization with the implicit instantiation declaration, we wrongly kept the value of DECL_INITIALIZED_IN_CLASS_P from the latter. gcc/cp/ChangeLog: PR c++/90674 * decl.c (duplicate_decls): Don't propagate DECL_INITIALIZED_IN_CLASS_P to a specialization. gcc/testsuite/ChangeLog: PR c++/90674 * g++.dg/debug/defaulted1.C: New test. --- gcc/cp/decl.c | 5 +++-- gcc/testsuite/g++.dg/debug/defaulted1.C | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/debug/defaulted1.C diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index ec05ee1f0b49..1cb473139238 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2556,8 +2556,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) if (!DECL_USE_TEMPLATE (newdecl)) DECL_USE_TEMPLATE (newdecl) = DECL_USE_TEMPLATE (olddecl); - DECL_INITIALIZED_IN_CLASS_P (newdecl) - |= DECL_INITIALIZED_IN_CLASS_P (olddecl); + if (!DECL_TEMPLATE_SPECIALIZATION (newdecl)) + DECL_INITIALIZED_IN_CLASS_P (newdecl) + |= DECL_INITIALIZED_IN_CLASS_P (olddecl); } /* Don't really know how much of the language-specific diff --git a/gcc/testsuite/g++.dg/debug/defaulted1.C b/gcc/testsuite/g++.dg/debug/defaulted1.C new file mode 100644 index 000000000000..3ea7ae72b96b --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/defaulted1.C @@ -0,0 +1,10 @@ +// PR c++/90674 +// { dg-do compile { target c++11 } } + +template +struct C { + C() {} +}; + +template<> +C::C() = default; -- 2.47.2