aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/libsupc++
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2011-12-06 20:03:25 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2011-12-06 20:03:25 +0000
commit8535715d0fb7c430787c257a9fc14cb34794e676 (patch)
treed7d90c64c9fb734a886b94cbda14b7158939c565 /libstdc++-v3/libsupc++
parent0e642d0671db79acb4bccc4268e461fdcf5c1cdf (diff)
downloadgcc-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
Diffstat (limited to 'libstdc++-v3/libsupc++')
-rw-r--r--libstdc++-v3/libsupc++/bad_alloc.cc6
-rw-r--r--libstdc++-v3/libsupc++/bad_cast.cc6
-rw-r--r--libstdc++-v3/libsupc++/bad_typeid.cc6
-rw-r--r--libstdc++-v3/libsupc++/eh_exception.cc10
-rw-r--r--libstdc++-v3/libsupc++/eh_ptr.cc42
-rw-r--r--libstdc++-v3/libsupc++/exception20
-rw-r--r--libstdc++-v3/libsupc++/exception_ptr.h57
-rw-r--r--libstdc++-v3/libsupc++/nested_exception.cc2
-rw-r--r--libstdc++-v3/libsupc++/nested_exception.h4
-rw-r--r--libstdc++-v3/libsupc++/typeinfo12
10 files changed, 88 insertions, 77 deletions
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