PR c++/52008
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 17 Apr 2012 02:29:43 +0000 (02:29 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 17 Apr 2012 02:29:43 +0000 (02:29 +0000)
* pt.c (process_partial_specialization): Complain about a partial
specialization with fewer args than primary template parms.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186521 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 24ce8e0..1b7f4be 100644 (file)
@@ -1,5 +1,9 @@
 2012-04-16  Jason Merrill  <jason@redhat.com>
 
+       PR c++/52008
+       * pt.c (process_partial_specialization): Complain about a partial
+       specialization with fewer args than primary template parms.
+
        PR c++/50830
        * pt.c (convert_template_argument): Handle template template
        argument packs.
index fcefc94..d6144d5 100644 (file)
@@ -4376,6 +4376,18 @@ process_partial_specialization (tree decl)
                                                   (maintmpl)))))
     error ("partial specialization %qT does not specialize any template arguments", type);
 
+  /* A partial specialization that replaces multiple parameters of the
+     primary template with a pack expansion is less specialized for those
+     parameters.  */
+  if (nargs < DECL_NTPARMS (maintmpl))
+    {
+      error ("partial specialization is not more specialized than the "
+            "primary template because it replaces multiple parameters "
+            "with a pack expansion");
+      inform (DECL_SOURCE_LOCATION (maintmpl), "primary template here");
+      return decl;
+    }
+
   /* [temp.class.spec]
 
      A partially specialized non-type argument expression shall not
index 1ced5be..2acdffe 100644 (file)
@@ -1,5 +1,8 @@
 2012-04-16  Jason Merrill  <jason@redhat.com>
 
+       PR c++/52008
+       * g++.dg/cpp0x/variadic130.C: New.
+
        PR c++/50830
        * g++.dg/cpp0x/variadic129.C: New.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic130.C b/gcc/testsuite/g++.dg/cpp0x/variadic130.C
new file mode 100644 (file)
index 0000000..f73c8b5
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/52008
+// { dg-do compile { target c++11 } }
+
+template <int I, typename T, typename... Ts>
+struct A;
+
+template<typename... Ts>
+struct A<0, Ts...>;            // { dg-error "not more specialized" }