aboutsummaryrefslogtreecommitdiffhomepage
path: root/c
diff options
context:
space:
mode:
author lemon<lsof@mailbox.org>2025-11-15 20:12:53 +0100
committer lemon<lsof@mailbox.org>2025-11-15 20:12:53 +0100
commit9abe27f6712852bd6a98d04baeca6d81470cc61c (patch)
tree93783d8e39fb0098255862063833b911904813d7 /c
parent09aad0efecdc4dea8a09b16976ec9639a6f97655 (diff)
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..
Diffstat (limited to 'c')
-rw-r--r--c/c.c6
1 files changed, 5 insertions, 1 deletions
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);