From: Jason Merrill Date: Tue, 19 Jun 2018 00:38:26 +0000 (-0400) Subject: PR c++/81060 - ICE with unexpanded parameter pack. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cae39eb41f37b8714f5684ee58b74460f2b76cd2;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b1a449f91e2..a8d0e626440 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2018-06-18 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. + PR c++/86171 - ICE with recursive alias instantiation. * pt.c (tsubst_decl): Handle recursive alias instantiation. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 3566668efef..b8709542066 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -6626,7 +6626,7 @@ extern bool template_parameter_pack_p (const_tree); extern bool function_parameter_pack_p (const_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 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 get_template_info (const_tree); extern vec *get_types_needing_access_check (tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index cc2d513a7a1..6d802c9e66d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10175,6 +10175,9 @@ grokdeclarator (const cp_declarator *declarator, break; if (qualifying_scope) { + if (check_for_bare_parameter_packs (qualifying_scope, + id_declarator->id_loc)) + return error_mark_node; if (at_function_scope_p ()) { /* [dcl.meaning] diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 6e590d4d342..5af0f9afefc 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 FALSE otherwise. */ 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; struct find_parameter_pack_data ppd; @@ -4055,7 +4055,8 @@ check_for_bare_parameter_packs (tree t) 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 %<...%>:"); while (parameter_packs) { diff --git a/gcc/testsuite/g++.dg/cpp0x/pr81060.C b/gcc/testsuite/g++.dg/cpp0x/pr81060.C index 67b2b38596a..673ec1587d6 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr81060.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr81060.C @@ -7,5 +7,5 @@ template struct A }; template -const int A::i // { dg-error "template definition of non-template" } +const int A::i // { dg-error "packs not expanded" } = []{ return 0; }(); // BOOM! diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C index a887e339848..8af3979d28d 100644 --- a/gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-ex2.C @@ -1,8 +1,8 @@ // { dg-do compile { target c++11 } } -template struct B { // { dg-message "declaration of" } +template struct B { void f3(); void f4(); }; template void B::f3() { } // OK -template void B::f4() { } // { dg-error "invalid" } +template void B::f4() { } // { dg-error "packs not expanded" }