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
This commit is contained in:
Paolo Carlini 2011-12-06 20:03:25 +00:00 committed by Paolo Carlini
parent 0e642d0671
commit 8535715d0f
22 changed files with 190 additions and 117 deletions

View File

@ -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> 2011-12-06 Jonathan Wakely <jwakely.gcc@gmail.com>
Chris Jefferson <chris@bubblescope.net> Chris Jefferson <chris@bubblescope.net>

View File

@ -63,7 +63,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
virtual char const* virtual char const*
what() const noexcept; 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. // Substitute for bad_weak_ptr object in the case of -fno-exceptions.

View File

@ -686,18 +686,18 @@ _GLIBCXX_END_NAMESPACE_VERSION
static constexpr bool is_steady = false; static constexpr bool is_steady = false;
static time_point static time_point
now() throw (); now() noexcept;
// Map to C API // Map to C API
static std::time_t 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> return std::time_t(duration_cast<chrono::seconds>
(__t.time_since_epoch()).count()); (__t.time_since_epoch()).count());
} }
static time_point 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; typedef chrono::time_point<system_clock, seconds> __from;
return time_point_cast<system_clock::duration> return time_point_cast<system_clock::duration>
@ -717,7 +717,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
static constexpr bool is_steady = true; static constexpr bool is_steady = true;
static time_point static time_point
now(); now() noexcept;
}; };
#else #else
typedef system_clock steady_clock; typedef system_clock steady_clock;

View File

@ -1633,7 +1633,7 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type)
class bad_function_call : public std::exception class bad_function_call : public std::exception
{ {
public: public:
virtual ~bad_function_call() throw(); virtual ~bad_function_call() noexcept;
}; };
/** /**

View File

@ -62,12 +62,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
explicit explicit
logic_error(const string& __arg); 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 /** Returns a C-style character string describing the general cause of
* the current error (the same string passed to the ctor). */ * the current error (the same string passed to the ctor). */
virtual const char* virtual const char*
what() const throw(); what() const _GLIBCXX_USE_NOEXCEPT;
}; };
/** Thrown by the library, or by you, to report domain errors (domain in /** Thrown by the library, or by you, to report domain errors (domain in
@ -76,7 +76,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ {
public: public:
explicit domain_error(const string& __arg); explicit domain_error(const string& __arg);
virtual ~domain_error() throw(); virtual ~domain_error() _GLIBCXX_USE_NOEXCEPT;
}; };
/** Thrown to report invalid arguments to functions. */ /** Thrown to report invalid arguments to functions. */
@ -84,7 +84,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ {
public: public:
explicit invalid_argument(const string& __arg); 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 /** Thrown when an object is constructed that would exceed its maximum
@ -93,7 +93,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ {
public: public:
explicit length_error(const string& __arg); 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 /** This represents an argument whose value is not within the expected
@ -102,7 +102,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ {
public: public:
explicit out_of_range(const string& __arg); 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; /** Runtime errors represent problems outside the scope of a program;
@ -119,12 +119,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
explicit explicit
runtime_error(const string& __arg); 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 /** Returns a C-style character string describing the general cause of
* the current error (the same string passed to the ctor). */ * the current error (the same string passed to the ctor). */
virtual const char* virtual const char*
what() const throw(); what() const _GLIBCXX_USE_NOEXCEPT;
}; };
/** Thrown to indicate range errors in internal computations. */ /** Thrown to indicate range errors in internal computations. */
@ -132,7 +132,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ {
public: public:
explicit range_error(const string& __arg); explicit range_error(const string& __arg);
virtual ~range_error() throw(); virtual ~range_error() _GLIBCXX_USE_NOEXCEPT;
}; };
/** Thrown to indicate arithmetic overflow. */ /** Thrown to indicate arithmetic overflow. */
@ -140,7 +140,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ {
public: public:
explicit overflow_error(const string& __arg); explicit overflow_error(const string& __arg);
virtual ~overflow_error() throw(); virtual ~overflow_error() _GLIBCXX_USE_NOEXCEPT;
}; };
/** Thrown to indicate arithmetic underflow. */ /** Thrown to indicate arithmetic underflow. */
@ -148,7 +148,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ {
public: public:
explicit underflow_error(const string& __arg); explicit underflow_error(const string& __arg);
virtual ~underflow_error() throw(); virtual ~underflow_error() _GLIBCXX_USE_NOEXCEPT;
}; };
// @} group exceptions // @} group exceptions

View File

@ -337,7 +337,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: runtime_error(__what + ": " + error_code(__v, __ecat).message()), : runtime_error(__what + ": " + error_code(__v, __ecat).message()),
_M_code(__v, __ecat) { } _M_code(__v, __ecat) { }
virtual ~system_error() throw(); virtual ~system_error() noexcept;
const error_code& const error_code&
code() const noexcept { return _M_code; } code() const noexcept { return _M_code; }

View File

@ -1,6 +1,6 @@
// Implementation file for the -*- C++ -*- dynamic memory management header. // 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. // This file is part of GCC.
// //
@ -25,10 +25,10 @@
#include "new" #include "new"
std::bad_alloc::~bad_alloc() throw() { } std::bad_alloc::~bad_alloc() _GLIBCXX_USE_NOEXCEPT { }
const char* const char*
std::bad_alloc::what() const throw() std::bad_alloc::what() const _GLIBCXX_USE_NOEXCEPT
{ {
return "std::bad_alloc"; return "std::bad_alloc";
} }

View File

@ -1,5 +1,5 @@
// Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2007, // 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. // This file is part of GCC.
// //
@ -26,10 +26,10 @@
namespace std { namespace std {
bad_cast::~bad_cast() throw() { } bad_cast::~bad_cast() _GLIBCXX_USE_NOEXCEPT { }
const char* const char*
bad_cast::what() const throw() bad_cast::what() const _GLIBCXX_USE_NOEXCEPT
{ {
return "std::bad_cast"; return "std::bad_cast";
} }

View File

@ -1,5 +1,5 @@
// Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2007, // 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. // This file is part of GCC.
// //
@ -26,10 +26,10 @@
namespace std { namespace std {
bad_typeid::~bad_typeid() throw() { } bad_typeid::~bad_typeid() _GLIBCXX_USE_NOEXCEPT { }
const char* const char*
bad_typeid::what() const throw() bad_typeid::what() const _GLIBCXX_USE_NOEXCEPT
{ {
return "std::bad_typeid"; return "std::bad_typeid";
} }

View File

@ -1,6 +1,6 @@
// -*- C++ -*- std::exception implementation. // -*- C++ -*- std::exception implementation.
// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, // 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 // Free Software Foundation
// //
// This file is part of GCC. // This file is part of GCC.
@ -28,16 +28,16 @@
#include "exception" #include "exception"
#include <cxxabi.h> #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::__forced_unwind::~__forced_unwind() throw() { }
abi::__foreign_exception::~__foreign_exception() throw() { } abi::__foreign_exception::~__foreign_exception() throw() { }
const char* const char*
std::exception::what() const throw() std::exception::what() const _GLIBCXX_USE_NOEXCEPT
{ {
// NB: Another elegant option would be returning typeid(*this).name() // NB: Another elegant option would be returning typeid(*this).name()
// and not overriding what() in bad_exception, bad_alloc, etc. In // and not overriding what() in bad_exception, bad_alloc, etc. In
@ -46,7 +46,7 @@ std::exception::what() const throw()
} }
const char* const char*
std::bad_exception::what() const throw() std::bad_exception::what() const _GLIBCXX_USE_NOEXCEPT
{ {
return "std::bad_exception"; return "std::bad_exception";
} }

View File

@ -35,31 +35,33 @@
using namespace __cxxabiv1; 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) { } : _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(); } : _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) { } : _M_exception_object(0) { }
std::__exception_ptr:: 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_exception_object(other._M_exception_object)
{ _M_addref(); } { _M_addref(); }
std::__exception_ptr::exception_ptr::~exception_ptr() throw() std::__exception_ptr::exception_ptr::~exception_ptr() _GLIBCXX_USE_NOEXCEPT
{ _M_release(); } { _M_release(); }
std::__exception_ptr::exception_ptr& std::__exception_ptr::exception_ptr&
std::__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); exception_ptr(other).swap(*this);
return *this; return *this;
@ -67,7 +69,7 @@ exception_ptr::operator=(const exception_ptr& other) throw()
void void
std::__exception_ptr::exception_ptr::_M_addref() throw() std::__exception_ptr::exception_ptr::_M_addref() _GLIBCXX_USE_NOEXCEPT
{ {
if (_M_exception_object) if (_M_exception_object)
{ {
@ -79,7 +81,7 @@ std::__exception_ptr::exception_ptr::_M_addref() throw()
void void
std::__exception_ptr::exception_ptr::_M_release() throw() std::__exception_ptr::exception_ptr::_M_release() _GLIBCXX_USE_NOEXCEPT
{ {
if (_M_exception_object) if (_M_exception_object)
{ {
@ -98,12 +100,13 @@ std::__exception_ptr::exception_ptr::_M_release() throw()
void* 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; } { return _M_exception_object; }
void 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; void *tmp = _M_exception_object;
_M_exception_object = other._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. // Retained for compatibility with CXXABI_1.3.
void 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. // Retained for compatibility with CXXABI_1.3.
bool bool
std::__exception_ptr::exception_ptr::operator!() const throw() std::__exception_ptr::exception_ptr::operator!() const _GLIBCXX_USE_NOEXCEPT
{ return _M_exception_object == 0; } { return _M_exception_object == 0; }
// Retained for compatibility with CXXABI_1.3. // 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; return _M_exception_object ? &exception_ptr::_M_safe_bool_dummy : 0;
} }
const std::type_info* 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); __cxa_exception *eh = __get_exception_header_from_obj (_M_exception_object);
return eh->exceptionType; 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, 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; } { return lhs._M_exception_object == rhs._M_exception_object; }
bool std::__exception_ptr::operator!=(const exception_ptr& lhs, bool std::__exception_ptr::operator!=(const exception_ptr& lhs,
const exception_ptr& rhs) throw() const exception_ptr& rhs)
_GLIBCXX_USE_NOEXCEPT
{ return !(lhs == rhs);} { return !(lhs == rhs);}
std::exception_ptr std::exception_ptr
std::current_exception() throw() std::current_exception() _GLIBCXX_USE_NOEXCEPT
{ {
__cxa_eh_globals *globals = __cxa_get_globals (); __cxa_eh_globals *globals = __cxa_get_globals ();
__cxa_exception *header = globals->caughtExceptions; __cxa_exception *header = globals->caughtExceptions;

View File

@ -62,12 +62,12 @@ namespace std
class exception class exception
{ {
public: public:
exception() throw() { } exception() _GLIBCXX_USE_NOEXCEPT { }
virtual ~exception() throw(); virtual ~exception() _GLIBCXX_USE_NOEXCEPT;
/** Returns a C-style character string describing the general cause /** Returns a C-style character string describing the general cause
* of the current error. */ * 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 /** If an %exception is thrown which is not listed in a function's
@ -75,14 +75,14 @@ namespace std
class bad_exception : public exception class bad_exception : public exception
{ {
public: public:
bad_exception() throw() { } bad_exception() _GLIBCXX_USE_NOEXCEPT { }
// This declaration is not useless: // This declaration is not useless:
// http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 // 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. // 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. /// If you write a replacement %terminate handler, it must be of this type.
@ -92,14 +92,14 @@ namespace std
typedef void (*unexpected_handler) (); typedef void (*unexpected_handler) ();
/// Takes a new handler function as an argument, returns the old function. /// 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 /** The runtime will call this function if %exception handling must be
* abandoned for any reason. It can also be called by the user. */ * 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. /// 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 /** The runtime will call this function if an %exception is thrown which
* violates the function's %exception specification. */ * violates the function's %exception specification. */
@ -116,7 +116,7 @@ namespace std
* %exception can result in a call of @c terminate() * %exception can result in a call of @c terminate()
* (15.5.1).' * (15.5.1).'
*/ */
bool uncaught_exception() throw() __attribute__ ((__pure__)); bool uncaught_exception() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
// @} group exceptions // @} group exceptions
} // namespace std } // namespace std

View File

@ -59,7 +59,7 @@ namespace std
* is none, or the currently handled exception is foreign, return the null * is none, or the currently handled exception is foreign, return the null
* value. * value.
*/ */
exception_ptr current_exception() throw(); exception_ptr current_exception() _GLIBCXX_USE_NOEXCEPT;
/// Throw the object pointed to by the exception_ptr. /// Throw the object pointed to by the exception_ptr.
void rethrow_exception(exception_ptr) __attribute__ ((__noreturn__)); void rethrow_exception(exception_ptr) __attribute__ ((__noreturn__));
@ -74,27 +74,27 @@ namespace std
{ {
void* _M_exception_object; void* _M_exception_object;
explicit exception_ptr(void* __e) throw(); explicit exception_ptr(void* __e) _GLIBCXX_USE_NOEXCEPT;
void _M_addref() throw(); void _M_addref() _GLIBCXX_USE_NOEXCEPT;
void _M_release() throw(); 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); friend void std::rethrow_exception(exception_ptr);
public: 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__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
exception_ptr(nullptr_t) throw() exception_ptr(nullptr_t) noexcept
: _M_exception_object(0) : _M_exception_object(0)
{ } { }
exception_ptr(exception_ptr&& __o) throw() exception_ptr(exception_ptr&& __o) noexcept
: _M_exception_object(__o._M_exception_object) : _M_exception_object(__o._M_exception_object)
{ __o._M_exception_object = 0; } { __o._M_exception_object = 0; }
#endif #endif
@ -103,31 +103,33 @@ namespace std
typedef void (exception_ptr::*__safe_bool)(); typedef void (exception_ptr::*__safe_bool)();
// For construction from nullptr or 0. // For construction from nullptr or 0.
exception_ptr(__safe_bool) throw(); exception_ptr(__safe_bool) _GLIBCXX_USE_NOEXCEPT;
#endif #endif
exception_ptr& exception_ptr&
operator=(const exception_ptr&) throw(); operator=(const exception_ptr&) _GLIBCXX_USE_NOEXCEPT;
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
exception_ptr& exception_ptr&
operator=(exception_ptr&& __o) throw() operator=(exception_ptr&& __o) noexcept
{ {
exception_ptr(static_cast<exception_ptr&&>(__o)).swap(*this); exception_ptr(static_cast<exception_ptr&&>(__o)).swap(*this);
return *this; return *this;
} }
#endif #endif
~exception_ptr() throw(); ~exception_ptr() _GLIBCXX_USE_NOEXCEPT;
void void
swap(exception_ptr&) throw(); swap(exception_ptr&) _GLIBCXX_USE_NOEXCEPT;
#ifdef _GLIBCXX_EH_PTR_COMPAT #ifdef _GLIBCXX_EH_PTR_COMPAT
// Retained for compatibility with CXXABI_1.3. // Retained for compatibility with CXXABI_1.3.
void _M_safe_bool_dummy() throw() __attribute__ ((__const__)); void _M_safe_bool_dummy() _GLIBCXX_USE_NOEXCEPT
bool operator!() const throw() __attribute__ ((__pure__)); __attribute__ ((__const__));
operator __safe_bool() const throw(); bool operator!() const _GLIBCXX_USE_NOEXCEPT
__attribute__ ((__pure__));
operator __safe_bool() const _GLIBCXX_USE_NOEXCEPT;
#endif #endif
#ifdef __GXX_EXPERIMENTAL_CXX0X__ #ifdef __GXX_EXPERIMENTAL_CXX0X__
@ -136,20 +138,21 @@ namespace std
#endif #endif
friend bool friend bool
operator==(const exception_ptr&, const exception_ptr&) throw() operator==(const exception_ptr&, const exception_ptr&)
__attribute__ ((__pure__)); _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
const class type_info* const class type_info*
__cxa_exception_type() const throw() __attribute__ ((__pure__)); __cxa_exception_type() const _GLIBCXX_USE_NOEXCEPT
__attribute__ ((__pure__));
}; };
bool bool
operator==(const exception_ptr&, const exception_ptr&) throw() operator==(const exception_ptr&, const exception_ptr&)
__attribute__ ((__pure__)); _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
bool bool
operator!=(const exception_ptr&, const exception_ptr&) throw() operator!=(const exception_ptr&, const exception_ptr&)
__attribute__ ((__pure__)); _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__));
inline void inline void
swap(exception_ptr& __lhs, exception_ptr& __rhs) 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. /// Obtain an exception_ptr pointing to a copy of the supplied object.
template<typename _Ex> template<typename _Ex>
exception_ptr exception_ptr
copy_exception(_Ex __ex) throw() copy_exception(_Ex __ex) _GLIBCXX_USE_NOEXCEPT
{ {
__try __try
{ {
@ -180,7 +183,7 @@ namespace std
/// Obtain an exception_ptr pointing to a copy of the supplied object. /// Obtain an exception_ptr pointing to a copy of the supplied object.
template<typename _Ex> template<typename _Ex>
exception_ptr exception_ptr
make_exception_ptr(_Ex __ex) throw() make_exception_ptr(_Ex __ex) _GLIBCXX_USE_NOEXCEPT
{ return std::copy_exception<_Ex>(__ex); } { return std::copy_exception<_Ex>(__ex); }
// @} group exceptions // @} group exceptions

View File

@ -26,6 +26,6 @@
namespace std namespace std
{ {
#if ATOMIC_INT_LOCK_FREE > 1 #if ATOMIC_INT_LOCK_FREE > 1
nested_exception::~nested_exception() = default; nested_exception::~nested_exception() noexcept = default;
#endif #endif
} // namespace std } // namespace std

View File

@ -57,13 +57,13 @@ namespace std
exception_ptr _M_ptr; exception_ptr _M_ptr;
public: public:
nested_exception() throw() : _M_ptr(current_exception()) { } nested_exception() noexcept : _M_ptr(current_exception()) { }
nested_exception(const nested_exception&) = default; nested_exception(const nested_exception&) = default;
nested_exception& operator=(const nested_exception&) = default; nested_exception& operator=(const nested_exception&) = default;
virtual ~nested_exception(); virtual ~nested_exception() noexcept;
void void
rethrow_nested() const __attribute__ ((__noreturn__)) rethrow_nested() const __attribute__ ((__noreturn__))

View File

@ -190,14 +190,14 @@ namespace std
class bad_cast : public exception class bad_cast : public exception
{ {
public: public:
bad_cast() throw() { } bad_cast() _GLIBCXX_USE_NOEXCEPT { }
// This declaration is not useless: // This declaration is not useless:
// http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 // 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. // 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 class bad_typeid : public exception
{ {
public: public:
bad_typeid () throw() { } bad_typeid () _GLIBCXX_USE_NOEXCEPT { }
// This declaration is not useless: // This declaration is not useless:
// http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 // 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. // See comment in eh_exception.cc.
virtual const char* what() const throw(); virtual const char* what() const _GLIBCXX_USE_NOEXCEPT;
}; };
} // namespace std } // namespace std

View File

@ -42,7 +42,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
constexpr bool system_clock::is_steady; constexpr bool system_clock::is_steady;
system_clock::time_point system_clock::time_point
system_clock::now() throw () system_clock::now() noexcept
{ {
#ifdef _GLIBCXX_USE_CLOCK_REALTIME #ifdef _GLIBCXX_USE_CLOCK_REALTIME
timespec tp; timespec tp;
@ -64,9 +64,9 @@ namespace std _GLIBCXX_VISIBILITY(default)
#ifdef _GLIBCXX_USE_CLOCK_MONOTONIC #ifdef _GLIBCXX_USE_CLOCK_MONOTONIC
constexpr bool steady_clock::is_steady; constexpr bool steady_clock::is_steady;
steady_clock::time_point steady_clock::time_point
steady_clock::now() steady_clock::now() noexcept
{ {
timespec tp; timespec tp;
// -EINVAL, -EFAULT // -EINVAL, -EFAULT

View File

@ -29,10 +29,10 @@ namespace std _GLIBCXX_VISIBILITY(default)
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
bad_weak_ptr::~bad_weak_ptr() throw() = default; bad_weak_ptr::~bad_weak_ptr() noexcept = default;
char const* char const*
bad_weak_ptr::what() const throw() bad_weak_ptr::what() const noexcept
{ return "std::bad_weak_ptr"; } { return "std::bad_weak_ptr"; }
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION

View File

@ -37,55 +37,55 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
logic_error::logic_error(const string& __arg) logic_error::logic_error(const string& __arg)
: exception(), _M_msg(__arg) { } : exception(), _M_msg(__arg) { }
logic_error::~logic_error() throw() { } logic_error::~logic_error() _GLIBCXX_USE_NOEXCEPT { }
const char* const char*
logic_error::what() const throw() logic_error::what() const _GLIBCXX_USE_NOEXCEPT
{ return _M_msg.c_str(); } { return _M_msg.c_str(); }
domain_error::domain_error(const string& __arg) domain_error::domain_error(const string& __arg)
: logic_error(__arg) { } : logic_error(__arg) { }
domain_error::~domain_error() throw() { } domain_error::~domain_error() _GLIBCXX_USE_NOEXCEPT { }
invalid_argument::invalid_argument(const string& __arg) invalid_argument::invalid_argument(const string& __arg)
: logic_error(__arg) { } : logic_error(__arg) { }
invalid_argument::~invalid_argument() throw() { } invalid_argument::~invalid_argument() _GLIBCXX_USE_NOEXCEPT { }
length_error::length_error(const string& __arg) length_error::length_error(const string& __arg)
: logic_error(__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) out_of_range::out_of_range(const string& __arg)
: logic_error(__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) runtime_error::runtime_error(const string& __arg)
: exception(), _M_msg(__arg) { } : exception(), _M_msg(__arg) { }
runtime_error::~runtime_error() throw() { } runtime_error::~runtime_error() _GLIBCXX_USE_NOEXCEPT { }
const char* const char*
runtime_error::what() const throw() runtime_error::what() const _GLIBCXX_USE_NOEXCEPT
{ return _M_msg.c_str(); } { return _M_msg.c_str(); }
range_error::range_error(const string& __arg) range_error::range_error(const string& __arg)
: runtime_error(__arg) { } : runtime_error(__arg) { }
range_error::~range_error() throw() { } range_error::~range_error() _GLIBCXX_USE_NOEXCEPT { }
overflow_error::overflow_error(const string& __arg) overflow_error::overflow_error(const string& __arg)
: runtime_error(__arg) { } : runtime_error(__arg) { }
overflow_error::~overflow_error() throw() { } overflow_error::~overflow_error() _GLIBCXX_USE_NOEXCEPT { }
underflow_error::underflow_error(const string& __arg) underflow_error::underflow_error(const string& __arg)
: runtime_error(__arg) { } : runtime_error(__arg) { }
underflow_error::~underflow_error() throw() { } underflow_error::~underflow_error() _GLIBCXX_USE_NOEXCEPT { }
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace } // namespace

View File

@ -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"));
}
}

View File

@ -1,7 +1,7 @@
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// { dg-require-atomic-builtins "" } // { 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 // 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 // software; you can redistribute it and/or modify it under the
@ -23,8 +23,8 @@
struct derived : std::nested_exception { }; struct derived : std::nested_exception { };
struct base { virtual ~base(); }; struct base { virtual ~base() noexcept; };
inline base::~base() = default; inline base::~base() noexcept = default;
struct derived2 : base, std::nested_exception { }; struct derived2 : base, std::nested_exception { };

View File

@ -1,7 +1,7 @@
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
// { dg-require-atomic-builtins "" } // { 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 // 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 // software; you can redistribute it and/or modify it under the
@ -23,8 +23,8 @@
struct derived : std::nested_exception { }; struct derived : std::nested_exception { };
struct not_derived { virtual ~not_derived(); }; struct not_derived { virtual ~not_derived() noexcept; };
inline not_derived::~not_derived() = default; inline not_derived::~not_derived() noexcept = default;
void test01() void test01()
{ {