diff options
-rw-r--r-- | eval.c | 9 | ||||
-rw-r--r-- | tests/compound-literal-static.c | 1 | ||||
-rw-r--r-- | tests/compound-literal-static.qbe | 2 |
3 files changed, 12 insertions, 0 deletions
@@ -1,3 +1,4 @@ +#include <stdbool.h> #include <stddef.h> #include <stdint.h> #include "util.h" @@ -12,6 +13,7 @@ struct expression * eval(struct expression *expr) { struct expression *l, *r, *c; + struct declaration *d; int op; switch (expr->kind) { @@ -21,6 +23,13 @@ eval(struct expression *expr) expr->kind = EXPRCONST; expr->constant.i = intconstvalue(expr->ident.decl->value); break; + case EXPRCOMPOUND: + d = mkdecl(DECLOBJECT, expr->type, LINKNONE); + d->value = mkglobal(NULL, true); + emitdata(d, expr->compound.init); + expr->kind = EXPRIDENT; + expr->ident.decl = d; + break; case EXPRUNARY: l = eval(expr->unary.base); if (expr->unary.op != TBAND) diff --git a/tests/compound-literal-static.c b/tests/compound-literal-static.c new file mode 100644 index 0000000..1b1afc9 --- /dev/null +++ b/tests/compound-literal-static.c @@ -0,0 +1 @@ +int *x = &(int){2}; diff --git a/tests/compound-literal-static.qbe b/tests/compound-literal-static.qbe new file mode 100644 index 0000000..c18ec1d --- /dev/null +++ b/tests/compound-literal-static.qbe @@ -0,0 +1,2 @@ +data $.L.1 = align 4 { w 2, } +export data $x = align 8 { l $.L.1, } |