brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 9e44c4c Raw
57 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// <stddef.h>10 11#include <stddef.h>12 13#include "test_macros.h"14 15void use() {16    // Make sure we can use the following types without including anything else17    (void)sizeof(size_t);18    (void)sizeof(ptrdiff_t);19#if TEST_STD_VER >= 1120    (void)sizeof(nullptr);21    (void)sizeof(nullptr_t);22    (void)sizeof(max_align_t);23#endif24}25 26#ifndef NULL27#error NULL not defined28#endif29 30#ifndef offsetof31#error offsetof not defined32#endif33 34#include <type_traits>35 36static_assert(sizeof(size_t) == sizeof(void*), "");37static_assert(std::is_unsigned<size_t>::value, "");38static_assert(std::is_integral<size_t>::value, "");39static_assert(sizeof(ptrdiff_t) == sizeof(void*), "");40static_assert(std::is_signed<ptrdiff_t>::value, "");41static_assert(std::is_integral<ptrdiff_t>::value, "");42static_assert((std::is_same<decltype(nullptr), nullptr_t>::value), "");43static_assert(sizeof(nullptr_t) == sizeof(void*), "");44#if TEST_STD_VER >= 1145#  if TEST_STD_VER >= 2046// P0767R1 and P3247R247static_assert(std::is_trivially_copyable<max_align_t>::value, "");48static_assert(std::is_trivially_default_constructible<max_align_t>::value, "");49static_assert(std::is_standard_layout<max_align_t>::value, "");50#  else51static_assert(std::is_pod<max_align_t>::value, "");52#  endif53static_assert(std::alignment_of<max_align_t>::value >= std::alignment_of<long long>::value, "");54static_assert(std::alignment_of<max_align_t>::value >= std::alignment_of<long double>::value, "");55static_assert(std::alignment_of<max_align_t>::value >= std::alignment_of<void*>::value, "");56#endif // TEST_STD_VER >= 1157