cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit a080e36dac54b82beef63580f36cb0da9ad31788
parent d36d945c646800a23a4d4f8c05ab3f2ca4c8f535
Author: Michael Forney <mforney@mforney.org>
Date:   Wed, 13 Feb 2019 18:08:41 -0800

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.

Diffstat:
Mexpr.c | 8+-------
Mexpr.h | 1-
2 files changed, 1 insertion(+), 8 deletions(-)

diff --git 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 @@ -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 *);