diff --git a/libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp b/libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp --- a/libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp +++ b/libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp @@ -43,20 +43,16 @@ test(); } -#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 @@ #if TEST_STD_VER >= 11 test_type(); -#endif test_type(); test_type(); + test_type(); +#endif return 0; } diff --git a/libcxx/test/std/language.support/support.types/max_align_t.compile.pass.cpp b/libcxx/test/std/language.support/support.types/max_align_t.compile.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/language.support/support.types/max_align_t.compile.pass.cpp @@ -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 +#include + +// 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::value, ""); +static_assert(std::is_standard_layout::value, ""); +#if TEST_STD_VER <= 17 +static_assert(std::is_pod::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 diff --git a/libcxx/test/std/language.support/support.types/max_align_t.pass.cpp b/libcxx/test/std/language.support/support.types/max_align_t.pass.cpp deleted file mode 100644 --- a/libcxx/test/std/language.support/support.types/max_align_t.pass.cpp +++ /dev/null @@ -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 -#include - -// max_align_t is a trivial standard-layout type whose alignment requirement -// is at least as great as that of every scalar type - -#include -#include "test_macros.h" - -int main(int, char**) -{ - -#if TEST_STD_VER > 17 -// P0767 - static_assert(std::is_trivial::value, - "std::is_trivial::value"); - static_assert(std::is_standard_layout::value, - "std::is_standard_layout::value"); -#else - static_assert(std::is_pod::value, - "std::is_pod::value"); -#endif - static_assert((std::alignment_of::value >= - std::alignment_of::value), - "std::alignment_of::value >= " - "std::alignment_of::value"); - static_assert(std::alignment_of::value >= - std::alignment_of::value, - "std::alignment_of::value >= " - "std::alignment_of::value"); - static_assert(std::alignment_of::value >= - std::alignment_of::value, - "std::alignment_of::value >= " - "std::alignment_of::value"); - -#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__ - static_assert(std::alignment_of::value <= - __STDCPP_DEFAULT_NEW_ALIGNMENT__, - "max_align_t alignment is no larger than new alignment"); -#endif - - return 0; -}