aboutsummaryrefslogtreecommitdiffhomepage
path: root/c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-10-25 17:35:41 +0200
committerlemon <lsof@mailbox.org>2025-10-25 17:35:41 +0200
commitd785a958cfb0404a9cbc8f53ad14efb57ccf3cf4 (patch)
tree915ec5e56696124a273914eddf2fb62071dd94c1 /c
parentf307f4dbb08f57f814c0482802c5b7f807f8c666 (diff)
c: alloca fixup wrong when not emitsing
Diffstat (limited to 'c')
-rw-r--r--c/c.c5
1 files 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;