re PR c++/15867 (-Wredundant-decls and explicit template specialization)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 3 Jan 2012 09:33:33 +0000 (09:33 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 3 Jan 2012 09:33:33 +0000 (09:33 +0000)
/cp
2012-01-03  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/15867
* decl.c (duplicate_decls): With -Wredundant-decls don't warn for
declaration followed by specialization.

/testsuite
2012-01-03  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/15867
* g++.dg/warn/Wredundant-decls-spec.C: New.

From-SVN: r182833

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wredundant-decls-spec.C [new file with mode: 0644]

index beee3bf8029e0440d560b3c71902457ae2d18596..4f6faf5b80644d4774d61a667a045e48257152fe 100644 (file)
@@ -1,3 +1,9 @@
+2012-01-03  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/15867
+       * decl.c (duplicate_decls): With -Wredundant-decls don't warn for
+       declaration followed by specialization.
+
 2012-01-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/51669
index 48f3085a92f1a43ed25902dcb4b406e66f18d531..7daac5feff480d81093b09f80c53175504e338cd 100644 (file)
@@ -1698,7 +1698,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
          /* Don't warn about extern decl followed by definition.  */
          && !(DECL_EXTERNAL (olddecl) && ! DECL_EXTERNAL (newdecl))
          /* Don't warn about friends, let add_friend take care of it.  */
-         && ! (newdecl_is_friend || DECL_FRIEND_P (olddecl)))
+         && ! (newdecl_is_friend || DECL_FRIEND_P (olddecl))
+         /* Don't warn about declaration followed by specialization.  */
+         && (! DECL_TEMPLATE_SPECIALIZATION (newdecl)
+             || DECL_TEMPLATE_SPECIALIZATION (olddecl)))
        {
          warning (OPT_Wredundant_decls, "redundant redeclaration of %qD in same scope", newdecl);
          warning (OPT_Wredundant_decls, "previous declaration of %q+D", olddecl);
index a75ef954a563e49a52c7bcfacad45fff8d24db38..6ac425a63d7b638816731f4fedcc6eebbd88dfd3 100644 (file)
@@ -1,3 +1,8 @@
+2012-01-03  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/15867
+       * g++.dg/warn/Wredundant-decls-spec.C: New.
+
 2012-01-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/51719
diff --git a/gcc/testsuite/g++.dg/warn/Wredundant-decls-spec.C b/gcc/testsuite/g++.dg/warn/Wredundant-decls-spec.C
new file mode 100644 (file)
index 0000000..b5c790f
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/15867
+// { dg-options -Wredundant-decls }
+
+template <typename T> struct S
+{  
+  void foo() {}          
+};  
+
+template<> void S<int>::foo();
+
+template<> void S<double>::foo();  // { dg-warning "previous declaration" }
+template<> void S<double>::foo();  // { dg-warning "redundant redeclaration" }