[clang] [CLANG] Add warning when INF or NAN are used in a binary operation or as function argument in fast math mode. (PR #76873)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 9 05:22:57 PST 2024
================
@@ -0,0 +1,245 @@
+// RUN: %clang_cc1 -x c++ -verify -triple powerpc64le-unknown-unknown %s \
+// RUN: -menable-no-infs -menable-no-nans -DFAST=1
+
+// RUN: %clang_cc1 -x c++ -verify -triple powerpc64le-unknown-unknown %s \
+// RUN: -DNOFAST=1
+
+// RUN: %clang_cc1 -x c++ -verify -triple powerpc64le-unknown-unknown %s \
+// RUN: -menable-no-infs -DNO_INFS=1
+
+// RUN: %clang_cc1 -x c++ -verify -triple powerpc64le-unknown-unknown %s \
+// RUN: -menable-no-nans -DNO_NANS=1
+
+int isunorderedf (float x, float y);
+#if NOFAST
+// expected-no-diagnostics
+#endif
+extern "C++" {
+namespace std __attribute__((__visibility__("default"))) {
+ bool
+ isinf(float __x);
+ bool
+ isinf(double __x);
+ bool
+ isinf(long double __x);
+ bool
+ isnan(float __x);
+ bool
+ isnan(double __x);
+ bool
+ isnan(long double __x);
+bool
+ isfinite(float __x);
+ bool
+ isfinite(double __x);
+ bool
+ isfinte(long double __x);
+ bool
+ isunordered(float __x, float __y);
+ bool
+ isunordered(double __x, double __y);
+ bool
+ isunordered(long double __x, long double __y);
+} // namespace )
+}
+#define NAN (__builtin_nanf(""))
+#define INFINITY (__builtin_inff())
+
----------------
arsenm wrote:
What about through std::numeric_limits<T>::infinity?
https://github.com/llvm/llvm-project/pull/76873
More information about the cfe-commits
mailing list