Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | 5b08a8a | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | 412dbeb | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <stddef.h> |
| 11 | |
| 12 | #include <stddef.h> |
Richard Smith | d6cffc4 | 2015-10-08 22:25:27 +0000 | [diff] [blame] | 13 | #include <cassert> |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 14 | #include <type_traits> |
| 15 | |
Marshall Clow | a9daa96 | 2018-03-06 15:01:55 +0000 | [diff] [blame] | 16 | #include "test_macros.h" |
| 17 | |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 18 | #ifndef NULL |
| 19 | #error NULL not defined |
| 20 | #endif |
| 21 | |
| 22 | #ifndef offsetof |
| 23 | #error offsetof not defined |
| 24 | #endif |
| 25 | |
| 26 | int main() |
| 27 | { |
Richard Smith | d6cffc4 | 2015-10-08 22:25:27 +0000 | [diff] [blame] | 28 | void *p = NULL; |
| 29 | assert(!p); |
| 30 | |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 31 | static_assert(sizeof(size_t) == sizeof(void*), |
| 32 | "sizeof(size_t) == sizeof(void*)"); |
| 33 | static_assert(std::is_unsigned<size_t>::value, |
| 34 | "std::is_unsigned<size_t>::value"); |
| 35 | static_assert(std::is_integral<size_t>::value, |
| 36 | "std::is_integral<size_t>::value"); |
| 37 | static_assert(sizeof(ptrdiff_t) == sizeof(void*), |
| 38 | "sizeof(ptrdiff_t) == sizeof(void*)"); |
| 39 | static_assert(std::is_signed<ptrdiff_t>::value, |
| 40 | "std::is_signed<ptrdiff_t>::value"); |
| 41 | static_assert(std::is_integral<ptrdiff_t>::value, |
| 42 | "std::is_integral<ptrdiff_t>::value"); |
Richard Smith | 55a7a24 | 2015-10-08 23:44:26 +0000 | [diff] [blame] | 43 | static_assert((std::is_same<decltype(nullptr), nullptr_t>::value), |
Richard Smith | d6cffc4 | 2015-10-08 22:25:27 +0000 | [diff] [blame] | 44 | "decltype(nullptr) == nullptr_t"); |
| 45 | static_assert(sizeof(nullptr_t) == sizeof(void*), |
| 46 | "sizeof(nullptr_t) == sizeof(void*)"); |
Marshall Clow | a9daa96 | 2018-03-06 15:01:55 +0000 | [diff] [blame] | 47 | #if TEST_STD_VER > 17 |
| 48 | // P0767 |
| 49 | static_assert(std::is_trivial<max_align_t>::value, |
| 50 | "std::is_trivial<max_align_t>::value"); |
Marshall Clow | 4a6f3c4 | 2018-03-21 00:36:05 +0000 | [diff] [blame] | 51 | static_assert(std::is_standard_layout<max_align_t>::value, |
| 52 | "std::is_standard_layout<max_align_t>::value"); |
Marshall Clow | a9daa96 | 2018-03-06 15:01:55 +0000 | [diff] [blame] | 53 | #else |
Richard Smith | d6cffc4 | 2015-10-08 22:25:27 +0000 | [diff] [blame] | 54 | static_assert(std::is_pod<max_align_t>::value, |
| 55 | "std::is_pod<max_align_t>::value"); |
Marshall Clow | a9daa96 | 2018-03-06 15:01:55 +0000 | [diff] [blame] | 56 | #endif |
Richard Smith | d6cffc4 | 2015-10-08 22:25:27 +0000 | [diff] [blame] | 57 | static_assert((std::alignment_of<max_align_t>::value >= |
| 58 | std::alignment_of<long long>::value), |
| 59 | "std::alignment_of<max_align_t>::value >= " |
| 60 | "std::alignment_of<long long>::value"); |
| 61 | static_assert(std::alignment_of<max_align_t>::value >= |
| 62 | std::alignment_of<long double>::value, |
| 63 | "std::alignment_of<max_align_t>::value >= " |
| 64 | "std::alignment_of<long double>::value"); |
| 65 | static_assert(std::alignment_of<max_align_t>::value >= |
| 66 | std::alignment_of<void*>::value, |
| 67 | "std::alignment_of<max_align_t>::value >= " |
| 68 | "std::alignment_of<void*>::value"); |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 69 | } |