diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2011-12-06 20:03:25 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2011-12-06 20:03:25 +0000 |
commit | 8535715d0fb7c430787c257a9fc14cb34794e676 (patch) | |
tree | d7d90c64c9fb734a886b94cbda14b7158939c565 | |
parent | 0e642d0671db79acb4bccc4268e461fdcf5c1cdf (diff) | |
download | gcc-8535715d0fb7c430787c257a9fc14cb34794e676.zip gcc-8535715d0fb7c430787c257a9fc14cb34794e676.tar.gz gcc-8535715d0fb7c430787c257a9fc14cb34794e676.tar.bz2 |
re PR libstdc++/51438 (std::exception and derived classes are not compatible with std::nested_exception and C++11 in general)
2011-12-06 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/51438
* libsupc++/nested_exception.h (nested_exception::~nested_exception):
Declare noexcept.
* libsupc++/nested_exception.cc: Adjust.
* testsuite/18_support/nested_exception/51438.cc: New.
* testsuite/18_support/nested_exception/throw_with_nested.cc: Adjust.
* testsuite/18_support/nested_exception/rethrow_if_nested.cc:
Likewise.
* src/shared_ptr.cc: Use noexcept where appropriate.
* include/std/system_error: Likewise.
* include/std/functional: Likewise.
* include/bits/shared_ptr_base.h: Likewise.
* src/stdexcept.cc: Use _GLIBCXX_USE_NOEXCEPT where appropriate.
* include/std/stdexcept: Likewise.
* libsupc++/bad_cast.cc: Likewise.
* libsupc++/bad_typeid.cc: Likewise.
* libsupc++/eh_exception.cc: Likewise.
* libsupc++/typeinfo: Likewise.
* libsupc++/exception: Likewise.
* libsupc++/eh_ptr.cc: Likewise.
* libsupc++/bad_alloc.cc: Likewise.
* libsupc++/exception_ptr.h: Likewise.
* include/std/chrono: Use noexcept where appropriate.
* src/chrono.cc: Likewise.
From-SVN: r182064
22 files changed, 190 insertions, 117 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b93cc65..065b635 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,32 @@ +2011-12-06 Paolo Carlini <paolo.carlini@oracle.com> + + PR libstdc++/51438 + * libsupc++/nested_exception.h (nested_exception::~nested_exception): + Declare noexcept. + * libsupc++/nested_exception.cc: Adjust. + * testsuite/18_support/nested_exception/51438.cc: New. + * testsuite/18_support/nested_exception/throw_with_nested.cc: Adjust. + * testsuite/18_support/nested_exception/rethrow_if_nested.cc: + Likewise. + + * src/shared_ptr.cc: Use noexcept where appropriate. + * include/std/system_error: Likewise. + * include/std/functional: Likewise. + * include/bits/shared_ptr_base.h: Likewise. + * src/stdexcept.cc: Use _GLIBCXX_USE_NOEXCEPT where appropriate. + * include/std/stdexcept: Likewise. + * libsupc++/bad_cast.cc: Likewise. + * libsupc++/bad_typeid.cc: Likewise. + * libsupc++/eh_exception.cc: Likewise. + * libsupc++/typeinfo: Likewise. + * libsupc++/exception: Likewise. + * libsupc++/eh_ptr.cc: Likewise. + * libsupc++/bad_alloc.cc: Likewise. + * libsupc++/exception_ptr.h: Likewise. + + * include/std/chrono: Use noexcept where appropriate. + * src/chrono.cc: Likewise. + 2011-12-06 Jonathan Wakely <jwakely.gcc@gmail.com> Chris Jefferson <chris@bubblescope.net> diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index c067754..c024b70 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -63,7 +63,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION virtual char const* what() const noexcept; - virtual ~bad_weak_ptr() throw(); + virtual ~bad_weak_ptr() noexcept; }; // Substitute for bad_weak_ptr object in the case of -fno-exceptions. diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index 6a087f5..0806a5d 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -686,18 +686,18 @@ _GLIBCXX_END_NAMESPACE_VERSION static constexpr bool is_steady = false; static time_point - now() throw (); + now() noexcept; // Map to C API static std::time_t - to_time_t(const time_point& __t) + to_time_t(const time_point& __t) noexcept { return std::time_t(duration_cast<chrono::seconds> (__t.time_since_epoch()).count()); } static time_point - from_time_t(std::time_t __t) + from_time_t(std::time_t __t) noexcept { typedef chrono::time_point<system_clock, seconds> __from; return time_point_cast<system_clock::duration> @@ -717,7 +717,7 @@ _GLIBCXX_END_NAMESPACE_VERSION static constexpr bool is_steady = true; static time_point - now(); + now() noexcept; }; #else typedef system_clock steady_clock; diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 465fc56..4be1bc7 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -1633,7 +1633,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) class bad_function_call : public std::exception { public: - virtual ~bad_function_call() throw(); + virtual ~bad_function_call() noexcept; }; /** diff --git a/libstdc++-v3/include/std/stdexcept b/libstdc++-v3/include/std/stdexcept index a461795..2cbf207 100644 --- a/libstdc++-v3/include/std/stdexcept +++ b/libstdc++-v3/include/std/stdexcept @@ -62,12 +62,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit logic_error(const string& __arg); - virtual ~logic_error() throw(); + virtual ~logic_error() _GLIBCXX_USE_NOEXCEPT; /** Returns a C-style character string describing the general cause of * the current error (the same string passed to the ctor). */ virtual const char* - what() const throw(); + what() const _GLIBCXX_USE_NOEXCEPT; }; /** Thrown by the library, or by you, to report domain errors (domain in @@ -76,7 +76,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { public: explicit domain_error(const string& __arg); - virtual ~domain_error() throw(); + virtual ~domain_error() _GLIBCXX_USE_NOEXCEPT; }; /** Thrown to report invalid arguments to functions. */ @@ -84,7 +84,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { public: explicit invalid_argument(const string& __arg); - virtual ~invalid_argument() throw(); + virtual ~invalid_argument() _GLIBCXX_USE_NOEXCEPT; }; /** Thrown when an object is constructed that would exceed its maximum @@ -93,7 +93,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { public: explicit length_error(const string& __arg); - virtual ~length_error() throw(); + virtual ~length_error() _GLIBCXX_USE_NOEXCEPT; }; /** This represents an argument whose value is not within the expected @@ -102,7 +102,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { public: explicit out_of_range(const string& __arg); - virtual ~out_of_range() throw(); + virtual ~out_of_range() _GLIBCXX_USE_NOEXCEPT; }; /** Runtime errors represent problems outside the scope of a program; @@ -119,12 +119,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit runtime_error(const string& __arg); - virtual ~runtime_error() throw(); + virtual ~runtime_error() _GLIBCXX_USE_NOEXCEPT; /** Returns a C-style character string describing the general cause of * the current error (the same string passed to the ctor). */ virtual const char* - what() const throw(); + what() const _GLIBCXX_USE_NOEXCEPT; }; /** Thrown to indicate range errors in internal computations. */ @@ -132,7 +132,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { public: explicit range_error(const string& __arg); - virtual ~range_error() throw(); + virtual ~range_error() _GLIBCXX_USE_NOEXCEPT; }; /** Thrown to indicate arithmetic overflow. */ @@ -140,7 +140,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { public: explicit overflow_error(const string& __arg); - virtual ~overflow_error() throw(); + virtual ~overflow_error() _GLIBCXX_USE_NOEXCEPT; }; /** Thrown to indicate arithmetic underflow. */ @@ -148,7 +148,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { public: explicit underflow_error(const string& __arg); - virtual ~underflow_error() throw(); + virtual ~underflow_error() _GLIBCXX_USE_NOEXCEPT; }; // @} group exceptions diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error index 19482bc..129cbeef 100644 --- a/libstdc++-v3/include/std/system_error +++ b/libstdc++-v3/include/std/system_error @@ -337,7 +337,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : runtime_error(__what + ": " + error_code(__v, __ecat).message()), _M_code(__v, __ecat) { } - virtual ~system_error() throw(); + virtual ~system_error() noexcept; const error_code& code() const noexcept { return _M_code; } diff --git a/libstdc++-v3/libsupc++/bad_alloc.cc b/libstdc++-v3/libsupc++/bad_alloc.cc index 16076ce..b5ed6da 100644 --- a/libstdc++-v3/libsupc++/bad_alloc.cc +++ b/libstdc++-v3/libsupc++/bad_alloc.cc @@ -1,6 +1,6 @@ // Implementation file for the -*- C++ -*- dynamic memory management header. -// Copyright (C) 2010 Free Software Foundation +// Copyright (C) 2010, 2011 Free Software Foundation // // This file is part of GCC. // @@ -25,10 +25,10 @@ #include "new" -std::bad_alloc::~bad_alloc() throw() { } +std::bad_alloc::~bad_alloc() _GLIBCXX_USE_NOEXCEPT { } const char* -std::bad_alloc::what() const throw() +std::bad_alloc::what() const _GLIBCXX_USE_NOEXCEPT { return "std::bad_alloc"; } diff --git a/libstdc++-v3/libsupc++/bad_cast.cc b/libstdc++-v3/libsupc++/bad_cast.cc index 2f56e4e..e6d492d 100644 --- a/libstdc++-v3/libsupc++/bad_cast.cc +++ b/libstdc++-v3/libsupc++/bad_cast.cc @@ -1,5 +1,5 @@ // Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2007, -// 2009 Free Software Foundation +// 2009, 2010, 2011 Free Software Foundation // // This file is part of GCC. // @@ -26,10 +26,10 @@ namespace std { -bad_cast::~bad_cast() throw() { } +bad_cast::~bad_cast() _GLIBCXX_USE_NOEXCEPT { } const char* -bad_cast::what() const throw() +bad_cast::what() const _GLIBCXX_USE_NOEXCEPT { return "std::bad_cast"; } diff --git a/libstdc++-v3/libsupc++/bad_typeid.cc b/libstdc++-v3/libsupc++/bad_typeid.cc index 54d7ef5..36a0d60 100644 --- a/libstdc++-v3/libsupc++/bad_typeid.cc +++ b/libstdc++-v3/libsupc++/bad_typeid.cc @@ -1,5 +1,5 @@ // Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2007, -// 2009 Free Software Foundation +// 2009, 2010, 2011 Free Software Foundation // // This file is part of GCC. // @@ -26,10 +26,10 @@ namespace std { -bad_typeid::~bad_typeid() throw() { } +bad_typeid::~bad_typeid() _GLIBCXX_USE_NOEXCEPT { } const char* -bad_typeid::what() const throw() +bad_typeid::what() const _GLIBCXX_USE_NOEXCEPT { return "std::bad_typeid"; } diff --git a/libstdc++-v3/libsupc++/eh_exception.cc b/libstdc++-v3/libsupc++/eh_exception.cc index 2f752b3..cbdca19 100644 --- a/libstdc++-v3/libsupc++/eh_exception.cc +++ b/libstdc++-v3/libsupc++/eh_exception.cc @@ -1,6 +1,6 @@ // -*- C++ -*- std::exception implementation. // Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -// 2003, 2004, 2005, 2006, 2007, 2009 +// 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011 // Free Software Foundation // // This file is part of GCC. @@ -28,16 +28,16 @@ #include "exception" #include <cxxabi.h> -std::exception::~exception() throw() { } +std::exception::~exception() _GLIBCXX_USE_NOEXCEPT { } -std::bad_exception::~bad_exception() throw() { } +std::bad_exception::~bad_exception() _GLIBCXX_USE_NOEXCEPT { } abi::__forced_unwind::~__forced_unwind() throw() { } abi::__foreign_exception::~__foreign_exception() throw() { } const char* -std::exception::what() const throw() +std::exception::what() const _GLIBCXX_USE_NOEXCEPT { // NB: Another elegant option would be returning typeid(*this).name() // and not overriding what() in bad_exception, bad_alloc, etc. In @@ -46,7 +46,7 @@ std::exception::what() const throw() } const char* -std::bad_exception::what() const throw() +std::bad_exception::what() const _GLIBCXX_USE_NOEXCEPT { return "std::bad_exception"; } diff --git a/libstdc++-v3/libsupc++/eh_ptr.cc b/libstdc++-v3/libsupc++/eh_ptr.cc index 0e710f2..684580f 100644 --- a/libstdc++-v3/libsupc++/eh_ptr.cc +++ b/libstdc++-v3/libsupc++/eh_ptr.cc @@ -35,31 +35,33 @@ using namespace __cxxabiv1; -std::__exception_ptr::exception_ptr::exception_ptr() throw() +std::__exception_ptr::exception_ptr::exception_ptr() _GLIBCXX_USE_NOEXCEPT : _M_exception_object(0) { } -std::__exception_ptr::exception_ptr::exception_ptr(void* obj) throw() +std::__exception_ptr::exception_ptr::exception_ptr(void* obj) +_GLIBCXX_USE_NOEXCEPT : _M_exception_object(obj) { _M_addref(); } -std::__exception_ptr::exception_ptr::exception_ptr(__safe_bool) throw() +std::__exception_ptr::exception_ptr::exception_ptr(__safe_bool) +_GLIBCXX_USE_NOEXCEPT : _M_exception_object(0) { } std::__exception_ptr:: -exception_ptr::exception_ptr(const exception_ptr& other) throw() +exception_ptr::exception_ptr(const exception_ptr& other) _GLIBCXX_USE_NOEXCEPT : _M_exception_object(other._M_exception_object) { _M_addref(); } -std::__exception_ptr::exception_ptr::~exception_ptr() throw() +std::__exception_ptr::exception_ptr::~exception_ptr() _GLIBCXX_USE_NOEXCEPT { _M_release(); } std::__exception_ptr::exception_ptr& std::__exception_ptr:: -exception_ptr::operator=(const exception_ptr& other) throw() +exception_ptr::operator=(const exception_ptr& other) _GLIBCXX_USE_NOEXCEPT { exception_ptr(other).swap(*this); return *this; @@ -67,7 +69,7 @@ exception_ptr::operator=(const exception_ptr& other) throw() void -std::__exception_ptr::exception_ptr::_M_addref() throw() +std::__exception_ptr::exception_ptr::_M_addref() _GLIBCXX_USE_NOEXCEPT { if (_M_exception_object) { @@ -79,7 +81,7 @@ std::__exception_ptr::exception_ptr::_M_addref() throw() void -std::__exception_ptr::exception_ptr::_M_release() throw() +std::__exception_ptr::exception_ptr::_M_release() _GLIBCXX_USE_NOEXCEPT { if (_M_exception_object) { @@ -98,12 +100,13 @@ std::__exception_ptr::exception_ptr::_M_release() throw() void* -std::__exception_ptr::exception_ptr::_M_get() const throw() +std::__exception_ptr::exception_ptr::_M_get() const _GLIBCXX_USE_NOEXCEPT { return _M_exception_object; } void -std::__exception_ptr::exception_ptr::swap(exception_ptr &other) throw() +std::__exception_ptr::exception_ptr::swap(exception_ptr &other) + _GLIBCXX_USE_NOEXCEPT { void *tmp = _M_exception_object; _M_exception_object = other._M_exception_object; @@ -113,24 +116,27 @@ std::__exception_ptr::exception_ptr::swap(exception_ptr &other) throw() // Retained for compatibility with CXXABI_1.3. void -std::__exception_ptr::exception_ptr::_M_safe_bool_dummy() throw () { } +std::__exception_ptr::exception_ptr::_M_safe_bool_dummy() + _GLIBCXX_USE_NOEXCEPT { } // Retained for compatibility with CXXABI_1.3. bool -std::__exception_ptr::exception_ptr::operator!() const throw() +std::__exception_ptr::exception_ptr::operator!() const _GLIBCXX_USE_NOEXCEPT { return _M_exception_object == 0; } // Retained for compatibility with CXXABI_1.3. -std::__exception_ptr::exception_ptr::operator __safe_bool() const throw() +std::__exception_ptr::exception_ptr::operator __safe_bool() const +_GLIBCXX_USE_NOEXCEPT { return _M_exception_object ? &exception_ptr::_M_safe_bool_dummy : 0; } const std::type_info* -std::__exception_ptr::exception_ptr::__cxa_exception_type() const throw() +std::__exception_ptr::exception_ptr::__cxa_exception_type() const + _GLIBCXX_USE_NOEXCEPT { __cxa_exception *eh = __get_exception_header_from_obj (_M_exception_object); return eh->exceptionType; @@ -138,17 +144,19 @@ std::__exception_ptr::exception_ptr::__cxa_exception_type() const throw() bool std::__exception_ptr::operator==(const exception_ptr& lhs, - const exception_ptr& rhs) throw() + const exception_ptr& rhs) + _GLIBCXX_USE_NOEXCEPT { return lhs._M_exception_object == rhs._M_exception_object; } bool std::__exception_ptr::operator!=(const exception_ptr& lhs, - const exception_ptr& rhs) throw() + const exception_ptr& rhs) + _GLIBCXX_USE_NOEXCEPT { return !(lhs == rhs);} std::exception_ptr -std::current_exception() throw() +std::current_exception() _GLIBCXX_USE_NOEXCEPT { __cxa_eh_globals *globals = __cxa_get_globals (); __cxa_exception *header = globals->caughtExceptions; diff --git a/libstdc++-v3/libsupc++/exception b/libstdc++-v3/libsupc++/exception index 3deb45e..94a0bcb 100644 --- a/libstdc++-v3/libsupc++/exception +++ b/libstdc++-v3/libsupc++/exception @@ -62,12 +62,12 @@ namespace std class exception { public: - exception() throw() { } - virtual ~exception() throw(); + exception() _GLIBCXX_USE_NOEXCEPT { } + virtual ~exception() _GLIBCXX_USE_NOEXCEPT; /** Returns a C-style character string describing the general cause * of the current error. */ - virtual const char* what() const throw(); + virtual const char* what() const _GLIBCXX_USE_NOEXCEPT; }; /** If an %exception is thrown which is not listed in a function's @@ -75,14 +75,14 @@ namespace std class bad_exception : public exception { public: - bad_exception() throw() { } + bad_exception() _GLIBCXX_USE_NOEXCEPT { } // This declaration is not useless: // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 - virtual ~bad_exception() throw(); + virtual ~bad_exception() _GLIBCXX_USE_NOEXCEPT; // See comment in eh_exception.cc. - virtual const char* what() const throw(); + virtual const char* what() const _GLIBCXX_USE_NOEXCEPT; }; /// If you write a replacement %terminate handler, it must be of this type. @@ -92,14 +92,14 @@ namespace std typedef void (*unexpected_handler) (); /// Takes a new handler function as an argument, returns the old function. - terminate_handler set_terminate(terminate_handler) throw(); + terminate_handler set_terminate(terminate_handler) _GLIBCXX_USE_NOEXCEPT; /** The runtime will call this function if %exception handling must be * abandoned for any reason. It can also be called by the user. */ - void terminate() throw() __attribute__ ((__noreturn__)); + void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__)); /// Takes a new handler function as an argument, returns the old function. - unexpected_handler set_unexpected(unexpected_handler) throw(); + unexpected_handler set_unexpected(unexpected_handler) _GLIBCXX_USE_NOEXCEPT; /** The runtime will call this function if an %exception is thrown which * violates the function's %exception specification. */ @@ -116,7 +116,7 @@ namespace std * %exception can result in a call of @c terminate() * (15.5.1).' */ - bool uncaught_exception() throw() __attribute__ ((__pure__)); + bool uncaught_exception() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__)); // @} group exceptions } // namespace std diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h index bd18dc1..b6fd08e 100644 --- a/libstdc++-v3/libsupc++/exception_ptr.h +++ b/libstdc++-v3/libsupc++/exception_ptr.h @@ -59,7 +59,7 @@ namespace std * is none, or the currently handled exception is foreign, return the null * value. */ - exception_ptr current_exception() throw(); + exception_ptr current_exception() _GLIBCXX_USE_NOEXCEPT; /// Throw the object pointed to by the exception_ptr. void rethrow_exception(exception_ptr) __attribute__ ((__noreturn__)); @@ -74,27 +74,27 @@ namespace std { void* _M_exception_object; - explicit exception_ptr(void* __e) throw(); + explicit exception_ptr(void* __e) _GLIBCXX_USE_NOEXCEPT; - void _M_addref() throw(); - void _M_release() throw(); + void _M_addref() _GLIBCXX_USE_NOEXCEPT; + void _M_release() _GLIBCXX_USE_NOEXCEPT; - void *_M_get() const throw() __attribute__ ((__pure__)); + void *_M_get() const _GLIBCXX_NOEXCEPT __attribute__ ((__pure__)); - friend exception_ptr std::current_exception() throw(); + friend exception_ptr std::current_exception() _GLIBCXX_USE_NOEXCEPT; friend void std::rethrow_exception(exception_ptr); public: - exception_ptr() throw(); + exception_ptr() _GLIBCXX_USE_NOEXCEPT; - exception_ptr(const exception_ptr&) throw(); + exception_ptr(const exception_ptr&) _GLIBCXX_USE_NOEXCEPT; #ifdef __GXX_EXPERIMENTAL_CXX0X__ - exception_ptr(nullptr_t) throw() + exception_ptr(nullptr_t) noexcept : _M_exception_object(0) { } - exception_ptr(exception_ptr&& __o) throw() + exception_ptr(exception_ptr&& __o) noexcept : _M_exception_object(__o._M_exception_object) { __o._M_exception_object = 0; } #endif @@ -103,31 +103,33 @@ namespace std typedef void (exception_ptr::*__safe_bool)(); // For construction from nullptr or 0. - exception_ptr(__safe_bool) throw(); + exception_ptr(__safe_bool) _GLIBCXX_USE_NOEXCEPT; #endif exception_ptr& - operator=(const exception_ptr&) throw(); + operator=(const exception_ptr&) _GLIBCXX_USE_NOEXCEPT; #ifdef __GXX_EXPERIMENTAL_CXX0X__ exception_ptr& - operator=(exception_ptr&& __o) throw() + operator=(exception_ptr&& __o) noexcept { exception_ptr(static_cast<exception_ptr&&>(__o)).swap(*this); return *this; } #endif - ~exception_ptr() throw(); + ~exception_ptr() _GLIBCXX_USE_NOEXCEPT; void - swap(exception_ptr&) throw(); + swap(exception_ptr&) _GLIBCXX_USE_NOEXCEPT; #ifdef _GLIBCXX_EH_PTR_COMPAT // Retained for compatibility with CXXABI_1.3. - void _M_safe_bool_dummy() throw() __attribute__ ((__const__)); - bool operator!() const throw() __attribute__ ((__pure__)); - operator __safe_bool() const throw(); + void _M_safe_bool_dummy() _GLIBCXX_USE_NOEXCEPT + __attribute__ ((__const__)); + bool operator!() const _GLIBCXX_USE_NOEXCEPT + __attribute__ ((__pure__)); + operator __safe_bool() const _GLIBCXX_USE_NOEXCEPT; #endif #ifdef __GXX_EXPERIMENTAL_CXX0X__ @@ -136,20 +138,21 @@ namespace std #endif friend bool - operator==(const exception_ptr&, const exception_ptr&) throw() - __attribute__ ((__pure__)); + operator==(const exception_ptr&, const exception_ptr&) + _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__)); const class type_info* - __cxa_exception_type() const throw() __attribute__ ((__pure__)); + __cxa_exception_type() const _GLIBCXX_USE_NOEXCEPT + __attribute__ ((__pure__)); }; bool - operator==(const exception_ptr&, const exception_ptr&) throw() - __attribute__ ((__pure__)); + operator==(const exception_ptr&, const exception_ptr&) + _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__)); bool - operator!=(const exception_ptr&, const exception_ptr&) throw() - __attribute__ ((__pure__)); + operator!=(const exception_ptr&, const exception_ptr&) + _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__)); inline void swap(exception_ptr& __lhs, exception_ptr& __rhs) @@ -161,7 +164,7 @@ namespace std /// Obtain an exception_ptr pointing to a copy of the supplied object. template<typename _Ex> exception_ptr - copy_exception(_Ex __ex) throw() + copy_exception(_Ex __ex) _GLIBCXX_USE_NOEXCEPT { __try { @@ -180,7 +183,7 @@ namespace std /// Obtain an exception_ptr pointing to a copy of the supplied object. template<typename _Ex> exception_ptr - make_exception_ptr(_Ex __ex) throw() + make_exception_ptr(_Ex __ex) _GLIBCXX_USE_NOEXCEPT { return std::copy_exception<_Ex>(__ex); } // @} group exceptions diff --git a/libstdc++-v3/libsupc++/nested_exception.cc b/libstdc++-v3/libsupc++/nested_exception.cc index ad83ecd..ec56369 100644 --- a/libstdc++-v3/libsupc++/nested_exception.cc +++ b/libstdc++-v3/libsupc++/nested_exception.cc @@ -26,6 +26,6 @@ namespace std { #if ATOMIC_INT_LOCK_FREE > 1 - nested_exception::~nested_exception() = default; + nested_exception::~nested_exception() noexcept = default; #endif } // namespace std diff --git a/libstdc++-v3/libsupc++/nested_exception.h b/libstdc++-v3/libsupc++/nested_exception.h index 9b99c32..d88f021 100644 --- a/libstdc++-v3/libsupc++/nested_exception.h +++ b/libstdc++-v3/libsupc++/nested_exception.h @@ -57,13 +57,13 @@ namespace std exception_ptr _M_ptr; public: - nested_exception() throw() : _M_ptr(current_exception()) { } + nested_exception() noexcept : _M_ptr(current_exception()) { } nested_exception(const nested_exception&) = default; nested_exception& operator=(const nested_exception&) = default; - virtual ~nested_exception(); + virtual ~nested_exception() noexcept; void rethrow_nested() const __attribute__ ((__noreturn__)) diff --git a/libstdc++-v3/libsupc++/typeinfo b/libstdc++-v3/libsupc++/typeinfo index 22ef49f..aaa756b 100644 --- a/libstdc++-v3/libsupc++/typeinfo +++ b/libstdc++-v3/libsupc++/typeinfo @@ -190,14 +190,14 @@ namespace std class bad_cast : public exception { public: - bad_cast() throw() { } + bad_cast() _GLIBCXX_USE_NOEXCEPT { } // This declaration is not useless: // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 - virtual ~bad_cast() throw(); + virtual ~bad_cast() _GLIBCXX_USE_NOEXCEPT; // See comment in eh_exception.cc. - virtual const char* what() const throw(); + virtual const char* what() const _GLIBCXX_USE_NOEXCEPT; }; /** @@ -207,14 +207,14 @@ namespace std class bad_typeid : public exception { public: - bad_typeid () throw() { } + bad_typeid () _GLIBCXX_USE_NOEXCEPT { } // This declaration is not useless: // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 - virtual ~bad_typeid() throw(); + virtual ~bad_typeid() _GLIBCXX_USE_NOEXCEPT; // See comment in eh_exception.cc. - virtual const char* what() const throw(); + virtual const char* what() const _GLIBCXX_USE_NOEXCEPT; }; } // namespace std diff --git a/libstdc++-v3/src/chrono.cc b/libstdc++-v3/src/chrono.cc index 07c932a..17b3402 100644 --- a/libstdc++-v3/src/chrono.cc +++ b/libstdc++-v3/src/chrono.cc @@ -42,7 +42,7 @@ namespace std _GLIBCXX_VISIBILITY(default) constexpr bool system_clock::is_steady; system_clock::time_point - system_clock::now() throw () + system_clock::now() noexcept { #ifdef _GLIBCXX_USE_CLOCK_REALTIME timespec tp; @@ -64,9 +64,9 @@ namespace std _GLIBCXX_VISIBILITY(default) #ifdef _GLIBCXX_USE_CLOCK_MONOTONIC constexpr bool steady_clock::is_steady; - + steady_clock::time_point - steady_clock::now() + steady_clock::now() noexcept { timespec tp; // -EINVAL, -EFAULT diff --git a/libstdc++-v3/src/shared_ptr.cc b/libstdc++-v3/src/shared_ptr.cc index 670b7ca..911e745 100644 --- a/libstdc++-v3/src/shared_ptr.cc +++ b/libstdc++-v3/src/shared_ptr.cc @@ -29,10 +29,10 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION - bad_weak_ptr::~bad_weak_ptr() throw() = default; + bad_weak_ptr::~bad_weak_ptr() noexcept = default; char const* - bad_weak_ptr::what() const throw() + bad_weak_ptr::what() const noexcept { return "std::bad_weak_ptr"; } _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/src/stdexcept.cc b/libstdc++-v3/src/stdexcept.cc index b693da2..dbc8f40 100644 --- a/libstdc++-v3/src/stdexcept.cc +++ b/libstdc++-v3/src/stdexcept.cc @@ -37,55 +37,55 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION logic_error::logic_error(const string& __arg) : exception(), _M_msg(__arg) { } - logic_error::~logic_error() throw() { } + logic_error::~logic_error() _GLIBCXX_USE_NOEXCEPT { } const char* - logic_error::what() const throw() + logic_error::what() const _GLIBCXX_USE_NOEXCEPT { return _M_msg.c_str(); } domain_error::domain_error(const string& __arg) : logic_error(__arg) { } - domain_error::~domain_error() throw() { } + domain_error::~domain_error() _GLIBCXX_USE_NOEXCEPT { } invalid_argument::invalid_argument(const string& __arg) : logic_error(__arg) { } - invalid_argument::~invalid_argument() throw() { } + invalid_argument::~invalid_argument() _GLIBCXX_USE_NOEXCEPT { } length_error::length_error(const string& __arg) : logic_error(__arg) { } - length_error::~length_error() throw() { } + length_error::~length_error() _GLIBCXX_USE_NOEXCEPT { } out_of_range::out_of_range(const string& __arg) : logic_error(__arg) { } - out_of_range::~out_of_range() throw() { } + out_of_range::~out_of_range() _GLIBCXX_USE_NOEXCEPT { } runtime_error::runtime_error(const string& __arg) : exception(), _M_msg(__arg) { } - runtime_error::~runtime_error() throw() { } + runtime_error::~runtime_error() _GLIBCXX_USE_NOEXCEPT { } const char* - runtime_error::what() const throw() + runtime_error::what() const _GLIBCXX_USE_NOEXCEPT { return _M_msg.c_str(); } range_error::range_error(const string& __arg) : runtime_error(__arg) { } - range_error::~range_error() throw() { } + range_error::~range_error() _GLIBCXX_USE_NOEXCEPT { } overflow_error::overflow_error(const string& __arg) : runtime_error(__arg) { } - overflow_error::~overflow_error() throw() { } + overflow_error::~overflow_error() _GLIBCXX_USE_NOEXCEPT { } underflow_error::underflow_error(const string& __arg) : runtime_error(__arg) { } - underflow_error::~underflow_error() throw() { } + underflow_error::~underflow_error() _GLIBCXX_USE_NOEXCEPT { } _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/testsuite/18_support/nested_exception/51438.cc b/libstdc++-v3/testsuite/18_support/nested_exception/51438.cc new file mode 100644 index 0000000..f4a81ff --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/nested_exception/51438.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } +// { dg-require-atomic-builtins "" } + +// Copyright (C) 2011 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/>. + +#include <exception> +#include <stdexcept> + +// libstdc++/51438 +void test() +{ + try { + throw 2; + } catch(int) { + std::throw_with_nested(std::runtime_error("test")); + } +} diff --git a/libstdc++-v3/testsuite/18_support/nested_exception/rethrow_if_nested.cc b/libstdc++-v3/testsuite/18_support/nested_exception/rethrow_if_nested.cc index ec8d172..f76cbdf 100644 --- a/libstdc++-v3/testsuite/18_support/nested_exception/rethrow_if_nested.cc +++ b/libstdc++-v3/testsuite/18_support/nested_exception/rethrow_if_nested.cc @@ -1,7 +1,7 @@ // { dg-options "-std=gnu++0x" } // { dg-require-atomic-builtins "" } -// Copyright (C) 2009 Free Software Foundation, Inc. +// Copyright (C) 2009, 2010, 2011 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 @@ -23,8 +23,8 @@ struct derived : std::nested_exception { }; -struct base { virtual ~base(); }; -inline base::~base() = default; +struct base { virtual ~base() noexcept; }; +inline base::~base() noexcept = default; struct derived2 : base, std::nested_exception { }; diff --git a/libstdc++-v3/testsuite/18_support/nested_exception/throw_with_nested.cc b/libstdc++-v3/testsuite/18_support/nested_exception/throw_with_nested.cc index c846d09..f4d8577 100644 --- a/libstdc++-v3/testsuite/18_support/nested_exception/throw_with_nested.cc +++ b/libstdc++-v3/testsuite/18_support/nested_exception/throw_with_nested.cc @@ -1,7 +1,7 @@ // { dg-options "-std=gnu++0x" } // { dg-require-atomic-builtins "" } -// Copyright (C) 2009 Free Software Foundation, Inc. +// Copyright (C) 2009, 2010, 2011 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 @@ -23,8 +23,8 @@ struct derived : std::nested_exception { }; -struct not_derived { virtual ~not_derived(); }; -inline not_derived::~not_derived() = default; +struct not_derived { virtual ~not_derived() noexcept; }; +inline not_derived::~not_derived() noexcept = default; void test01() { |