joerg updated this revision to Diff 246524.
joerg added a comment.
Do not depend on max_align_t in C++03 mode in the test cases.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73245/new/
https://reviews.llvm.org/D73245
Files:
libcxx/include/cstddef
libcxx/include/new
libcxx/include/stddef.h
libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp
libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp
libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp
libcxx/test/std/depr/depr.c.headers/stddef_h.pass.cpp
libcxx/test/std/language.support/support.types/max_align_t.pass.cpp
libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
Index: libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
===================================================================
--- libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
+++ libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp
@@ -260,9 +260,11 @@
#endif
static_assert(std::is_trivial<T1>::value, "");
static_assert(std::is_standard_layout<T1>::value, "");
+#if TEST_STD_VER >= 11
static_assert(std::alignment_of<T1>::value == TEST_ALIGNOF(std::max_align_t),
"");
static_assert(sizeof(T1) == 16, "");
+#endif
}
{
typedef std::aligned_storage<17>::type T1;
@@ -271,9 +273,11 @@
#endif
static_assert(std::is_trivial<T1>::value, "");
static_assert(std::is_standard_layout<T1>::value, "");
+#if TEST_STD_VER >= 11
static_assert(std::alignment_of<T1>::value == TEST_ALIGNOF(std::max_align_t),
"");
static_assert(sizeof(T1) == 16 + TEST_ALIGNOF(std::max_align_t), "");
+#endif
}
{
typedef std::aligned_storage<10>::type T1;
Index: libcxx/test/std/language.support/support.types/max_align_t.pass.cpp
===================================================================
--- libcxx/test/std/language.support/support.types/max_align_t.pass.cpp
+++ libcxx/test/std/language.support/support.types/max_align_t.pass.cpp
@@ -18,6 +18,7 @@
int main(int, char**)
{
+#if TEST_STD_VER >= 11
#if TEST_STD_VER > 17
// P0767
static_assert(std::is_trivial<std::max_align_t>::value,
@@ -40,6 +41,7 @@
std::alignment_of<void*>::value,
"std::alignment_of<std::max_align_t>::value >= "
"std::alignment_of<void*>::value");
+#endif
return 0;
}
Index: libcxx/test/std/depr/depr.c.headers/stddef_h.pass.cpp
===================================================================
--- libcxx/test/std/depr/depr.c.headers/stddef_h.pass.cpp
+++ libcxx/test/std/depr/depr.c.headers/stddef_h.pass.cpp
@@ -49,10 +49,11 @@
"std::is_trivial<max_align_t>::value");
static_assert(std::is_standard_layout<max_align_t>::value,
"std::is_standard_layout<max_align_t>::value");
-#else
+#elif TEST_STD_VER >= 11
static_assert(std::is_pod<max_align_t>::value,
"std::is_pod<max_align_t>::value");
#endif
+#if TEST_STD_VER >= 11
static_assert((std::alignment_of<max_align_t>::value >=
std::alignment_of<long long>::value),
"std::alignment_of<max_align_t>::value >= "
@@ -65,6 +66,7 @@
std::alignment_of<void*>::value,
"std::alignment_of<max_align_t>::value >= "
"std::alignment_of<void*>::value");
+#endif
return 0;
}
Index: libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp
===================================================================
--- libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp
+++ libcxx/test/std/containers/sequences/array/size_and_alignment.pass.cpp
@@ -49,6 +49,7 @@
test<T, 0>();
}
+#if TEST_STD_VER >= 11
struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType1 {
};
@@ -56,6 +57,7 @@
struct TEST_ALIGNAS(TEST_ALIGNOF(std::max_align_t) * 2) TestType2 {
char data[1000];
};
+#endif
//static_assert(sizeof(void*) == 4, "");
@@ -64,9 +66,11 @@
test_type<int>();
test_type<double>();
test_type<long double>();
+#if TEST_STD_VER >= 11
test_type<std::max_align_t>();
test_type<TestType1>();
test_type<TestType2>();
+#endif
return 0;
}
Index: libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp
===================================================================
--- libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp
+++ libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp
@@ -49,6 +49,7 @@
const T* p = c.data();
LIBCPP_ASSERT(p != nullptr);
}
+#if TEST_STD_VER >= 11
{
typedef std::max_align_t T;
typedef std::array<T, 0> C;
@@ -58,6 +59,7 @@
std::uintptr_t pint = reinterpret_cast<std::uintptr_t>(p);
assert(pint % TEST_ALIGNOF(std::max_align_t) == 0);
}
+#endif
#if TEST_STD_VER > 14
{
typedef std::array<int, 5> C;
Index: libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp
===================================================================
--- libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp
+++ libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp
@@ -51,7 +51,8 @@
static_assert((std::is_same<decltype(c.data()), const T*>::value), "");
LIBCPP_ASSERT(p != nullptr);
}
- {
+#if TEST_STD_VER >= 11
+ {
typedef std::max_align_t T;
typedef std::array<T, 0> C;
const C c = {};
@@ -60,6 +61,7 @@
std::uintptr_t pint = reinterpret_cast<std::uintptr_t>(p);
assert(pint % TEST_ALIGNOF(std::max_align_t) == 0);
}
+#endif
{
typedef NoDefault T;
typedef std::array<T, 0> C;
Index: libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
===================================================================
--- libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
+++ libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
@@ -141,7 +141,9 @@
void test_libcpp_dealloc() {
void* p = nullptr;
+#if TEST_STD_VER >= 11
size_t over_align_val = TEST_ALIGNOF(std::max_align_t) * 2;
+#endif
size_t under_align_val = TEST_ALIGNOF(int);
size_t with_size_val = 2;
@@ -151,6 +153,7 @@
}
stats.reset();
+#if TEST_STD_VER >= 11
#if defined(NO_SIZE) && defined(NO_ALIGN)
{
std::__libcpp_deallocate(p, with_size_val, over_align_val);
@@ -186,6 +189,7 @@
}
stats.reset();
#endif
+#endif
}
struct TEST_ALIGNAS(128) AlignedType {
Index: libcxx/include/stddef.h
===================================================================
--- libcxx/include/stddef.h
+++ libcxx/include/stddef.h
@@ -51,12 +51,6 @@
using std::nullptr_t;
}
-// Re-use the compiler's <stddef.h> max_align_t where possible.
-#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \
- !defined(__DEFINED_max_align_t) && !defined(__NetBSD__)
-typedef long double max_align_t;
-#endif
-
#endif
#endif // _LIBCPP_STDDEF_H
Index: libcxx/include/new
===================================================================
--- libcxx/include/new
+++ libcxx/include/new
@@ -226,9 +226,19 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#if defined(_LIBCPP_CXX03_LANG)
+union __libcpp_max_align_t {
+ void * __f1;
+ long long int __f2;
+ long double __f3;
+};
+#endif
+
_LIBCPP_CONSTEXPR inline _LIBCPP_INLINE_VISIBILITY bool __is_overaligned_for_new(size_t __align) _NOEXCEPT {
#ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__;
+#elif defined(_LIBCPP_CXX03_LANG)
+ return __align > alignment_of<__libcpp_max_align_t>::value;
#else
return __align > alignment_of<max_align_t>::value;
#endif
Index: libcxx/include/cstddef
===================================================================
--- libcxx/include/cstddef
+++ libcxx/include/cstddef
@@ -25,7 +25,7 @@
ptrdiff_t
size_t
- max_align_t
+ max_align_t // C++11
nullptr_t
byte // C++17
@@ -49,12 +49,8 @@
using ::ptrdiff_t;
using ::size_t;
-#if defined(__CLANG_MAX_ALIGN_T_DEFINED) || defined(_GCC_MAX_ALIGN_T) || \
- defined(__DEFINED_max_align_t) || defined(__NetBSD__)
-// Re-use the compiler's <stddef.h> max_align_t where possible.
+#if !defined(_LIBCPP_CXX03_LANG)
using ::max_align_t;
-#else
-typedef long double max_align_t;
#endif
template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; };
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits