[clang] [C23] Support the SNAN macros in <float.h> (PR #162858)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 14 20:16:16 PDT 2025
================
@@ -1,17 +1,24 @@
-// RUN: %clang_cc1 -verify -std=c2y -Wall -pedantic -emit-llvm -o - %s
-// RUN: %clang_cc1 -verify -Wall -pedantic -emit-llvm -o - %s
+// RUN: %clang_cc1 -verify -std=c2y -ffreestanding -Wall -pedantic -emit-llvm -o - %s
+// RUN: %clang_cc1 -verify -ffreestanding -Wall -pedantic -emit-llvm -o - %s
// expected-no-diagnostics
/* WG14 N3364: Yes
* Give consistent wording for SNAN initialization v3
*
* Ensure that initializing from a signaling NAN (optionally with a unary + or
* -) at translation time behaves correctly at runtime.
+ *
+ * This also serves as a test for C23's WG14 N2710 which introduces these
+ * macros into float.h in Clang 22.
*/
-#define FLT_SNAN __builtin_nansf("1")
-#define DBL_SNAN __builtin_nans("1")
-#define LD_SNAN __builtin_nansl("1")
+#if __STDC_VERSION__ >= 202311L
+#include <float.h>
+#else
+#define FLT_SNAN __builtin_nansf("")
----------------
shafik wrote:
I am quiet curious how changing the arguments from "1" to "" did not result in any of the results changing.
https://github.com/llvm/llvm-project/pull/162858
More information about the cfe-commits
mailing list