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 @@ -37,6 +37,11 @@ :header-rows: 1 :widths: auto +.. note:: + + .. [#note-P1413R3] P1413R3: ``std::aligned_storage_t`` and ``std::aligned_union_t`` are not marked + deprecated because there is currently no way to do that. + .. _issues-status-cxx2b: Library Working Group Issues Status 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","","" "`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","","" -"`P1413R3 `__","LWG","Deprecate ``std::aligned_storage`` and ``std::aligned_union``","February 2022","","" +"`P1413R3 `__","LWG","Deprecate ``std::aligned_storage`` and ``std::aligned_union``","February 2022","|Partial| [#note-P1413R3]_","" "`P2255R3 `__","LWG","A type trait to detect reference binding to temporary","February 2022","","" "`P2273R3 `__","LWG","Making ``std::unique_ptr`` constexpr","February 2022","","" "`P2387R3 `__","LWG","Pipe support for user-defined range adaptors","February 2022","","" diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -870,6 +870,12 @@ # define _LIBCPP_DEPRECATED_IN_CXX20 #endif +#if _LIBCPP_STD_VER > 20 +# 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/type_traits b/libcxx/include/type_traits --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -732,7 +732,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 @@ -744,12 +744,12 @@ #if _LIBCPP_STD_VER > 11 template ::value> - using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; +using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; #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\ {\ @@ -798,7 +798,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; 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 @@ -28,7 +28,7 @@ template void testForSizeAndAlign() { - using T = typename std::aligned_storage::type; + struct T { alignas(Align) std::byte data[S]; }; TestResource R; ex::polymorphic_allocator a(&R); @@ -44,7 +44,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS template void testAllocForSizeThrows() { - using T = typename std::aligned_storage::type; + struct T { std::byte 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 @@ -26,7 +26,7 @@ template void testForSizeAndAlign() { - using T = typename std::aligned_storage::type; + struct T { alignas(Align) std::byte 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}}