libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

traps.pass.cpp (2076B)


      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 #include "test_macros.h"
     17 
     18 #if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || \
     19     defined(__wasm__)
     20 static const bool integral_types_trap = true;
     21 #else
     22 static const bool integral_types_trap = false;
     23 #endif
     24 
     25 template <class T, bool expected>
     26 void
     27 test()
     28 {
     29     static_assert(std::numeric_limits<T>::traps == expected, "traps test 1");
     30     static_assert(std::numeric_limits<const T>::traps == expected, "traps test 2");
     31     static_assert(std::numeric_limits<volatile T>::traps == expected, "traps test 3");
     32     static_assert(std::numeric_limits<const volatile T>::traps == expected, "traps test 4");
     33 }
     34 
     35 int main()
     36 {
     37     test<bool, false>();
     38     test<char, integral_types_trap>();
     39     test<signed char, integral_types_trap>();
     40     test<unsigned char, integral_types_trap>();
     41     test<wchar_t, integral_types_trap>();
     42 #if TEST_STD_VER > 17 && defined(__cpp_char8_t)
     43     test<char8_t, integral_types_trap>();
     44 #endif
     45 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
     46     test<char16_t, integral_types_trap>();
     47     test<char32_t, integral_types_trap>();
     48 #endif  // _LIBCPP_HAS_NO_UNICODE_CHARS
     49     test<short, integral_types_trap>();
     50     test<unsigned short, integral_types_trap>();
     51     test<int, integral_types_trap>();
     52     test<unsigned int, integral_types_trap>();
     53     test<long, integral_types_trap>();
     54     test<unsigned long, integral_types_trap>();
     55     test<long long, integral_types_trap>();
     56     test<unsigned long long, integral_types_trap>();
     57 #ifndef _LIBCPP_HAS_NO_INT128
     58     test<__int128_t, integral_types_trap>();
     59     test<__uint128_t, integral_types_trap>();
     60 #endif
     61     test<float, false>();
     62     test<double, false>();
     63     test<long double, false>();
     64 }