65 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// test numeric_limits10 11// traps12 13// XFAIL: FROZEN-CXX03-HEADERS-FIXME14 15#include <limits>16 17#include "test_macros.h"18 19#if defined(__i386__) || defined(__x86_64__) || defined(__wasm__)20static const bool integral_types_trap = true;21#else22static const bool integral_types_trap = false;23#endif24 25template <class T, bool expected>26void27test()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 35int main(int, char**)36{37 test<bool, false>();38 test<char, false>();39 test<signed char, false>();40 test<unsigned char, false>();41 test<wchar_t, false>();42#if TEST_STD_VER > 17 && defined(__cpp_char8_t)43 test<char8_t, false>();44#endif45 test<char16_t, false>();46 test<char32_t, false>();47 test<short, false>();48 test<unsigned short, false>();49 test<int, integral_types_trap>();50 test<unsigned int, integral_types_trap>();51 test<long, integral_types_trap>();52 test<unsigned long, integral_types_trap>();53 test<long long, integral_types_trap>();54 test<unsigned long long, integral_types_trap>();55#ifndef TEST_HAS_NO_INT12856 test<__int128_t, integral_types_trap>();57 test<__uint128_t, integral_types_trap>();58#endif59 test<float, false>();60 test<double, false>();61 test<long double, false>();62 63 return 0;64}65