diff options
author | Jason Merrill <jason@redhat.com> | 2018-04-02 14:20:04 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-04-02 14:20:04 -0400 |
commit | 82a926bf06e8b7989ee189ef2b3bf7a6c055d6b8 (patch) | |
tree | 2315159f618963a9946fe3e5887d2ac62313f5ad /gcc/cp | |
parent | 078c5aff5ed83e9c237f3090e947860314838e00 (diff) | |
download | gcc-82a926bf06e8b7989ee189ef2b3bf7a6c055d6b8.zip gcc-82a926bf06e8b7989ee189ef2b3bf7a6c055d6b8.tar.gz gcc-82a926bf06e8b7989ee189ef2b3bf7a6c055d6b8.tar.bz2 |
PR c++/64095 - auto... parameter pack.
* parser.c (cp_parser_parameter_declaration): Handle turning autos
into packs here.
(cp_parser_parameter_declaration_list): Not here.
From-SVN: r259015
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/parser.c | 40 |
2 files changed, 28 insertions, 19 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d52a0dc..e97442a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-04-02 Jason Merrill <jason@redhat.com> + + PR c++/64095 - auto... parameter pack. + * parser.c (cp_parser_parameter_declaration): Handle turning autos + into packs here. + (cp_parser_parameter_declaration_list): Not here. + 2018-03-31 Alexandre Oliva <aoliva@redhat.com> PR c++/85027 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e946d0b..d526a4e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -21320,9 +21320,6 @@ cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error) cp_parameter_declarator *parameter; tree decl = error_mark_node; bool parenthesized_p = false; - int template_parm_idx = (function_being_declared_is_template_p (parser)? - TREE_VEC_LENGTH (INNERMOST_TEMPLATE_PARMS - (current_template_parms)) : 0); /* Parse the parameter. */ parameter @@ -21336,22 +21333,6 @@ cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error) if (parameter) { - /* If a function parameter pack was specified and an implicit template - parameter was introduced during cp_parser_parameter_declaration, - change any implicit parameters introduced into packs. */ - if (parser->implicit_template_parms - && parameter->declarator - && parameter->declarator->parameter_pack_p) - { - int latest_template_parm_idx = TREE_VEC_LENGTH - (INNERMOST_TEMPLATE_PARMS (current_template_parms)); - - if (latest_template_parm_idx != template_parm_idx) - parameter->decl_specifiers.type = convert_generic_types_to_packs - (parameter->decl_specifiers.type, - template_parm_idx, latest_template_parm_idx); - } - decl = grokdeclarator (parameter->declarator, ¶meter->decl_specifiers, PARM, @@ -21511,6 +21492,10 @@ cp_parser_parameter_declaration (cp_parser *parser, parser->type_definition_forbidden_message = G_("types may not be defined in parameter types"); + int template_parm_idx = (function_being_declared_is_template_p (parser) ? + TREE_VEC_LENGTH (INNERMOST_TEMPLATE_PARMS + (current_template_parms)) : 0); + /* Parse the declaration-specifiers. */ cp_token *decl_spec_token_start = cp_lexer_peek_token (parser->lexer); cp_parser_decl_specifier_seq (parser, @@ -21600,6 +21585,23 @@ cp_parser_parameter_declaration (cp_parser *parser, parameter pack expansion expression. Otherwise, leave the ellipsis for a C-style variadic function. */ token = cp_lexer_peek_token (parser->lexer); + + /* If a function parameter pack was specified and an implicit template + parameter was introduced during cp_parser_parameter_declaration, + change any implicit parameters introduced into packs. */ + if (parser->implicit_template_parms + && (token->type == CPP_ELLIPSIS + || (declarator && declarator->parameter_pack_p))) + { + int latest_template_parm_idx = TREE_VEC_LENGTH + (INNERMOST_TEMPLATE_PARMS (current_template_parms)); + + if (latest_template_parm_idx != template_parm_idx) + decl_specifiers.type = convert_generic_types_to_packs + (decl_specifiers.type, + template_parm_idx, latest_template_parm_idx); + } + if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS)) { tree type = decl_specifiers.type; |