From 54aa834f49ab0e8855400d7d9ed513bf666ecb24 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 16 Apr 2012 22:29:43 -0400 Subject: [PATCH] re PR c++/52008 ([Core/1495] ICE when adding partial specialization for variadic-templated structure) 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 | 4 ++++ gcc/cp/pt.c | 12 ++++++++++++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp0x/variadic130.C | 8 ++++++++ 4 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic130.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 24ce8e0cd6b..1b7f4be2bc3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2012-04-16 Jason Merrill + 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. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index fcefc943376..d6144d59dd8 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1ced5be65fb..2acdffe9178 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2012-04-16 Jason Merrill + 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 index 00000000000..f73c8b5126c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic130.C @@ -0,0 +1,8 @@ +// PR c++/52008 +// { dg-do compile { target c++11 } } + +template +struct A; + +template +struct A<0, Ts...>; // { dg-error "not more specialized" } -- 2.30.2