From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Remove redundant noexcept-specifier on definitions
Date: Tue, 31 Aug 2021 17:49:46 +0100 [thread overview]
Message-ID: <YS5dqtCWWW/kgETK@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 785 bytes --]
These destructors are noexcept anyway. I removed the redundant noexcept
from the error_category destructor's declaration in r0-123475, but
didn't remove it from the defaulted definition in system_error.cc. That
causes warnings if the library is built with Clang.
This removes the redundant noexcept from ~error_category and
~system_error and adds tests to ensure they really are noexcept.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* src/c++11/system_error.cc (error_category::~error_category()):
Remove noexcept-specifier.
(system_error::~system_error()): Likewise.
* testsuite/19_diagnostics/error_category/noexcept.cc: New test.
* testsuite/19_diagnostics/system_error/noexcept.cc: New test.
Tested powerpc64le-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3356 bytes --]
commit f63e86f797d82772c62a7475dbc6e881727b666f
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Aug 31 16:30:01 2021
libstdc++: Remove redundant noexcept-specifier on definitions
These destructors are noexcept anyway. I removed the redundant noexcept
from the error_category destructor's declaration in r0-123475, but
didn't remove it from the defaulted definition in system_error.cc. That
causes warnings if the library is built with Clang.
This removes the redundant noexcept from ~error_category and
~system_error and adds tests to ensure they really are noexcept.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* src/c++11/system_error.cc (error_category::~error_category()):
Remove noexcept-specifier.
(system_error::~system_error()): Likewise.
* testsuite/19_diagnostics/error_category/noexcept.cc: New test.
* testsuite/19_diagnostics/system_error/noexcept.cc: New test.
diff --git a/libstdc++-v3/src/c++11/system_error.cc b/libstdc++-v3/src/c++11/system_error.cc
index 23fb6182825..f12290adaee 100644
--- a/libstdc++-v3/src/c++11/system_error.cc
+++ b/libstdc++-v3/src/c++11/system_error.cc
@@ -338,7 +338,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_THROW_OR_ABORT(system_error(error_code(__i, generic_category())));
}
- error_category::~error_category() noexcept = default;
+ error_category::~error_category() = default;
const error_category&
_V2::system_category() noexcept { return system_category_instance; }
@@ -346,7 +346,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const error_category&
_V2::generic_category() noexcept { return generic_category_instance; }
- system_error::~system_error() noexcept = default;
+ system_error::~system_error() = default;
error_condition
error_category::default_error_condition(int __i) const noexcept
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_category/noexcept.cc b/libstdc++-v3/testsuite/19_diagnostics/error_category/noexcept.cc
new file mode 100644
index 00000000000..210344c7607
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_category/noexcept.cc
@@ -0,0 +1,13 @@
+// { dg-do compile { target c++11 } }
+#include <system_error>
+
+extern const std::error_category& cat;
+
+static_assert(std::is_nothrow_destructible<std::error_category>::value, "");
+static_assert(noexcept(cat.name()), "");
+static_assert(noexcept(cat.default_error_condition(1)), "");
+static_assert(noexcept(cat.equivalent(1, {})), "");
+static_assert(noexcept(cat.equivalent({}, 1)), "");
+static_assert(noexcept(cat == cat), "");
+static_assert(noexcept(cat != cat), "");
+static_assert(noexcept(cat < cat), "");
diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/noexcept.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/noexcept.cc
new file mode 100644
index 00000000000..853b7f922b6
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/noexcept.cc
@@ -0,0 +1,6 @@
+// { dg-do compile { target c++11 } }
+#include <system_error>
+
+static_assert(std::is_nothrow_destructible<std::system_error>::value, "");
+static_assert(noexcept(std::declval<const std::system_error&>().code()), "");
+static_assert(noexcept(std::declval<const std::system_error&>().what()), "");
reply other threads:[~2021-08-31 16:49 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=YS5dqtCWWW/kgETK@redhat.com \
--to=jwakely@redhat.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).