diff options
author | Michael Forney <mforney@mforney.org> | 2019-02-13 18:08:41 -0800 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-02-13 19:42:25 -0800 |
commit | a080e36dac54b82beef63580f36cb0da9ad31788 (patch) | |
tree | 6628e31ab0de6b89c1200d0eb3cf10853568ad84 | |
parent | d36d945c646800a23a4d4f8c05ab3f2ca4c8f535 (diff) |
Fold constexpr function into intconstexpr
We usually only care about integer constant expressions, and when we
parse initializers, we need to handle non-constant expressions too,
so we call eval explicitly when emitting global data.
-rw-r--r-- | expr.c | 8 | ||||
-rw-r--r-- | expr.h | 1 |
2 files changed, 1 insertions, 8 deletions
@@ -782,18 +782,12 @@ condexpr(struct scope *s) return e; } -struct expression * -constexpr(struct scope *s) -{ - return eval(condexpr(s)); -} - uint64_t intconstexpr(struct scope *s) { struct expression *e; - e = constexpr(s); + e = eval(condexpr(s)); if (e->kind != EXPRCONST || !(typeprop(e->type) & PROPINT)) error(&tok.loc, "not an integer constant expression"); return e->constant.i; @@ -92,7 +92,6 @@ struct scope; struct expression *expr(struct scope *); struct expression *assignexpr(struct scope *); -struct expression *constexpr(struct scope *); uint64_t intconstexpr(struct scope *); void delexpr(struct expression *); |