Improve parse_va_start():
authorChristoph Mallon <christoph.mallon@gmx.de>
Tue, 16 Sep 2008 09:39:36 +0000 (09:39 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Tue, 16 Sep 2008 09:39:36 +0000 (09:39 +0000)
- 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

index 0b84140..019528e 100644 (file)
--- 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 == &current_function->scope &&
-                   decl->next == NULL) {
-                       expression->va_starte.parameter = decl;
-                       expect(')');
-                       return expression;
+               if (decl->parent_scope != &current_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();
 }