From 9abe27f6712852bd6a98d04baeca6d81470cc61c Mon Sep 17 00:00:00 2001 From: lemon Date: Sat, 15 Nov 2025 20:12:53 +0100 Subject: c: due to __builtin_trap (in the future also things like noreturn function calls), compileexpr() can terminate current block. add checks for that in callexpr. more are probably needed.. --- c/c.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'c') diff --git a/c/c.c b/c/c.c index d2d842d..2aa8014 100644 --- a/c/c.c +++ b/c/c.c @@ -3097,12 +3097,16 @@ compilecall(struct function *fn, const struct expr *ex) assert(ins.cls || ex->ty.t == TYVOID); } ins.l = exprvalue(fn, &sub[0]); - for (int i = 0; i < ex->narg; ++i) { + for (int i = 0; i < ex->narg && fn->curblk; ++i) { struct expr *arg = &sub[i+1]; union type ty = i < td->nmemb ? td->param[i] : argpromote(arg->ty); union ref r = cvt(fn, ty, typedecay(arg->ty), exprvalue(fn, arg)); vpush(&insns, mkarginstr(mkirtype(ty), r)); } + if (!fn->curblk) { + vfree(&insns); + return NOREF; + } for (int i = 0; i < insns.n; ++i) addinstr(fn, insns.p[i]); vfree(&insns); -- cgit v1.2.3