From 156fd3d36db184ae464e5f1e7dee80f644421b4a Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Tue, 16 Sep 2008 09:39:36 +0000 Subject: [PATCH] Improve parse_va_start(): - reference expressions never have no declaration, at least there is an error declaration - do not return an invalid expression, when the second argument is a reference, but not the last parameter - if the second parameter is invalid, still expect the ). [r21997] --- parser.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/parser.c b/parser.c index 0b84140..019528e 100644 --- a/parser.c +++ b/parser.c @@ -6471,17 +6471,15 @@ static expression_t *parse_va_start(void) expression_t *const expr = parse_assignment_expression(); if (expr->kind == EXPR_REFERENCE) { declaration_t *const decl = expr->reference.declaration; - if (decl == NULL) - return create_invalid_expression(); - if (decl->parent_scope == ¤t_function->scope && - decl->next == NULL) { - expression->va_starte.parameter = decl; - expect(')'); - return expression; + if (decl->parent_scope != ¤t_function->scope || decl->next != NULL) { + errorf(&expr->base.source_position, + "second argument of 'va_start' must be last parameter of the current function"); } + expression->va_starte.parameter = decl; + expect(')'); + return expression; } - errorf(&expr->base.source_position, - "second argument of 'va_start' must be last parameter of the current function"); + expect(')'); end_error: return create_invalid_expression(); } -- 2.20.1