Commit cd8a9d6d by Jason Merrill Committed by Jason Merrill

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
parent 0df9da03
2014-04-01 Jason Merrill <jason@redhat.com>
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 <fabien@gcc.gnu.org> 2014-04-01 Fabien Chêne <fabien@gcc.gnu.org>
* cp/init.c (perform_member_init): Homogenize uninitialized * cp/init.c (perform_member_init): Homogenize uninitialized
......
...@@ -6933,6 +6933,26 @@ coerce_template_parms (tree parms, ...@@ -6933,6 +6933,26 @@ coerce_template_parms (tree parms,
{ {
if (PACK_EXPANSION_P (arg)) 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 /* We don't know how many args we have yet, just
use the unconverted ones for now. */ use the unconverted ones for now. */
new_inner_args = inner_args; new_inner_args = inner_args;
......
// PR c++/60374
// { dg-do compile { target c++11 } }
template<typename> struct A {};
template<typename...T> struct A<T::T...> {}; // { dg-error "typename|partial|T" }
A<int> a;
// { dg-do compile { target c++11 } }
template <typename T> struct A {};
template <int... I> struct B: A<I...> {}; // { dg-error "type" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment