re PR c++/79361 (ICE redefining a template function as defaulted or deleted)
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 23 Feb 2017 23:20:58 +0000 (23:20 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 23 Feb 2017 23:20:58 +0000 (23:20 +0000)
/cp
2017-02-23  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/79361
* pt.c (register_specialization): Check duplicate_decls return value
for error_mark_node and pass it back.

/testsuite
2017-02-23  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/79361
* g++.dg/cpp0x/pr79361-1.C: New.
* g++.dg/cpp0x/pr79361-2.C: Likewise.

From-SVN: r245692

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr79361-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/pr79361-2.C [new file with mode: 0644]

index fb17a1913d25fb6fa59a1c537b6cc5ac7a0ba4a6..d7470221d153ba00ad9c38188ed729e88b4920aa 100644 (file)
@@ -1,3 +1,9 @@
+2017-02-23  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/79361
+       * pt.c (register_specialization): Check duplicate_decls return value
+       for error_mark_node and pass it back.
+
 2017-02-22  Jason Merrill  <jason@redhat.com>
 
        PR c++/79679 - missing destructor for argument
index 17175bad45eb69ffa7bbb791c3c86f77548eb47e..aaca70fe43672ed5ab5eb04142b09d6ea62bf88e 100644 (file)
@@ -1599,7 +1599,12 @@ register_specialization (tree spec, tree tmpl, tree args, bool is_friend,
        }
       else if (DECL_TEMPLATE_SPECIALIZATION (fn))
        {
-         if (!duplicate_decls (spec, fn, is_friend) && DECL_INITIAL (spec))
+         tree dd = duplicate_decls (spec, fn, is_friend);
+         if (dd == error_mark_node)
+           /* We've already complained in duplicate_decls.  */
+           return error_mark_node;
+
+         if (dd == NULL_TREE && DECL_INITIAL (spec))
            /* Dup decl failed, but this is a new definition. Set the
               line number so any errors match this new
               definition.  */
index 96a0234baaa4bed2a621289062e373c57ecf689c..6efe58d151dbe741884cb3ef1a04349e8aca6d4f 100644 (file)
@@ -1,3 +1,9 @@
+2017-02-23  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/79361
+       * g++.dg/cpp0x/pr79361-1.C: New.
+       * g++.dg/cpp0x/pr79361-2.C: Likewise.
+
 2017-02-23  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.target/visium/bit_test.c: Accept any lsr form.
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr79361-1.C b/gcc/testsuite/g++.dg/cpp0x/pr79361-1.C
new file mode 100644 (file)
index 0000000..2960067
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/79361
+// { dg-do compile { target c++11 } }
+
+template<typename T> void foo(T);
+
+template<> void foo<int>(int) {}   // { dg-message "declared" }
+template<> void foo<int>(int) = delete;  // { dg-error "redefinition" }
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr79361-2.C b/gcc/testsuite/g++.dg/cpp0x/pr79361-2.C
new file mode 100644 (file)
index 0000000..2556211
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/79361
+// { dg-do compile { target c++11 } }
+
+template<typename T> void foo(T);
+
+template<> void foo<int>(int) {}   // { dg-message "declared" }
+template<> void foo<int>(int) = default;  // { dg-error "redefinition" }