aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-04-02 14:20:04 -0400
committerJason Merrill <jason@gcc.gnu.org>2018-04-02 14:20:04 -0400
commit82a926bf06e8b7989ee189ef2b3bf7a6c055d6b8 (patch)
tree2315159f618963a9946fe3e5887d2ac62313f5ad /gcc/cp/parser.c
parent078c5aff5ed83e9c237f3090e947860314838e00 (diff)
downloadgcc-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/parser.c')
-rw-r--r--gcc/cp/parser.c40
1 files changed, 21 insertions, 19 deletions
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,
&parameter->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;