[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / constant-builtins-fmax.cpp
blobc2fd97a4df63a09dde55963b948930114248562e
1 // RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
2 // expected-no-diagnostics
4 constexpr double NaN = __builtin_nan("");
5 constexpr double Inf = __builtin_inf();
6 constexpr double NegInf = -__builtin_inf();
8 #define FMAX_TEST_SIMPLE(T, FUNC) \
9 static_assert(T(6.7890) == FUNC(T(1.2345), T(6.7890))); \
10 static_assert(T(6.7890) == FUNC(T(6.7890), T(1.2345)));
12 #define FMAX_TEST_NAN(T, FUNC) \
13 static_assert(Inf == FUNC(NaN, Inf)); \
14 static_assert(NegInf == FUNC(NegInf, NaN)); \
15 static_assert(0.0 == FUNC(NaN, 0.0)); \
16 static_assert(-0.0 == FUNC(-0.0, NaN)); \
17 static_assert(T(-1.2345) == FUNC(NaN, T(-1.2345))); \
18 static_assert(T(1.2345) == FUNC(T(1.2345), NaN)); \
19 static_assert(__builtin_isnan(FUNC(NaN, NaN)));
21 #define FMAX_TEST_INF(T, FUNC) \
22 static_assert(Inf == FUNC(NegInf, Inf)); \
23 static_assert(Inf == FUNC(Inf, 0.0)); \
24 static_assert(Inf == FUNC(-0.0, Inf)); \
25 static_assert(Inf == FUNC(Inf, T(1.2345))); \
26 static_assert(Inf == FUNC(T(-1.2345), Inf));
28 #define FMAX_TEST_NEG_INF(T, FUNC) \
29 static_assert(Inf == FUNC(Inf, NegInf)); \
30 static_assert(0.0 == FUNC(NegInf, 0.0)); \
31 static_assert(-0.0 == FUNC(-0.0, NegInf)); \
32 static_assert(T(-1.2345) == FUNC(NegInf, T(-1.2345))); \
33 static_assert(T(1.2345) == FUNC(T(1.2345), NegInf));
35 #define FMAX_TEST_BOTH_ZERO(T, FUNC) \
36 static_assert(__builtin_copysign(1.0, FUNC(0.0, 0.0)) == 1.0); \
37 static_assert(__builtin_copysign(1.0, FUNC(-0.0, 0.0)) == 1.0); \
38 static_assert(__builtin_copysign(1.0, FUNC(0.0, -0.0)) == 1.0); \
39 static_assert(__builtin_copysign(1.0, FUNC(-0.0, -0.0)) == -1.0);
41 #define LIST_FMAX_TESTS(T, FUNC) \
42 FMAX_TEST_SIMPLE(T, FUNC) \
43 FMAX_TEST_NAN(T, FUNC) \
44 FMAX_TEST_INF(T, FUNC) \
45 FMAX_TEST_NEG_INF(T, FUNC) \
46 FMAX_TEST_BOTH_ZERO(T, FUNC)
48 LIST_FMAX_TESTS(double, __builtin_fmax)
49 LIST_FMAX_TESTS(float, __builtin_fmaxf)
50 LIST_FMAX_TESTS((long double), __builtin_fmaxl)
51 LIST_FMAX_TESTS(__fp16, __builtin_fmaxf16)
52 #ifdef __FLOAT128__
53 LIST_FMAX_TESTS(__float128, __builtin_fmaxf128)
54 #endif