From: Nathaniel Shead <nathanieloshead@gmail.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [PATCH 2/2] libstdc++: Implement P1413R3 'deprecate aligned_storage and aligned_union'
Date: Thu, 29 Dec 2022 01:28:25 +1100 [thread overview]
Message-ID: <Y6xSiYH9k9JrId6H@Thaum.localdomain> (raw)
These two patches implement P1413 (deprecate std::aligned_storage and
std::aligned_union) for C++23. Tested on x86_64-linux.
-- >8 --
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 <nathanieloshead@gmail.com>
---
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(-)
create mode 100644 libstdc++-v3/testsuite/20_util/aligned_storage/deprecated-2b.cc
create mode 100644 libstdc++-v3/testsuite/20_util/aligned_union/deprecated-2b.cc
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 d2b0cfa15ce..7cec5d3de2d 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 2f4d4bb8d4d..9df833e82be 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<std::size_t _Len, std::size_t _Align =
__alignof__(typename __aligned_storage_msa<_Len>::__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 <size_t _Len, typename... _Types>
- 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<size_t _Len, size_t _Align =
__alignof__(typename __aligned_storage_msa<_Len>::__type)>
- using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
+ using aligned_storage_t _GLIBCXX23_DEPRECATED = typename aligned_storage<_Len, _Align>::type;
template <size_t _Len, typename... _Types>
- 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<typename _Tp>
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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++23" }
+// { dg-do compile { target c++23 } }
+
+#include <type_traits>
+
+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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++23" }
+// { dg-do compile { target c++23 } }
+
+#include <type_traits>
+
+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" }
--
2.34.1
reply other threads:[~2022-12-28 14:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y6xSiYH9k9JrId6H@Thaum.localdomain \
--to=nathanieloshead@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).