re PR c++/52008 ([Core/1495] ICE when adding partial specialization for variadic...
authorJason Merrill <jason@redhat.com>
Tue, 17 Apr 2012 02:29:43 +0000 (22:29 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 17 Apr 2012 02:29:43 +0000 (22:29 -0400)
PR c++/52008
* pt.c (process_partial_specialization): Complain about a partial
specialization with fewer args than primary template parms.

From-SVN: r186521

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

index 24ce8e0cd6bcb3232dbcd55121f18715babd4af8..1b7f4be2bc3721191c2d0bd91062b84e61dd8d7b 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 fcefc943376d8f07df042b58e6c94fb04e5e513e..d6144d59dd8d98fa55bad68f183f91719f605272 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 1ced5be65fb70c97fcb625c119f38c876ebd201b..2acdffe9178eb0cb5b8fa86fc56a8227563c4c98 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" }