[libcxx-commits] [libcxx] 15bf66d - [libc++] Tidy-up instances of __STDCPP_DEFAULT_NEW_ALIGNMENT__ in the tests

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 19 16:37:20 PDT 2021


Author: Louis Dionne
Date: 2021-07-19T19:37:07-04:00
New Revision: 15bf66d2f831338eef997ba1d1b6841d915bbe14

URL: https://github.com/llvm/llvm-project/commit/15bf66d2f831338eef997ba1d1b6841d915bbe14
DIFF: https://github.com/llvm/llvm-project/commit/15bf66d2f831338eef997ba1d1b6841d915bbe14.diff

LOG: [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

Added: 
    libcxx/test/std/language.support/support.types/max_align_t.compile.pass.cpp

Modified: 
    libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp

Removed: 
    libcxx/test/std/language.support/support.types/max_align_t.pass.cpp


################################################################################
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
index 11eac5cc825bb..82d0909f30219 100644
--- 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 @@ 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;
 }

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
index 0000000000000..aef00bbc0ddac
--- /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 <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

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
index 35adbbbd59409..0000000000000
--- 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 <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;
-}


        


More information about the libcxx-commits mailing list