Report an error if __builtin_va_start() is used in a non-variadic function, even...
authorChristoph Mallon <christoph.mallon@gmx.de>
Thu, 17 May 2012 17:03:02 +0000 (19:03 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sat, 19 May 2012 08:10:36 +0000 (10:10 +0200)
Also show the position of __builtin_va_start, not its second argument, as the location of the error.

parser.c

index e7eb0a9..3620827 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -6437,12 +6437,11 @@ static expression_t *parse_va_start(void)
 
        if (!current_function) {
                errorf(&expression->base.source_position, "'va_start' used outside of function");
+       } else if (!current_function->base.type->function.variadic) {
+               errorf(&expression->base.source_position, "'va_start' used in non-variadic function");
        } else if (param->kind == EXPR_REFERENCE) {
                entity_t *const entity = param->reference.entity;
-               if (!current_function->base.type->function.variadic) {
-                       errorf(&param->base.source_position,
-                                       "'va_start' used in non-variadic function");
-               } else if (entity->base.parent_scope != &current_function->parameters ||
+               if (entity->base.parent_scope != &current_function->parameters ||
                                entity->base.next != NULL ||
                                entity->kind != ENTITY_PARAMETER) {
                        errorf(&param->base.source_position,