forked from OSchip/llvm-project
[libc++] Tidy-up instances of __STDCPP_DEFAULT_NEW_ALIGNMENT__ in the tests
See https://reviews.llvm.org/D105905 for context. Differential Revision: https://reviews.llvm.org/D106182
This commit is contained in:
parent
d153e7d0a5
commit
15bf66d2f8
|
@ -43,20 +43,16 @@ void test_type() {
|
|||
test<T, 0>();
|
||||
}
|
||||
|
||||
#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
|
||||
struct TEST_ALIGNAS(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2) TestType1 {
|
||||
#if TEST_STD_VER >= 11
|
||||
struct alignas(alignof(std::max_align_t) * 2) TestType1 {
|
||||
|
||||
};
|
||||
|
||||
struct TEST_ALIGNAS(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2) TestType2 {
|
||||
struct alignas(alignof(std::max_align_t) * 2) TestType2 {
|
||||
char data[1000];
|
||||
};
|
||||
#else
|
||||
struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType1 {
|
||||
|
||||
};
|
||||
|
||||
struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType2 {
|
||||
struct alignas(alignof(std::max_align_t)) TestType3 {
|
||||
char data[1000];
|
||||
};
|
||||
#endif
|
||||
|
@ -69,9 +65,10 @@ int main(int, char**) {
|
|||
|
||||
#if TEST_STD_VER >= 11
|
||||
test_type<std::max_align_t>();
|
||||
#endif
|
||||
test_type<TestType1>();
|
||||
test_type<TestType2>();
|
||||
test_type<TestType3>();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
// max_align_t is a trivial standard-layout type whose alignment requirement
|
||||
// is at least as great as that of every scalar type
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
static_assert(std::is_trivial<std::max_align_t>::value, "");
|
||||
static_assert(std::is_standard_layout<std::max_align_t>::value, "");
|
||||
#if TEST_STD_VER <= 17
|
||||
static_assert(std::is_pod<std::max_align_t>::value, "");
|
||||
#endif
|
||||
static_assert(alignof(std::max_align_t) >= alignof(long long), "");
|
||||
static_assert(alignof(std::max_align_t) >= alignof(long double), "");
|
||||
static_assert(alignof(std::max_align_t) >= alignof(void*), "");
|
||||
#if TEST_STD_VER > 14
|
||||
static_assert(alignof(std::max_align_t) <= __STDCPP_DEFAULT_NEW_ALIGNMENT__,
|
||||
"max_align_t alignment should be no larger than operator new's alignment");
|
||||
#endif
|
|
@ -1,53 +0,0 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
// max_align_t is a trivial standard-layout type whose alignment requirement
|
||||
// is at least as great as that of every scalar type
|
||||
|
||||
#include <stdio.h>
|
||||
#include "test_macros.h"
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
|
||||
#if TEST_STD_VER > 17
|
||||
// P0767
|
||||
static_assert(std::is_trivial<std::max_align_t>::value,
|
||||
"std::is_trivial<std::max_align_t>::value");
|
||||
static_assert(std::is_standard_layout<std::max_align_t>::value,
|
||||
"std::is_standard_layout<std::max_align_t>::value");
|
||||
#else
|
||||
static_assert(std::is_pod<std::max_align_t>::value,
|
||||
"std::is_pod<std::max_align_t>::value");
|
||||
#endif
|
||||
static_assert((std::alignment_of<std::max_align_t>::value >=
|
||||
std::alignment_of<long long>::value),
|
||||
"std::alignment_of<std::max_align_t>::value >= "
|
||||
"std::alignment_of<long long>::value");
|
||||
static_assert(std::alignment_of<std::max_align_t>::value >=
|
||||
std::alignment_of<long double>::value,
|
||||
"std::alignment_of<std::max_align_t>::value >= "
|
||||
"std::alignment_of<long double>::value");
|
||||
static_assert(std::alignment_of<std::max_align_t>::value >=
|
||||
std::alignment_of<void*>::value,
|
||||
"std::alignment_of<std::max_align_t>::value >= "
|
||||
"std::alignment_of<void*>::value");
|
||||
|
||||
#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
|
||||
static_assert(std::alignment_of<std::max_align_t>::value <=
|
||||
__STDCPP_DEFAULT_NEW_ALIGNMENT__,
|
||||
"max_align_t alignment is no larger than new alignment");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue