Commit cae39eb4 by Jason Merrill Committed by Jason Merrill

PR c++/81060 - ICE with unexpanded parameter pack.

	* pt.c (check_for_bare_parameter_packs): Add loc parameter.
	* decl.c (grokdeclarator): Call it for qualifying_scope.

From-SVN: r261725
parent 094c2a23
2018-06-18 Jason Merrill <jason@redhat.com> 2018-06-18 Jason Merrill <jason@redhat.com>
PR c++/81060 - ICE with unexpanded parameter pack.
* pt.c (check_for_bare_parameter_packs): Add loc parameter.
* decl.c (grokdeclarator): Call it for qualifying_scope.
PR c++/86171 - ICE with recursive alias instantiation. PR c++/86171 - ICE with recursive alias instantiation.
* pt.c (tsubst_decl): Handle recursive alias instantiation. * pt.c (tsubst_decl): Handle recursive alias instantiation.
......
...@@ -6626,7 +6626,7 @@ extern bool template_parameter_pack_p (const_tree); ...@@ -6626,7 +6626,7 @@ extern bool template_parameter_pack_p (const_tree);
extern bool function_parameter_pack_p (const_tree); extern bool function_parameter_pack_p (const_tree);
extern bool function_parameter_expanded_from_pack_p (tree, tree); extern bool function_parameter_expanded_from_pack_p (tree, tree);
extern tree make_pack_expansion (tree, tsubst_flags_t = tf_warning_or_error); extern tree make_pack_expansion (tree, tsubst_flags_t = tf_warning_or_error);
extern bool check_for_bare_parameter_packs (tree); extern bool check_for_bare_parameter_packs (tree, location_t = UNKNOWN_LOCATION);
extern tree build_template_info (tree, tree); extern tree build_template_info (tree, tree);
extern tree get_template_info (const_tree); extern tree get_template_info (const_tree);
extern vec<qualified_typedef_usage_t, va_gc> *get_types_needing_access_check (tree); extern vec<qualified_typedef_usage_t, va_gc> *get_types_needing_access_check (tree);
......
...@@ -10175,6 +10175,9 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -10175,6 +10175,9 @@ grokdeclarator (const cp_declarator *declarator,
break; break;
if (qualifying_scope) if (qualifying_scope)
{ {
if (check_for_bare_parameter_packs (qualifying_scope,
id_declarator->id_loc))
return error_mark_node;
if (at_function_scope_p ()) if (at_function_scope_p ())
{ {
/* [dcl.meaning] /* [dcl.meaning]
......
...@@ -4031,7 +4031,7 @@ make_pack_expansion (tree arg, tsubst_flags_t complain) ...@@ -4031,7 +4031,7 @@ make_pack_expansion (tree arg, tsubst_flags_t complain)
Returns TRUE and emits an error if there were bare parameter packs, Returns TRUE and emits an error if there were bare parameter packs,
returns FALSE otherwise. */ returns FALSE otherwise. */
bool bool
check_for_bare_parameter_packs (tree t) check_for_bare_parameter_packs (tree t, location_t loc /* = UNKNOWN_LOCATION */)
{ {
tree parameter_packs = NULL_TREE; tree parameter_packs = NULL_TREE;
struct find_parameter_pack_data ppd; struct find_parameter_pack_data ppd;
...@@ -4055,7 +4055,8 @@ check_for_bare_parameter_packs (tree t) ...@@ -4055,7 +4055,8 @@ check_for_bare_parameter_packs (tree t)
if (parameter_packs) if (parameter_packs)
{ {
location_t loc = EXPR_LOC_OR_LOC (t, input_location); if (loc == UNKNOWN_LOCATION)
loc = EXPR_LOC_OR_LOC (t, input_location);
error_at (loc, "parameter packs not expanded with %<...%>:"); error_at (loc, "parameter packs not expanded with %<...%>:");
while (parameter_packs) while (parameter_packs)
{ {
......
...@@ -7,5 +7,5 @@ template<typename... T> struct A ...@@ -7,5 +7,5 @@ template<typename... T> struct A
}; };
template<typename... T> template<typename... T>
const int A<T>::i // { dg-error "template definition of non-template" } const int A<T>::i // { dg-error "packs not expanded" }
= []{ return 0; }(); // BOOM! = []{ return 0; }(); // BOOM!
// { dg-do compile { target c++11 } } // { dg-do compile { target c++11 } }
template<class... Types> struct B { // { dg-message "declaration of" } template<class... Types> struct B {
void f3(); void f3();
void f4(); void f4();
}; };
template<class... Types> void B<Types...>::f3() { } // OK template<class... Types> void B<Types...>::f3() { } // OK
template<class... Types> void B<Types>::f4() { } // { dg-error "invalid" } template<class... Types> void B<Types>::f4() { } // { dg-error "packs not expanded" }
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