43 lines · c
1// RUN: %clang_cc1 -verify -std=c2y -ffreestanding -Wall -pedantic -emit-llvm -o - %s | FileCheck %s2// RUN: %clang_cc1 -verify -ffreestanding -Wall -pedantic -emit-llvm -o - %s | FileCheck %s3// expected-no-diagnostics4 5/* WG14 N3364: Yes6 * Give consistent wording for SNAN initialization v37 *8 * Ensure that initializing from a signaling NAN (optionally with a unary + or9 * -) at translation time behaves correctly at runtime.10 *11 * This also serves as a test for C23's WG14 N2710 which introduces these12 * macros into float.h in Clang 22.13 */14 15#if __STDC_VERSION__ >= 202311L16#include <float.h>17#else18#define FLT_SNAN __builtin_nansf("")19#define DBL_SNAN __builtin_nans("")20#define LDBL_SNAN __builtin_nansl("")21#endif22 23float f1 = FLT_SNAN;24float f2 = +FLT_SNAN;25float f3 = -FLT_SNAN;26// CHECK: @f1 = {{.*}}global float 0x7FF400000000000027// CHECK: @f2 = {{.*}}global float 0x7FF400000000000028// CHECK: @f3 = {{.*}}global float 0xFFF400000000000029 30double d1 = DBL_SNAN;31double d2 = +DBL_SNAN;32double d3 = -DBL_SNAN;33// CHECK: @d1 = {{.*}}global double 0x7FF400000000000034// CHECK: @d2 = {{.*}}global double 0x7FF400000000000035// CHECK: @d3 = {{.*}}global double 0xFFF400000000000036 37long double ld1 = LDBL_SNAN;38long double ld2 = +LDBL_SNAN;39long 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}}43