commit 714600f9073b2b5a7ba8c770f6341232ec4ccaac
parent 8279e1a441a258b1a8abd07331f65b535c42e650
Author: Drew DeVault <sir@cmpwn.com>
Date: Sat, 19 Mar 2022 12:01:11 +0100
check: fix some bugs with C variadism
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/check.c b/src/check.c
@@ -1167,7 +1167,7 @@ check_expr_call(struct context *ctx,
param = param->next;
}
- if (aarg) {
+ if (aarg && fntype->func.variadism != VARIADISM_C) {
error(ctx, aexpr->loc, expr,
"Too many parameters for function call");
return;
@@ -2831,10 +2831,6 @@ check_function(struct context *ctx,
ctx->store, &fn_atype);
ctx->fntype = fntype;
- expect(&adecl->loc,
- fntype->func.variadism != VARIADISM_C,
- "C-style variadism is not allowed for function declarations");
-
struct declaration *decl = xcalloc(1, sizeof(struct declaration));
decl->type = DECL_FUNC;
decl->func.type = fntype;
@@ -2849,6 +2845,10 @@ check_function(struct context *ctx,
return decl; // Prototype
}
+ expect(&adecl->loc,
+ fntype->func.variadism != VARIADISM_C,
+ "C-style variadism is not allowed for function declarations");
+
decl->func.scope = scope_push(&ctx->scope, SCOPE_FUNC);
struct ast_function_parameters *params = afndecl->prototype.params;
while (params) {