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 // <stddef.h>
11
12 #include <stddef.h>
13 #include <cassert>
14 #include <type_traits>
15
16 #ifndef NULL
17 #error NULL not defined
18 #endif
19
20 #ifndef offsetof
21 #error offsetof not defined
22 #endif
23
main()24 int main()
25 {
26 void *p = NULL;
27 assert(!p);
28
29 static_assert(sizeof(size_t) == sizeof(void*),
30 "sizeof(size_t) == sizeof(void*)");
31 static_assert(std::is_unsigned<size_t>::value,
32 "std::is_unsigned<size_t>::value");
33 static_assert(std::is_integral<size_t>::value,
34 "std::is_integral<size_t>::value");
35 static_assert(sizeof(ptrdiff_t) == sizeof(void*),
36 "sizeof(ptrdiff_t) == sizeof(void*)");
37 static_assert(std::is_signed<ptrdiff_t>::value,
38 "std::is_signed<ptrdiff_t>::value");
39 static_assert(std::is_integral<ptrdiff_t>::value,
40 "std::is_integral<ptrdiff_t>::value");
41 static_assert((std::is_same<decltype(nullptr), nullptr_t>::value),
42 "decltype(nullptr) == nullptr_t");
43 static_assert(sizeof(nullptr_t) == sizeof(void*),
44 "sizeof(nullptr_t) == sizeof(void*)");
45 static_assert(std::is_pod<max_align_t>::value,
46 "std::is_pod<max_align_t>::value");
47 static_assert((std::alignment_of<max_align_t>::value >=
48 std::alignment_of<long long>::value),
49 "std::alignment_of<max_align_t>::value >= "
50 "std::alignment_of<long long>::value");
51 static_assert(std::alignment_of<max_align_t>::value >=
52 std::alignment_of<long double>::value,
53 "std::alignment_of<max_align_t>::value >= "
54 "std::alignment_of<long double>::value");
55 static_assert(std::alignment_of<max_align_t>::value >=
56 std::alignment_of<void*>::value,
57 "std::alignment_of<max_align_t>::value >= "
58 "std::alignment_of<void*>::value");
59 }
60