From: Paolo Carlini Date: Tue, 10 Mar 2015 22:20:41 +0000 (+0000) Subject: re PR c++/65370 (r213519 causes: error: redeclaration of 'template... may not have... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=58cbf8d4dcaa6d0d81cd94bc3e8001b419265dd0;p=gcc.git re PR c++/65370 (r213519 causes: error: redeclaration of 'template... may not have default arguments [-fpermissive]) /cp 2015-03-10 Paolo Carlini PR c++/65370 * decl.c (duplicate_decls): Call check_redeclaration_no_default_args only if the location of newdecl doesn't match the location of olddecl. /testsuite 2015-03-10 Paolo Carlini PR c++/65370 * g++.dg/other/default11.C: New. * g++.dg/other/default12.C: Likewise. From-SVN: r221337 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1202b0fc868..625b03409ca 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-03-10 Paolo Carlini + + PR c++/65370 + * decl.c (duplicate_decls): Call check_redeclaration_no_default_args + only if the location of newdecl doesn't match the location of olddecl. + 2015-03-10 Jakub Jelinek PR c++/65127 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 83e060b4d11..54e6418b322 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1922,7 +1922,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) { /* Per C++11 8.3.6/4, default arguments cannot be added in later declarations of a function template. */ - check_redeclaration_no_default_args (newdecl); + if (DECL_SOURCE_LOCATION (newdecl) + != DECL_SOURCE_LOCATION (olddecl)) + check_redeclaration_no_default_args (newdecl); check_default_args (newdecl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2a201e18ff6..a45346aaf18 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-03-10 Paolo Carlini + + PR c++/65370 + * g++.dg/other/default11.C: New. + * g++.dg/other/default12.C: Likewise. + 2015-03-10 Jakub Jelinek PR target/65368 diff --git a/gcc/testsuite/g++.dg/other/default11.C b/gcc/testsuite/g++.dg/other/default11.C new file mode 100644 index 00000000000..e747c44a11b --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default11.C @@ -0,0 +1,11 @@ +// PR c++/65370 + +template class C +{ + template + C(const C&, bool = false); +}; + +template <> +template +C::C(const C&, bool); diff --git a/gcc/testsuite/g++.dg/other/default12.C b/gcc/testsuite/g++.dg/other/default12.C new file mode 100644 index 00000000000..3d7ba5497d0 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default12.C @@ -0,0 +1,16 @@ +// PR c++/65370 + +template class C +{ + template + C(const C&, bool = false); +}; + +template<> +class C +{ + template + C(const C&, bool); +}; + +template C::C(const C&, bool = false) { } // { dg-error "default arguments" }