Skip to content

Commit fe51305

Browse files
committed
test constant snan
1 parent 9c821fb commit fe51305

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

clang/test/Sema/constant-builtins-fmaximum-num.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,26 @@
33
// expected-no-diagnostics
44

55
constexpr double NaN = __builtin_nan("");
6+
constexpr double SNaN = __builtin_nans("");
67
constexpr double Inf = __builtin_inf();
78
constexpr double NegInf = -__builtin_inf();
89

910
#define FMAXIMUMNUM_TEST_SIMPLE(T, FUNC) \
1011
static_assert(T(6.7890) == FUNC(T(1.2345), T(6.7890))); \
1112
static_assert(T(6.7890) == FUNC(T(6.7890), T(1.2345)));
1213

14+
#define FMAXIMUMNUM_TEST_SNAN(T, FUNC) \
15+
static_assert(Inf == FUNC(SNaN, Inf)); \
16+
static_assert(NegInf == FUNC(NegInf, SNaN)); \
17+
static_assert(0.0 == FUNC(SNaN, 0.0)); \
18+
static_assert(-0.0 == FUNC(-0.0, SNaN)); \
19+
static_assert(T(-1.2345) == FUNC(SNaN, T(-1.2345))); \
20+
static_assert(T(1.2345) == FUNC(T(1.2345), SNaN)); \
21+
static_assert(__builtin_isnan(FUNC(SNaN, SNaN))); \
22+
static_assert(__builtin_isnan(FUNC(NaN, SNaN))); \
23+
static_assert(!__builtin_issignaling(FUNC(SNaN, SNaN))); \
24+
static_assert(!__builtin_issignaling(FUNC(NaN, SNaN)));
25+
1326
#define FMAXIMUMNUM_TEST_NAN(T, FUNC) \
1427
static_assert(Inf == FUNC(NaN, Inf)); \
1528
static_assert(NegInf == FUNC(NegInf, NaN)); \
@@ -42,6 +55,7 @@ constexpr double NegInf = -__builtin_inf();
4255
#define LIST_FMAXIMUMNUM_TESTS(T, FUNC) \
4356
FMAXIMUMNUM_TEST_SIMPLE(T, FUNC) \
4457
FMAXIMUMNUM_TEST_NAN(T, FUNC) \
58+
FMAXIMUMNUM_TEST_SNAN(T, FUNC) \
4559
FMAXIMUMNUM_TEST_INF(T, FUNC) \
4660
FMAXIMUMNUM_TEST_NEG_INF(T, FUNC) \
4761
FMAXIMUMNUM_TEST_BOTH_ZERO(T, FUNC)

clang/test/Sema/constant-builtins-fminimum-num.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// expected-no-diagnostics
44

55
constexpr double NaN = __builtin_nan("");
6+
constexpr double SNaN = __builtin_nans("");
67
constexpr double Inf = __builtin_inf();
78
constexpr double NegInf = -__builtin_inf();
89

@@ -19,6 +20,18 @@ constexpr double NegInf = -__builtin_inf();
1920
static_assert(T(1.2345) == FUNC(T(1.2345), NaN)); \
2021
static_assert(__builtin_isnan(FUNC(NaN, NaN)));
2122

23+
#define FMINIMUMNUM_TEST_SNAN(T, FUNC) \
24+
static_assert(Inf == FUNC(SNaN, Inf)); \
25+
static_assert(NegInf == FUNC(NegInf, SNaN)); \
26+
static_assert(0.0 == FUNC(SNaN, 0.0)); \
27+
static_assert(-0.0 == FUNC(-0.0, SNaN)); \
28+
static_assert(T(-1.2345) == FUNC(SNaN, T(-1.2345))); \
29+
static_assert(T(1.2345) == FUNC(T(1.2345), SNaN)); \
30+
static_assert(__builtin_isnan(FUNC(SNaN, SNaN))); \
31+
static_assert(__builtin_isnan(FUNC(NaN, SNaN))); \
32+
static_assert(!__builtin_issignaling(FUNC(SNaN, SNaN))); \
33+
static_assert(!__builtin_issignaling(FUNC(NaN, SNaN)));
34+
2235
#define FMINIMUMNUM_TEST_INF(T, FUNC) \
2336
static_assert(NegInf == FUNC(NegInf, Inf)); \
2437
static_assert(0.0 == FUNC(Inf, 0.0)); \
@@ -42,6 +55,7 @@ constexpr double NegInf = -__builtin_inf();
4255
#define LIST_FMINIMUMNUM_TESTS(T, FUNC) \
4356
FMINIMUMNUM_TEST_SIMPLE(T, FUNC) \
4457
FMINIMUMNUM_TEST_NAN(T, FUNC) \
58+
FMINIMUMNUM_TEST_SNAN(T, FUNC) \
4559
FMINIMUMNUM_TEST_INF(T, FUNC) \
4660
FMINIMUMNUM_TEST_NEG_INF(T, FUNC) \
4761
FMINIMUMNUM_TEST_BOTH_ZERO(T, FUNC)

0 commit comments

Comments
 (0)