diff options
author | Michael Forney <mforney@mforney.org> | 2019-03-12 18:43:14 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-03-12 18:44:40 -0700 |
commit | cd1c07667495e7dd991cfcd0637eddf2bb65eac9 (patch) | |
tree | 98678662672376b2ab3f6c59a83eb511306200fc /expr.c | |
parent | 842176df9208931f62d5e3dd62825fe04b9ae44d (diff) |
Implement __builtin_constant_p
Diffstat (limited to 'expr.c')
-rw-r--r-- | expr.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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 */ |