DR 941
authorJason Merrill <jason@redhat.com>
Fri, 19 Apr 2013 16:28:03 +0000 (12:28 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 19 Apr 2013 16:28:03 +0000 (12:28 -0400)
DR 941
* decl.c (duplicate_decls): Don't propagate DECL_DELETED_FN to
template specializations.

From-SVN: r198098

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

index 94e29af..9d6ad14 100644 (file)
@@ -1,3 +1,9 @@
+2013-04-19  Jason Merrill  <jason@redhat.com>
+
+       DR 941
+       * decl.c (duplicate_decls): Don't propagate DECL_DELETED_FN to
+       template specializations.
+
 2013-04-16  Ed Smith-Rowland  <3dw4rd@verizon.net>
 
        Implement n3599 - Literal operator templates for strings.
index 01804d2..3328812 100644 (file)
@@ -1764,12 +1764,16 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
          warning (OPT_Wredundant_decls, "previous declaration of %q+D", olddecl);
        }
 
-      if (DECL_DELETED_FN (newdecl))
+      if (!(DECL_TEMPLATE_INSTANTIATION (olddecl)
+           && DECL_TEMPLATE_SPECIALIZATION (newdecl)))
        {
-         error ("deleted definition of %qD", newdecl);
-         error ("after previous declaration %q+D", olddecl);
+         if (DECL_DELETED_FN (newdecl))
+           {
+             error ("deleted definition of %qD", newdecl);
+             error ("after previous declaration %q+D", olddecl);
+           }
+         DECL_DELETED_FN (newdecl) |= DECL_DELETED_FN (olddecl);
        }
-      DECL_DELETED_FN (newdecl) |= DECL_DELETED_FN (olddecl);
     }
 
   /* Deal with C++: must preserve virtual function table size.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted42.C b/gcc/testsuite/g++.dg/cpp0x/defaulted42.C
new file mode 100644 (file)
index 0000000..1ac25a9
--- /dev/null
@@ -0,0 +1,10 @@
+// DR 941
+// { dg-require-effective-target c++11 }
+
+template <class T> T f(T) = delete;
+template<> int f(int) { return 42; }
+
+int main()
+{
+  f(42);
+}