Do not crash, when __builtin_va_start() is used outside of a function and report...
authorChristoph Mallon <christoph.mallon@gmx.de>
Thu, 17 May 2012 16:57:48 +0000 (18:57 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sat, 19 May 2012 08:10:36 +0000 (10:10 +0200)
parser.c

index 0695e71..e7eb0a9 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -6435,7 +6435,9 @@ static expression_t *parse_va_start(void)
        rem_anchor_token(')');
        expect(')');
 
-       if (param->kind == EXPR_REFERENCE) {
+       if (!current_function) {
+               errorf(&expression->base.source_position, "'va_start' used outside of 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,