diff options
-rw-r--r-- | decl.h | 1 | ||||
-rw-r--r-- | expr.c | 5 | ||||
-rw-r--r-- | scope.c | 1 | ||||
-rw-r--r-- | tests/builtin-inff.c | 1 | ||||
-rw-r--r-- | tests/builtin-inff.qbe | 1 |
5 files changed, 9 insertions, 0 deletions
@@ -20,6 +20,7 @@ enum builtinkind { BUILTINVAEND, BUILTINOFFSETOF, BUILTINALLOCA, + BUILTININFF, }; struct declaration { @@ -481,6 +481,11 @@ postfixexpr(struct scope *s, struct expression *r) e->builtin.kind = BUILTINALLOCA; e->builtin.arg = exprconvert(assignexpr(s), &typeulong); break; + case BUILTININFF: + e = mkexpr(EXPRCONST, &typefloat, 0); + /* TODO: use INFINITY here when we can handle musl's math.h */ + e->constant.f = strtod("inf", NULL); + break; default: fatal("internal error; unknown builtin"); } @@ -24,6 +24,7 @@ scopeinit(void) {"__builtin_va_end", {.kind = DECLBUILTIN, .builtin = BUILTINVAEND}}, {"__builtin_offsetof", {.kind = DECLBUILTIN, .builtin = BUILTINOFFSETOF}}, {"__builtin_alloca", {.kind = DECLBUILTIN, .builtin = BUILTINALLOCA}}, + {"__builtin_inff", {.kind = DECLBUILTIN, .builtin = BUILTININFF}}, }; struct builtin *b; diff --git a/tests/builtin-inff.c b/tests/builtin-inff.c new file mode 100644 index 0000000..2dcd040 --- /dev/null +++ b/tests/builtin-inff.c @@ -0,0 +1 @@ +float x = __builtin_inff(); diff --git a/tests/builtin-inff.qbe b/tests/builtin-inff.qbe new file mode 100644 index 0000000..5eb8060 --- /dev/null +++ b/tests/builtin-inff.qbe @@ -0,0 +1 @@ +export data $x = align 4 { s s_inf, } |