diff options
-rw-r--r-- | cc.h | 2 | ||||
-rw-r--r-- | decl.c | 1 | ||||
-rw-r--r-- | eval.c | 5 | ||||
-rw-r--r-- | qbe.c | 7 |
4 files changed, 5 insertions, 10 deletions
@@ -287,6 +287,7 @@ struct decl { bool inlinedefn; bool isnoreturn; } func; + unsigned long long enumconst; enum builtinkind builtin; } u; }; @@ -553,7 +554,6 @@ struct block *mkblock(char *); struct value *mkglobal(struct decl *); struct value *mkintconst(unsigned long long); -unsigned long long intconstvalue(struct value *); struct func *mkfunc(struct decl *, char *, struct type *, struct scope *); void delfunc(struct func *); @@ -274,6 +274,7 @@ tagspec(struct scope *s) assert(i < LEN(inttypes)); } d = mkdecl(name, DECLCONST, et, QUALNONE, LINKNONE); + d->u.enumconst = value; d->value = mkintconst(value); d->next = enumconsts; enumconsts = d; @@ -110,10 +110,11 @@ eval(struct expr *expr) t = expr->type; switch (expr->kind) { case EXPRIDENT: - if (expr->u.ident.decl->kind != DECLCONST) + d = expr->u.ident.decl; + if (d->kind != DECLCONST) break; expr->kind = EXPRCONST; - expr->u.constant.u = intconstvalue(expr->u.ident.decl->value); + expr->u.constant.u = d->u.enumconst; break; case EXPRCOMPOUND: if (expr->u.compound.decl->u.obj.storage != SDSTATIC) @@ -163,13 +163,6 @@ mkintconst(unsigned long long n) return v; } -unsigned long long -intconstvalue(struct value *v) -{ - assert(v->kind == VALUE_INTCONST); - return v->u.i; -} - static struct value * mkfltconst(int kind, double n) { |