1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
13 #include "test_macros.h"
16 // Make sure we can use the following types without including anything else
18 (void)sizeof(ptrdiff_t);
19 #if TEST_STD_VER >= 11
20 (void)sizeof(nullptr);
21 (void)sizeof(nullptr_t
);
22 (void)sizeof(max_align_t
);
27 #error NULL not defined
31 #error offsetof not defined
34 #include <type_traits>
36 static_assert(sizeof(size_t) == sizeof(void*), "");
37 static_assert(std::is_unsigned
<size_t>::value
, "");
38 static_assert(std::is_integral
<size_t>::value
, "");
39 static_assert(sizeof(ptrdiff_t) == sizeof(void*), "");
40 static_assert(std::is_signed
<ptrdiff_t>::value
, "");
41 static_assert(std::is_integral
<ptrdiff_t>::value
, "");
42 static_assert((std::is_same
<decltype(nullptr), nullptr_t
>::value
), "");
43 static_assert(sizeof(nullptr_t
) == sizeof(void*), "");
44 #if TEST_STD_VER >= 11
45 # if TEST_STD_VER >= 20
47 static_assert(std::is_trivial
<max_align_t
>::value
, "");
48 static_assert(std::is_standard_layout
<max_align_t
>::value
, "");
50 static_assert(std::is_pod
<max_align_t
>::value
, "");
52 static_assert(std::alignment_of
<max_align_t
>::value
>= std::alignment_of
<long long>::value
, "");
53 static_assert(std::alignment_of
<max_align_t
>::value
>= std::alignment_of
<long double>::value
, "");
54 static_assert(std::alignment_of
<max_align_t
>::value
>= std::alignment_of
<void*>::value
, "");
55 #endif // TEST_STD_VER >= 11