================
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -DWIN -verify -std=c++23 -fsyntax-only  %s
+// RUN: %clang_cc1 -verify -std=c++23 -fsyntax-only  %s
+
+// expected-no-diagnostics
+
+
+#ifdef WIN
+#define INFINITY ((float)(1e+300 * 1e+300))
+#define NAN      (-(float)(INFINITY * 0.0F))
+#else
+#define NAN (__builtin_nanf(""))
+#define INFINITY (__builtin_inff())
+#endif
+
+extern "C" void abort() noexcept;
+extern "C" int write(int, const void*, unsigned long);
+
+#define assert(condition) \
+  do {                     \
+    if (!(condition)) {                                        \
+      write(2, "Assertion failed: ", 18);              \
+      write(2, #condition, sizeof(#condition) - 1);    \
+      write(2, "\n", 1);                               \
+      abort();                                         \
+    }                                                  \
+  } while (false)
+
+int main() {
+    int i;
+
+    // fmin
+    static_assert(__builtin_fmin(15.24, 1.3) == 1.3, "");
+    static_assert(__builtin_fmin(-0.0, +0.0) == -0.0, "");
+    static_assert(__builtin_fmin(+0.0, -0.0) == -0.0, "");
+    assert(__builtin_isnan(__builtin_fminf(NAN,NAN)));
+    assert(__builtin_isnan(__builtin_fminf(NAN, -1)));
+    assert(__builtin_isnan(__builtin_fminf(-INFINITY, 0)));
+    assert(__builtin_iszero(__builtin_fminf(+INFINITY, 0)));
+
+    // frexp
+    static_assert(__builtin_frexp(123.45, &i) == 0.96445312500000002);
----------------
zahiraam wrote:

Still working on this. Can you please review the implementation of frexp I have 
added in `ExprConstant.cpp`?
@frederick-vs-ja  are you suggesting using something like this for the use of 
`frexp` in this test?
```
struct FrexpResult {
  double fraction;
  int exponent;
};

FrexpResult simulateFrexp(double value) {
  FrexpResult result;
  result.fraction = __builtin_frexp(value, &result.exponent);
  return result;
}

int main () {
  double value = 123.456;
  FrexpResult result = simulateFrexp(123.456);
  
  return 0;
}

```
Still no way of asserting what the return values of fraction and exponent are 
from calls to `simulateFrex`p with various arguments. Any suggestions?


https://github.com/llvm/llvm-project/pull/88978
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to