diff --git a/libcxx/include/version b/libcxx/include/version --- a/libcxx/include/version +++ b/libcxx/include/version @@ -252,7 +252,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) +# 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 +# else +# ifdef __cpp_lib_constexpr_dynamic_alloc +# error "__cpp_lib_constexpr_dynamic_alloc should not be defined when defined(__cpp_constexpr_dynamic_alloc) is not defined!" +# 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 @@ -1890,11 +1890,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) +# 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 +# else +# ifdef __cpp_lib_constexpr_dynamic_alloc +# error "__cpp_lib_constexpr_dynamic_alloc should not be defined when defined(__cpp_constexpr_dynamic_alloc) is not defined!" +# 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 @@ -18,6 +18,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, clang-10 + #include #include #include @@ -86,7 +90,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 @@ -172,7 +172,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 @@ -20,6 +20,9 @@ // ... // }; +// constexpr destructors are only supported starting with clang 10 +// UNSUPPORTED: clang-5, clang-6, clang-7, clang-8, clang-9 + #include #include #include @@ -131,7 +134,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 @@ -80,7 +80,7 @@ } } -#if TEST_STD_VER > 17 +#if defined(__cpp_constexpr_dynamic_alloc) template constexpr bool test_aligned_constexpr() { typedef AlignedType T; @@ -102,7 +102,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>()); diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -481,6 +481,8 @@ "internal_depends": "!defined(_LIBCPP_HAS_NO_THREADS)", }, { "name": "__cpp_lib_constexpr_dynamic_alloc", + "depends": "defined(__cpp_constexpr_dynamic_alloc)", + "internal_depends": "defined(__cpp_constexpr_dynamic_alloc)", "values": { "c++2a": int(201907) }, "headers": ["memory"] },