• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // test numeric_limits
11 
12 // traps
13 
14 #include <limits>
15 
16 #if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || \
17     defined(__wasm__)
18 static const bool integral_types_trap = true;
19 #else
20 static const bool integral_types_trap = false;
21 #endif
22 
23 template <class T, bool expected>
24 void
test()25 test()
26 {
27     static_assert(std::numeric_limits<T>::traps == expected, "traps test 1");
28     static_assert(std::numeric_limits<const T>::traps == expected, "traps test 2");
29     static_assert(std::numeric_limits<volatile T>::traps == expected, "traps test 3");
30     static_assert(std::numeric_limits<const volatile T>::traps == expected, "traps test 4");
31 }
32 
main()33 int main()
34 {
35     test<bool, false>();
36     test<char, integral_types_trap>();
37     test<signed char, integral_types_trap>();
38     test<unsigned char, integral_types_trap>();
39     test<wchar_t, integral_types_trap>();
40 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
41     test<char16_t, integral_types_trap>();
42     test<char32_t, integral_types_trap>();
43 #endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
44     test<short, integral_types_trap>();
45     test<unsigned short, integral_types_trap>();
46     test<int, integral_types_trap>();
47     test<unsigned int, integral_types_trap>();
48     test<long, integral_types_trap>();
49     test<unsigned long, integral_types_trap>();
50     test<long long, integral_types_trap>();
51     test<unsigned long long, integral_types_trap>();
52 #ifndef _LIBCPP_HAS_NO_INT128
53     test<__int128_t, integral_types_trap>();
54     test<__uint128_t, integral_types_trap>();
55 #endif
56     test<float, false>();
57     test<double, false>();
58     test<long double, false>();
59 }
60