On 09/21/2016 08:44 AM, Marek Polacek wrote:
@@ -10733,12 +10758,35 @@ cp_parser_expression_statement (cp_parser* parser, tree in_statement_expr) statement. */ if (cp_lexer_next_token_is_not (parser->lexer, CPP_SEMICOLON)) { + /* This might be attribute fallthrough. */ + if (cp_lexer_next_token_is_keyword (parser->lexer, RID_ATTRIBUTE)) { + tree attr = cp_parser_gnu_attributes_opt (parser); + if (maybe_attribute_fallthrough_p (attr)) + statement = build_call_expr_internal_loc (token->location, + IFN_FALLTHROUGH, + void_type_node, 0); + else if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON)) + { + cp_parser_error (parser, "only attribute %<fallthrough%> " + "can be applied to a null statement"); + return error_mark_node; + } + else + { + cp_parser_error (parser, "expected primary-expression"); + return error_mark_node; + } + }
Attributes that we don't handle should be warnings, not errors. Like we do for C++11 attributes in cp_parser_statement, we should first parse attributes, then parse the expression-statement, then give any appropriate warnings.
Jason