diff --git a/libcxx/docs/Status/Cxx2b.rst b/libcxx/docs/Status/Cxx2b.rst --- a/libcxx/docs/Status/Cxx2b.rst +++ b/libcxx/docs/Status/Cxx2b.rst @@ -41,6 +41,8 @@ .. [#note-P2273] P2273: ``make_unique_for_overwrite`` isn't done yet since `P1020` hasn't been implemented yet. .. [#note-P0533R9] P0533R9: ``isfinite``, ``isinf``, ``isnan`` and ``isnormal`` are implemented. + .. [#note-P1413R3] P1413R3: ``std::aligned_storage_t`` and ``std::aligned_union_t`` are marked deprecated, but + clang doesn't issue a diagnostic for deprecated using template declarations. .. _issues-status-cxx2b: diff --git a/libcxx/docs/Status/Cxx2bPapers.csv b/libcxx/docs/Status/Cxx2bPapers.csv --- a/libcxx/docs/Status/Cxx2bPapers.csv +++ b/libcxx/docs/Status/Cxx2bPapers.csv @@ -42,7 +42,7 @@ "`P0533R9 `__","LWG","``constexpr`` for ```` and ````","February 2022","|In progress| [#note-P0533R9]_","" "`P0627R6 `__","LWG","Function to mark unreachable code","February 2022","|Complete|","15.0" "`P1206R7 `__","LWG","``ranges::to``: A function to convert any range to a container","February 2022","","","|ranges|" -"`P1413R3 `__","LWG","Deprecate ``std::aligned_storage`` and ``std::aligned_union``","February 2022","","" +"`P1413R3 `__","LWG","Deprecate ``std::aligned_storage`` and ``std::aligned_union``","February 2022","|Complete| [#note-P1413R3]_","" "`P2255R2 `__","LWG","A type trait to detect reference binding to temporary","February 2022","","" "`P2273R3 `__","LWG","Making ``std::unique_ptr`` constexpr","February 2022","|Partial| [#note-P2273]_","16.0" "`P2387R3 `__","LWG","Pipe support for user-defined range adaptors","February 2022","","","|ranges|" diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -802,6 +802,12 @@ # define _LIBCPP_DEPRECATED_IN_CXX20 # endif +#if _LIBCPP_STD_VER >= 23 +# define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED +#else +# define _LIBCPP_DEPRECATED_IN_CXX23 +#endif + # if !defined(_LIBCPP_HAS_NO_CHAR8_T) # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED # else diff --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h --- a/libcxx/include/__functional/function.h +++ b/libcxx/include/__functional/function.h @@ -382,7 +382,9 @@ template class __value_func<_Rp(_ArgTypes...)> { + _LIBCPP_SUPPRESS_DEPRECATED_PUSH typename aligned_storage<3 * sizeof(void*)>::type __buf_; + _LIBCPP_SUPPRESS_DEPRECATED_POP typedef __base<_Rp(_ArgTypes...)> __func; __func* __f_; @@ -515,7 +517,9 @@ return; if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_) { + _LIBCPP_SUPPRESS_DEPRECATED_PUSH typename aligned_storage::type __tempbuf; + _LIBCPP_SUPPRESS_DEPRECATED_POP __func* __t = __as_base(&__tempbuf); __f_->__clone(__t); __f_->destroy(); diff --git a/libcxx/include/__type_traits/aligned_storage.h b/libcxx/include/__type_traits/aligned_storage.h --- a/libcxx/include/__type_traits/aligned_storage.h +++ b/libcxx/include/__type_traits/aligned_storage.h @@ -83,7 +83,7 @@ : public integral_constant::value>::value> {}; template ::value> -struct _LIBCPP_TEMPLATE_VIS aligned_storage +struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS aligned_storage { typedef typename __find_pod<__all_types, _Align>::type _Aligner; union type @@ -94,13 +94,17 @@ }; #if _LIBCPP_STD_VER > 11 + + _LIBCPP_SUPPRESS_DEPRECATED_PUSH template ::value> - using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; + using aligned_storage_t _LIBCPP_DEPRECATED_IN_CXX23 = typename aligned_storage<_Len, _Align>::type; + _LIBCPP_SUPPRESS_DEPRECATED_POP + #endif #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ template \ -struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\ +struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\ {\ struct _ALIGNAS(n) type\ {\ diff --git a/libcxx/include/__type_traits/aligned_union.h b/libcxx/include/__type_traits/aligned_union.h --- a/libcxx/include/__type_traits/aligned_union.h +++ b/libcxx/include/__type_traits/aligned_union.h @@ -37,7 +37,7 @@ }; template -struct aligned_union +struct _LIBCPP_DEPRECATED_IN_CXX23 aligned_union { static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value; @@ -47,7 +47,8 @@ }; #if _LIBCPP_STD_VER > 11 -template using aligned_union_t = typename aligned_union<_Len, _Types...>::type; +template +using aligned_union_t _LIBCPP_DEPRECATED_IN_CXX23 = typename aligned_union<_Len, _Types...>::type; #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/any b/libcxx/include/any --- a/libcxx/include/any +++ b/libcxx/include/any @@ -138,7 +138,9 @@ namespace __any_imp { + _LIBCPP_SUPPRESS_DEPRECATED_PUSH using _Buffer = aligned_storage_t<3*sizeof(void*), alignment_of::value>; + _LIBCPP_SUPPRESS_DEPRECATED_POP template using _IsSmallObject = integral_constant::value>::type _Up; +_LIBCPP_SUPPRESS_DEPRECATED_POP protected: _Up __value_; @@ -1702,7 +1704,9 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_NO_CFI __base* __get_buf() { return (__base*)&__buf_; } + _LIBCPP_SUPPRESS_DEPRECATED_PUSH typename aligned_storage<3*sizeof(void*)>::type __buf_; + _LIBCPP_SUPPRESS_DEPRECATED_POP __base* __f_; public: @@ -1835,7 +1839,9 @@ { if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) { + _LIBCPP_SUPPRESS_DEPRECATED_PUSH typename aligned_storage::type __tempbuf; + _LIBCPP_SUPPRESS_DEPRECATED_POP __base* __t = (__base*)&__tempbuf; __f_->__move_to(__t); __f_->destroy(); diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -158,8 +158,8 @@ // Alignment properties and transformations: template struct alignment_of; template - struct aligned_storage; - template struct aligned_union; + struct aligned_storage; // deprecated in C++23 + template struct aligned_union; // deprecated in C++23 template struct remove_cvref; // C++20 template struct decay; diff --git a/libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/allocate.pass.cpp b/libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/allocate.pass.cpp --- a/libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/allocate.pass.cpp +++ b/libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/allocate.pass.cpp @@ -38,7 +38,7 @@ template void testForSizeAndAlign() { - using T = typename std::aligned_storage::type; + struct T { alignas(Align) char data[S]; }; TestResource R; ex::polymorphic_allocator a(&R); @@ -54,7 +54,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS template void testAllocForSizeThrows() { - using T = typename std::aligned_storage::type; + struct T { char data[S]; }; using Alloc = ex::polymorphic_allocator; using Traits = std::allocator_traits; NullResource R; diff --git a/libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/deallocate.pass.cpp b/libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/deallocate.pass.cpp --- a/libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/deallocate.pass.cpp +++ b/libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/deallocate.pass.cpp @@ -36,7 +36,7 @@ template void testForSizeAndAlign() { - using T = typename std::aligned_storage::type; + struct T { alignas(Align) char data[S]; }; TestResource R; ex::polymorphic_allocator a(&R); diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.depr.verify.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.depr.verify.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.depr.verify.cpp @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++14, c++17, c++20 + +#include + +std::aligned_storage<1, 1>::type s2; // expected-warning {{'aligned_storage<1, 1>' is deprecated}} +std::aligned_storage<3, 1>::type s3; // expected-warning {{'aligned_storage<3, 1>' is deprecated}} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp --- a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp @@ -13,6 +13,8 @@ // Issue 3034 added: // The member typedef type shall be a trivial standard-layout type. +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS + #include #include // for std::max_align_t #include "test_macros.h" diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.depr.verify.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.depr.verify.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.depr.verify.cpp @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// 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, c++14, c++17, c++20 + +#include + +std::aligned_union<1, int>::type s2; // expected-warning {{'aligned_union<1, int>' is deprecated}} +std::aligned_union<3, char, char>::type s3; // expected-warning {{'aligned_union<3, char, char>' is deprecated}} diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp --- a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_union.pass.cpp @@ -6,6 +6,8 @@ // //===----------------------------------------------------------------------===// +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS + // type_traits // aligned_union diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/allocate.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/allocate.pass.cpp --- a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/allocate.pass.cpp +++ b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/allocate.pass.cpp @@ -31,7 +31,10 @@ template void testForSizeAndAlign() { - using T = typename std::aligned_storage::type; + struct T { + alignas(Align) std::byte buf[S]; + }; + TestResource R; std::pmr::polymorphic_allocator a(&R); @@ -47,7 +50,10 @@ #ifndef TEST_HAS_NO_EXCEPTIONS template void testAllocForSizeThrows() { - using T = typename std::aligned_storage::type; + struct T { + std::byte buf[S]; + }; + using Alloc = std::pmr::polymorphic_allocator; using Traits = std::allocator_traits; NullResource R; diff --git a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/deallocate.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/deallocate.pass.cpp --- a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/deallocate.pass.cpp +++ b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/deallocate.pass.cpp @@ -28,7 +28,9 @@ template void testForSizeAndAlign() { - using T = typename std::aligned_storage::type; + struct T { + alignas(Align) std::byte buf[S]; + }; TestResource R; std::pmr::polymorphic_allocator a(&R);