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 a0c8910f8f834b833ce2b8a38915b7857875c942
parent 8957f55d531472e8ee742cc1e8d74deba2b6997d
Author: Michael Forney <mforney@mforney.org>
Date:   Sat, 13 Apr 2019 23:44:09 -0700

Revert "Fold constexpr function into intconstexpr"

This reverts commit a080e36dac54b82beef63580f36cb0da9ad31788.

Diffstat:
Mcc.h | 1+
Mexpr.c | 8+++++++-
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/cc.h b/cc.h @@ -440,6 +440,7 @@ extern struct scope filescope; struct expr *expr(struct scope *); struct expr *assignexpr(struct scope *); +struct expr *constexpr(struct scope *); uint64_t intconstexpr(struct scope *, _Bool); void delexpr(struct expr *); diff --git a/expr.c b/expr.c @@ -820,12 +820,18 @@ condexpr(struct scope *s) return e; } +struct expr * +constexpr(struct scope *s) +{ + return eval(condexpr(s)); +} + uint64_t intconstexpr(struct scope *s, bool allowneg) { struct expr *e; - e = eval(condexpr(s)); + e = constexpr(s); if (e->kind != EXPRCONST || !(typeprop(e->type) & PROPINT)) error(&tok.loc, "not an integer constant expression"); if (!allowneg && e->type->basic.issigned && e->constant.i > INT64_MAX)