From f4130a3eb545ab1aaf3ecb44f3d06b43e3751e04 Mon Sep 17 00:00:00 2001
From: Jonathan Wakely
Date: Wed, 29 Sep 2021 21:18:42 +0100
Subject: libstdc++: Deprecate std::unexpected and handler functions
These functions have been deprecated since C++11, and were removed in
C++17. The proposal P0323 wants to reuse the name std::unexpected for a
class template, so we will need to stop defining the current function
for C++23 anyway.
This marks them as deprecated for C++11 and up, to warn users they won't
continue to be available. It disables them for C++17 and up, unless the
_GLIBCXX_USE_DEPRECATED macro is defined.
The header uses std::unexpected_handler in the public
API, but since that type is the same as std::terminate_handler we can
just use that instead, to avoid warnings about it being deprecated.
libstdc++-v3/ChangeLog:
* doc/xml/manual/evolution.xml: Document deprecations.
* doc/html/*: Regenerate.
* libsupc++/exception (unexpected_handler, unexpected)
(get_unexpected, set_unexpected): Add deprecated attribute.
Do not define without _GLIBCXX_USE_DEPRECATED for C++17 and up.
* libsupc++/eh_personality.cc (PERSONALITY_FUNCTION): Disable
deprecated warnings.
* libsupc++/eh_ptr.cc (std::rethrow_exception): Likewise.
* libsupc++/eh_terminate.cc: Likewise.
* libsupc++/eh_throw.cc (__cxa_init_primary_exception):
Likewise.
* libsupc++/unwind-cxx.h (struct __cxa_exception): Use
terminate_handler instead of unexpected_handler.
(struct __cxa_dependent_exception): Likewise.
(__unexpected): Likewise.
* testsuite/18_support/headers/exception/synopsis.cc: Add
dg-warning for deprecated warning.
* testsuite/18_support/exception_ptr/60612-unexpected.cc:
Disable deprecated warnings.
* testsuite/18_support/set_unexpected.cc: Likewise.
* testsuite/18_support/unexpected_handler.cc: Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/lambda/lambda-eh2.C: Add dg-warning for new
deprecation warnings.
* g++.dg/cpp0x/noexcept06.C: Likewise.
* g++.dg/cpp0x/noexcept07.C: Likewise.
* g++.dg/eh/forced3.C: Likewise.
* g++.dg/eh/unexpected1.C: Likewise.
* g++.old-deja/g++.eh/spec1.C: Likewise.
* g++.old-deja/g++.eh/spec2.C: Likewise.
* g++.old-deja/g++.eh/spec3.C: Likewise.
* g++.old-deja/g++.eh/spec4.C: Likewise.
* g++.old-deja/g++.mike/eh33.C: Likewise.
* g++.old-deja/g++.mike/eh34.C: Likewise.
* g++.old-deja/g++.mike/eh50.C: Likewise.
* g++.old-deja/g++.mike/eh51.C: Likewise.
---
libstdc++-v3/doc/html/manual/api.html | 4 ++++
libstdc++-v3/doc/xml/manual/evolution.xml | 6 +++++
libstdc++-v3/libsupc++/eh_personality.cc | 9 +++++---
libstdc++-v3/libsupc++/eh_ptr.cc | 3 +++
libstdc++-v3/libsupc++/eh_terminate.cc | 1 +
libstdc++-v3/libsupc++/eh_throw.cc | 3 +++
libstdc++-v3/libsupc++/exception | 27 +++++++++++++++++-----
libstdc++-v3/libsupc++/unwind-cxx.h | 8 +++----
.../18_support/exception_ptr/60612-unexpected.cc | 1 +
.../18_support/headers/exception/synopsis.cc | 2 +-
.../testsuite/18_support/set_unexpected.cc | 2 +-
.../testsuite/18_support/unexpected_handler.cc | 1 +
12 files changed, 52 insertions(+), 15 deletions(-)
(limited to 'libstdc++-v3')
diff --git a/libstdc++-v3/doc/html/manual/api.html b/libstdc++-v3/doc/html/manual/api.html
index 376a403..3281078 100644
--- a/libstdc++-v3/doc/html/manual/api.html
+++ b/libstdc++-v3/doc/html/manual/api.html
@@ -440,4 +440,8 @@ now defaults to zero.
The std::random_shuffle
algorithms are deprecated
for C++14 and later. The C++11 std::shuffle
algorithm
can be used instead.
+
+The std::unexpected
function and related typedef and
+accessors for the unexpected handler are deprecated for C++11 and later.
+Dynamic exception specifications should be replaced with noexcept
.