Emit an error, if a non-variadic function contains va_start.
authorChristoph Mallon <christoph.mallon@gmx.de>
Wed, 3 Jun 2009 10:21:18 +0000 (10:21 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Wed, 3 Jun 2009 10:21:18 +0000 (10:21 +0000)
[r26096]

parser.c

index d05ec2a..0e8658e 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -6863,9 +6863,12 @@ static expression_t *parse_va_start(void)
        expression_t *const expr = parse_assignment_expression();
        if (expr->kind == EXPR_REFERENCE) {
                entity_t *const entity = expr->reference.entity;
-               if (entity->base.parent_scope != &current_function->parameters
-                               || entity->base.next != NULL
-                               || entity->kind != ENTITY_PARAMETER) {
+               if (!current_function->base.type->function.variadic) {
+                       errorf(&expr->base.source_position,
+                                       "'va_start' used in non-variadic function");
+               } else if (entity->base.parent_scope != &current_function->parameters ||
+                               entity->base.next != NULL ||
+                               entity->kind != ENTITY_PARAMETER) {
                        errorf(&expr->base.source_position,
                               "second argument of 'va_start' must be last parameter of the current function");
                } else {