diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2015-03-10 22:20:41 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2015-03-10 22:20:41 +0000 |
commit | 58cbf8d4dcaa6d0d81cd94bc3e8001b419265dd0 (patch) | |
tree | cf5ced19b7d49227299751b10fdc0edf1b11b546 /gcc | |
parent | 2d977ff983f86b3f7b7c9f1cb5a479af75cd589e (diff) | |
download | gcc-58cbf8d4dcaa6d0d81cd94bc3e8001b419265dd0.zip gcc-58cbf8d4dcaa6d0d81cd94bc3e8001b419265dd0.tar.gz gcc-58cbf8d4dcaa6d0d81cd94bc3e8001b419265dd0.tar.bz2 |
re PR c++/65370 (r213519 causes: error: redeclaration of 'template... may not have default arguments [-fpermissive])
/cp
2015-03-10 Paolo Carlini <paolo.carlini@oracle.com>
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 <paolo.carlini@oracle.com>
PR c++/65370
* g++.dg/other/default11.C: New.
* g++.dg/other/default12.C: Likewise.
From-SVN: r221337
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/default11.C | 11 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/default12.C | 16 |
5 files changed, 42 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1202b0f..625b034 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-03-10 Paolo Carlini <paolo.carlini@oracle.com> + + 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 <jakub@redhat.com> PR c++/65127 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 83e060b..54e6418 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 2a201e1..a45346a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-03-10 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/65370 + * g++.dg/other/default11.C: New. + * g++.dg/other/default12.C: Likewise. + 2015-03-10 Jakub Jelinek <jakub@redhat.com> 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 0000000..e747c44 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default11.C @@ -0,0 +1,11 @@ +// PR c++/65370 + +template <typename> class C +{ + template <typename U> + C(const C<U>&, bool = false); +}; + +template <> +template <typename U> +C<int>::C(const C<U>&, bool); diff --git a/gcc/testsuite/g++.dg/other/default12.C b/gcc/testsuite/g++.dg/other/default12.C new file mode 100644 index 0000000..3d7ba54 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default12.C @@ -0,0 +1,16 @@ +// PR c++/65370 + +template <typename> class C +{ + template <typename U> + C(const C<U>&, bool = false); +}; + +template<> +class C<int> +{ + template <typename U> + C(const C<U>&, bool); +}; + +template <typename U> C<int>::C(const C<U>&, bool = false) { } // { dg-error "default arguments" } |