diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-07 12:13:23 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-07 12:13:23 +0000 |
commit | 007670eddc01d11ff1dcc4229c10c7755e48dca9 (patch) | |
tree | 0373601b01fbd7966bc4a6e634699aef2af18fbd /libstdc++-v3 | |
parent | ec6f02586a7b4bef66a49febd0b491471668d8f7 (diff) | |
download | gcc-007670eddc01d11ff1dcc4229c10c7755e48dca9.tar.gz |
2011-12-07 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 182077 using svnmerge
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@182079 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
26 files changed, 298 insertions, 143 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7b66e6a178d..065b6357e96 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,52 @@ +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> + + PR libstdc++/51183 + * include/std/stl_pair.h (pair<>::__cons, pair<>::__do_cons): Remove. + (pair<>::pair(piecewise_construct_t, tuple<>, tuple<>): Only declare. + (pair<>::pair(tuple<>&, tuple<>&, _Index_tuple<>, _Index_tuple<>)): + Declare. + * include/std/tuple (pair<>::__cons, pair<>::__do_cons): Remove. + (pair<>::pair(tuple<>&, tuple<>&, _Index_tuple<>, _Index_tuple<>)): + Define. + (pair<>::pair(piecewise_construct_t, tuple<>, tuple<>): Define, + delegating to the latter. + * testsuite/20_util/pair/piecewise2.cc: New. + +2011-12-05 Paolo Carlini <paolo.carlini@oracle.com> + + * libsupc++/initializer_list: Do not declare anything if + __GXX_EXPERIMENTAL_CXX0X__ is not defined. + 2011-12-04 Jonathan Wakely <jwakely.gcc@gmail.com> * include/std/type_traits: Doxygen improvements. diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index c0677547553..c024b70fb50 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/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index bb33cc6437d..c1df571c5d5 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -149,11 +149,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) { } - template<class... _Args1, class... _Args2> - pair(piecewise_construct_t, - tuple<_Args1...> __first, tuple<_Args2...> __second) - : first(__cons<first_type>(std::move(__first))), - second(__cons<second_type>(std::move(__second))) { } + template<typename... _Args1, typename... _Args2> + pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>); pair& operator=(const pair& __p) @@ -202,13 +199,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } private: - template<typename _Tp, typename... _Args> - static _Tp - __cons(tuple<_Args...>&&); - - template<typename _Tp, typename... _Args, std::size_t... _Indexes> - static _Tp - __do_cons(tuple<_Args...>&&, const _Index_tuple<_Indexes...>&); + template<typename... _Args1, std::size_t... _Indexes1, + typename... _Args2, std::size_t... _Indexes2> + pair(tuple<_Args1...>&, tuple<_Args2...>&, + _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>); #endif }; diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index 6a087f51a2f..0806a5dc1c5 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 465fc569b23..4be1bc793f3 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 a461795d7ec..2cbf207df9e 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 19482bc2181..129cbeefe59 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/include/std/tuple b/libstdc++-v3/include/std/tuple index 282d4509d3a..e8aaf4610c3 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -1057,21 +1057,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // See stl_pair.h... template<class _T1, class _T2> - template<typename _Tp, typename... _Args> - inline _Tp - pair<_T1, _T2>::__cons(tuple<_Args...>&& __tuple) - { - typedef typename _Build_index_tuple<sizeof...(_Args)>::__type - _Indexes; - return __do_cons<_Tp>(std::move(__tuple), _Indexes()); - } + template<typename... _Args1, typename... _Args2> + inline + pair<_T1, _T2>:: + pair(piecewise_construct_t, + tuple<_Args1...> __first, tuple<_Args2...> __second) + : pair(__first, __second, + typename _Build_index_tuple<sizeof...(_Args1)>::__type(), + typename _Build_index_tuple<sizeof...(_Args2)>::__type()) + { } template<class _T1, class _T2> - template<typename _Tp, typename... _Args, std::size_t... _Indexes> - inline _Tp - pair<_T1, _T2>::__do_cons(tuple<_Args...>&& __tuple, - const _Index_tuple<_Indexes...>&) - { return _Tp(std::forward<_Args>(get<_Indexes>(__tuple))...); } + template<typename... _Args1, std::size_t... _Indexes1, + typename... _Args2, std::size_t... _Indexes2> + inline + pair<_T1, _T2>:: + pair(tuple<_Args1...>& __tuple1, tuple<_Args2...>& __tuple2, + _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>) + : first(std::forward<_Args1>(std::get<_Indexes1>(__tuple1))...), + second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...) + { } _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/libsupc++/bad_alloc.cc b/libstdc++-v3/libsupc++/bad_alloc.cc index 16076cef933..b5ed6da4908 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 2f56e4e82bf..e6d492d7f28 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 54d7ef59d65..36a0d601b7c 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 2f752b31083..cbdca199ba9 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 0e710f2de62..684580f413e 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 3deb45ef38f..94a0bcbc662 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 bd18dc1b3a0..b6fd08e09a8 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++/initializer_list b/libstdc++-v3/libsupc++/initializer_list index 0e2c58a43ae..6b991b7d663 100644 --- a/libstdc++-v3/libsupc++/initializer_list +++ b/libstdc++-v3/libsupc++/initializer_list @@ -34,7 +34,7 @@ #ifndef __GXX_EXPERIMENTAL_CXX0X__ # include <bits/c++0x_warning.h> -#endif // C++0x +#else // C++0x #pragma GCC visibility push(default) @@ -101,4 +101,7 @@ namespace std } #pragma GCC visibility pop + +#endif // __GXX_EXPERIMENTAL_CXX0X__ + #endif // _INITIALIZER_LIST diff --git a/libstdc++-v3/libsupc++/nested_exception.cc b/libstdc++-v3/libsupc++/nested_exception.cc index ad83ecdfb53..ec56369393c 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 9b99c32dd7e..d88f021c5c5 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 22ef49fa7b2..aaa756bfebc 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 07c932a1ad8..17b3402c76c 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 670b7ca7ff0..911e745ebe2 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 b693da23f4f..dbc8f408e2f 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 00000000000..f4a81ff7bfe --- /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 ec8d172c400..f76cbdf8242 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 c846d0944fb..f4d85777c29 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() { diff --git a/libstdc++-v3/testsuite/20_util/pair/piecewise2.cc b/libstdc++-v3/testsuite/20_util/pair/piecewise2.cc new file mode 100644 index 00000000000..695a3c94399 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/piecewise2.cc @@ -0,0 +1,60 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 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 <utility> +#include <tuple> + +struct NoCon +{ + NoCon() = delete; + NoCon(const NoCon&) = delete; +}; + +struct RefCheck1 +{ + RefCheck1(NoCon&, NoCon&&) { } + RefCheck1() = delete; + RefCheck1(const RefCheck1&) = delete; +}; + +struct RefCheck2 +{ + RefCheck2(const NoCon&, const NoCon&&, NoCon&) { } + RefCheck2() = delete; + RefCheck2(const RefCheck2&) = delete; +}; + +struct Default +{ + Default(); + Default(const Default&) = delete; +}; + +// libstdc++/51183 +void test01(std::tuple<NoCon&, NoCon&&> t1, + std::tuple<NoCon&, NoCon&&, NoCon&> t2) +{ + std::pair<RefCheck1, RefCheck2>(std::piecewise_construct, t1, t2); +} + +void test02(std::tuple<> t1, std::tuple<int> t2) +{ + std::pair<Default, int> A(std::piecewise_construct, t1, t2); +} |