From: Paolo Carlini Date: Thu, 23 Feb 2017 23:20:58 +0000 (+0000) Subject: re PR c++/79361 (ICE redefining a template function as defaulted or deleted) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e3beb191c5b574b7a735827ce96f3b4583c6bf7d;p=gcc.git re PR c++/79361 (ICE redefining a template function as defaulted or deleted) /cp 2017-02-23 Paolo Carlini 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 PR c++/79361 * g++.dg/cpp0x/pr79361-1.C: New. * g++.dg/cpp0x/pr79361-2.C: Likewise. From-SVN: r245692 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fb17a1913d2..d7470221d15 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-02-23 Paolo Carlini + + 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 PR c++/79679 - missing destructor for argument diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 17175bad45e..aaca70fe436 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 96a0234baaa..6efe58d151d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-02-23 Paolo Carlini + + PR c++/79361 + * g++.dg/cpp0x/pr79361-1.C: New. + * g++.dg/cpp0x/pr79361-2.C: Likewise. + 2017-02-23 Eric Botcazou * 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 index 00000000000..2960067be6a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr79361-1.C @@ -0,0 +1,7 @@ +// PR c++/79361 +// { dg-do compile { target c++11 } } + +template void foo(T); + +template<> void foo(int) {} // { dg-message "declared" } +template<> void foo(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 index 00000000000..25562118ffa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr79361-2.C @@ -0,0 +1,7 @@ +// PR c++/79361 +// { dg-do compile { target c++11 } } + +template void foo(T); + +template<> void foo(int) {} // { dg-message "declared" } +template<> void foo(int) = default; // { dg-error "redefinition" }