From 4274138c763818238ae8b931fe825b490e755a64 Mon Sep 17 00:00:00 2001 From: MichaelRizkalla Date: Sat, 23 Jan 2021 16:15:26 +0000 Subject: [PATCH 1/3] remove deprecated allocator members in cxx20 --- stl/inc/xmemory | 11 ++++++++++- stl/inc/yvals_core.h | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/stl/inc/xmemory b/stl/inc/xmemory index 38209d5c9cd..0c31a622465 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -788,16 +788,20 @@ public: using value_type = _Ty; +#if _HAS_DEPRECATED_ALLOCATOR_MEMBERS _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS typedef _Ty* pointer; _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS typedef const _Ty* const_pointer; _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS typedef _Ty& reference; _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS typedef const _Ty& const_reference; +#endif // _HAS_DEPRECATED_ALLOCATOR_MEMBERS using size_type = size_t; using difference_type = ptrdiff_t; - using propagate_on_container_move_assignment = true_type; + using propagate_on_container_move_assignment = true_type; + +#if _HAS_DEPRECATED_ALLOCATOR_MEMBERS using is_always_equal _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS = true_type; template @@ -812,6 +816,7 @@ public: _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS _NODISCARD const _Ty* address(const _Ty& _Val) const noexcept { return _STD addressof(_Val); } +#endif // _HAS_DEPRECATED_ALLOCATOR_MEMBERS constexpr allocator() noexcept {} @@ -830,6 +835,7 @@ public: return static_cast<_Ty*>(_Allocate<_New_alignof<_Ty>>(_Get_size_of_n(_Count))); } +#if _HAS_DEPRECATED_ALLOCATOR_MEMBERS _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS _NODISCARD __declspec(allocator) _Ty* allocate( _CRT_GUARDOVERFLOW const size_t _Count, const void*) { return allocate(_Count); @@ -848,8 +854,10 @@ public: _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS _NODISCARD size_t max_size() const noexcept { return static_cast(-1) / sizeof(_Ty); } +#endif // _HAS_DEPRECATED_ALLOCATOR_MEMBERS }; +#if _HAS_DEPRECATED_ALLOCATOR_MEMBERS // CLASS allocator template <> class allocator { @@ -869,6 +877,7 @@ public: using other = allocator<_Other>; }; }; +#endif // _HAS_DEPRECATED_ALLOCATOR_MEMBERS template _NODISCARD _CONSTEXPR20_DYNALLOC bool operator==(const allocator<_Ty>&, const allocator<_Other>&) noexcept { diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index e37d8daf036..c40c71a547d 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -1024,6 +1024,10 @@ #define _HAS_DEPRECATED_ADAPTOR_TYPEDEFS (_HAS_FEATURES_REMOVED_IN_CXX20) #endif // _HAS_DEPRECATED_ADAPTOR_TYPEDEFS +#ifndef _HAS_DEPRECATED_ALLOCATOR_MEMBERS +#define _HAS_DEPRECATED_ALLOCATOR_MEMBERS (_HAS_FEATURES_REMOVED_IN_CXX20) +#endif // _HAS_DEPRECATED_ALLOCATOR_MEMBERS + #ifndef _HAS_DEPRECATED_IS_LITERAL_TYPE #define _HAS_DEPRECATED_IS_LITERAL_TYPE (_HAS_FEATURES_REMOVED_IN_CXX20) #endif // _HAS_DEPRECATED_IS_LITERAL_TYPE From 228569c361d0900b9e8257758a9f58d806f49c60 Mon Sep 17 00:00:00 2001 From: MichaelRizkalla Date: Sun, 24 Jan 2021 11:22:54 +0000 Subject: [PATCH 2/3] Enable allocator's removed function in unit tests --- tests/std/tests/Dev11_0920385_list_sort_allocator/test.cpp | 1 + .../VSO_0000000_instantiate_iterators_misc/test.compile.pass.cpp | 1 + tests/tr1/tests/memory/test.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/tests/std/tests/Dev11_0920385_list_sort_allocator/test.cpp b/tests/std/tests/Dev11_0920385_list_sort_allocator/test.cpp index aa38f7b4c6a..d1c74c1e5ad 100644 --- a/tests/std/tests/Dev11_0920385_list_sort_allocator/test.cpp +++ b/tests/std/tests/Dev11_0920385_list_sort_allocator/test.cpp @@ -3,6 +3,7 @@ // Test DevDiv-920385 ": list::sort shouldn't default-construct allocators". +#define _HAS_DEPRECATED_ALLOCATOR_MEMBERS 1 #define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING #include diff --git a/tests/std/tests/VSO_0000000_instantiate_iterators_misc/test.compile.pass.cpp b/tests/std/tests/VSO_0000000_instantiate_iterators_misc/test.compile.pass.cpp index c00a3dd8e21..3ad5fb18bf2 100644 --- a/tests/std/tests/VSO_0000000_instantiate_iterators_misc/test.compile.pass.cpp +++ b/tests/std/tests/VSO_0000000_instantiate_iterators_misc/test.compile.pass.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #define _HAS_DEPRECATED_ADAPTOR_TYPEDEFS 1 +#define _HAS_DEPRECATED_ALLOCATOR_MEMBERS 1 #define _HAS_DEPRECATED_NEGATORS 1 #define _HAS_DEPRECATED_RAW_STORAGE_ITERATOR 1 #define _HAS_DEPRECATED_TEMPORARY_BUFFER 1 diff --git a/tests/tr1/tests/memory/test.cpp b/tests/tr1/tests/memory/test.cpp index 897339b784e..5daa40cb0ce 100644 --- a/tests/tr1/tests/memory/test.cpp +++ b/tests/tr1/tests/memory/test.cpp @@ -5,6 +5,7 @@ #define TEST_NAME "" #define _HAS_AUTO_PTR_ETC 1 +#define _HAS_DEPRECATED_ALLOCATOR_MEMBERS 1 #define _HAS_DEPRECATED_RAW_STORAGE_ITERATOR 1 #define _HAS_DEPRECATED_TEMPORARY_BUFFER 1 #define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING From 8bf7aa810ba23635fd684387238ef40c574553b3 Mon Sep 17 00:00:00 2001 From: Michael Rizkalla Date: Wed, 27 Jan 2021 18:12:32 +0000 Subject: [PATCH 3/3] keep allocator in c++20, remove only deprecated members --- stl/inc/xmemory | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/stl/inc/xmemory b/stl/inc/xmemory index 0c31a622465..dfaa386ea32 100644 --- a/stl/inc/xmemory +++ b/stl/inc/xmemory @@ -857,27 +857,30 @@ public: #endif // _HAS_DEPRECATED_ALLOCATOR_MEMBERS }; -#if _HAS_DEPRECATED_ALLOCATOR_MEMBERS // CLASS allocator template <> class allocator { public: using value_type = void; +#if _HAS_DEPRECATED_ALLOCATOR_MEMBERS _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS typedef void* pointer; _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS typedef const void* const_pointer; +#endif // _HAS_DEPRECATED_ALLOCATOR_MEMBERS using size_type = size_t; using difference_type = ptrdiff_t; - using propagate_on_container_move_assignment = true_type; + using propagate_on_container_move_assignment = true_type; + +#if _HAS_DEPRECATED_ALLOCATOR_MEMBERS using is_always_equal _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS = true_type; template struct _CXX17_DEPRECATE_OLD_ALLOCATOR_MEMBERS rebind { using other = allocator<_Other>; }; -}; #endif // _HAS_DEPRECATED_ALLOCATOR_MEMBERS +}; template _NODISCARD _CONSTEXPR20_DYNALLOC bool operator==(const allocator<_Ty>&, const allocator<_Other>&) noexcept {