From d785a958cfb0404a9cbc8f53ad14efb57ccf3cf4 Mon Sep 17 00:00:00 2001 From: lemon Date: Sat, 25 Oct 2025 17:35:41 +0200 Subject: c: alloca fixup wrong when not emitsing --- c/c.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/c/c.c b/c/c.c index 094931f..b9341f3 100644 --- a/c/c.c +++ b/c/c.c @@ -3879,6 +3879,7 @@ localdecl(struct comp *cm, struct function *fn, bool forini) case SCREGISTER: if (decl.ty.t == TYFUNC) { error(&decl.span, "declaring variable '%s' with function type '%ty'", decl.name, decl.ty); + goto Err; } else if (isincomplete(decl.ty) && !(dynarr = (decl.ty.t == TYARRAY && st.varini))) { error(&decl.span, "declaring variable '%s' with incomplete type '%ty'", decl.name, decl.ty); goto Err; @@ -3889,7 +3890,7 @@ localdecl(struct comp *cm, struct function *fn, bool forini) Initz: if (st.varini) { struct decl *d = putdecl(cm, &decl); - bool statik = st.scls & (SCSTATIC | SCEXTERN); + bool statik = decl.scls & (SCSTATIC | SCEXTERN); const char *name = decl.name; put = 1; if (decl.scls == SCSTATIC) @@ -3900,7 +3901,7 @@ localdecl(struct comp *cm, struct function *fn, bool forini) if (!statik) { /* fix alloca for actual size, for implicitly sized arrays */ assert(!isincomplete(d->ty)); - instrtab[decl.id] = mkalloca(typesize(d->ty), typealign(d->ty)); + EMITS instrtab[decl.id] = mkalloca(typesize(d->ty), typealign(d->ty)); if (!initcheck(d->ty, &ini)) { struct span span = decl.span; -- cgit v1.2.3