Commit d05f74f1 by Jason Merrill Committed by Jason Merrill

re PR other/28145 (C++ (throw() and catch(...) {/* fall through */ } ) and…

re PR other/28145 (C++ (throw() and catch(...) {/*  fall through */ } ) and pthread cancellation are incompatible (at least with NPTL))

        PR c++/28145
        * libsupc++/cxxabi.h (__forced_unwind, __foreign_exception):
        New classes.
        * libsupc++/eh_exception.cc: Define their destructors.
        * config/abi/pre/gnu.ver: Export their type_infos.
        * config/abi/pre/gnu-versioned-namespace.ver: Likewise.
        * libsupc++/eh_personality.cc: A handler for abi::__forced_unwind
        matches a forced unwind, and a handler for abi::__foreign_exception
        matches a foreign exception.

        * include/bits/istream.tcc: Rethrow forced unwind.
        * include/bits/ostream.tcc: Likewise.
        * include/bits/ostream_insert.h: Likewise.
        * include/bits/basic_string.tcc (operator>>, getline): Likewise.
        * include/bits/fstream.tcc (basic_filebuf::close): Likewise.
        * include/ext/vstring.cc (operator>>, getline): Likewise.
        * src/istream.cc: Likewise.
        * src/compatibility.cc (basic_istream::ignore): Likewise.
        * include/std/bitset (operator>>): Likewise.
        * include/std/fstream (basic_filebuf::close): Remove throw() spec.
        * libsupc++/cxxabi-internal.h: Split out from...
        * libsupc++/cxxabi.h: ...here.

From-SVN: r124517
parent 1e7c1ba8
// This test only applies to glibc (NPTL) targets.
// { dg-do run { target *-*-linux* } }
// { dg-options "-pthread" }
#include <pthread.h>
#include <cxxabi.h>
extern "C" int printf (const char *, ...);
int main()
{
try
{
pthread_exit (0);
}
catch (abi::__forced_unwind &)
{
printf ("caught forced unwind\n");
throw;
}
catch (...)
{
printf ("caught ...\n");
return 1;
}
}
2007-05-07 Jason Merrill <jason@redhat.com>
PR c++/28145
* libsupc++/cxxabi.h (__forced_unwind, __foreign_exception):
New classes.
* libsupc++/eh_exception.cc: Define their destructors.
* config/abi/pre/gnu.ver: Export their type_infos.
* config/abi/pre/gnu-versioned-namespace.ver: Likewise.
* libsupc++/eh_personality.cc: A handler for abi::__forced_unwind
matches a forced unwind, and a handler for abi::__foreign_exception
matches a foreign exception.
* include/bits/istream.tcc: Rethrow forced unwind.
* include/bits/ostream.tcc: Likewise.
* include/bits/ostream_insert.h: Likewise.
* include/bits/basic_string.tcc (operator>>, getline): Likewise.
* include/bits/fstream.tcc (basic_filebuf::close): Likewise.
* include/ext/vstring.cc (operator>>, getline): Likewise.
* src/istream.cc: Likewise.
* src/compatibility.cc (basic_istream::ignore): Likewise.
* include/std/bitset (operator>>): Likewise.
* include/std/fstream (basic_filebuf::close): Remove throw() spec.
* libsupc++/cxxabi-internal.h: Split out from...
* libsupc++/cxxabi.h: ...here.
2007-05-07 Paolo Carlini <pcarlini@suse.de> 2007-05-07 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_algobase.h: Do not include <cstring>. * include/bits/stl_algobase.h: Do not include <cstring>.
......
...@@ -178,6 +178,8 @@ CXXABI_1.7 { ...@@ -178,6 +178,8 @@ CXXABI_1.7 {
_ZTIN10__cxxabiv119__pointer_type_infoE; _ZTIN10__cxxabiv119__pointer_type_infoE;
_ZTIN10__cxxabiv120__si_class_type_infoE; _ZTIN10__cxxabiv120__si_class_type_infoE;
_ZTIN10__cxxabiv121__vmi_class_type_infoE; _ZTIN10__cxxabiv121__vmi_class_type_infoE;
_ZTIN10__cxxabiv115__forced_unwindE;
_ZTIN10__cxxabiv119__foreign_exceptionE;
# typeinfo name # typeinfo name
_ZTS[a-z]; _ZTS[a-z];
......
...@@ -793,6 +793,8 @@ CXXABI_1.3 { ...@@ -793,6 +793,8 @@ CXXABI_1.3 {
_ZTIN10__cxxabiv119__pointer_type_infoE; _ZTIN10__cxxabiv119__pointer_type_infoE;
_ZTIN10__cxxabiv120__si_class_type_infoE; _ZTIN10__cxxabiv120__si_class_type_infoE;
_ZTIN10__cxxabiv121__vmi_class_type_infoE; _ZTIN10__cxxabiv121__vmi_class_type_infoE;
_ZTIN10__cxxabiv115__forced_unwindE;
_ZTIN10__cxxabiv119__foreign_exceptionE;
# typeinfo name # typeinfo name
_ZTS[a-fh-z]; _ZTS[a-fh-z];
......
...@@ -448,7 +448,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -448,7 +448,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_M_data->_M_curr_symbol = L""; _M_data->_M_curr_symbol = L"";
_M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol); _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
} }
catch (...) catch(...)
{ {
delete _M_data; delete _M_data;
_M_data = 0; _M_data = 0;
...@@ -591,7 +591,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -591,7 +591,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_M_data->_M_curr_symbol = L""; _M_data->_M_curr_symbol = L"";
_M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol); _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
} }
catch (...) catch(...)
{ {
delete _M_data; delete _M_data;
_M_data = 0; _M_data = 0;
......
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
#pragma GCC system_header #pragma GCC system_header
#include <cxxabi-internal.h>
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _CharT, typename _Traits, typename _Alloc> template<typename _CharT, typename _Traits, typename _Alloc>
...@@ -1015,6 +1017,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1015,6 +1017,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__err |= __ios_base::eofbit; __err |= __ios_base::eofbit;
__in.width(0); __in.width(0);
} }
catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(__ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ {
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
...@@ -1074,6 +1081,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -1074,6 +1081,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else else
__err |= __ios_base::failbit; __err |= __ios_base::failbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(__ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ {
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
......
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
#pragma GCC system_header #pragma GCC system_header
#include <cxxabi-internal.h>
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
...@@ -127,36 +129,51 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -127,36 +129,51 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::__filebuf_type* typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
basic_filebuf<_CharT, _Traits>:: basic_filebuf<_CharT, _Traits>::
close() throw() close()
{ {
__filebuf_type* __ret = NULL; if (!this->is_open())
if (this->is_open()) return NULL;
bool __testfail = false;
{
// NB: Do this here so that re-opened filebufs will be cool...
struct __close_sentry
{ {
bool __testfail = false; basic_filebuf *__fb;
try __close_sentry (basic_filebuf *__fbi): __fb(__fbi) { }
{ ~__close_sentry ()
if (!_M_terminate_output()) {
__testfail = true; __fb->_M_mode = ios_base::openmode(0);
} __fb->_M_pback_init = false;
catch(...) __fb->_M_destroy_internal_buffer();
{ __testfail = true; } __fb->_M_reading = false;
__fb->_M_writing = false;
// NB: Do this here so that re-opened filebufs will be cool... __fb->_M_set_buffer(-1);
_M_mode = ios_base::openmode(0); __fb->_M_state_last = __fb->_M_state_cur = __fb->_M_state_beg;
_M_pback_init = false; }
_M_destroy_internal_buffer(); } __cs (this);
_M_reading = false;
_M_writing = false; try
_M_set_buffer(-1); {
_M_state_last = _M_state_cur = _M_state_beg; if (!_M_terminate_output())
__testfail = true;
if (!_M_file.close()) }
__testfail = true; catch(__cxxabiv1::__forced_unwind&)
{
if (!__testfail) _M_file.close();
__ret = this; __throw_exception_again;
} }
return __ret; catch(...)
{ __testfail = true; }
}
if (!_M_file.close())
__testfail = true;
if (__testfail)
return NULL;
else
return this;
} }
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
......
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#pragma GCC system_header #pragma GCC system_header
#include <cxxabi-internal.h>
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
...@@ -98,6 +100,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -98,6 +100,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
const __num_get_type& __ng = __check_facet(this->_M_num_get); const __num_get_type& __ng = __check_facet(this->_M_num_get);
__ng.get(*this, 0, *this, __err, __v); __ng.get(*this, 0, *this, __err, __v);
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -163,6 +170,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -163,6 +170,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (__ineof) if (__ineof)
__err |= ios_base::eofbit; __err |= ios_base::eofbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::failbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::failbit); } { this->_M_setstate(ios_base::failbit); }
} }
...@@ -194,6 +206,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -194,6 +206,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else else
__err |= ios_base::eofbit; __err |= ios_base::eofbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
} }
...@@ -226,6 +243,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -226,6 +243,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else else
__err |= ios_base::eofbit; __err |= ios_base::eofbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
} }
...@@ -264,6 +286,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -264,6 +286,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (traits_type::eq_int_type(__c, __eof)) if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit; __err |= ios_base::eofbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
} }
...@@ -307,6 +334,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -307,6 +334,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (traits_type::eq_int_type(__c, __eof)) if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit; __err |= ios_base::eofbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
} }
...@@ -355,6 +387,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -355,6 +387,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__err |= ios_base::failbit; __err |= ios_base::failbit;
} }
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
} }
...@@ -392,6 +429,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -392,6 +429,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else else
_M_gcount = 1; _M_gcount = 1;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -449,6 +491,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -449,6 +491,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (traits_type::eq_int_type(__c, __eof)) if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit; __err |= ios_base::eofbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -509,6 +556,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -509,6 +556,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__sb->sbumpc(); __sb->sbumpc();
} }
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -534,6 +586,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -534,6 +586,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (traits_type::eq_int_type(__c, traits_type::eof())) if (traits_type::eq_int_type(__c, traits_type::eof()))
__err |= ios_base::eofbit; __err |= ios_base::eofbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -558,6 +615,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -558,6 +615,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (_M_gcount != __n) if (_M_gcount != __n)
__err |= (ios_base::eofbit | ios_base::failbit); __err |= (ios_base::eofbit | ios_base::failbit);
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -585,6 +647,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -585,6 +647,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else if (__num == -1) else if (__num == -1)
__err |= ios_base::eofbit; __err |= ios_base::eofbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -613,6 +680,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -613,6 +680,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|| traits_type::eq_int_type(__sb->sputbackc(__c), __eof)) || traits_type::eq_int_type(__sb->sputbackc(__c), __eof))
__err |= ios_base::badbit; __err |= ios_base::badbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -641,6 +713,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -641,6 +713,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|| traits_type::eq_int_type(__sb->sungetc(), __eof)) || traits_type::eq_int_type(__sb->sungetc(), __eof))
__err |= ios_base::badbit; __err |= ios_base::badbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -672,6 +749,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -672,6 +749,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__ret = 0; __ret = 0;
} }
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -694,6 +776,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -694,6 +776,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__ret = this->rdbuf()->pubseekoff(0, ios_base::cur, __ret = this->rdbuf()->pubseekoff(0, ios_base::cur,
ios_base::in); ios_base::in);
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
return __ret; return __ret;
...@@ -720,6 +807,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -720,6 +807,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__err |= ios_base::failbit; __err |= ios_base::failbit;
} }
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -748,6 +840,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -748,6 +840,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__err |= ios_base::failbit; __err |= ios_base::failbit;
} }
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -775,6 +872,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -775,6 +872,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else else
__err |= (ios_base::eofbit | ios_base::failbit); __err |= (ios_base::eofbit | ios_base::failbit);
} }
catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ __in._M_setstate(ios_base::badbit); } { __in._M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -828,6 +930,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -828,6 +930,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
*__s = char_type(); *__s = char_type();
__in.width(0); __in.width(0);
} }
catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ __in._M_setstate(ios_base::badbit); } { __in._M_setstate(ios_base::badbit); }
} }
......
...@@ -409,7 +409,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -409,7 +409,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ {
try try
{ delete this; } { delete this; }
catch (...) catch(...)
{ } { }
} }
} }
......
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#pragma GCC system_header #pragma GCC system_header
#include <cxxabi-internal.h>
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
...@@ -76,6 +78,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -76,6 +78,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (__np.put(*this, *this, this->fill(), __v).failed()) if (__np.put(*this, *this, this->fill(), __v).failed())
__err |= ios_base::badbit; __err |= ios_base::badbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -126,6 +133,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -126,6 +133,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (!__copy_streambufs(__sbin, this->rdbuf())) if (!__copy_streambufs(__sbin, this->rdbuf()))
__err |= ios_base::failbit; __err |= ios_base::failbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::failbit); } { this->_M_setstate(ios_base::failbit); }
} }
...@@ -157,7 +169,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -157,7 +169,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (traits_type::eq_int_type(__put, traits_type::eof())) if (traits_type::eq_int_type(__put, traits_type::eof()))
__err |= ios_base::badbit; __err |= ios_base::badbit;
} }
catch (...) catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
this->setstate(__err); this->setstate(__err);
...@@ -182,7 +199,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -182,7 +199,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ {
try try
{ _M_write(__s, __n); } { _M_write(__s, __n); }
catch (...) catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
} }
return *this; return *this;
...@@ -202,6 +224,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -202,6 +224,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (this->rdbuf() && this->rdbuf()->pubsync() == -1) if (this->rdbuf() && this->rdbuf()->pubsync() == -1)
__err |= ios_base::badbit; __err |= ios_base::badbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -220,6 +247,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -220,6 +247,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (!this->fail()) if (!this->fail())
__ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out); __ret = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
return __ret; return __ret;
...@@ -245,6 +277,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -245,6 +277,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__err |= ios_base::failbit; __err |= ios_base::failbit;
} }
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -272,6 +309,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -272,6 +309,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__err |= ios_base::failbit; __err |= ios_base::failbit;
} }
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -289,31 +331,29 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -289,31 +331,29 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ {
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// 167. Improper use of traits_type::length() // 167. Improper use of traits_type::length()
const size_t __clen = char_traits<char>::length(__s); const size_t __clen = char_traits<char>::length(__s);
_CharT* __ws = 0;
try try
{
__ws = new _CharT[__clen];
for (size_t __i = 0; __i < __clen; ++__i)
__ws[__i] = __out.widen(__s[__i]);
}
catch(...)
{ {
delete [] __ws; struct __ptr_guard
__out._M_setstate(ios_base::badbit); {
return __out; _CharT *p;
} __ptr_guard (_CharT *ip): p(ip) { }
~__ptr_guard() { delete[] p; }
_CharT* __get() { return p; }
} __pg (new _CharT[__clen]);
try _CharT *__ws = __pg.__get();
{ for (size_t __i = 0; __i < __clen; ++__i)
__ws[__i] = __out.widen(__s[__i]);
__ostream_insert(__out, __ws, __clen); __ostream_insert(__out, __ws, __clen);
delete [] __ws;
} }
catch(...) catch(__cxxabiv1::__forced_unwind&)
{ {
delete [] __ws; __out._M_setstate(ios_base::badbit);
__throw_exception_again; __throw_exception_again;
} }
catch(...)
{ __out._M_setstate(ios_base::badbit); }
} }
return __out; return __out;
} }
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#pragma GCC system_header #pragma GCC system_header
#include <iosfwd> #include <iosfwd>
#include <cxxabi-internal.h>
_GLIBCXX_BEGIN_NAMESPACE(std) _GLIBCXX_BEGIN_NAMESPACE(std)
...@@ -103,6 +104,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -103,6 +104,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__ostream_write(__out, __s, __n); __ostream_write(__out, __s, __n);
__out.width(0); __out.width(0);
} }
catch(__cxxabiv1::__forced_unwind&)
{
__out._M_setstate(__ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ __out._M_setstate(__ios_base::badbit); } { __out._M_setstate(__ios_base::badbit); }
} }
......
...@@ -313,7 +313,7 @@ namespace __debug ...@@ -313,7 +313,7 @@ namespace __debug
return iterator(_Base::erase(__first.base(), __last.base()), return iterator(_Base::erase(__first.base(), __last.base()),
this); this);
} }
catch (...) catch(...)
{ {
this->_M_revalidate_singular(); this->_M_revalidate_singular();
__throw_exception_again; __throw_exception_again;
......
...@@ -265,7 +265,7 @@ set_loads(std::pair<float, float> load_pair) ...@@ -265,7 +265,7 @@ set_loads(std::pair<float, float> load_pair)
m_load_max = load_pair.second; m_load_max = load_pair.second;
do_resize(static_cast<size_type>(size_base::get_size() / ((m_load_min + m_load_max) / 2))); do_resize(static_cast<size_type>(size_base::get_size() / ((m_load_min + m_load_max) / 2)));
} }
catch (...) catch(...)
{ {
m_load_min = old_load_min; m_load_min = old_load_min;
m_load_max = old_load_max; m_load_max = old_load_max;
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#pragma GCC system_header #pragma GCC system_header
#include <cxxabi-internal.h>
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
template<typename _CharT, typename _Traits, typename _Alloc, template<typename _CharT, typename _Traits, typename _Alloc,
...@@ -598,6 +600,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -598,6 +600,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__err |= __ios_base::eofbit; __err |= __ios_base::eofbit;
__in.width(0); __in.width(0);
} }
catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(__ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ {
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
...@@ -669,6 +676,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -669,6 +676,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else else
__err |= __ios_base::failbit; __err |= __ios_base::failbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(__ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ {
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include <bits/functexcept.h> // For invalid_argument, out_of_range, #include <bits/functexcept.h> // For invalid_argument, out_of_range,
// overflow_error // overflow_error
#include <iosfwd> #include <iosfwd>
#include <cxxabi-internal.h>
#define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * sizeof(unsigned long)) #define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * sizeof(unsigned long))
#define _GLIBCXX_BITSET_WORDS(__n) \ #define _GLIBCXX_BITSET_WORDS(__n) \
...@@ -1271,6 +1272,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) ...@@ -1271,6 +1272,11 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
} }
} }
} }
catch(__cxxabiv1::__forced_unwind&)
{
__is._M_setstate(__ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ __is._M_setstate(__ios_base::badbit); } { __is._M_setstate(__ios_base::badbit); }
} }
......
...@@ -275,7 +275,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -275,7 +275,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* If any operations fail, this function also fails. * If any operations fail, this function also fails.
*/ */
__filebuf_type* __filebuf_type*
close() throw(); close();
protected: protected:
void void
......
...@@ -613,7 +613,7 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1) ...@@ -613,7 +613,7 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
__sgn_g1cb = __log_gamma_sign(__c - __b); __sgn_g1cb = __log_gamma_sign(__c - __b);
__ln_g1cb = __log_gamma(__c - __b); __ln_g1cb = __log_gamma(__c - __b);
} }
catch (...) catch(...)
{ {
__ok1 = false; __ok1 = false;
} }
...@@ -628,7 +628,7 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1) ...@@ -628,7 +628,7 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
__sgn_g2b = __log_gamma_sign(__b); __sgn_g2b = __log_gamma_sign(__b);
__ln_g2b = __log_gamma(__b); __ln_g2b = __log_gamma(__b);
} }
catch (...) catch(...)
{ {
__ok2 = false; __ok2 = false;
} }
......
...@@ -31,12 +31,16 @@ ...@@ -31,12 +31,16 @@
#include "typeinfo" #include "typeinfo"
#include "exception" #include "exception"
#include "unwind-cxx.h" #include <cxxabi.h>
std::exception::~exception() throw() { } std::exception::~exception() throw() { }
std::bad_exception::~bad_exception() throw() { } std::bad_exception::~bad_exception() throw() { }
abi::__forced_unwind::~__forced_unwind() throw() { }
abi::__foreign_exception::~__foreign_exception() throw() { }
const char* const char*
std::exception::what() const throw() std::exception::what() const throw()
{ {
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <bits/c++config.h> #include <bits/c++config.h>
#include <cstdlib> #include <cstdlib>
#include <exception_defines.h> #include <exception_defines.h>
#include <cxxabi.h>
#include "unwind-cxx.h" #include "unwind-cxx.h"
using namespace __cxxabiv1; using namespace __cxxabiv1;
...@@ -541,13 +542,19 @@ PERSONALITY_FUNCTION (int version, ...@@ -541,13 +542,19 @@ PERSONALITY_FUNCTION (int version,
bool saw_cleanup = false; bool saw_cleanup = false;
bool saw_handler = false; bool saw_handler = false;
// During forced unwinding, we only run cleanups. With a foreign // During forced unwinding, match a magic exception type.
// exception class, there's no exception type. if (actions & _UA_FORCE_UNWIND)
// ??? What to do about GNU Java and GNU Ada exceptions. {
throw_type = &typeid(abi::__forced_unwind);
if ((actions & _UA_FORCE_UNWIND) thrown_ptr = 0;
|| foreign_exception) }
throw_type = 0; // With a foreign exception class, there's no exception type.
// ??? What to do about GNU Java and GNU Ada exceptions?
else if (foreign_exception)
{
throw_type = &typeid(abi::__foreign_exception);
thrown_ptr = 0;
}
else else
#ifdef __ARM_EABI_UNWINDER__ #ifdef __ARM_EABI_UNWINDER__
throw_type = ue_header; throw_type = ue_header;
...@@ -590,7 +597,9 @@ PERSONALITY_FUNCTION (int version, ...@@ -590,7 +597,9 @@ PERSONALITY_FUNCTION (int version,
// object to stuff bits in for __cxa_call_unexpected to use. // object to stuff bits in for __cxa_call_unexpected to use.
// Allow them iff the exception spec is non-empty. I.e. // Allow them iff the exception spec is non-empty. I.e.
// a throw() specification results in __unexpected. // a throw() specification results in __unexpected.
if (throw_type if ((throw_type
&& !(actions & _UA_FORCE_UNWIND)
&& !foreign_exception)
? ! check_exception_spec (&info, throw_type, thrown_ptr, ? ! check_exception_spec (&info, throw_type, thrown_ptr,
ar_filter) ar_filter)
: empty_exception_spec (&info, ar_filter)) : empty_exception_spec (&info, ar_filter))
......
...@@ -114,6 +114,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -114,6 +114,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (traits_type::eq_int_type(__c, __eof)) if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit; __err |= ios_base::eofbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -180,6 +185,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -180,6 +185,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
if (traits_type::eq_int_type(__c, __eof)) if (traits_type::eq_int_type(__c, __eof))
__err |= ios_base::eofbit; __err |= ios_base::eofbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
......
...@@ -127,7 +127,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -127,7 +127,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__newsize = __ix + 1; __newsize = __ix + 1;
try try
{ __words = new _Words[__newsize]; } { __words = new _Words[__newsize]; }
catch (...) catch(...)
{ {
_M_streambuf_state |= badbit; _M_streambuf_state |= badbit;
if (_M_streambuf_state & _M_exception) if (_M_streambuf_state & _M_exception)
...@@ -172,7 +172,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -172,7 +172,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{ {
try try
{ (*__p->_M_fn) (__e, *this, __p->_M_index); } { (*__p->_M_fn) (__e, *this, __p->_M_index); }
catch (...) catch(...)
{ } { }
__p = __p->_M_next; __p = __p->_M_next;
} }
......
...@@ -142,7 +142,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -142,7 +142,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
wclog.flush(); wclog.flush();
#endif #endif
} }
catch (...) catch(...)
{ } { }
} }
} }
......
...@@ -91,6 +91,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -91,6 +91,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else else
__err |= ios_base::failbit; __err |= ios_base::failbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
} }
...@@ -177,6 +182,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -177,6 +182,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__sb->sbumpc(); __sb->sbumpc();
} }
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -251,6 +261,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -251,6 +261,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
*__s = __char_type(); *__s = __char_type();
__in.width(0); __in.width(0);
} }
catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ __in._M_setstate(ios_base::badbit); } { __in._M_setstate(ios_base::badbit); }
} }
...@@ -321,6 +336,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -321,6 +336,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__err |= ios_base::eofbit; __err |= ios_base::eofbit;
__in.width(0); __in.width(0);
} }
catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ {
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
...@@ -401,6 +421,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -401,6 +421,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else else
__err |= ios_base::failbit; __err |= ios_base::failbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ {
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
...@@ -473,6 +498,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -473,6 +498,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else else
__err |= ios_base::failbit; __err |= ios_base::failbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
} }
...@@ -559,6 +589,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -559,6 +589,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__sb->sbumpc(); __sb->sbumpc();
} }
} }
catch(__cxxabiv1::__forced_unwind&)
{
this->_M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ this->_M_setstate(ios_base::badbit); } { this->_M_setstate(ios_base::badbit); }
if (__err) if (__err)
...@@ -632,6 +667,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) ...@@ -632,6 +667,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
else else
__err |= ios_base::failbit; __err |= ios_base::failbit;
} }
catch(__cxxabiv1::__forced_unwind&)
{
__in._M_setstate(ios_base::badbit);
__throw_exception_again;
}
catch(...) catch(...)
{ {
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment