re PR c++/65370 (r213519 causes: error: redeclaration of 'template... may not have...
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 10 Mar 2015 22:20:41 +0000 (22:20 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 10 Mar 2015 22:20:41 +0000 (22:20 +0000)
/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

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/default11.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/default12.C [new file with mode: 0644]

index 1202b0fc868e3c4f653ef15f33d83e4613105247..625b03409ca754b101cfd949723cfb94dc06caae 100644 (file)
@@ -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
index 83e060b4d11723d7eb6c1e5e72d39721746607a0..54e6418b32277c9e63fd9f2ce75bbad15fba6c7e 100644 (file)
@@ -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);
 
index 2a201e18ff68bb3aecd2ce0321c35c3fd6fd500f..a45346aaf188667906439a9dcd2c9c19b4c49c22 100644 (file)
@@ -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 (file)
index 0000000..e747c44
--- /dev/null
@@ -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 (file)
index 0000000..3d7ba54
--- /dev/null
@@ -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" }