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.
Tested x86_64-pc-linux-gnu, applying to trunk.
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 ec05ee1f0b4..1cb47313923 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 00000000000..3ea7ae72b96
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/defaulted1.C
@@ -0,0 +1,10 @@
+// PR c++/90674
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+struct C {
+ C() {}
+};
+
+template<>
+C<int>::C() = default;
base-commit: 006783f4b165dff25aae3697920fcf54754dddd4
--
2.27.0