| 1 |
// RUN: %clang_cc1 -verify -std=c2y -ffreestanding -Wall -pedantic -emit-llvm -o - %s | FileCheck %s |
| 2 |
// RUN: %clang_cc1 -verify -ffreestanding -Wall -pedantic -emit-llvm -o - %s | FileCheck %s |
| 3 |
// expected-no-diagnostics |
| 4 |
|
| 5 |
/* WG14 N3364: Yes |
| 6 |
* Give consistent wording for SNAN initialization v3 |
| 7 |
* |
| 8 |
* Ensure that initializing from a signaling NAN (optionally with a unary + or |
| 9 |
* -) at translation time behaves correctly at runtime. |
| 10 |
* |
| 11 |
* This also serves as a test for C23's WG14 N2710 which introduces these |
| 12 |
* macros into float.h in Clang 22. |
| 13 |
*/ |
| 14 |
|
| 15 |
#if __STDC_VERSION__ >= 202311L |
| 16 |
#include <float.h> |
| 17 |
#else |
| 18 |
#define FLT_SNAN __builtin_nansf("") |
| 19 |
#define DBL_SNAN __builtin_nans("") |
| 20 |
#define LDBL_SNAN __builtin_nansl("") |
| 21 |
#endif |
| 22 |
|
| 23 |
float f1 = FLT_SNAN; |
| 24 |
float f2 = +FLT_SNAN; |
| 25 |
float f3 = -FLT_SNAN; |
| 26 |
// CHECK: @f1 = {{.*}}global float 0x7FF4000000000000 |
| 27 |
// CHECK: @f2 = {{.*}}global float 0x7FF4000000000000 |
| 28 |
// CHECK: @f3 = {{.*}}global float 0xFFF4000000000000 |
| 29 |
|
| 30 |
double d1 = DBL_SNAN; |
| 31 |
double d2 = +DBL_SNAN; |
| 32 |
double d3 = -DBL_SNAN; |
| 33 |
// CHECK: @d1 = {{.*}}global double 0x7FF4000000000000 |
| 34 |
// CHECK: @d2 = {{.*}}global double 0x7FF4000000000000 |
| 35 |
// CHECK: @d3 = {{.*}}global double 0xFFF4000000000000 |
| 36 |
|
| 37 |
long double ld1 = LDBL_SNAN; |
| 38 |
long double ld2 = +LDBL_SNAN; |
| 39 |
long double ld3 = -LDBL_SNAN; |
| 40 |
// CHECK: @ld1 = {{.*}}global {{double 0x7FF4000000000000|x86_fp80 0xK7FFFA000000000000000|fp128 0xL00000000000000007FFF400000000000|ppc_fp128 0xM7FF40000000000000000000000000000}} |
| 41 |
// CHECK: @ld2 = {{.*}}global {{double 0x7FF4000000000000|x86_fp80 0xK7FFFA000000000000000|fp128 0xL00000000000000007FFF400000000000|ppc_fp128 0xM7FF40000000000000000000000000000}} |
| 42 |
// CHECK: @ld3 = {{.*}}global {{double 0xFFF4000000000000|x86_fp80 0xKFFFFA000000000000000|fp128 0xL0000000000000000FFFF400000000000|ppc_fp128 0xMFFF40000000000008000000000000000}} |