diff options
author | Michael Forney <mforney@mforney.org> | 2024-04-21 01:34:15 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2024-04-21 01:34:15 -0700 |
commit | 593ca07956c6abc8bffcd2a2c5c06c521952f737 (patch) | |
tree | b65e2eda7afa23e444485cb44db607a13cfbc34e | |
parent | 55263d181d28026a176729f7734dcd7558ae60f7 (diff) |
expr: Create decl for compound literal during parse
-rw-r--r-- | cc.h | 2 | ||||
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | expr.c | 5 | ||||
-rw-r--r-- | qbe.c | 3 |
4 files changed, 7 insertions, 5 deletions
@@ -358,7 +358,7 @@ struct expr { struct bitfield bits; } bitfield; struct { - enum storageduration storage; + struct decl *decl; struct init *init; } compound; struct { @@ -116,7 +116,7 @@ eval(struct expr *expr) expr->u.constant.u = intconstvalue(expr->u.ident.decl->value); break; case EXPRCOMPOUND: - if (expr->u.compound.storage != SDSTATIC) + if (expr->u.compound.decl->u.obj.storage != SDSTATIC) break; d = mkdecl(NULL, DECLOBJECT, t, expr->qual, LINKNONE); d->value = mkglobal(d); @@ -1107,6 +1107,7 @@ static struct expr * castexpr(struct scope *s) { struct type *t, *ct; + struct decl *d; enum typequal tq; struct expr *r, *e, **end; @@ -1126,8 +1127,10 @@ castexpr(struct scope *s) e = mkexpr(EXPRCOMPOUND, t, NULL); e->qual = tq; e->lvalue = true; + d = mkdecl(NULL, DECLOBJECT, t, tq, LINKNONE); + d->u.obj.storage = s == &filescope ? SDSTATIC : SDAUTO; + e->u.compound.decl = d; e->u.compound.init = parseinit(s, t); - e->u.compound.storage = s == &filescope ? SDSTATIC : SDAUTO; e = postfixexpr(s, decay(e)); goto done; } @@ -645,8 +645,7 @@ funclval(struct func *f, struct expr *e) lval.addr = d->value; break; case EXPRCOMPOUND: - d = mkdecl(NULL, DECLOBJECT, e->type, e->qual, LINKNONE); - d->u.obj.storage = SDAUTO; + d = e->u.compound.decl; funcinit(f, d, e->u.compound.init, true); lval.addr = d->value; break; |