From: Jason Merrill Date: Tue, 1 Apr 2014 21:25:20 +0000 (-0400) Subject: re PR c++/60374 ([c++11] ICE with invalid template specialization) X-Git-Tag: basepoints/gcc-5~121 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd8a9d6d1c66d77e3d6a82468b5ea4794de3ffca;p=thirdparty%2Fgcc.git re PR c++/60374 ([c++11] ICE with invalid template specialization) PR c++/60374 * pt.c (coerce_template_parms): Check that the pack expansion pattern works with the first matching parameter. From-SVN: r208999 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 332894f8ab6d..764400c78554 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-04-01 Jason Merrill + + PR c++/60374 + * pt.c (coerce_template_parms): Check that the pack expansion + pattern works with the first matching parameter. + 2014-04-01 Fabien Chêne * cp/init.c (perform_member_init): Homogenize uninitialized diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index bfb49d7f8244..9de00d556e20 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6933,6 +6933,26 @@ coerce_template_parms (tree parms, { if (PACK_EXPANSION_P (arg)) { + /* "If every valid specialization of a variadic template + requires an empty template parameter pack, the template is + ill-formed, no diagnostic required." So check that the + pattern works with this parameter. */ + tree pattern = PACK_EXPANSION_PATTERN (arg); + tree conv = convert_template_argument (TREE_VALUE (parm), + pattern, new_args, + complain, parm_idx, + in_decl); + if (conv == error_mark_node) + { + inform (input_location, "so any instantiation with a " + "non-empty parameter pack would be ill-formed"); + ++lost; + } + else if (TYPE_P (conv) && !TYPE_P (pattern)) + /* Recover from missing typename. */ + TREE_VEC_ELT (inner_args, arg_idx) + = make_pack_expansion (conv); + /* We don't know how many args we have yet, just use the unconverted ones for now. */ new_inner_args = inner_args; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic154.C b/gcc/testsuite/g++.dg/cpp0x/variadic154.C new file mode 100644 index 000000000000..198f9c5ba395 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic154.C @@ -0,0 +1,8 @@ +// PR c++/60374 +// { dg-do compile { target c++11 } } + +template struct A {}; + +template struct A {}; // { dg-error "typename|partial|T" } + +A a; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic155.C b/gcc/testsuite/g++.dg/cpp0x/variadic155.C new file mode 100644 index 000000000000..d912317bdc4f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic155.C @@ -0,0 +1,4 @@ +// { dg-do compile { target c++11 } } + +template struct A {}; +template struct B: A {}; // { dg-error "type" }