diff --git a/libcxx/include/version b/libcxx/include/version --- a/libcxx/include/version +++ b/libcxx/include/version @@ -251,7 +251,9 @@ # define __cpp_lib_char8_t 201811L # endif // # define __cpp_lib_concepts 201806L -# define __cpp_lib_constexpr_dynamic_alloc 201907L +# if defined(__cpp_constexpr_dynamic_alloc) +# define __cpp_lib_constexpr_dynamic_alloc 201907L +# endif // # define __cpp_lib_constexpr_misc 201811L // # define __cpp_lib_constexpr_swap_algorithms 201806L # define __cpp_lib_constexpr_utility 201811L diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp --- a/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/memory.version.pass.cpp @@ -226,11 +226,17 @@ # endif # endif -# ifndef __cpp_lib_constexpr_dynamic_alloc -# error "__cpp_lib_constexpr_dynamic_alloc should be defined in c++2a" -# endif -# if __cpp_lib_constexpr_dynamic_alloc != 201907L -# error "__cpp_lib_constexpr_dynamic_alloc should have the value 201907L in c++2a" +# if !defined(__cpp_constexpr_dynamic_alloc) +# ifdef __cpp_lib_constexpr_dynamic_alloc +# error "__cpp_lib_constexpr_dynamic_alloc should be not be defined without compiler support" +# endif +# else +# ifndef __cpp_lib_constexpr_dynamic_alloc +# error "__cpp_lib_constexpr_dynamic_alloc should be defined in c++2a" +# endif +# if __cpp_lib_constexpr_dynamic_alloc != 201907L +# error "__cpp_lib_constexpr_dynamic_alloc should have the value 201907L in c++2a" +# endif # endif # ifndef __cpp_lib_enable_shared_from_this diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.pass.cpp @@ -1877,11 +1877,13 @@ # endif # endif -# ifndef __cpp_lib_constexpr_dynamic_alloc -# error "__cpp_lib_constexpr_dynamic_alloc should be defined in c++2a" -# endif -# if __cpp_lib_constexpr_dynamic_alloc != 201907L -# error "__cpp_lib_constexpr_dynamic_alloc should have the value 201907L in c++2a" +# if TEST_STD_VER > 17 && defined(__cpp_constexpr_dynamic_alloc) +# ifndef __cpp_lib_constexpr_dynamic_alloc +# error "__cpp_lib_constexpr_dynamic_alloc should be defined in c++2a" +# endif +# if __cpp_lib_constexpr_dynamic_alloc != 201907L +# error "__cpp_lib_constexpr_dynamic_alloc should have the value 201907L in c++2a" +# endif # endif # if !defined(_LIBCPP_VERSION) diff --git a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp --- a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp +++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp @@ -15,6 +15,10 @@ // ... // }; +// constexpr bool test() results in "error: constexpr function never produces a +// constant expression" before clang 11 +// UNSUPPORTED: clang-5, clang-6, clang-7, clang-8, clang-9 + #include #include #include @@ -83,7 +87,7 @@ int main(int, char**) { test(); -#if TEST_STD_VER > 17 +#if defined(__cpp_constexpr_dynamic_alloc) static_assert(test()); #endif return 0; diff --git a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp --- a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp +++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp @@ -169,7 +169,7 @@ { test(); -#if TEST_STD_VER > 17 +#if defined(__cpp_constexpr_dynamic_alloc) static_assert(test()); #endif diff --git a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp --- a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp +++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp @@ -16,6 +16,9 @@ // ... // }; +// constexpr destructors are only supported starting with clang 10 +// UNSUPPORTED: clang-5, clang-6, clang-7, clang-8, clang-9 + #include #include #include @@ -127,7 +130,7 @@ int main(int, char**) { test(); -#if TEST_STD_VER > 17 +#if defined(__cpp_constexpr_dynamic_alloc) static_assert(test()); #endif return 0; diff --git a/libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp b/libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp --- a/libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp +++ b/libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp @@ -77,7 +77,7 @@ } } -#if TEST_STD_VER > 17 +#if defined(__cpp_constexpr_dynamic_alloc) template constexpr bool test_aligned_constexpr() { typedef AlignedType T; @@ -99,7 +99,7 @@ test_aligned(); test_aligned(); -#if TEST_STD_VER > 17 +#if defined(__cpp_constexpr_dynamic_alloc) static_assert(test_aligned_constexpr<1>()); static_assert(test_aligned_constexpr<2>()); static_assert(test_aligned_constexpr<4>());