First part of P0482 - Establish that char8_t is an integral type, and that numeric_limits<char8_t> is valid and sane.

llvm-svn: 347904
This commit is contained in:
Marshall Clow 2018-11-29 19:49:48 +00:00
parent e823b6d7e6
commit 8143278500
35 changed files with 172 additions and 0 deletions

View File

@ -82,6 +82,7 @@ template<> class numeric_limits<cv char>;
template<> class numeric_limits<cv signed char>;
template<> class numeric_limits<cv unsigned char>;
template<> class numeric_limits<cv wchar_t>;
template<> class numeric_limits<cv char8_t>; // C++20
template<> class numeric_limits<cv char16_t>;
template<> class numeric_limits<cv char32_t>;

View File

@ -709,6 +709,9 @@ template <> struct __libcpp_is_integral<char> : public tr
template <> struct __libcpp_is_integral<signed char> : public true_type {};
template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
#if _LIBCPP_STD_VER > 17
template <> struct __libcpp_is_integral<char8_t> : public true_type {};
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
template <> struct __libcpp_is_integral<char16_t> : public true_type {};
template <> struct __libcpp_is_integral<char32_t> : public true_type {};

View File

@ -9,6 +9,8 @@
#include <limits>
#include "test_macros.h"
/*
<limits>:
numeric_limits
@ -99,6 +101,14 @@ int main()
TEST_NUMERIC_LIMITS(volatile wchar_t)
TEST_NUMERIC_LIMITS(const volatile wchar_t)
#if TEST_STD_VER > 17
// char8_t
TEST_NUMERIC_LIMITS(char8_t)
TEST_NUMERIC_LIMITS(const char8_t)
TEST_NUMERIC_LIMITS(volatile char8_t)
TEST_NUMERIC_LIMITS(const volatile char8_t)
#endif
// char16_t
TEST_NUMERIC_LIMITS(char16_t)
TEST_NUMERIC_LIMITS(const char16_t)

View File

@ -15,6 +15,8 @@
#include <cfloat>
#include <cassert>
#include "test_macros.h"
template <class T>
void
test(T expected)
@ -32,6 +34,9 @@ int main()
test<signed char>(0);
test<unsigned char>(0);
test<wchar_t>(0);
#if TEST_STD_VER > 17
test<char8_t>(0);
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>(0);
test<char32_t>(0);

View File

@ -14,6 +14,8 @@
#include <limits>
#include <cfloat>
#include "test_macros.h"
template <class T, int expected>
void
test()
@ -31,6 +33,9 @@ int main()
test<signed char, 7>();
test<unsigned char, 8>();
test<wchar_t, std::numeric_limits<wchar_t>::is_signed ? sizeof(wchar_t)*8-1 : sizeof(wchar_t)*8>();
#if TEST_STD_VER > 17
test<char8_t, 8>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 16>();
test<char32_t, 32>();

View File

@ -14,6 +14,8 @@
#include <limits>
#include <cfloat>
#include "test_macros.h"
template <class T, int expected>
void
test()
@ -35,6 +37,9 @@ int main()
test<signed char, 2>();
test<unsigned char, 2>();
test<wchar_t, 5*sizeof(wchar_t)/2-1>(); // 4 -> 9 and 2 -> 4
#if TEST_STD_VER > 17
test<char8_t, 2>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 4>();
test<char32_t, 9>();

View File

@ -15,6 +15,8 @@
#include <cfloat>
#include <cassert>
#include "test_macros.h"
template <class T>
void
test(T expected)
@ -32,6 +34,9 @@ int main()
test<signed char>(0);
test<unsigned char>(0);
test<wchar_t>(0);
#if TEST_STD_VER > 17
test<char8_t>(0);
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>(0);
test<char32_t>(0);

View File

@ -13,6 +13,8 @@
#include <limits>
#include "test_macros.h"
template <class T, std::float_denorm_style expected>
void
test()
@ -30,6 +32,9 @@ int main()
test<signed char, std::denorm_absent>();
test<unsigned char, std::denorm_absent>();
test<wchar_t, std::denorm_absent>();
#if TEST_STD_VER > 17
test<char8_t, std::denorm_absent>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, std::denorm_absent>();
test<char32_t, std::denorm_absent>();

View File

@ -13,6 +13,8 @@
#include <limits>
#include "test_macros.h"
template <class T, bool expected>
void
test()
@ -30,6 +32,9 @@ int main()
test<signed char, false>();
test<unsigned char, false>();
test<wchar_t, false>();
#if TEST_STD_VER > 17
test<char8_t, false>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, false>();
test<char32_t, false>();

View File

@ -13,6 +13,8 @@
#include <limits>
#include "test_macros.h"
template <class T, bool expected>
void
test()
@ -30,6 +32,9 @@ int main()
test<signed char, false>();
test<unsigned char, false>();
test<wchar_t, false>();
#if TEST_STD_VER > 17
test<char8_t, false>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, false>();
test<char32_t, false>();

View File

@ -13,6 +13,8 @@
#include <limits>
#include "test_macros.h"
template <class T, bool expected>
void
test()
@ -30,6 +32,9 @@ int main()
test<signed char, false>();
test<unsigned char, false>();
test<wchar_t, false>();
#if TEST_STD_VER > 17
test<char8_t, false>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, false>();
test<char32_t, false>();

View File

@ -13,6 +13,8 @@
#include <limits>
#include "test_macros.h"
template <class T, bool expected>
void
test()
@ -30,6 +32,9 @@ int main()
test<signed char, false>();
test<unsigned char, false>();
test<wchar_t, false>();
#if TEST_STD_VER > 17
test<char8_t, false>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, false>();
test<char32_t, false>();

View File

@ -15,6 +15,8 @@
#include <cfloat>
#include <cassert>
#include "test_macros.h"
template <class T>
void
test(T expected)
@ -34,6 +36,9 @@ int main()
test<signed char>(0);
test<unsigned char>(0);
test<wchar_t>(0);
#if TEST_STD_VER > 17
test<char8_t>(0);
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>(0);
test<char32_t>(0);

View File

@ -13,6 +13,8 @@
#include <limits>
#include "test_macros.h"
template <class T, bool expected>
void
test()
@ -30,6 +32,9 @@ int main()
test<signed char, true>();
test<unsigned char, true>();
test<wchar_t, true>();
#if TEST_STD_VER > 17
test<char8_t, true>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, true>();
test<char32_t, true>();

View File

@ -13,6 +13,8 @@
#include <limits>
#include "test_macros.h"
template <class T, bool expected>
void
test()
@ -30,6 +32,9 @@ int main()
test<signed char, true>();
test<unsigned char, true>();
test<wchar_t, true>();
#if TEST_STD_VER > 17
test<char8_t, true>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, true>();
test<char32_t, true>();

View File

@ -13,6 +13,8 @@
#include <limits>
#include "test_macros.h"
template <class T, bool expected>
void
test()
@ -30,6 +32,9 @@ int main()
test<signed char, false>();
test<unsigned char, false>();
test<wchar_t, false>();
#if TEST_STD_VER > 17
test<char8_t, false>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, false>();
test<char32_t, false>();

View File

@ -13,6 +13,8 @@
#include <limits>
#include "test_macros.h"
template <class T, bool expected>
void
test()
@ -30,6 +32,9 @@ int main()
test<signed char, true>();
test<unsigned char, true>();
test<wchar_t, true>();
#if TEST_STD_VER > 17
test<char8_t, true>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, true>();
test<char32_t, true>();

View File

@ -13,6 +13,8 @@
#include <limits>
#include "test_macros.h"
template <class T, bool expected>
void
test()
@ -30,6 +32,9 @@ int main()
test<signed char, false>();
test<unsigned char, true>();
// test<wchar_t, false>(); // don't know
#if TEST_STD_VER > 17
test<char8_t, true>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, true>();
test<char32_t, true>();

View File

@ -13,6 +13,8 @@
#include <limits>
#include "test_macros.h"
template <class T, bool expected>
void
test()
@ -30,6 +32,9 @@ int main()
test<signed char, true>();
test<unsigned char, false>();
test<wchar_t, wchar_t(-1) < wchar_t(0)>();
#if TEST_STD_VER > 17
test<char8_t, false>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, false>();
test<char32_t, false>();

View File

@ -17,6 +17,8 @@
#include <cfloat>
#include <cassert>
#include "test_macros.h"
template <class T>
void
test(T expected)
@ -38,6 +40,9 @@ int main()
test<signed char>(SCHAR_MIN);
test<unsigned char>(0);
test<wchar_t>(WCHAR_MIN);
#if TEST_STD_VER > 17
test<char8_t>(0);
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>(0);
test<char32_t>(0);

View File

@ -17,6 +17,8 @@
#include <cfloat>
#include <cassert>
#include "test_macros.h"
template <class T>
void
test(T expected)
@ -38,6 +40,9 @@ int main()
test<signed char>(SCHAR_MAX);
test<unsigned char>(UCHAR_MAX);
test<wchar_t>(WCHAR_MAX);
#if TEST_STD_VER > 17
test<char8_t>(UCHAR_MAX); // ??
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>(USHRT_MAX);
test<char32_t>(UINT_MAX);

View File

@ -14,6 +14,8 @@
#include <limits>
#include <cfloat>
#include "test_macros.h"
template <class T, int expected>
void
test()
@ -31,6 +33,9 @@ int main()
test<signed char, 0>();
test<unsigned char, 0>();
test<wchar_t, 0>();
#if TEST_STD_VER > 17
test<char8_t, 0>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 0>();
test<char32_t, 0>();

View File

@ -14,6 +14,8 @@
#include <limits>
#include <cfloat>
#include "test_macros.h"
template <class T, int expected>
void
test()
@ -31,6 +33,9 @@ int main()
test<signed char, 0>();
test<unsigned char, 0>();
test<wchar_t, 0>();
#if TEST_STD_VER > 17
test<char8_t, 0>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 0>();
test<char32_t, 0>();

View File

@ -14,6 +14,8 @@
#include <limits>
#include <cfloat>
#include "test_macros.h"
template <class T, int expected>
void
test()
@ -31,6 +33,9 @@ int main()
test<signed char, 0>();
test<unsigned char, 0>();
test<wchar_t, 0>();
#if TEST_STD_VER > 17
test<char8_t, 0>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 0>();
test<char32_t, 0>();

View File

@ -17,6 +17,8 @@
#include <cfloat>
#include <cassert>
#include "test_macros.h"
template <class T>
void
test(T expected)
@ -38,6 +40,9 @@ int main()
test<signed char>(SCHAR_MIN);
test<unsigned char>(0);
test<wchar_t>(WCHAR_MIN);
#if TEST_STD_VER > 17
test<char8_t>(0);
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>(0);
test<char32_t>(0);

View File

@ -14,6 +14,8 @@
#include <limits>
#include <cfloat>
#include "test_macros.h"
template <class T, int expected>
void
test()
@ -31,6 +33,9 @@ int main()
test<signed char, 0>();
test<unsigned char, 0>();
test<wchar_t, 0>();
#if TEST_STD_VER > 17
test<char8_t, 0>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 0>();
test<char32_t, 0>();

View File

@ -14,6 +14,8 @@
#include <limits>
#include <cfloat>
#include "test_macros.h"
template <class T, int expected>
void
test()
@ -31,6 +33,9 @@ int main()
test<signed char, 0>();
test<unsigned char, 0>();
test<wchar_t, 0>();
#if TEST_STD_VER > 17
test<char8_t, 0>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 0>();
test<char32_t, 0>();

View File

@ -16,6 +16,8 @@
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <class T>
void
test_imp(std::true_type)
@ -51,6 +53,9 @@ int main()
test<signed char>();
test<unsigned char>();
test<wchar_t>();
#if TEST_STD_VER > 17
test<char8_t>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();

View File

@ -14,6 +14,8 @@
#include <limits>
#include <cfloat>
#include "test_macros.h"
template <class T, int expected>
void
test()
@ -31,6 +33,9 @@ int main()
test<signed char, 2>();
test<unsigned char, 2>();
test<wchar_t, 2>();
#if TEST_STD_VER > 17
test<char8_t, 2>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, 2>();
test<char32_t, 2>();

View File

@ -15,6 +15,8 @@
#include <cfloat>
#include <cassert>
#include "test_macros.h"
template <class T>
void
test(T expected)
@ -32,6 +34,9 @@ int main()
test<signed char>(0);
test<unsigned char>(0);
test<wchar_t>(0);
#if TEST_STD_VER > 17
test<char8_t>(0);
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>(0);
test<char32_t>(0);

View File

@ -13,6 +13,8 @@
#include <limits>
#include "test_macros.h"
template <class T, std::float_round_style expected>
void
test()
@ -30,6 +32,9 @@ int main()
test<signed char, std::round_toward_zero>();
test<unsigned char, std::round_toward_zero>();
test<wchar_t, std::round_toward_zero>();
#if TEST_STD_VER > 17
test<char8_t, std::round_toward_zero>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, std::round_toward_zero>();
test<char32_t, std::round_toward_zero>();

View File

@ -16,6 +16,8 @@
#include <type_traits>
#include <cassert>
#include "test_macros.h"
template <class T>
void
test_imp(std::true_type)
@ -51,6 +53,9 @@ int main()
test<signed char>();
test<unsigned char>();
test<wchar_t>();
#if TEST_STD_VER > 17
test<char8_t>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t>();
test<char32_t>();

View File

@ -13,6 +13,8 @@
#include <limits>
#include "test_macros.h"
template <class T, bool expected>
void
test()
@ -30,6 +32,9 @@ int main()
test<signed char, false>();
test<unsigned char, false>();
test<wchar_t, false>();
#if TEST_STD_VER > 17
test<char8_t, false>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, false>();
test<char32_t, false>();

View File

@ -13,6 +13,8 @@
#include <limits>
#include "test_macros.h"
#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || \
defined(__wasm__)
static const bool integral_types_trap = true;
@ -37,6 +39,9 @@ int main()
test<signed char, integral_types_trap>();
test<unsigned char, integral_types_trap>();
test<wchar_t, integral_types_trap>();
#if TEST_STD_VER > 17
test<char8_t, integral_types_trap>();
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test<char16_t, integral_types_trap>();
test<char32_t, integral_types_trap>();

View File

@ -85,6 +85,9 @@ int main()
test_is_integral<signed char>();
test_is_integral<unsigned char>();
test_is_integral<wchar_t>();
#if TEST_STD_VER > 14
test_is_integral<char8_t>();
#endif
test_is_not_integral<std::nullptr_t>();
test_is_not_integral<void>();