aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-02-13 18:08:41 -0800
committerMichael Forney <mforney@mforney.org>2019-02-13 19:42:25 -0800
commita080e36dac54b82beef63580f36cb0da9ad31788 (patch)
tree6628e31ab0de6b89c1200d0eb3cf10853568ad84
parentd36d945c646800a23a4d4f8c05ab3f2ca4c8f535 (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.c8
-rw-r--r--expr.h1
2 files changed, 1 insertions, 8 deletions
diff --git a/expr.c b/expr.c
index a1834c5..6a28efb 100644
--- a/expr.c
+++ b/expr.c
@@ -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;
diff --git a/expr.h b/expr.h
index 5c8ef96..a6cac6d 100644
--- a/expr.h
+++ b/expr.h
@@ -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 *);