From: Christoph Mallon Date: Sat, 5 May 2012 15:43:27 +0000 (+0200) Subject: Improve error recovery in parse_parameters(). X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=a81dc4c1999d4853ddff49a749240440024aa6a3;p=cparser Improve error recovery in parse_parameters(). --- diff --git a/parser.c b/parser.c index b496be7..b952f9c 100644 --- a/parser.c +++ b/parser.c @@ -3194,22 +3194,18 @@ static void parse_parameters(function_type_t *type, scope_t *scope) eat('('); add_anchor_token(')'); - if (token.kind == T_IDENTIFIER - && !is_typedef_symbol(token.identifier.symbol)) { - token_kind_t la1_type = (token_kind_t)look_ahead(1)->kind; - if (la1_type == ',' || la1_type == ')') { - type->kr_style_parameters = true; - parse_identifier_list(scope); - goto parameters_finished; - } - } - - if (token.kind == ')') { + if (token.kind == T_IDENTIFIER && + !is_typedef_symbol(token.identifier.symbol) && + (look_ahead(1)->kind == ',' || look_ahead(1)->kind == ')')) { + type->kr_style_parameters = true; + parse_identifier_list(scope); + } else if (token.kind == ')') { /* ISO/IEC 14882:1998(E) §C.1.6:1 */ if (!(c_mode & _CXX)) type->unspecified_parameters = true; } else if (has_parameters()) { function_parameter_t **anchor = &type->parameters; + add_anchor_token(','); do { switch (token.kind) { case T_DOTDOTDOT: @@ -3246,9 +3242,10 @@ static void parse_parameters(function_type_t *type, scope_t *scope) goto parameters_finished; } } while (next_if(',')); +parameters_finished: + rem_anchor_token(','); } -parameters_finished: rem_anchor_token(')'); expect(')'); }