aboutsummaryrefslogtreecommitdiff
path: root/expr.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-03-12 18:43:14 -0700
committerMichael Forney <mforney@mforney.org>2019-03-12 18:44:40 -0700
commitcd1c07667495e7dd991cfcd0637eddf2bb65eac9 (patch)
tree98678662672376b2ab3f6c59a83eb511306200fc /expr.c
parent842176df9208931f62d5e3dd62825fe04b9ae44d (diff)
Implement __builtin_constant_p
Diffstat (limited to 'expr.c')
-rw-r--r--expr.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/expr.c b/expr.c
index 4dd16a8..b6e7bbc 100644
--- a/expr.c
+++ b/expr.c
@@ -405,6 +405,8 @@ primaryexpr(struct scope *s)
return e;
}
+static struct expression *condexpr(struct scope *);
+
static struct expression *
builtinfunc(struct scope *s, enum builtinkind kind)
{
@@ -419,6 +421,10 @@ builtinfunc(struct scope *s, enum builtinkind kind)
e->builtin.kind = BUILTINALLOCA;
e->builtin.arg = exprconvert(assignexpr(s), &typeulong);
break;
+ case BUILTINCONSTANTP:
+ /* XXX: does this need to consider address constants? */
+ e = mkconstexpr(&typeint, eval(condexpr(s))->kind == EXPRCONST);
+ break;
case BUILTININFF:
e = mkexpr(EXPRCONST, &typefloat, 0);
/* TODO: use INFINITY here when we can handle musl's math.h */