mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-20 01:25:03 +08:00
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.
This commit is contained in:
parent
763eb1f192
commit
f63e86f797
@ -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
|
||||
|
@ -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), "");
|
@ -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()), "");
|
Loading…
Reference in New Issue
Block a user