From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id AEE2E3854811; Mon, 6 Feb 2023 14:25:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AEE2E3854811 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675693535; bh=Uoy7Y9MYaFxg4xmA4K85UetYNcBURANdAUA1NBDNBps=; h=From:To:Subject:Date:From; b=k7aAGzREYK2ex9FsO1sQ3Oo/azLQ03xvlgbn/289Dys/bD78wK7l4M7GF1H6+RE9V tW0mHaTwjMRP3sPFODmlPtbrVVU0nMZtxK7iA2Q41mgKRl7Y3E9/F5yYeqS2ne6PmP 4V0FUxernL8vzkAe7sLZno6EIuh7xxjgykjYR14Y= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-5715] libstdc++: Implement P1413R3 'deprecate aligned_storage and aligned_union' X-Act-Checkin: gcc X-Git-Author: Nathaniel Shead X-Git-Refname: refs/heads/master X-Git-Oldrev: 4f49ae607cb1ed312fd63967ede418601343ef24 X-Git-Newrev: aa02a69e15dfc4b276457b65fae283f1a06fb2a0 Message-Id: <20230206142535.AEE2E3854811@sourceware.org> Date: Mon, 6 Feb 2023 14:25:35 +0000 (GMT) List-Id: https://gcc.gnu.org/g:aa02a69e15dfc4b276457b65fae283f1a06fb2a0 commit r13-5715-gaa02a69e15dfc4b276457b65fae283f1a06fb2a0 Author: Nathaniel Shead Date: Thu Dec 29 01:28:25 2022 +1100 libstdc++: Implement P1413R3 'deprecate aligned_storage and aligned_union' Adds deprecated attributes for C++23, and makes use of it for std::aligned_storage, std::aligned_storage_t, std::aligned_union, and std::aligned_union_t. libstdc++-v3/ChangeLog: * doc/doxygen/user.cfg.in (PREDEFINED): Add new macros. * include/bits/c++config (_GLIBCXX23_DEPRECATED) (_GLIBCXX23_DEPRECATED_SUGGEST): New macros. * include/std/type_traits (aligned_storage, aligned_union) (aligned_storage_t, aligned_union_t): Deprecate for C++23. * testsuite/20_util/aligned_storage/deprecated-2b.cc: New test. * testsuite/20_util/aligned_union/deprecated-2b.cc: New test. Signed-off-by: Nathaniel Shead Reviewed-by: Jonathan Wakely Diff: --- libstdc++-v3/doc/doxygen/user.cfg.in | 2 ++ libstdc++-v3/include/bits/c++config | 10 +++++++++ libstdc++-v3/include/std/type_traits | 17 ++++++++++---- .../20_util/aligned_storage/deprecated-2b.cc | 26 ++++++++++++++++++++++ .../20_util/aligned_union/deprecated-2b.cc | 26 ++++++++++++++++++++++ 5 files changed, 77 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in index fc46e722529..31613f51517 100644 --- a/libstdc++-v3/doc/doxygen/user.cfg.in +++ b/libstdc++-v3/doc/doxygen/user.cfg.in @@ -2396,6 +2396,8 @@ PREDEFINED = __cplusplus=202002L \ "_GLIBCXX17_DEPRECATED_SUGGEST(E)= " \ "_GLIBCXX20_DEPRECATED= " \ "_GLIBCXX20_DEPRECATED_SUGGEST(E)= " \ + "_GLIBCXX23_DEPRECATED= " \ + "_GLIBCXX23_DEPRECATED_SUGGEST(E)= " \ _GLIBCXX17_INLINE=inline \ _GLIBCXX_CHRONO_INT64_T=int64_t \ _GLIBCXX_DEFAULT_ABI_TAG \ diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index adbb4a6e11f..71f2401402f 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -86,6 +86,8 @@ // _GLIBCXX17_DEPRECATED_SUGGEST( string-literal ) // _GLIBCXX20_DEPRECATED // _GLIBCXX20_DEPRECATED_SUGGEST( string-literal ) +// _GLIBCXX23_DEPRECATED +// _GLIBCXX23_DEPRECATED_SUGGEST( string-literal ) #ifndef _GLIBCXX_USE_DEPRECATED # define _GLIBCXX_USE_DEPRECATED 1 #endif @@ -131,6 +133,14 @@ # define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) #endif +#if defined(__DEPRECATED) && (__cplusplus >= 202100L) +# define _GLIBCXX23_DEPRECATED [[__deprecated__]] +# define _GLIBCXX23_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) +#else +# define _GLIBCXX23_DEPRECATED +# define _GLIBCXX23_DEPRECATED_SUGGEST(ALT) +#endif + // Macros for ABI tag attributes. #ifndef _GLIBCXX_ABI_TAG_CXX11 # define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11"))) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 3f31950de29..d13af433a17 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -2088,10 +2088,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * type shall be a POD type suitable for use as uninitialized * storage for any object whose size is at most _Len and whose * alignment is a divisor of _Align. + * + * @deprecated Deprecated in C++23. Uses can be replaced by an + * array std::byte[_Len] declared with alignas(_Align). */ template::__type)> - struct aligned_storage + struct + _GLIBCXX23_DEPRECATED + aligned_storage { union type { @@ -2127,9 +2132,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * least size _Len. * * @see aligned_storage + * + * @deprecated Deprecated in C++23. */ template - struct aligned_union + struct + _GLIBCXX23_DEPRECATED + aligned_union { private: static_assert(sizeof...(_Types) != 0, "At least one type is required"); @@ -2580,10 +2589,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Alias template for aligned_storage template::__type)> - using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; + using aligned_storage_t _GLIBCXX23_DEPRECATED = typename aligned_storage<_Len, _Align>::type; template - using aligned_union_t = typename aligned_union<_Len, _Types...>::type; + using aligned_union_t _GLIBCXX23_DEPRECATED = typename aligned_union<_Len, _Types...>::type; /// Alias template for decay template diff --git a/libstdc++-v3/testsuite/20_util/aligned_storage/deprecated-2b.cc b/libstdc++-v3/testsuite/20_util/aligned_storage/deprecated-2b.cc new file mode 100644 index 00000000000..a0e338a5843 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/aligned_storage/deprecated-2b.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++23" } +// { dg-do compile { target c++23 } } + +#include + +std::aligned_storage<1, 1>::type x; // { dg-warning "is deprecated" } +std::aligned_storage_t<1, 1> y; // { dg-warning "is deprecated" } + +// { dg-prune-output "declared here" } diff --git a/libstdc++-v3/testsuite/20_util/aligned_union/deprecated-2b.cc b/libstdc++-v3/testsuite/20_util/aligned_union/deprecated-2b.cc new file mode 100644 index 00000000000..fa00a923856 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/aligned_union/deprecated-2b.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2022 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// { dg-options "-std=gnu++23" } +// { dg-do compile { target c++23 } } + +#include + +std::aligned_union<4, int>::type x; // { dg-warning "is deprecated" } +std::aligned_union_t<4, int> y; // { dg-warning "is deprecated" } + +// { dg-prune-output "declared here" }