]> git.ipfire.org Git - people/ms/gcc.git/commitdiff
c++: DWARF ICE with defaulted specialization [PR90674]
authorJason Merrill <jason@redhat.com>
Wed, 14 Apr 2021 00:32:13 +0000 (20:32 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 14 Apr 2021 00:32:13 +0000 (20:32 -0400)
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
gcc/testsuite/g++.dg/debug/defaulted1.C [new file with mode: 0644]

index ec05ee1f0b49365f6843cb7477883b302188619f..1cb4731392387231cfcef9d08a4633bd019c9479 100644 (file)
@@ -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 (file)
index 0000000..3ea7ae7
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/90674
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+struct C {
+    C() {}
+};
+
+template<>
+C<int>::C() = default;