diff options
| author | 2025-12-14 21:55:19 +0100 | |
|---|---|---|
| committer | 2025-12-14 21:55:19 +0100 | |
| commit | 1339b832245fc6c1a5a9e7acf88c5b1f1f5f740f (patch) | |
| tree | fda3bf0d5309231e390c57dfefcb4efb2f585c7b /c | |
| parent | 0559d1b932bc5614ce4f1f44747b38d03b2fef5b (diff) | |
c/builtin: fix vacopy
Diffstat (limited to 'c')
| -rw-r--r-- | c/builtin.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/c/builtin.c b/c/builtin.c index 913d6b3..a923bf1 100644 --- a/c/builtin.c +++ b/c/builtin.c @@ -43,7 +43,7 @@ static union ref va_start_comp(struct function *fn, struct expr *ex, bool discard) { assert(ex->t == ECALL && ex->narg == 1); - assert(ex->sub[1].ty.bits == cvalistty.bits); + assert(typedecay(ex->sub[1].ty).bits == typedecay(cvalistty).bits); if (!typedata[fn->fnty.dat].variadic) error(&ex->span, "va_start used in non-variadic function"); addinstr(fn, mkinstr(Ovastart, 0, compileexpr(fn, &ex->sub[1], 0))); @@ -71,10 +71,11 @@ static union ref va_copy_comp(struct function *fn, struct expr *ex, bool discard) { union irtype typ = mkirtype(cvalistty.t == TYARRAY ? typechild(cvalistty) : cvalistty); - assert(ex->sub[1].ty.bits == cvalistty.bits); - assert(ex->sub[2].ty.bits == cvalistty.bits); - addinstr(fn, mkarginstr(typ, compileexpr(fn, &ex->sub[1], 0))); - addinstr(fn, mkarginstr(typ, compileexpr(fn, &ex->sub[2], 0))); + for (int i = 1; i < 2; ++i) + assert(typedecay(ex->sub[i].ty).bits == typedecay(cvalistty).bits); + union ref dst = compileexpr(fn, &ex->sub[1], 0), src = compileexpr(fn, &ex->sub[2], 0); + addinstr(fn, mkarginstr(typ, dst)); + addinstr(fn, mkarginstr(typ, src)); addinstr(fn, mkintrin(INstructcopy, 0, 2)); return NOREF; } |