diff --git a/libcxx/include/__availability b/libcxx/include/__availability --- a/libcxx/include/__availability +++ b/libcxx/include/__availability @@ -169,6 +169,11 @@ // # define _LIBCPP_AVAILABILITY_HAS_NO_VERBOSE_ABORT # define _LIBCPP_AVAILABILITY_VERBOSE_ABORT + // This controls the availability of the C++17 std::pmr library, + // which is implemented in large part in the built library. +// # define _LIBCPP_AVAILABILITY_HAS_NO_PMR +# define _LIBCPP_AVAILABILITY_PMR + #elif defined(__APPLE__) // shared_mutex and shared_timed_mutex @@ -322,6 +327,13 @@ # define _LIBCPP_AVAILABILITY_VERBOSE_ABORT \ __attribute__((unavailable)) + // std::pmr +# if 1 // TODO: Update once this is released +# define _LIBCPP_AVAILABILITY_HAS_NO_PMR +# endif +# define _LIBCPP_AVAILABILITY_PMR \ + __attribute__((unavailable)) + #else // ...New vendors can add availability markup here... diff --git a/libcxx/include/__fwd/memory_resource.h b/libcxx/include/__fwd/memory_resource.h --- a/libcxx/include/__fwd/memory_resource.h +++ b/libcxx/include/__fwd/memory_resource.h @@ -9,6 +9,7 @@ #ifndef _LIBCPP___FWD_MEMORY_RESOURCE_H #define _LIBCPP___FWD_MEMORY_RESOURCE_H +#include <__availability> #include <__config> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -19,7 +20,7 @@ namespace pmr { template -class _LIBCPP_TEMPLATE_VIS polymorphic_allocator; +class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TEMPLATE_VIS polymorphic_allocator; } // namespace pmr _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__fwd/string.h b/libcxx/include/__fwd/string.h --- a/libcxx/include/__fwd/string.h +++ b/libcxx/include/__fwd/string.h @@ -9,6 +9,7 @@ #ifndef _LIBCPP___FWD_STRING_H #define _LIBCPP___FWD_STRING_H +#include <__availability> #include <__config> #include <__fwd/memory_resource.h> @@ -61,21 +62,20 @@ namespace pmr { template > -using basic_string = std::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>; +using basic_string _LIBCPP_AVAILABILITY_PMR = std::basic_string<_CharT, _Traits, polymorphic_allocator<_CharT>>; -using string = basic_string; +using string _LIBCPP_AVAILABILITY_PMR = basic_string; # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -using wstring = basic_string; +using wstring _LIBCPP_AVAILABILITY_PMR = basic_string; # endif # ifndef _LIBCPP_HAS_NO_CHAR8_T -using u8string = basic_string; +using u8string _LIBCPP_AVAILABILITY_PMR = basic_string; # endif -using u16string = basic_string; -using u32string = basic_string; - +using u16string _LIBCPP_AVAILABILITY_PMR = basic_string; +using u32string _LIBCPP_AVAILABILITY_PMR = basic_string; } // namespace pmr #endif // _LIBCPP_STD_VER >= 17 diff --git a/libcxx/include/__memory_resource/memory_resource.h b/libcxx/include/__memory_resource/memory_resource.h --- a/libcxx/include/__memory_resource/memory_resource.h +++ b/libcxx/include/__memory_resource/memory_resource.h @@ -9,6 +9,7 @@ #ifndef _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H #define _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H +#include <__availability> #include <__config> #include @@ -24,7 +25,7 @@ // [mem.res.class] -class _LIBCPP_TYPE_VIS memory_resource { +class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TYPE_VIS memory_resource { static const size_t __max_align = alignof(max_align_t); public: @@ -51,20 +52,26 @@ // [mem.res.eq] -inline _LIBCPP_HIDE_FROM_ABI bool operator==(const memory_resource& __lhs, const memory_resource& __rhs) noexcept { +inline _LIBCPP_AVAILABILITY_PMR _LIBCPP_HIDE_FROM_ABI bool +operator==(const memory_resource& __lhs, const memory_resource& __rhs) noexcept { return &__lhs == &__rhs || __lhs.is_equal(__rhs); } -inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const memory_resource& __lhs, const memory_resource& __rhs) noexcept { +inline _LIBCPP_AVAILABILITY_PMR _LIBCPP_HIDE_FROM_ABI bool +operator!=(const memory_resource& __lhs, const memory_resource& __rhs) noexcept { return !(__lhs == __rhs); } // [mem.res.global] -[[__gnu__::__returns_nonnull__]] _LIBCPP_FUNC_VIS memory_resource* get_default_resource() noexcept; -[[__gnu__::__returns_nonnull__]] _LIBCPP_FUNC_VIS memory_resource* set_default_resource(memory_resource*) noexcept; -[[using __gnu__: __returns_nonnull__, __const__]] _LIBCPP_FUNC_VIS memory_resource* new_delete_resource() noexcept; -[[using __gnu__: __returns_nonnull__, __const__]] _LIBCPP_FUNC_VIS memory_resource* null_memory_resource() noexcept; +[[__gnu__::__returns_nonnull__]] _LIBCPP_AVAILABILITY_PMR _LIBCPP_FUNC_VIS memory_resource* +get_default_resource() noexcept; +[[__gnu__::__returns_nonnull__]] _LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_PMR memory_resource* +set_default_resource(memory_resource*) noexcept; +[[using __gnu__: __returns_nonnull__, __const__]] _LIBCPP_AVAILABILITY_PMR _LIBCPP_FUNC_VIS memory_resource* +new_delete_resource() noexcept; +[[using __gnu__: __returns_nonnull__, __const__]] _LIBCPP_AVAILABILITY_PMR _LIBCPP_FUNC_VIS memory_resource* +null_memory_resource() noexcept; } // namespace pmr diff --git a/libcxx/include/__memory_resource/monotonic_buffer_resource.h b/libcxx/include/__memory_resource/monotonic_buffer_resource.h --- a/libcxx/include/__memory_resource/monotonic_buffer_resource.h +++ b/libcxx/include/__memory_resource/monotonic_buffer_resource.h @@ -9,6 +9,7 @@ #ifndef _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H #define _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H +#include <__availability> #include <__config> #include <__memory/addressof.h> #include <__memory_resource/memory_resource.h> @@ -26,7 +27,7 @@ // [mem.res.monotonic.buffer] -class _LIBCPP_TYPE_VIS monotonic_buffer_resource : public memory_resource { +class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TYPE_VIS monotonic_buffer_resource : public memory_resource { static const size_t __default_buffer_capacity = 1024; static const size_t __default_buffer_alignment = 16; diff --git a/libcxx/include/__memory_resource/polymorphic_allocator.h b/libcxx/include/__memory_resource/polymorphic_allocator.h --- a/libcxx/include/__memory_resource/polymorphic_allocator.h +++ b/libcxx/include/__memory_resource/polymorphic_allocator.h @@ -10,6 +10,7 @@ #define _LIBCPP___MEMORY_RESOURCE_POLYMORPHIC_ALLOCATOR_H #include <__assert> +#include <__availability> #include <__config> #include <__memory_resource/memory_resource.h> #include <__utility/exception_guard.h> @@ -39,7 +40,7 @@ = byte # endif > -class _LIBCPP_TEMPLATE_VIS polymorphic_allocator { +class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TEMPLATE_VIS polymorphic_allocator { public: using value_type = _ValueType; diff --git a/libcxx/include/__memory_resource/synchronized_pool_resource.h b/libcxx/include/__memory_resource/synchronized_pool_resource.h --- a/libcxx/include/__memory_resource/synchronized_pool_resource.h +++ b/libcxx/include/__memory_resource/synchronized_pool_resource.h @@ -9,6 +9,7 @@ #ifndef _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H #define _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H +#include <__availability> #include <__config> #include <__memory_resource/memory_resource.h> #include <__memory_resource/pool_options.h> @@ -30,7 +31,7 @@ // [mem.res.pool.overview] -class _LIBCPP_TYPE_VIS synchronized_pool_resource : public memory_resource { +class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TYPE_VIS synchronized_pool_resource : public memory_resource { public: _LIBCPP_HIDE_FROM_ABI synchronized_pool_resource(const pool_options& __opts, memory_resource* __upstream) : __unsync_(__opts, __upstream) {} diff --git a/libcxx/include/__memory_resource/unsynchronized_pool_resource.h b/libcxx/include/__memory_resource/unsynchronized_pool_resource.h --- a/libcxx/include/__memory_resource/unsynchronized_pool_resource.h +++ b/libcxx/include/__memory_resource/unsynchronized_pool_resource.h @@ -9,6 +9,7 @@ #ifndef _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H #define _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H +#include <__availability> #include <__config> #include <__memory_resource/memory_resource.h> #include <__memory_resource/pool_options.h> @@ -27,7 +28,7 @@ // [mem.res.pool.overview] -class _LIBCPP_TYPE_VIS unsynchronized_pool_resource : public memory_resource { +class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TYPE_VIS unsynchronized_pool_resource : public memory_resource { class __fixed_pool; class __adhoc_pool { diff --git a/libcxx/include/deque b/libcxx/include/deque --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -174,6 +174,7 @@ #include <__algorithm/remove_if.h> #include <__algorithm/unwrap_iter.h> #include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> #include <__config> #include <__format/enable_insertable.h> #include <__iterator/iterator_traits.h> @@ -2445,7 +2446,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template -using deque = std::deque<_ValueT, polymorphic_allocator<_ValueT>>; +using deque _LIBCPP_AVAILABILITY_PMR = std::deque<_ValueT, polymorphic_allocator<_ValueT>>; } // namespace pmr _LIBCPP_END_NAMESPACE_STD #endif diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list --- a/libcxx/include/forward_list +++ b/libcxx/include/forward_list @@ -188,6 +188,7 @@ #include <__algorithm/lexicographical_compare_three_way.h> #include <__algorithm/min.h> #include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> #include <__config> #include <__iterator/distance.h> #include <__iterator/iterator_traits.h> @@ -1817,7 +1818,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template -using forward_list = std::forward_list<_ValueT, polymorphic_allocator<_ValueT>>; +using forward_list _LIBCPP_AVAILABILITY_PMR = std::forward_list<_ValueT, polymorphic_allocator<_ValueT>>; } // namespace pmr _LIBCPP_END_NAMESPACE_STD #endif diff --git a/libcxx/include/list b/libcxx/include/list --- a/libcxx/include/list +++ b/libcxx/include/list @@ -189,6 +189,7 @@ #include <__algorithm/lexicographical_compare_three_way.h> #include <__algorithm/min.h> #include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> #include <__config> #include <__debug> #include <__format/enable_insertable.h> @@ -2393,7 +2394,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template -using list = std::list<_ValueT, polymorphic_allocator<_ValueT>>; +using list _LIBCPP_AVAILABILITY_PMR = std::list<_ValueT, polymorphic_allocator<_ValueT>>; } // namespace pmr _LIBCPP_END_NAMESPACE_STD #endif diff --git a/libcxx/include/map b/libcxx/include/map --- a/libcxx/include/map +++ b/libcxx/include/map @@ -542,6 +542,7 @@ #include <__algorithm/lexicographical_compare.h> #include <__algorithm/lexicographical_compare_three_way.h> #include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> #include <__config> #include <__functional/binary_function.h> #include <__functional/is_transparent.h> @@ -2394,10 +2395,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template > -using map = std::map<_KeyT, _ValueT, _CompareT, polymorphic_allocator>>; +using map _LIBCPP_AVAILABILITY_PMR = std::map<_KeyT, _ValueT, _CompareT, polymorphic_allocator>>; template > -using multimap = std::multimap<_KeyT, _ValueT, _CompareT, polymorphic_allocator>>; +using multimap _LIBCPP_AVAILABILITY_PMR = std::multimap<_KeyT, _ValueT, _CompareT, polymorphic_allocator>>; } // namespace pmr _LIBCPP_END_NAMESPACE_STD #endif diff --git a/libcxx/include/regex b/libcxx/include/regex --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -767,6 +767,7 @@ #include <__algorithm/find.h> #include <__algorithm/search.h> #include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> #include <__config> #include <__iterator/back_insert_iterator.h> #include <__iterator/wrap_iter.h> @@ -6861,14 +6862,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template -using match_results = std::match_results<_BidirT, polymorphic_allocator>>; +using match_results _LIBCPP_AVAILABILITY_PMR = std::match_results<_BidirT, polymorphic_allocator>>; -using cmatch = match_results; -using smatch = match_results; +using cmatch _LIBCPP_AVAILABILITY_PMR = match_results; +using smatch _LIBCPP_AVAILABILITY_PMR = match_results; #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -using wcmatch = match_results; -using wsmatch = match_results; +using wcmatch _LIBCPP_AVAILABILITY_PMR = match_results; +using wsmatch _LIBCPP_AVAILABILITY_PMR = match_results; #endif } // namespace pmr _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/set b/libcxx/include/set --- a/libcxx/include/set +++ b/libcxx/include/set @@ -474,6 +474,7 @@ #include <__algorithm/equal.h> #include <__algorithm/lexicographical_compare.h> #include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> #include <__config> #include <__functional/is_transparent.h> #include <__functional/operations.h> @@ -1588,10 +1589,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template > -using set = std::set<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>; +using set _LIBCPP_AVAILABILITY_PMR = std::set<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>; template > -using multiset = std::multiset<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>; +using multiset _LIBCPP_AVAILABILITY_PMR = std::multiset<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>; } // namespace pmr _LIBCPP_END_NAMESPACE_STD #endif diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map --- a/libcxx/include/unordered_map +++ b/libcxx/include/unordered_map @@ -516,6 +516,7 @@ #include <__algorithm/is_permutation.h> #include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> #include <__config> #include <__debug> #include <__functional/is_transparent.h> @@ -2633,11 +2634,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template , class _PredT = std::equal_to<_KeyT>> -using unordered_map = +using unordered_map _LIBCPP_AVAILABILITY_PMR = std::unordered_map<_KeyT, _ValueT, _HashT, _PredT, polymorphic_allocator>>; template , class _PredT = std::equal_to<_KeyT>> -using unordered_multimap = +using unordered_multimap _LIBCPP_AVAILABILITY_PMR = std::unordered_multimap<_KeyT, _ValueT, _HashT, _PredT, polymorphic_allocator>>; } // namespace pmr _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set --- a/libcxx/include/unordered_set +++ b/libcxx/include/unordered_set @@ -461,6 +461,7 @@ #include <__algorithm/is_permutation.h> #include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> #include <__config> #include <__debug> #include <__functional/is_transparent.h> @@ -1807,10 +1808,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template , class _PredT = std::equal_to<_KeyT>> -using unordered_set = std::unordered_set<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>; +using unordered_set _LIBCPP_AVAILABILITY_PMR = std::unordered_set<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>; template , class _PredT = std::equal_to<_KeyT>> -using unordered_multiset = std::unordered_multiset<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>; +using unordered_multiset _LIBCPP_AVAILABILITY_PMR = std::unordered_multiset<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>; } // namespace pmr _LIBCPP_END_NAMESPACE_STD #endif diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -287,6 +287,7 @@ #include <__algorithm/rotate.h> #include <__algorithm/unwrap_iter.h> #include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> #include <__bit_reference> #include <__concepts/same_as.h> #include <__config> @@ -3350,7 +3351,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace pmr { template -using vector = std::vector<_ValueT, polymorphic_allocator<_ValueT>>; +using vector _LIBCPP_AVAILABILITY_PMR = std::vector<_ValueT, polymorphic_allocator<_ValueT>>; } // namespace pmr _LIBCPP_END_NAMESPACE_STD #endif diff --git a/libcxx/include/version b/libcxx/include/version --- a/libcxx/include/version +++ b/libcxx/include/version @@ -271,7 +271,9 @@ # define __cpp_lib_make_from_tuple 201606L # define __cpp_lib_map_try_emplace 201411L // # define __cpp_lib_math_special_functions 201603L -# define __cpp_lib_memory_resource 201603L +# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR) +# define __cpp_lib_memory_resource 201603L +# endif # define __cpp_lib_node_extract 201606L # define __cpp_lib_nonmember_container_access 201411L # define __cpp_lib_not_fn 201603L @@ -360,7 +362,9 @@ # define __cpp_lib_list_remove_return_type 201806L # define __cpp_lib_math_constants 201907L # define __cpp_lib_move_iterator_concept 202207L -# define __cpp_lib_polymorphic_allocator 201902L +# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR) +# define __cpp_lib_polymorphic_allocator 201902L +# endif # define __cpp_lib_ranges 202106L # define __cpp_lib_remove_cvref 201711L # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_HAS_NO_SYNC) diff --git a/libcxx/test/libcxx/utilities/utility/mem.res/pmr.availability.verify.cpp b/libcxx/test/libcxx/utilities/utility/mem.res/pmr.availability.verify.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/utilities/utility/mem.res/pmr.availability.verify.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++11 +// REQUIRES: availability-pmr-missing + +// Test the availability markup on std::pmr components. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void f() { + [[maybe_unused]] std::pmr::match_results m1; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::cmatch m2; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::wcmatch m3; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::smatch m4; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::wsmatch m5; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::deque m6; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::forward_list m7; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::list m8; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::map m9; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::multimap m10; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::set m11; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::multiset m12; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::string m13; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::wstring m14; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::u8string m15; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::u16string m16; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::u32string m17; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::basic_string m18; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::unordered_map m19; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::unordered_multimap m20; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::unordered_set m21; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::unordered_multiset m22; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::vector m23; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::polymorphic_allocator poly; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::memory_resource* res = nullptr; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::synchronized_pool_resource r1; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::monotonic_buffer_resource r2; // expected-error {{is unavailable}} + [[maybe_unused]] std::pmr::unsynchronized_pool_resource r3; // expected-error {{is unavailable}} + (void)std::pmr::get_default_resource(); // expected-error {{is unavailable}} + (void)std::pmr::set_default_resource(nullptr); // expected-error {{is unavailable}} + (void)std::pmr::new_delete_resource(); // expected-error {{is unavailable}} + (void)std::pmr::null_memory_resource(); // expected-error {{is unavailable}} + (void)(*res == *res); // expected-error {{is unavailable}} +} diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/memory_resource.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/memory_resource.version.compile.pass.cpp --- a/libcxx/test/std/language.support/support.limits/support.limits.general/memory_resource.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/memory_resource.version.compile.pass.cpp @@ -45,11 +45,17 @@ #elif TEST_STD_VER == 17 -# ifndef __cpp_lib_memory_resource -# error "__cpp_lib_memory_resource should be defined in c++17" -# endif -# if __cpp_lib_memory_resource != 201603L -# error "__cpp_lib_memory_resource should have the value 201603L in c++17" +# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR) +# ifndef __cpp_lib_memory_resource +# error "__cpp_lib_memory_resource should be defined in c++17" +# endif +# if __cpp_lib_memory_resource != 201603L +# error "__cpp_lib_memory_resource should have the value 201603L in c++17" +# endif +# else +# ifdef __cpp_lib_memory_resource +# error "__cpp_lib_memory_resource should not be defined when the requirement '!defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR)' is not met!" +# endif # endif # ifdef __cpp_lib_polymorphic_allocator @@ -58,34 +64,58 @@ #elif TEST_STD_VER == 20 -# ifndef __cpp_lib_memory_resource -# error "__cpp_lib_memory_resource should be defined in c++20" -# endif -# if __cpp_lib_memory_resource != 201603L -# error "__cpp_lib_memory_resource should have the value 201603L in c++20" +# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR) +# ifndef __cpp_lib_memory_resource +# error "__cpp_lib_memory_resource should be defined in c++20" +# endif +# if __cpp_lib_memory_resource != 201603L +# error "__cpp_lib_memory_resource should have the value 201603L in c++20" +# endif +# else +# ifdef __cpp_lib_memory_resource +# error "__cpp_lib_memory_resource should not be defined when the requirement '!defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR)' is not met!" +# endif # endif -# ifndef __cpp_lib_polymorphic_allocator -# error "__cpp_lib_polymorphic_allocator should be defined in c++20" -# endif -# if __cpp_lib_polymorphic_allocator != 201902L -# error "__cpp_lib_polymorphic_allocator should have the value 201902L in c++20" +# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR) +# ifndef __cpp_lib_polymorphic_allocator +# error "__cpp_lib_polymorphic_allocator should be defined in c++20" +# endif +# if __cpp_lib_polymorphic_allocator != 201902L +# error "__cpp_lib_polymorphic_allocator should have the value 201902L in c++20" +# endif +# else +# ifdef __cpp_lib_polymorphic_allocator +# error "__cpp_lib_polymorphic_allocator should not be defined when the requirement '!defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR)' is not met!" +# endif # endif #elif TEST_STD_VER > 20 -# ifndef __cpp_lib_memory_resource -# error "__cpp_lib_memory_resource should be defined in c++2b" -# endif -# if __cpp_lib_memory_resource != 201603L -# error "__cpp_lib_memory_resource should have the value 201603L in c++2b" +# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR) +# ifndef __cpp_lib_memory_resource +# error "__cpp_lib_memory_resource should be defined in c++2b" +# endif +# if __cpp_lib_memory_resource != 201603L +# error "__cpp_lib_memory_resource should have the value 201603L in c++2b" +# endif +# else +# ifdef __cpp_lib_memory_resource +# error "__cpp_lib_memory_resource should not be defined when the requirement '!defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR)' is not met!" +# endif # endif -# ifndef __cpp_lib_polymorphic_allocator -# error "__cpp_lib_polymorphic_allocator should be defined in c++2b" -# endif -# if __cpp_lib_polymorphic_allocator != 201902L -# error "__cpp_lib_polymorphic_allocator should have the value 201902L in c++2b" +# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR) +# ifndef __cpp_lib_polymorphic_allocator +# error "__cpp_lib_polymorphic_allocator should be defined in c++2b" +# endif +# if __cpp_lib_polymorphic_allocator != 201902L +# error "__cpp_lib_polymorphic_allocator should have the value 201902L in c++2b" +# endif +# else +# ifdef __cpp_lib_polymorphic_allocator +# error "__cpp_lib_polymorphic_allocator should not be defined when the requirement '!defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR)' is not met!" +# endif # endif #endif // TEST_STD_VER > 20 diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp --- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp +++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp @@ -2100,11 +2100,17 @@ # endif # endif -# ifndef __cpp_lib_memory_resource -# error "__cpp_lib_memory_resource should be defined in c++17" -# endif -# if __cpp_lib_memory_resource != 201603L -# error "__cpp_lib_memory_resource should have the value 201603L in c++17" +# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR) +# ifndef __cpp_lib_memory_resource +# error "__cpp_lib_memory_resource should be defined in c++17" +# endif +# if __cpp_lib_memory_resource != 201603L +# error "__cpp_lib_memory_resource should have the value 201603L in c++17" +# endif +# else +# ifdef __cpp_lib_memory_resource +# error "__cpp_lib_memory_resource should not be defined when the requirement '!defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR)' is not met!" +# endif # endif # ifdef __cpp_lib_move_iterator_concept @@ -3216,11 +3222,17 @@ # endif # endif -# ifndef __cpp_lib_memory_resource -# error "__cpp_lib_memory_resource should be defined in c++20" -# endif -# if __cpp_lib_memory_resource != 201603L -# error "__cpp_lib_memory_resource should have the value 201603L in c++20" +# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR) +# ifndef __cpp_lib_memory_resource +# error "__cpp_lib_memory_resource should be defined in c++20" +# endif +# if __cpp_lib_memory_resource != 201603L +# error "__cpp_lib_memory_resource should have the value 201603L in c++20" +# endif +# else +# ifdef __cpp_lib_memory_resource +# error "__cpp_lib_memory_resource should not be defined when the requirement '!defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR)' is not met!" +# endif # endif # ifndef __cpp_lib_move_iterator_concept @@ -3286,11 +3298,17 @@ # endif # endif -# ifndef __cpp_lib_polymorphic_allocator -# error "__cpp_lib_polymorphic_allocator should be defined in c++20" -# endif -# if __cpp_lib_polymorphic_allocator != 201902L -# error "__cpp_lib_polymorphic_allocator should have the value 201902L in c++20" +# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR) +# ifndef __cpp_lib_polymorphic_allocator +# error "__cpp_lib_polymorphic_allocator should be defined in c++20" +# endif +# if __cpp_lib_polymorphic_allocator != 201902L +# error "__cpp_lib_polymorphic_allocator should have the value 201902L in c++20" +# endif +# else +# ifdef __cpp_lib_polymorphic_allocator +# error "__cpp_lib_polymorphic_allocator should not be defined when the requirement '!defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR)' is not met!" +# endif # endif # ifndef __cpp_lib_quoted_string_io @@ -4488,11 +4506,17 @@ # endif # endif -# ifndef __cpp_lib_memory_resource -# error "__cpp_lib_memory_resource should be defined in c++2b" -# endif -# if __cpp_lib_memory_resource != 201603L -# error "__cpp_lib_memory_resource should have the value 201603L in c++2b" +# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR) +# ifndef __cpp_lib_memory_resource +# error "__cpp_lib_memory_resource should be defined in c++2b" +# endif +# if __cpp_lib_memory_resource != 201603L +# error "__cpp_lib_memory_resource should have the value 201603L in c++2b" +# endif +# else +# ifdef __cpp_lib_memory_resource +# error "__cpp_lib_memory_resource should not be defined when the requirement '!defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR)' is not met!" +# endif # endif # ifndef __cpp_lib_move_iterator_concept @@ -4576,11 +4600,17 @@ # endif # endif -# ifndef __cpp_lib_polymorphic_allocator -# error "__cpp_lib_polymorphic_allocator should be defined in c++2b" -# endif -# if __cpp_lib_polymorphic_allocator != 201902L -# error "__cpp_lib_polymorphic_allocator should have the value 201902L in c++2b" +# if !defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR) +# ifndef __cpp_lib_polymorphic_allocator +# error "__cpp_lib_polymorphic_allocator should be defined in c++2b" +# endif +# if __cpp_lib_polymorphic_allocator != 201902L +# error "__cpp_lib_polymorphic_allocator should have the value 201902L in c++2b" +# endif +# else +# ifdef __cpp_lib_polymorphic_allocator +# error "__cpp_lib_polymorphic_allocator should not be defined when the requirement '!defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR)' is not met!" +# endif # endif # ifndef __cpp_lib_quoted_string_io diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.ctor/assign.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.ctor/assign.pass.cpp --- a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.ctor/assign.pass.cpp +++ b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.ctor/assign.pass.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14 +// XFAIL: availability-pmr-missing // diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.ctor/copy.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.ctor/copy.pass.cpp --- a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.ctor/copy.pass.cpp +++ b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.ctor/copy.pass.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14 +// XFAIL: availability-pmr-missing // diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.ctor/other_alloc.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.ctor/other_alloc.pass.cpp --- a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.ctor/other_alloc.pass.cpp +++ b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.ctor/other_alloc.pass.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14 +// XFAIL: availability-pmr-missing // diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.ctor/copy_move.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.ctor/copy_move.pass.cpp --- a/libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.ctor/copy_move.pass.cpp +++ b/libcxx/test/std/utilities/utility/mem.res/mem.res.monotonic.buffer/mem.res.monotonic.buffer.ctor/copy_move.pass.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14 +// XFAIL: availability-pmr-missing // diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res/construct.fail.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res/construct.fail.cpp --- a/libcxx/test/std/utilities/utility/mem.res/mem.res/construct.fail.cpp +++ b/libcxx/test/std/utilities/utility/mem.res/mem.res/construct.fail.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14 +// XFAIL: availability-pmr-missing // diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res/mem.res.private/private_members.fail.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res/mem.res.private/private_members.fail.cpp --- a/libcxx/test/std/utilities/utility/mem.res/mem.res/mem.res.private/private_members.fail.cpp +++ b/libcxx/test/std/utilities/utility/mem.res/mem.res/mem.res.private/private_members.fail.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14 +// XFAIL: availability-pmr-missing // diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.res/mem.res.private/protected_members.fail.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.res/mem.res.private/protected_members.fail.cpp --- a/libcxx/test/std/utilities/utility/mem.res/mem.res/mem.res.private/protected_members.fail.cpp +++ b/libcxx/test/std/utilities/utility/mem.res/mem.res/mem.res.private/protected_members.fail.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14 +// XFAIL: availability-pmr-missing // diff --git a/libcxx/test/std/utilities/utility/mem.res/nodiscard.verify.cpp b/libcxx/test/std/utilities/utility/mem.res/nodiscard.verify.cpp --- a/libcxx/test/std/utilities/utility/mem.res/nodiscard.verify.cpp +++ b/libcxx/test/std/utilities/utility/mem.res/nodiscard.verify.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17 +// XFAIL: availability-pmr-missing // check that functions are marked [[nodiscard]] 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 @@ -498,6 +498,8 @@ "name": "__cpp_lib_memory_resource", "values": { "c++17": 201603 }, "headers": ["memory_resource"], + "test_suite_guard": "!defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR)", + "libcxx_guard": "!defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR)", }, { "name": "__cpp_lib_move_iterator_concept", "values": { "c++20": 202207 }, @@ -541,6 +543,8 @@ "name": "__cpp_lib_polymorphic_allocator", "values": { "c++20": 201902 }, "headers": ["memory_resource"], + "test_suite_guard": "!defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR)", + "libcxx_guard": "!defined(_LIBCPP_AVAILABILITY_HAS_NO_PMR)", }, { "name": "__cpp_lib_quoted_string_io", "values": { "c++14": 201304 }, diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py --- a/libcxx/utils/libcxx/test/features.py +++ b/libcxx/utils/libcxx/test/features.py @@ -363,7 +363,7 @@ # Tests that require std::pmr support in the built library Feature(name='availability-pmr-missing', - when=lambda cfg: BooleanExpression.evaluate('stdlib=apple-libc++ && target={{.+}}-apple-macosx{{(10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0)(.0)?}}', cfg.available_features)), + when=lambda cfg: BooleanExpression.evaluate('stdlib=apple-libc++ && target={{.+}}-apple-macosx{{(10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0|13.0)(.0)?}}', cfg.available_features)), # Tests that require std::filesystem support in the built library Feature(name='availability-filesystem-missing',