diff --git a/libcxx/include/memory b/libcxx/include/memory index 54176f4e3996..ebb0a723a162 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -115,8 +115,8 @@ template class allocator { public: - typedef size_t size_type; // deprecated in C++17, removed in C++20 - typedef ptrdiff_t difference_type; // deprecated in C++17, removed in C++20 + typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef T* pointer; // deprecated in C++17, removed in C++20 typedef const T* const_pointer; // deprecated in C++17, removed in C++20 typedef typename add_lvalue_reference::type @@ -1748,9 +1748,9 @@ template class _LIBCPP_TEMPLATE_VIS allocator { public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t size_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef ptrdiff_t difference_type; _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer; _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference; @@ -1816,9 +1816,9 @@ template class _LIBCPP_TEMPLATE_VIS allocator { public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t size_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef ptrdiff_t difference_type; _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer; _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference; diff --git a/libcxx/test/libcxx/depr/depr.default.allocator/allocator_types.cxx2a.pass.cpp b/libcxx/test/libcxx/depr/depr.default.allocator/allocator_types.cxx2a.pass.cpp index 33ed39a7c483..bfff214127ba 100644 --- a/libcxx/test/libcxx/depr/depr.default.allocator/allocator_types.cxx2a.pass.cpp +++ b/libcxx/test/libcxx/depr/depr.default.allocator/allocator_types.cxx2a.pass.cpp @@ -8,7 +8,8 @@ // -// check nested types: +// Check that the following types are provided regardless of the Standard when +// we request them from libc++. // template // class allocator @@ -45,5 +46,5 @@ int main(int, char**) static_assert((std::is_same::rebind::other, std::allocator >::value), ""); - return 0; + return 0; } diff --git a/libcxx/test/libcxx/depr/depr.default.allocator/allocator_void.cxx2a.pass.cpp b/libcxx/test/libcxx/depr/depr.default.allocator/allocator_void.cxx2a.pass.cpp index 3b941d2ce9ea..d03f90b506d5 100644 --- a/libcxx/test/libcxx/depr/depr.default.allocator/allocator_void.cxx2a.pass.cpp +++ b/libcxx/test/libcxx/depr/depr.default.allocator/allocator_void.cxx2a.pass.cpp @@ -8,6 +8,9 @@ // +// Check that the following member types of allocator are provided +// regardless of the Standard when we request them from libc++. + // template <> // class allocator // { diff --git a/libcxx/test/libcxx/depr/depr.default.allocator/allocator_types.depr_in_cxx17.verify.cpp b/libcxx/test/std/utilities/memory/default.allocator/allocator_types.deprecated_in_cxx17.verify.cpp similarity index 63% rename from libcxx/test/libcxx/depr/depr.default.allocator/allocator_types.depr_in_cxx17.verify.cpp rename to libcxx/test/std/utilities/memory/default.allocator/allocator_types.deprecated_in_cxx17.verify.cpp index 90ff97452b6a..f09651a81eee 100644 --- a/libcxx/test/libcxx/depr/depr.default.allocator/allocator_types.depr_in_cxx17.verify.cpp +++ b/libcxx/test/std/utilities/memory/default.allocator/allocator_types.deprecated_in_cxx17.verify.cpp @@ -8,16 +8,14 @@ // -// check nested types: +// Check that the following nested types are deprecated in C++17: // template // class allocator // { // public: -// typedef size_t size_type; -// typedef ptrdiff_t difference_type; -// typedef T* pointer; -// typedef const T* const_pointer; +// typedef T* pointer; +// typedef const T* const_pointer; // typedef typename add_lvalue_reference::type reference; // typedef typename add_lvalue_reference::type const_reference; // @@ -25,28 +23,27 @@ // ... // }; -// Deprecated in C++17 - -// UNSUPPORTED: c++03, c++11, c++14 +// REQUIRES: c++17 // Clang 6 does not handle the deprecated attribute on template members properly, // so the rebind check below fails. // UNSUPPORTED: clang-6 -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS - #include #include "test_macros.h" int main(int, char**) { - typedef std::allocator::size_type AST; // expected-warning {{'size_type' is deprecated}} - typedef std::allocator::difference_type ADT; // expected-warning {{'difference_type' is deprecated}} typedef std::allocator::pointer AP; // expected-warning {{'pointer' is deprecated}} typedef std::allocator::const_pointer ACP; // expected-warning {{'const_pointer' is deprecated}} typedef std::allocator::reference AR; // expected-warning {{'reference' is deprecated}} typedef std::allocator::const_reference ACR; // expected-warning {{'const_reference' is deprecated}} typedef std::allocator::rebind::other ARO; // expected-warning {{'rebind' is deprecated}} - return 0; + typedef std::allocator::pointer AP2; // expected-warning {{'pointer' is deprecated}} + typedef std::allocator::const_pointer ACP2; // expected-warning {{'const_pointer' is deprecated}} + typedef std::allocator::reference AR2; // expected-warning {{'reference' is deprecated}} + typedef std::allocator::const_reference ACR2; // expected-warning {{'const_reference' is deprecated}} + typedef std::allocator::rebind::other ARO2; // expected-warning {{'rebind' is deprecated}} + return 0; } diff --git a/libcxx/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp b/libcxx/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp index 26feeedf85de..2265ed3d66fa 100644 --- a/libcxx/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp +++ b/libcxx/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp @@ -8,12 +8,14 @@ // -// check nested types: +// Check that the nested types of std::allocator are provided: // template // class allocator // { // public: +// typedef size_t size_type; +// typedef ptrdiff_t difference_type; // typedef T value_type; // // typedef true_type propagate_on_container_move_assignment; @@ -27,21 +29,25 @@ #include "test_macros.h" +template +void check() +{ + static_assert((std::is_same::size_type, std::size_t>::value), ""); + static_assert((std::is_same::difference_type, std::ptrdiff_t>::value), ""); + static_assert((std::is_same::value_type, T>::value), ""); + static_assert((std::is_same::propagate_on_container_move_assignment, std::true_type>::value), ""); + static_assert((std::is_same::is_always_equal, std::true_type>::value), ""); + + std::allocator a; + std::allocator a2 = a; + a2 = a; + std::allocator a3 = a2; + (void)a3; +} + int main(int, char**) { - static_assert((std::is_same::value_type, char>::value), ""); - - static_assert((std::is_same::propagate_on_container_move_assignment, std::true_type>::value), ""); - LIBCPP_STATIC_ASSERT((std::is_same::propagate_on_container_move_assignment, std::true_type>::value), ""); - - static_assert((std::is_same::is_always_equal, std::true_type>::value), ""); - LIBCPP_STATIC_ASSERT((std::is_same::is_always_equal, std::true_type>::value), ""); - - std::allocator a; - std::allocator a2 = a; - a2 = a; - std::allocator a3 = a2; - ((void)a3); - - return 0; + check(); + check(); + return 0; } diff --git a/libcxx/test/std/utilities/memory/default.allocator/allocator_types.removed_in_cxx20.verify.cpp b/libcxx/test/std/utilities/memory/default.allocator/allocator_types.removed_in_cxx20.verify.cpp new file mode 100644 index 000000000000..9805accda20a --- /dev/null +++ b/libcxx/test/std/utilities/memory/default.allocator/allocator_types.removed_in_cxx20.verify.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// + +// Check that the following nested types are removed in C++20: + +// template +// class allocator +// { +// public: +// typedef T* pointer; +// typedef const T* const_pointer; +// typedef typename add_lvalue_reference::type reference; +// typedef typename add_lvalue_reference::type const_reference; +// +// template struct rebind {typedef allocator other;}; +// ... +// }; + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +#include +#include "test_macros.h" + +template +void check() +{ + typedef typename std::allocator::pointer AP; // expected-error 2 {{no type named 'pointer'}} + typedef typename std::allocator::const_pointer ACP; // expected-error 2 {{no type named 'const_pointer'}} + typedef typename std::allocator::reference AR; // expected-error 2 {{no type named 'reference'}} + typedef typename std::allocator::const_reference ACR; // expected-error 2 {{no type named 'const_reference'}} + typedef typename std::allocator::template rebind::other ARO; // expected-error 2 {{no member named 'rebind'}} +} + +int main(int, char**) +{ + check(); + check(); + return 0; +} diff --git a/libcxx/test/libcxx/depr/depr.default.allocator/allocator_void.depr_in_cxx17.verify.cpp b/libcxx/test/std/utilities/memory/default.allocator/allocator_void.deprecated_in_cxx17.verify.cpp similarity index 61% rename from libcxx/test/libcxx/depr/depr.default.allocator/allocator_void.depr_in_cxx17.verify.cpp rename to libcxx/test/std/utilities/memory/default.allocator/allocator_void.deprecated_in_cxx17.verify.cpp index 70e5627074aa..cd98e6364b7e 100644 --- a/libcxx/test/libcxx/depr/depr.default.allocator/allocator_void.depr_in_cxx17.verify.cpp +++ b/libcxx/test/std/utilities/memory/default.allocator/allocator_void.deprecated_in_cxx17.verify.cpp @@ -7,23 +7,10 @@ //===----------------------------------------------------------------------===// // -// -// template <> -// class allocator -// { -// public: -// typedef void* pointer; -// typedef const void* const_pointer; -// typedef void value_type; -// -// template struct rebind {typedef allocator<_Up> other;}; -// }; -// -// Deprecated in C++17 -// UNSUPPORTED: c++03, c++11, c++14 +// Check that allocator is deprecated in C++17. -// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS +// REQUIRES: c++17 #include #include "test_macros.h" @@ -33,6 +20,5 @@ int main(int, char**) typedef std::allocator::pointer AP; // expected-warning {{'allocator' is deprecated}} typedef std::allocator::const_pointer ACP; // expected-warning {{'allocator' is deprecated}} typedef std::allocator::rebind::other ARO; // expected-warning {{'allocator' is deprecated}} - - return 0; + return 0; } diff --git a/libcxx/www/cxx1z_status.html b/libcxx/www/cxx1z_status.html index c8b3374ba42e..b1db58e26ce3 100644 --- a/libcxx/www/cxx1z_status.html +++ b/libcxx/www/cxx1z_status.html @@ -105,7 +105,7 @@ p0088r3LWGVariant: a type-safe union for C++17OuluComplete4.0 p0137r1CWGCore Issue 1776: Replacement of class objects containing reference membersOuluComplete6.0 p0163r0LWGshared_ptr::weak_typeOuluComplete3.9 - p0174r2LWGDeprecating Vestigial Library Parts in C++17Oulu + p0174r2LWGDeprecating Vestigial Library Parts in C++17OuluPartial p0175r1LWGSynopses for the C libraryOulu p0180r2LWGReserve a New Library Namespace for Future StandardizationOuluNothing to don/a p0181r1LWGOrdered by DefaultOuluRemoved in Konan/a diff --git a/libcxx/www/cxx2a_status.html b/libcxx/www/cxx2a_status.html index ad9bb36859cb..73a2c50c71c9 100644 --- a/libcxx/www/cxx2a_status.html +++ b/libcxx/www/cxx2a_status.html @@ -89,7 +89,7 @@ P0528R3CWGThe Curious Case of Padding Bits, Featuring Atomic Compare-and-ExchangeRapperswil P0542R5CWGSupport for contract based programming in C++Rapperswil P0556R3LWGIntegral power-of-2 operationsRapperswilComplete9.0 - P0619R4LWGReviewing Deprecated Facilities of C++17 for C++20Rapperswil + P0619R4LWGReviewing Deprecated Facilities of C++17 for C++20RapperswilPartial
(only std::allocator part is implemented) P0646R1LWGImproving the Return Value of Erase-Like AlgorithmsRapperswilComplete10.0 P0722R3CWGEfficient sized delete for variable sized classesRapperswilComplete9.0 P0758R1LWGImplicit conversion traits and utility functionsRapperswilComplete