From 91f9108f1bd90c307daadfb4876258ec57cb746b Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Fri, 23 Mar 2018 01:18:48 +0000 Subject: Disable auto_is_implicit_function_template_parm_p while parsing attributes We don't want functions to become implicit templates just because of random uses of auto in unexpected places. Disabling the special handling of auto while parsing attributes, for example, makes for more sensible errors. for gcc/cp/ChangeLog PR c++/84610 PR c++/84642 PR c++/84942 * cp-tree.h (temp_override): New template class, generalizing a cleanup that was only used... * parser.c (cp_parser_parameter_declaration_clause): ... here for auto_is_implicit_function_template_parm_p. (cp_parser_gnu_attributes_opt): Use it here as well. (cp_parser_std_attribute): Likewise. From-SVN: r258790 --- gcc/cp/parser.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'gcc/cp/parser.c') diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 6dcfae1..3461929 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -21196,16 +21196,8 @@ cp_parser_parameter_declaration_clause (cp_parser* parser) bool ellipsis_p; bool is_error; - struct cleanup { - cp_parser* parser; - int auto_is_implicit_function_template_parm_p; - ~cleanup() { - parser->auto_is_implicit_function_template_parm_p - = auto_is_implicit_function_template_parm_p; - } - } cleanup = { parser, parser->auto_is_implicit_function_template_parm_p }; - - (void) cleanup; + temp_override cleanup + (parser->auto_is_implicit_function_template_parm_p); if (!processing_specialization && !processing_template_parmlist @@ -24968,6 +24960,9 @@ cp_parser_gnu_attributes_opt (cp_parser* parser) { tree attributes = NULL_TREE; + temp_override cleanup + (parser->auto_is_implicit_function_template_parm_p, false); + while (true) { cp_token *token; @@ -25159,6 +25154,9 @@ cp_parser_std_attribute (cp_parser *parser, tree attr_ns) tree attribute, attr_id = NULL_TREE, arguments; cp_token *token; + temp_override cleanup + (parser->auto_is_implicit_function_template_parm_p, false); + /* First, parse name of the attribute, a.k.a attribute-token. */ token = cp_lexer_peek_token (parser->lexer); -- cgit v1.1