aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cc.h2
-rw-r--r--decl.c2
-rw-r--r--expr.c12
3 files changed, 4 insertions, 12 deletions
diff --git a/cc.h b/cc.h
index 068eb72..97d3e66 100644
--- a/cc.h
+++ b/cc.h
@@ -518,7 +518,7 @@ struct type *stringconcat(struct stringlit *, bool);
struct expr *expr(struct scope *);
struct expr *assignexpr(struct scope *);
-struct expr *evalexpr(struct scope *);
+struct expr *condexpr(struct scope *);
unsigned long long intconstexpr(struct scope *, bool);
void delexpr(struct expr *);
diff --git a/decl.c b/decl.c
index 0075baf..9b7f664 100644
--- a/decl.c
+++ b/decl.c
@@ -247,7 +247,7 @@ tagspec(struct scope *s)
next();
attr(NULL, 0);
if (consume(TASSIGN)) {
- e = evalexpr(s);
+ e = eval(condexpr(s));
if (e->kind != EXPRCONST || !(e->type->prop & PROPINT))
error(&tok.loc, "expected integer constant expression");
value = e->u.constant.u;
diff --git a/expr.c b/expr.c
index e1cd271..bcf4fc7 100644
--- a/expr.c
+++ b/expr.c
@@ -734,8 +734,6 @@ primaryexpr(struct scope *s)
return e;
}
-static struct expr *condexpr(struct scope *);
-
/* TODO: merge with init.c:designator() */
static void
designator(struct scope *s, struct type *t, unsigned long long *offset)
@@ -1201,7 +1199,7 @@ binaryexpr(struct scope *s, struct expr *l, int i)
return l;
}
-static struct expr *
+struct expr *
condexpr(struct scope *s)
{
struct expr *e, *l, *r;
@@ -1257,18 +1255,12 @@ condexpr(struct scope *s)
return e;
}
-struct expr *
-evalexpr(struct scope *s)
-{
- return eval(condexpr(s));
-}
-
unsigned long long
intconstexpr(struct scope *s, bool allowneg)
{
struct expr *e;
- e = evalexpr(s);
+ e = eval(condexpr(s));
if (e->kind != EXPRCONST || !(e->type->prop & PROPINT))
error(&tok.loc, "not an integer constant expression");
if (!allowneg && e->type->u.basic.issigned && e->u.constant.u >> 63)