1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
10
11 // test numeric_limits
12
13 // has_denorm
14
15 #include <limits>
16
17 #include "test_macros.h"
18
19 template <class T, std::float_denorm_style expected>
20 void
test()21 test()
22 {
23 static_assert(std::numeric_limits<T>::has_denorm == expected, "has_denorm test 1");
24 static_assert(std::numeric_limits<const T>::has_denorm == expected, "has_denorm test 2");
25 static_assert(std::numeric_limits<volatile T>::has_denorm == expected, "has_denorm test 3");
26 static_assert(std::numeric_limits<const volatile T>::has_denorm == expected, "has_denorm test 4");
27 }
28
main(int,char **)29 int main(int, char**)
30 {
31 test<bool, std::denorm_absent>();
32 test<char, std::denorm_absent>();
33 test<signed char, std::denorm_absent>();
34 test<unsigned char, std::denorm_absent>();
35 test<wchar_t, std::denorm_absent>();
36 #if TEST_STD_VER > 17 && defined(__cpp_char8_t)
37 test<char8_t, std::denorm_absent>();
38 #endif
39 test<char16_t, std::denorm_absent>();
40 test<char32_t, std::denorm_absent>();
41 test<short, std::denorm_absent>();
42 test<unsigned short, std::denorm_absent>();
43 test<int, std::denorm_absent>();
44 test<unsigned int, std::denorm_absent>();
45 test<long, std::denorm_absent>();
46 test<unsigned long, std::denorm_absent>();
47 test<long long, std::denorm_absent>();
48 test<unsigned long long, std::denorm_absent>();
49 #ifndef TEST_HAS_NO_INT128
50 test<__int128_t, std::denorm_absent>();
51 test<__uint128_t, std::denorm_absent>();
52 #endif
53 test<float, std::denorm_present>();
54 test<double, std::denorm_present>();
55 test<long double, std::denorm_present>();
56
57 return 0;
58 }
59