return end_template_parm_list (parameter_list);
}
+/* Parse a default argument for a type template-parameter.
+ Note that diagnostics are handled in cp_parser_template_parameter. */
+
+static tree
+cp_parser_default_type_template_argument (cp_parser *parser)
+{
+ gcc_assert (cp_lexer_next_token_is (parser->lexer, CPP_EQ));
+
+ /* Consume the `=' token. */
+ cp_lexer_consume_token (parser->lexer);
+
+ /* Parse the default-argument. */
+ push_deferring_access_checks (dk_no_deferred);
+ tree default_argument = cp_parser_type_id (parser);
+ pop_deferring_access_checks ();
+
+ return default_argument;
+}
+
+/* Parse a default argument for a template template-parameter. */
+
+static tree
+cp_parser_default_template_template_argument (cp_parser *parser)
+{
+ gcc_assert (cp_lexer_next_token_is (parser->lexer, CPP_EQ));
+
+ bool is_template;
+
+ /* Consume the `='. */
+ cp_lexer_consume_token (parser->lexer);
+ /* Parse the id-expression. */
+ push_deferring_access_checks (dk_no_deferred);
+ /* save token before parsing the id-expression, for error
+ reporting */
+ const cp_token* token = cp_lexer_peek_token (parser->lexer);
+ tree default_argument
+ = cp_parser_id_expression (parser,
+ /*template_keyword_p=*/false,
+ /*check_dependency_p=*/true,
+ /*template_p=*/&is_template,
+ /*declarator_p=*/false,
+ /*optional_p=*/false);
+ if (TREE_CODE (default_argument) == TYPE_DECL)
+ /* If the id-expression was a template-id that refers to
+ a template-class, we already have the declaration here,
+ so no further lookup is needed. */
+ ;
+ else
+ /* Look up the name. */
+ default_argument
+ = cp_parser_lookup_name (parser, default_argument,
+ none_type,
+ /*is_template=*/is_template,
+ /*is_namespace=*/false,
+ /*check_dependency=*/true,
+ /*ambiguous_decls=*/NULL,
+ token->location);
+ /* See if the default argument is valid. */
+ default_argument = check_template_template_default_arg (default_argument);
+ pop_deferring_access_checks ();
+ return default_argument;
+}
+
/* Parse a template-parameter.
template-parameter:
/* If the next token is an `=', we have a default argument. */
if (cp_lexer_next_token_is (parser->lexer, CPP_EQ))
{
- /* Consume the `=' token. */
- cp_lexer_consume_token (parser->lexer);
- /* Parse the default-argument. */
- push_deferring_access_checks (dk_no_deferred);
- default_argument = cp_parser_type_id (parser);
+ default_argument
+ = cp_parser_default_type_template_argument (parser);
/* Template parameter packs cannot have default
arguments. */
}
else if (check_for_bare_parameter_packs (default_argument))
default_argument = error_mark_node;
- pop_deferring_access_checks ();
}
else
default_argument = NULL_TREE;
default-argument. */
if (cp_lexer_next_token_is (parser->lexer, CPP_EQ))
{
- bool is_template;
-
- /* Consume the `='. */
- cp_lexer_consume_token (parser->lexer);
- /* Parse the id-expression. */
- push_deferring_access_checks (dk_no_deferred);
- /* save token before parsing the id-expression, for error
- reporting */
- token = cp_lexer_peek_token (parser->lexer);
- default_argument
- = cp_parser_id_expression (parser,
- /*template_keyword_p=*/false,
- /*check_dependency_p=*/true,
- /*template_p=*/&is_template,
- /*declarator_p=*/false,
- /*optional_p=*/false);
- if (TREE_CODE (default_argument) == TYPE_DECL)
- /* If the id-expression was a template-id that refers to
- a template-class, we already have the declaration here,
- so no further lookup is needed. */
- ;
- else
- /* Look up the name. */
- default_argument
- = cp_parser_lookup_name (parser, default_argument,
- none_type,
- /*is_template=*/is_template,
- /*is_namespace=*/false,
- /*check_dependency=*/true,
- /*ambiguous_decls=*/NULL,
- token->location);
- /* See if the default argument is valid. */
default_argument
- = check_template_template_default_arg (default_argument);
+ = cp_parser_default_template_template_argument (parser);
/* Template parameter packs cannot have default
arguments. */
"have default arguments");
default_argument = NULL_TREE;
}
- pop_deferring_access_checks ();
}
else
default_argument = NULL_TREE;