]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - fold.c
local compile-time const values are now created as globals, thus they're now subject...
[xonotic/gmqcc.git] / fold.c
diff --git a/fold.c b/fold.c
index 1cd8dfa21aeda2757d751f33bc784a2669d22b90..8227537bc68f20793b45fcf199c7f35146966341 100644 (file)
--- a/fold.c
+++ b/fold.c
@@ -820,6 +820,9 @@ static bool fold_check_except_float(sfloat_t (*callback)(sfloat_state_t *, sfloa
     sfloat_cast_t ca;
     sfloat_cast_t cb;
 
+    if (!OPTS_FLAG(ARITHMETIC_EXCEPTIONS) && !OPTS_WARN(WARN_INEXACT_COMPARES))
+        return false;
+
     s.roundingmode   = SFLOAT_ROUND_NEAREST_EVEN;
     s.tiny           = SFLOAT_TBEFORE;
     s.exceptionflags = 0;
@@ -830,27 +833,26 @@ static bool fold_check_except_float(sfloat_t (*callback)(sfloat_state_t *, sfloa
     if (s.exceptionflags == 0)
         return false;
 
+    if (!OPTS_FLAG(ARITHMETIC_EXCEPTIONS))
+        goto inexact_possible;
+
     if (s.exceptionflags & SFLOAT_DIVBYZERO)
         compile_error(fold_ctx(fold), "division by zero");
-#if 0
-    /*
-     * To be enabled once softfloat implementations for stuff like sqrt()
-     * exist
-     */
     if (s.exceptionflags & SFLOAT_INVALID)
-        compile_error(fold_ctx(fold), "invalid argument");
-#endif
-
+        compile_error(fold_ctx(fold), "undefined (inf)");
     if (s.exceptionflags & SFLOAT_OVERFLOW)
         compile_error(fold_ctx(fold), "arithmetic overflow");
     if (s.exceptionflags & SFLOAT_UNDERFLOW)
         compile_error(fold_ctx(fold), "arithmetic underflow");
 
-    return s.exceptionflags == SFLOAT_INEXACT;
+inexact_possible:
+    return s.exceptionflags & SFLOAT_INEXACT;
 }
 
 static bool fold_check_inexact_float(fold_t *fold, ast_value *a, ast_value *b) {
     lex_ctx_t ctx = fold_ctx(fold);
+    if (!OPTS_WARN(WARN_INEXACT_COMPARES))
+        return false;
     if (!a->inexact && !b->inexact)
         return false;
     return compile_warning(ctx, WARN_INEXACT_COMPARES, "inexact value in comparison");