Commit 322821b9 by Benjamin Kosnik Committed by Benjamin Kosnik

Make -fno-exceptions work.


2001-10-23  Benjamin Kosnik  <bkoz@redhat.com>

	Make -fno-exceptions work.
	* config/locale/c_locale_gnu.cc: Use functexcept.
	* include/bits/c++config (__stl_assert): Remove.
	(__STL_USE_EXCEPTIONS): Same.
	(__STL_TRY): Same.
	(__STL_CATCH_ALL): Same.
	(__STL_THROW): Same.
	(__STL_RETHROW): Same.
	(__STL_NOTHROW): Same.
	(__STL_UNWIND): Same.
	* include/bits/pthread_allocimpl.h: Fix.
	* include/bits/std_bitset.h: Same.
	* include/bits/std_list.h: Same.
	* include/bits/std_memory.h: Same.
	* include/bits/std_queue.h: Same.
	* include/bits/stl_alloc.h: Same.
	* include/bits/stl_deque.h: Same.
	* include/bits/stl_list.h: Same.
	* include/bits/stl_queue.h: Same.
	* include/bits/stl_tempbuf.h: Same.
	* include/bits/stl_tree.h: Same.
	* include/bits/stl_uninitialized.h: Same.
	* include/bits/stl_vector.h: Same.
	* include/ext/ropeimpl.h: Same.
	* include/ext/slist: Same.
	* include/ext/stl_hashtable.h: Same.
	* include/ext/stl_rope.h: Same.
	* libsupc++/new_op.cc: Include cstdlib.
	* libsupc++/eh_personality.cc: Add exception_defines include. Use
	__throw_exception_again, tweak.
	* libsupc++/eh_aux_runtime.cc: Include stdlib for abort.
	* libsupc++/vec.cc: Tweak.
	* src/functexcept.cc: Remove unused arguments.
	* testsuite/23_containers/bitset_members.cc: Tweak.

From-SVN: r46455
parent c8cf201f
2001-10-23 Benjamin Kosnik <bkoz@redhat.com>
Make -fno-exceptions work.
* config/locale/c_locale_gnu.cc: Use functexcept.
* include/bits/c++config (__stl_assert): Remove.
(__STL_USE_EXCEPTIONS): Same.
(__STL_TRY): Same.
(__STL_CATCH_ALL): Same.
(__STL_THROW): Same.
(__STL_RETHROW): Same.
(__STL_NOTHROW): Same.
(__STL_UNWIND): Same.
* include/bits/pthread_allocimpl.h: Fix.
* include/bits/std_bitset.h: Same.
* include/bits/std_list.h: Same.
* include/bits/std_memory.h: Same.
* include/bits/std_queue.h: Same.
* include/bits/stl_alloc.h: Same.
* include/bits/stl_deque.h: Same.
* include/bits/stl_list.h: Same.
* include/bits/stl_queue.h: Same.
* include/bits/stl_tempbuf.h: Same.
* include/bits/stl_tree.h: Same.
* include/bits/stl_uninitialized.h: Same.
* include/bits/stl_vector.h: Same.
* include/ext/ropeimpl.h: Same.
* include/ext/slist: Same.
* include/ext/stl_hashtable.h: Same.
* include/ext/stl_rope.h: Same.
* libsupc++/new_op.cc: Include cstdlib.
* libsupc++/eh_personality.cc: Add exception_defines include. Use
__throw_exception_again, tweak.
* libsupc++/eh_aux_runtime.cc: Include stdlib for abort.
* libsupc++/vec.cc: Tweak.
* src/functexcept.cc: Remove unused arguments.
* testsuite/23_containers/bitset_members.cc: Tweak.
2001-10-22 Benjamin Kosnik <bkoz@redhat.com>
* config/cpu/i386/bits/limits.h: Move to...
......
......@@ -50,7 +50,7 @@ namespace std
if (!__cloc)
{
// This named locale is not supported by the underlying OS.
throw runtime_error("attempt to create locale from unknown name");
__throw_runtime_error("attempt to create locale from unknown name");
}
}
......
......@@ -72,25 +72,6 @@
// internal ABI change).
#define __STL_GTHREADS
#define __STL_THREADS
#define __STL_VOLATILE volatile
// This is also a user hook, but via -f[no-]exceptions, not direct #defines.
#ifdef __EXCEPTIONS
# define __STL_USE_EXCEPTIONS
# define __STL_TRY try
# define __STL_CATCH_ALL catch(...)
# define __STL_THROW(x) throw x
# define __STL_RETHROW throw
# define __STL_NOTHROW throw()
# define __STL_UNWIND(action) catch(...) { action; throw; }
#else
# define __STL_TRY
# define __STL_CATCH_ALL if (false)
# define __STL_THROW(x)
# define __STL_RETHROW
# define __STL_NOTHROW
# define __STL_UNWIND(action)
#endif
// Default to the typically high-speed, pool-based allocator (as
// libstdc++-v2) instead of the malloc-based allocator (libstdc++-v3
......@@ -104,11 +85,6 @@
// The remainder of the prewritten config is mostly automatic; all the
// user hooks are listed above.
// XXX
// Only used in the SGI rope extensions; this is from stl_config.h and
// should be cleaned up.
# define __stl_assert(expr)
/** @namespace std
* @brief Everything defined by the ISO C++ Standard is within namespace std.
*/
......
......@@ -422,12 +422,12 @@ public:
typedef pthread_allocator<_NewType> other;
};
pthread_allocator() __STL_NOTHROW {}
pthread_allocator(const pthread_allocator& a) __STL_NOTHROW {}
pthread_allocator() throw() {}
pthread_allocator(const pthread_allocator& a) throw() {}
template <class _OtherType>
pthread_allocator(const pthread_allocator<_OtherType>&)
__STL_NOTHROW {}
~pthread_allocator() __STL_NOTHROW {}
throw() {}
~pthread_allocator() throw() {}
pointer address(reference __x) const { return &__x; }
const_pointer address(const_reference __x) const { return &__x; }
......@@ -443,7 +443,7 @@ public:
void deallocate(pointer __p, size_type __n)
{ _S_Alloc::deallocate(__p, __n * sizeof(_Tp)); }
size_type max_size() const __STL_NOTHROW
size_type max_size() const throw()
{ return size_t(-1) / sizeof(_Tp); }
void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }
......
......@@ -59,9 +59,9 @@
#include <bits/std_cstddef.h> // for size_t
#include <bits/std_cstring.h> // for memset
#include <bits/std_string.h>
#include <bits/std_stdexcept.h> // for invalid_argument, out_of_range,
// overflow_error
#include <bits/std_stdexcept.h>
#include <bits/functexcept.h> // for invalid_argument, out_of_range,
// overflow_error
#include <bits/std_ostream.h> // for ostream (operator<<)
#include <bits/std_istream.h> // for istream (operator>>)
......@@ -244,7 +244,7 @@ unsigned long _Base_bitset<_Nw>::_M_do_to_ulong() const
{
for (size_t __i = 1; __i < _Nw; ++__i)
if (_M_w[__i])
__STL_THROW(overflow_error("bitset"));
__throw_overflow_error("bitset");
return _M_w[0];
}
......@@ -490,7 +490,7 @@ public:
: _Base()
{
if (__pos > __s.size())
__STL_THROW(out_of_range("bitset"));
__throw_out_of_range("bitset");
_M_copy_from_string(__s, __pos,
basic_string<_CharT, _Traits, _Alloc>::npos);
}
......@@ -501,7 +501,7 @@ public:
: _Base()
{
if (__pos > __s.size())
__STL_THROW(out_of_range("bitset"));
__throw_out_of_range("bitset");
_M_copy_from_string(__s, __pos, __n);
}
......@@ -577,7 +577,7 @@ public:
bitset<_Nb>& set(size_t __pos, bool __val = true) {
if (__pos >= _Nb)
__STL_THROW(out_of_range("bitset"));
__throw_out_of_range("bitset");
return _Unchecked_set(__pos, __val);
}
......@@ -589,7 +589,7 @@ public:
bitset<_Nb>& reset(size_t __pos) {
if (__pos >= _Nb)
__STL_THROW(out_of_range("bitset"));
__throw_out_of_range("bitset");
return _Unchecked_reset(__pos);
}
......@@ -602,7 +602,7 @@ public:
bitset<_Nb>& flip(size_t __pos) {
if (__pos >= _Nb)
__STL_THROW(out_of_range("bitset"));
__throw_out_of_range("bitset");
return _Unchecked_flip(__pos);
}
......@@ -650,7 +650,7 @@ public:
bool test(size_t __pos) const {
if (__pos >= _Nb)
__STL_THROW(out_of_range("bitset"));
__throw_out_of_range("bitset");
return _Unchecked_test(__pos);
}
......@@ -700,7 +700,7 @@ void bitset<_Nb>
set(__i);
break;
default:
__STL_THROW(invalid_argument("bitset"));
__throw_invalid_argument("bitset");
}
}
}
......
......@@ -58,6 +58,7 @@
#pragma GCC system_header
#include <bits/functexcept.h>
#include <bits/stl_algobase.h>
#include <bits/stl_alloc.h>
#include <bits/stl_construct.h>
......
......@@ -69,19 +69,19 @@ private:
public:
typedef _Tp element_type;
explicit auto_ptr(_Tp* __p = 0) __STL_NOTHROW : _M_ptr(__p) {}
auto_ptr(auto_ptr& __a) __STL_NOTHROW : _M_ptr(__a.release()) {}
explicit auto_ptr(_Tp* __p = 0) throw() : _M_ptr(__p) {}
auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) {}
template <class _Tp1> auto_ptr(auto_ptr<_Tp1>& __a) __STL_NOTHROW
template <class _Tp1> auto_ptr(auto_ptr<_Tp1>& __a) throw()
: _M_ptr(__a.release()) {}
auto_ptr& operator=(auto_ptr& __a) __STL_NOTHROW {
auto_ptr& operator=(auto_ptr& __a) throw() {
reset(__a.release());
return *this;
}
template <class _Tp1>
auto_ptr& operator=(auto_ptr<_Tp1>& __a) __STL_NOTHROW {
auto_ptr& operator=(auto_ptr<_Tp1>& __a) throw() {
reset(__a.release());
return *this;
}
......@@ -92,21 +92,21 @@ public:
// this is prohibited.
~auto_ptr() { delete _M_ptr; }
_Tp& operator*() const __STL_NOTHROW {
_Tp& operator*() const throw() {
return *_M_ptr;
}
_Tp* operator->() const __STL_NOTHROW {
_Tp* operator->() const throw() {
return _M_ptr;
}
_Tp* get() const __STL_NOTHROW {
_Tp* get() const throw() {
return _M_ptr;
}
_Tp* release() __STL_NOTHROW {
_Tp* release() throw() {
_Tp* __tmp = _M_ptr;
_M_ptr = 0;
return __tmp;
}
void reset(_Tp* __p = 0) __STL_NOTHROW {
void reset(_Tp* __p = 0) throw() {
if (__p != _M_ptr) {
delete _M_ptr;
_M_ptr = __p;
......@@ -118,10 +118,10 @@ public:
// in fact, most present-day compilers do not support the language
// features that these conversions rely on.
public:
auto_ptr(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW
auto_ptr(auto_ptr_ref<_Tp> __ref) throw()
: _M_ptr(__ref._M_ptr) {}
auto_ptr& operator=(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW {
auto_ptr& operator=(auto_ptr_ref<_Tp> __ref) throw() {
if (__ref._M_ptr != this->get()) {
delete _M_ptr;
_M_ptr = __ref._M_ptr;
......@@ -129,9 +129,9 @@ public:
return *this;
}
template <class _Tp1> operator auto_ptr_ref<_Tp1>() __STL_NOTHROW
template <class _Tp1> operator auto_ptr_ref<_Tp1>() throw()
{ return auto_ptr_ref<_Tp>(this->release()); }
template <class _Tp1> operator auto_ptr<_Tp1>() __STL_NOTHROW
template <class _Tp1> operator auto_ptr<_Tp1>() throw()
{ return auto_ptr<_Tp1>(this->release()); }
};
......
......@@ -58,6 +58,7 @@
#pragma GCC system_header
#include <bits/c++config.h>
#include <bits/functexcept.h>
#include <bits/stl_algobase.h>
#include <bits/stl_alloc.h>
#include <bits/stl_construct.h>
......
......@@ -306,7 +306,7 @@ private:
char _M_client_data[1]; /* The client sees this. */
};
static _Obj* __STL_VOLATILE _S_free_list[];
static _Obj* volatile _S_free_list[];
// Specifying a size results in duplicate def for 4.1
static size_t _S_freelist_index(size_t __bytes) {
return (((__bytes) + (size_t)_ALIGN-1)/(size_t)_ALIGN - 1);
......@@ -349,7 +349,7 @@ public:
__ret = __mem_interface::allocate(__n);
else
{
_Obj* __STL_VOLATILE* __my_free_list = _S_free_list + _S_freelist_index(__n);
_Obj* volatile* __my_free_list = _S_free_list + _S_freelist_index(__n);
// Acquire the lock here with a constructor call.
// This ensures that it is released in exit or during stack
// unwinding.
......@@ -377,7 +377,7 @@ public:
__mem_interface::deallocate(__p, __n);
else
{
_Obj* __STL_VOLATILE* __my_free_list
_Obj* volatile* __my_free_list
= _S_free_list + _S_freelist_index(__n);
_Obj* __q = (_Obj*)__p;
......@@ -448,7 +448,7 @@ __default_alloc_template<__threads, __inst>::_S_chunk_alloc(size_t __size,
// Try to make use of the left-over piece.
if (__bytes_left > 0)
{
_Obj* __STL_VOLATILE* __my_free_list =
_Obj* volatile* __my_free_list =
_S_free_list + _S_freelist_index(__bytes_left);
((_Obj*)_S_start_free) -> _M_free_list_link = *__my_free_list;
......@@ -458,7 +458,7 @@ __default_alloc_template<__threads, __inst>::_S_chunk_alloc(size_t __size,
if (0 == _S_start_free)
{
size_t __i;
_Obj* __STL_VOLATILE* __my_free_list;
_Obj* volatile* __my_free_list;
_Obj* __p;
// Try to make do with what we have. That can't hurt. We
// do not try smaller requests, since that tends to result
......@@ -500,7 +500,7 @@ __default_alloc_template<__threads, __inst>::_S_refill(size_t __n)
{
int __nobjs = 20;
char* __chunk = _S_chunk_alloc(__n, __nobjs);
_Obj* __STL_VOLATILE* __my_free_list;
_Obj* volatile* __my_free_list;
_Obj* __result;
_Obj* __current_obj;
_Obj* __next_obj;
......@@ -563,7 +563,7 @@ template <bool __threads, int __inst>
size_t __default_alloc_template<__threads, __inst>::_S_heap_size = 0;
template <bool __threads, int __inst>
typename __default_alloc_template<__threads, __inst>::_Obj* __STL_VOLATILE
typename __default_alloc_template<__threads, __inst>::_Obj* volatile
__default_alloc_template<__threads, __inst> ::_S_free_list[
__default_alloc_template<__threads, __inst>::_NFREELISTS
] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
......@@ -597,10 +597,10 @@ public:
typedef allocator<_Tp1> other;
};
allocator() __STL_NOTHROW {}
allocator(const allocator&) __STL_NOTHROW {}
template <class _Tp1> allocator(const allocator<_Tp1>&) __STL_NOTHROW {}
~allocator() __STL_NOTHROW {}
allocator() throw() {}
allocator(const allocator&) throw() {}
template <class _Tp1> allocator(const allocator<_Tp1>&) throw() {}
~allocator() throw() {}
pointer address(reference __x) const { return &__x; }
const_pointer address(const_reference __x) const { return &__x; }
......@@ -616,7 +616,7 @@ public:
void deallocate(pointer __p, size_type __n)
{ _Alloc::deallocate(__p, __n * sizeof(_Tp)); }
size_type max_size() const __STL_NOTHROW
size_type max_size() const throw()
{ return size_t(-1) / sizeof(_Tp); }
void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }
......@@ -673,13 +673,13 @@ struct __allocator {
typedef __allocator<_Tp1, _Alloc> other;
};
__allocator() __STL_NOTHROW {}
__allocator(const __allocator& __a) __STL_NOTHROW
__allocator() throw() {}
__allocator(const __allocator& __a) throw()
: __underlying_alloc(__a.__underlying_alloc) {}
template <class _Tp1>
__allocator(const __allocator<_Tp1, _Alloc>& __a) __STL_NOTHROW
__allocator(const __allocator<_Tp1, _Alloc>& __a) throw()
: __underlying_alloc(__a.__underlying_alloc) {}
~__allocator() __STL_NOTHROW {}
~__allocator() throw() {}
pointer address(reference __x) const { return &__x; }
const_pointer address(const_reference __x) const { return &__x; }
......@@ -695,7 +695,7 @@ struct __allocator {
void deallocate(pointer __p, size_type __n)
{ __underlying_alloc.deallocate(__p, __n * sizeof(_Tp)); }
size_type max_size() const __STL_NOTHROW
size_type max_size() const throw()
{ return size_t(-1) / sizeof(_Tp); }
void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }
......
......@@ -265,20 +265,28 @@ protected:
_Node* _M_create_node(const _Tp& __x)
{
_Node* __p = _M_get_node();
__STL_TRY {
try {
_Construct(&__p->_M_data, __x);
}
__STL_UNWIND(_M_put_node(__p));
catch(...)
{
_M_put_node(__p);
__throw_exception_again;
}
return __p;
}
_Node* _M_create_node()
{
_Node* __p = _M_get_node();
__STL_TRY {
try {
_Construct(&__p->_M_data);
}
__STL_UNWIND(_M_put_node(__p));
catch(...)
{
_M_put_node(__p);
__throw_exception_again;
}
return __p;
}
......
......@@ -200,19 +200,35 @@ public:
bool empty() const { return c.empty(); }
size_type size() const { return c.size(); }
const_reference top() const { return c.front(); }
void push(const value_type& __x) {
__STL_TRY {
c.push_back(__x);
push_heap(c.begin(), c.end(), comp);
}
__STL_UNWIND(c.clear());
void
push(const value_type& __x)
{
try
{
c.push_back(__x);
push_heap(c.begin(), c.end(), comp);
}
catch(...)
{
c.clear();
__throw_exception_again;
}
}
void pop() {
__STL_TRY {
pop_heap(c.begin(), c.end(), comp);
c.pop_back();
}
__STL_UNWIND(c.clear());
void
pop()
{
try
{
pop_heap(c.begin(), c.end(), comp);
c.pop_back();
}
catch(...)
{
c.clear();
__throw_exception_again;
}
}
};
......
......@@ -138,14 +138,20 @@ public:
typedef typename __type_traits<_Tp>::has_trivial_default_constructor
_Trivial;
__STL_TRY {
try {
_M_len = 0;
distance(__first, __last, _M_len);
_M_allocate_buffer();
if (_M_len > 0)
_M_initialize_buffer(*__first, _Trivial());
}
__STL_UNWIND(free(_M_buffer); _M_buffer = 0; _M_len = 0);
catch(...)
{
free(_M_buffer);
_M_buffer = 0;
_M_len = 0;
__throw_exception_again;
}
}
~_Temporary_buffer() {
......
......@@ -556,10 +556,14 @@ protected:
_M_create_node(const value_type& __x)
{
_Link_type __tmp = _M_get_node();
__STL_TRY {
try {
_Construct(&__tmp->_M_value_field, __x);
}
__STL_UNWIND(_M_put_node(__tmp));
catch(...)
{
_M_put_node(__tmp);
__throw_exception_again;
}
return __tmp;
}
......@@ -1032,7 +1036,7 @@ _Rb_tree<_Key,_Val,_KoV,_Compare,_Alloc>
_Link_type __top = _M_clone_node(__x);
__top->_M_parent = __p;
__STL_TRY {
try {
if (__x->_M_right)
__top->_M_right = _M_copy(_S_right(__x), __top);
__p = __top;
......@@ -1048,8 +1052,11 @@ _Rb_tree<_Key,_Val,_KoV,_Compare,_Alloc>
__x = _S_left(__x);
}
}
__STL_UNWIND(_M_erase(__top));
catch(...)
{
_M_erase(__top);
__throw_exception_again;
}
return __top;
}
......
......@@ -81,12 +81,16 @@ namespace std
__false_type)
{
_ForwardIter __cur = __result;
__STL_TRY {
try {
for ( ; __first != __last; ++__first, ++__cur)
_Construct(&*__cur, *__first);
return __cur;
}
__STL_UNWIND(_Destroy(__result, __cur));
catch(...)
{
_Destroy(__result, __cur);
__throw_exception_again;
}
}
template<typename _InputIter, typename _ForwardIter>
......@@ -122,12 +126,16 @@ namespace std
input_iterator_tag)
{
_ForwardIter __cur = __result;
__STL_TRY {
try {
for ( ; __count > 0 ; --__count, ++__first, ++__cur)
_Construct(&*__cur, *__first);
return pair<_InputIter, _ForwardIter>(__first, __cur);
}
__STL_UNWIND(_Destroy(__result, __cur));
catch(...)
{
_Destroy(__result, __cur);
__throw_exception_again;
}
}
template<typename _RandomAccessIter, typename _Size, typename _ForwardIter>
......@@ -172,11 +180,15 @@ namespace std
const _Tp& __x, __false_type)
{
_ForwardIter __cur = __first;
__STL_TRY {
try {
for ( ; __cur != __last; ++__cur)
_Construct(&*__cur, __x);
}
__STL_UNWIND(_Destroy(__first, __cur));
catch(...)
{
_Destroy(__first, __cur);
__throw_exception_again;
}
}
template<typename _ForwardIter, typename _Tp>
......@@ -204,12 +216,16 @@ namespace std
const _Tp& __x, __false_type)
{
_ForwardIter __cur = __first;
__STL_TRY {
try {
for ( ; __n > 0; --__n, ++__cur)
_Construct(&*__cur, __x);
return __cur;
}
__STL_UNWIND(_Destroy(__first, __cur));
catch(...)
{
_Destroy(__first, __cur);
__throw_exception_again;
}
}
template<typename _ForwardIter, typename _Size, typename _Tp>
......@@ -236,10 +252,14 @@ namespace std
_ForwardIter __result)
{
_ForwardIter __mid = uninitialized_copy(__first1, __last1, __result);
__STL_TRY {
try {
return uninitialized_copy(__first2, __last2, __mid);
}
__STL_UNWIND(_Destroy(__result, __mid));
catch(...)
{
_Destroy(__result, __mid);
__throw_exception_again;
}
}
// __uninitialized_fill_copy
......@@ -252,10 +272,14 @@ namespace std
_InputIter __first, _InputIter __last)
{
uninitialized_fill(__result, __mid, __x);
__STL_TRY {
try {
return uninitialized_copy(__first, __last, __mid);
}
__STL_UNWIND(_Destroy(__result, __mid));
catch(...)
{
_Destroy(__result, __mid);
__throw_exception_again;
}
}
// __uninitialized_copy_fill
......@@ -268,10 +292,14 @@ namespace std
const _Tp& __x)
{
_ForwardIter __mid2 = uninitialized_copy(__first1, __last1, __first2);
__STL_TRY {
try {
uninitialized_fill(__mid2, __last2, __x);
}
__STL_UNWIND(_Destroy(__first2, __mid2));
catch(...)
{
_Destroy(__first2, __mid2);
__throw_exception_again;
}
}
} // namespace std
......
......@@ -437,11 +437,15 @@ protected:
_ForwardIterator __last)
{
pointer __result = _M_allocate(__n);
__STL_TRY {
try {
uninitialized_copy(__first, __last, __result);
return __result;
}
__STL_UNWIND(_M_deallocate(__result, __n));
catch(...)
{
_M_deallocate(__result, __n);
__throw_exception_again;
}
}
template <class _InputIterator>
......@@ -617,7 +621,7 @@ vector<_Tp, _Alloc>::_M_insert_aux(iterator __position, const _Tp& __x)
const size_type __len = __old_size != 0 ? 2 * __old_size : 1;
iterator __new_start(_M_allocate(__len));
iterator __new_finish(__new_start);
__STL_TRY {
try {
__new_finish = uninitialized_copy(iterator(_M_start), __position,
__new_start);
_Construct(__new_finish.base(), __x);
......@@ -625,8 +629,12 @@ vector<_Tp, _Alloc>::_M_insert_aux(iterator __position, const _Tp& __x)
__new_finish = uninitialized_copy(__position, iterator(_M_finish),
__new_finish);
}
__STL_UNWIND((_Destroy(__new_start,__new_finish),
_M_deallocate(__new_start.base(),__len)));
catch(...)
{
_Destroy(__new_start,__new_finish);
_M_deallocate(__new_start.base(),__len);
__throw_exception_again;
}
_Destroy(begin(), end());
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __new_start.base();
......@@ -651,7 +659,7 @@ vector<_Tp, _Alloc>::_M_insert_aux(iterator __position)
const size_type __len = __old_size != 0 ? 2 * __old_size : 1;
pointer __new_start = _M_allocate(__len);
pointer __new_finish = __new_start;
__STL_TRY {
try {
__new_finish = uninitialized_copy(iterator(_M_start), __position,
__new_start);
_Construct(__new_finish);
......@@ -659,8 +667,12 @@ vector<_Tp, _Alloc>::_M_insert_aux(iterator __position)
__new_finish = uninitialized_copy(__position, iterator(_M_finish),
__new_finish);
}
__STL_UNWIND((_Destroy(__new_start,__new_finish),
_M_deallocate(__new_start,__len)));
catch(...)
{
_Destroy(__new_start,__new_finish);
_M_deallocate(__new_start,__len);
__throw_exception_again;
}
_Destroy(begin(), end());
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __new_start;
......@@ -697,14 +709,18 @@ void vector<_Tp, _Alloc>::_M_fill_insert(iterator __position, size_type __n,
const size_type __len = __old_size + max(__old_size, __n);
iterator __new_start(_M_allocate(__len));
iterator __new_finish(__new_start);
__STL_TRY {
try {
__new_finish = uninitialized_copy(begin(), __position, __new_start);
__new_finish = uninitialized_fill_n(__new_finish, __n, __x);
__new_finish
= uninitialized_copy(__position, end(), __new_finish);
}
__STL_UNWIND((_Destroy(__new_start,__new_finish),
_M_deallocate(__new_start.base(),__len)));
catch(...)
{
_Destroy(__new_start,__new_finish);
_M_deallocate(__new_start.base(),__len);
__throw_exception_again;
}
_Destroy(_M_start, _M_finish);
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __new_start.base();
......@@ -761,15 +777,19 @@ vector<_Tp, _Alloc>::_M_range_insert(iterator __position,
const size_type __len = __old_size + max(__old_size, __n);
iterator __new_start(_M_allocate(__len));
iterator __new_finish(__new_start);
__STL_TRY {
try {
__new_finish = uninitialized_copy(iterator(_M_start),
__position, __new_start);
__new_finish = uninitialized_copy(__first, __last, __new_finish);
__new_finish
= uninitialized_copy(__position, iterator(_M_finish), __new_finish);
}
__STL_UNWIND((_Destroy(__new_start,__new_finish),
_M_deallocate(__new_start.base(),__len)));
catch(...)
{
_Destroy(__new_start,__new_finish);
_M_deallocate(__new_start.base(), __len);
__throw_exception_again;
}
_Destroy(_M_start, _M_finish);
_M_deallocate(_M_start, _M_end_of_storage - _M_start);
_M_start = __new_start.base();
......
......@@ -317,21 +317,29 @@ private:
_Node* _M_create_node(const value_type& __x) {
_Node* __node = this->_M_get_node();
__STL_TRY {
try {
_Construct(&__node->_M_data, __x);
__node->_M_next = 0;
}
__STL_UNWIND(this->_M_put_node(__node));
catch(...)
{
this->_M_put_node(__node);
__throw_exception_again;
}
return __node;
}
_Node* _M_create_node() {
_Node* __node = this->_M_get_node();
__STL_TRY {
try {
_Construct(&__node->_M_data);
__node->_M_next = 0;
}
__STL_UNWIND(this->_M_put_node(__node));
catch(...)
{
this->_M_put_node(__node);
__throw_exception_again;
}
return __node;
}
......
......@@ -516,11 +516,15 @@ private:
{
_Node* __n = _M_get_node();
__n->_M_next = 0;
__STL_TRY {
try {
_Construct(&__n->_M_val, __obj);
return __n;
}
__STL_UNWIND(_M_put_node(__n));
catch(...)
{
_M_put_node(__n);
__throw_exception_again;
}
}
void _M_delete_node(_Node* __n)
......@@ -849,7 +853,7 @@ void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
if (__n > __old_n) {
vector<_Node*, _All> __tmp(__n, (_Node*)(0),
_M_buckets.get_allocator());
__STL_TRY {
try {
for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) {
_Node* __first = _M_buckets[__bucket];
while (__first) {
......@@ -862,7 +866,6 @@ void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
}
_M_buckets.swap(__tmp);
}
# ifdef __STL_USE_EXCEPTIONS
catch(...) {
for (size_type __bucket = 0; __bucket < __tmp.size(); ++__bucket) {
while (__tmp[__bucket]) {
......@@ -871,9 +874,8 @@ void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
__tmp[__bucket] = __next;
}
}
throw;
__throw_exception_again;
}
# endif /* __STL_USE_EXCEPTIONS */
}
}
}
......@@ -937,7 +939,7 @@ void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
_M_buckets.clear();
_M_buckets.reserve(__ht._M_buckets.size());
_M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*) 0);
__STL_TRY {
try {
for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) {
const _Node* __cur = __ht._M_buckets[__i];
if (__cur) {
......@@ -954,7 +956,11 @@ void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
}
_M_num_elements = __ht._M_num_elements;
}
__STL_UNWIND(clear());
catch(...)
{
clear();
__throw_exception_again;
}
}
} // namespace std
......
......@@ -572,7 +572,6 @@ struct _Rope_RopeLeaf : public _Rope_RopeRep<_CharT,_Alloc> {
: _Rope_RopeRep<_CharT,_Alloc>(_S_leaf, 0, true, __size, __a),
_M_data(__d)
{
__stl_assert(__size > 0);
if (_S_is_basic_char_type((_CharT *)0)) {
// already eos terminated.
_M_c_string = __d;
......@@ -646,7 +645,6 @@ struct _Rope_RopeFunction : public _Rope_RopeRep<_CharT,_Alloc> {
, _M_delete_when_done(__d)
# endif
{
__stl_assert(__size > 0);
# ifdef __GC
if (__d) {
GC_REGISTER_FINALIZER(
......@@ -685,8 +683,6 @@ struct _Rope_RopeSubstring : public _Rope_RopeFunction<_CharT,_Alloc>,
{
char_producer<_CharT>* __fn =
((_Rope_RopeFunction<_CharT,_Alloc>*)_M_base)->_M_fn;
__stl_assert(__start_pos + __req_len <= _M_size);
__stl_assert(_M_start + _M_size <= _M_base->_M_size);
(*__fn)(__start_pos + _M_start, __req_len, __buffer);
}
break;
......@@ -699,7 +695,7 @@ struct _Rope_RopeSubstring : public _Rope_RopeFunction<_CharT,_Alloc>,
}
break;
default:
__stl_assert(false);
break;
}
}
typedef typename _Rope_rep_base<_CharT,_Alloc>::allocator_type
......@@ -711,8 +707,6 @@ struct _Rope_RopeSubstring : public _Rope_RopeFunction<_CharT,_Alloc>,
_M_base(__b),
_M_start(__s)
{
__stl_assert(__l > 0);
__stl_assert(__s + __l <= __b->_M_size);
# ifndef __GC
_M_base->_M_ref_nonnil();
# endif
......@@ -743,11 +737,11 @@ struct _Rope_RopeSubstring : public _Rope_RopeFunction<_CharT,_Alloc>,
_Rope_RopeRep<_CharT,_Alloc>* _M_ptr;
~_Rope_self_destruct_ptr()
{ _Rope_RopeRep<_CharT,_Alloc>::_S_unref(_M_ptr); }
# ifdef __STL_USE_EXCEPTIONS
#ifdef __EXCEPTIONS
_Rope_self_destruct_ptr() : _M_ptr(0) {};
# else
#else
_Rope_self_destruct_ptr() {};
# endif
#endif
_Rope_self_destruct_ptr(_Rope_RopeRep<_CharT,_Alloc>* __p) : _M_ptr(__p) {}
_Rope_RopeRep<_CharT,_Alloc>& operator*() { return *_M_ptr; }
_Rope_RopeRep<_CharT,_Alloc>* operator->() { return _M_ptr; }
......@@ -818,7 +812,6 @@ class _Rope_char_ptr_proxy {
: _M_pos(__x._M_pos), _M_root(__x._M_root) {}
_Rope_char_ptr_proxy() {}
_Rope_char_ptr_proxy(_CharT* __x) : _M_root(0), _M_pos(0) {
__stl_assert(0 == __x);
}
_Rope_char_ptr_proxy&
operator= (const _Rope_char_ptr_proxy& __x) {
......@@ -1403,10 +1396,14 @@ class rope : public _Rope_base<_CharT,_Alloc> {
uninitialized_copy_n(__s, __size, __buf);
_S_cond_store_eos(__buf[__size]);
__STL_TRY {
try {
return _S_new_RopeLeaf(__buf, __size, __a);
}
__STL_UNWIND(_RopeRep::__STL_FREE_STRING(__buf, __size, __a))
catch(...)
{
_RopeRep::__STL_FREE_STRING(__buf, __size, __a);
__throw_exception_again;
}
}
......@@ -1541,10 +1538,14 @@ class rope : public _Rope_base<_CharT,_Alloc> {
_CharT* __buf = _Data_allocate(_S_rounded_up_size(1));
_Construct(__buf, __c);
__STL_TRY {
try {
_M_tree_ptr = _S_new_RopeLeaf(__buf, 1, __a);
}
__STL_UNWIND(_RopeRep::__STL_FREE_STRING(__buf, 1, __a))
catch(...)
{
_RopeRep::__STL_FREE_STRING(__buf, 1, __a);
__throw_exception_again;
}
}
rope(size_t __n, _CharT __c,
......@@ -1576,7 +1577,6 @@ class rope : public _Rope_base<_CharT,_Alloc> {
rope& operator=(const rope& __x)
{
_RopeRep* __old = _M_tree_ptr;
__stl_assert(get_allocator() == __x.get_allocator());
_M_tree_ptr = __x._M_tree_ptr;
_S_ref(_M_tree_ptr);
_S_unref(__old);
......@@ -1614,12 +1614,16 @@ class rope : public _Rope_base<_CharT,_Alloc> {
_RopeRep* __old = _M_tree_ptr;
_RopeRep* __left =
__STL_ROPE_FROM_UNOWNED_CHAR_PTR(&__x, 1, get_allocator());
__STL_TRY {
try {
_M_tree_ptr = _S_concat(__left, _M_tree_ptr);
_S_unref(__old);
_S_unref(__left);
}
__STL_UNWIND(_S_unref(__left))
catch(...)
{
_S_unref(__left);
__throw_exception_again;
}
}
void pop_front()
......@@ -1793,8 +1797,6 @@ class rope : public _Rope_base<_CharT,_Alloc> {
}
rope& append(const_iterator __s, const_iterator __e) {
__stl_assert(__s._M_root == __e._M_root);
__stl_assert(get_allocator() == __s._M_root->get_allocator());
_Self_destruct_ptr __appendee(_S_substring(
__s._M_root, __s._M_current_pos, __e._M_current_pos));
_RopeRep* __result =
......@@ -1815,7 +1817,6 @@ class rope : public _Rope_base<_CharT,_Alloc> {
rope& append() { return append(_CharT()); } // XXX why?
rope& append(const rope& __y) {
__stl_assert(__y.get_allocator() == get_allocator());
_RopeRep* __result = _S_concat(_M_tree_ptr, __y._M_tree_ptr);
_S_unref(_M_tree_ptr);
_M_tree_ptr = __result;
......@@ -1828,7 +1829,6 @@ class rope : public _Rope_base<_CharT,_Alloc> {
}
void swap(rope& __b) {
__stl_assert(get_allocator() == __b.get_allocator());
_RopeRep* __tmp = _M_tree_ptr;
_M_tree_ptr = __b._M_tree_ptr;
__b._M_tree_ptr = __tmp;
......@@ -1846,7 +1846,6 @@ class rope : public _Rope_base<_CharT,_Alloc> {
_S_substring(__old, __pos2, __old->_M_size));
_RopeRep* __result;
__stl_assert(__old->get_allocator() == __r->get_allocator());
if (0 == __r) {
__result = _S_concat(__left, __right);
} else {
......@@ -1860,7 +1859,6 @@ class rope : public _Rope_base<_CharT,_Alloc> {
void insert(size_t __p, const rope& __r) {
_RopeRep* __result =
replace(_M_tree_ptr, __p, __p, __r._M_tree_ptr);
__stl_assert(get_allocator() == __r.get_allocator());
_S_unref(_M_tree_ptr);
_M_tree_ptr = __result;
}
......@@ -2326,7 +2324,6 @@ rope<_CharT,_Alloc>
operator+ (const rope<_CharT,_Alloc>& __left,
const rope<_CharT,_Alloc>& __right)
{
__stl_assert(__left.get_allocator() == __right.get_allocator());
return rope<_CharT,_Alloc>(
rope<_CharT,_Alloc>::_S_concat(__left._M_tree_ptr, __right._M_tree_ptr));
// Inlining this should make it possible to keep __left and
......
......@@ -30,7 +30,7 @@
#include "typeinfo"
#include "exception"
#include <cstddef>
#include <cstdlib>
#include "unwind-cxx.h"
#include "exception_defines.h"
......@@ -54,3 +54,4 @@ __cxa_bad_typeid ()
std::abort();
#endif
}
......@@ -30,6 +30,7 @@
#include <bits/c++config.h>
#include <cstdlib>
#include <exception_defines.h>
#include "unwind-cxx.h"
using namespace __cxxabiv1;
......@@ -412,31 +413,33 @@ __cxa_call_unexpected (_Unwind_Exception *exc_obj)
__cxa_exception *xh = __get_exception_header_from_ue (exc_obj);
try {
__unexpected (xh->unexpectedHandler);
} catch (...) {
// Get the exception thrown from unexpected.
// ??? Foreign exceptions can't be stacked this way.
__cxa_eh_globals *globals = __cxa_get_globals_fast ();
__cxa_exception *new_xh = globals->caughtExceptions;
// We don't quite have enough stuff cached; re-parse the LSDA.
lsda_header_info info;
parse_lsda_header (0, xh->languageSpecificData, &info);
info.ttype_base = (_Unwind_Ptr) xh->catchTemp;
// If this new exception meets the exception spec, allow it.
if (check_exception_spec (&info, new_xh->exceptionType,
xh->handlerSwitchValue))
throw;
// If the exception spec allows std::bad_exception, throw that.
const std::type_info &bad_exc = typeid (std::bad_exception);
if (check_exception_spec (&info, &bad_exc, xh->handlerSwitchValue))
throw std::bad_exception ();
// Otherwise, die.
__terminate(xh->terminateHandler);
}
try
{ __unexpected (xh->unexpectedHandler); }
catch(...)
{
// Get the exception thrown from unexpected.
// ??? Foreign exceptions can't be stacked this way.
__cxa_eh_globals *globals = __cxa_get_globals_fast ();
__cxa_exception *new_xh = globals->caughtExceptions;
// We don't quite have enough stuff cached; re-parse the LSDA.
lsda_header_info info;
parse_lsda_header (0, xh->languageSpecificData, &info);
info.ttype_base = (_Unwind_Ptr) xh->catchTemp;
// If this new exception meets the exception spec, allow it.
if (check_exception_spec (&info, new_xh->exceptionType,
xh->handlerSwitchValue))
__throw_exception_again;
// If the exception spec allows std::bad_exception, throw that.
#ifdef __EXCEPTIONS
const std::type_info &bad_exc = typeid (std::bad_exception);
if (check_exception_spec (&info, &bad_exc, xh->handlerSwitchValue))
throw std::bad_exception();
#endif
// Otherwise, die.
__terminate(xh->terminateHandler);
}
}
......@@ -28,6 +28,7 @@
// the GNU General Public License.
#include "new"
#include <cstdlib>
#include <exception_defines.h>
using std::new_handler;
......
......@@ -34,7 +34,6 @@
#include <new>
#include <exception>
#include <exception_defines.h>
#include "unwind-cxx.h"
namespace __cxxabiv1
......
......@@ -110,43 +110,43 @@ namespace std
{ abort(); }
void
__throw_logic_error(const char* __s)
__throw_logic_error(const char*)
{ abort(); }
void
__throw_domain_error(const char* __s)
__throw_domain_error(const char*)
{ abort(); }
void
__throw_invalid_argument(const char* __s)
__throw_invalid_argument(const char*)
{ abort(); }
void
__throw_length_error(const char* __s)
__throw_length_error(const char*)
{ abort(); }
void
__throw_out_of_range(const char* __s)
__throw_out_of_range(const char*)
{ abort(); }
void
__throw_runtime_error(const char* __s)
__throw_runtime_error(const char*)
{ abort(); }
void
__throw_range_error(const char* __s)
__throw_range_error(const char*)
{ abort(); }
void
__throw_overflow_error(const char* __s)
__throw_overflow_error(const char*)
{ abort(); }
void
__throw_underflow_error(const char* __s)
__throw_underflow_error(const char*)
{ abort(); }
void
__throw_ios_failure(const char* __s)
__throw_ios_failure(const char*)
{ abort(); }
#endif //__EXCEPTIONS
}
......@@ -23,15 +23,13 @@
#include <bitset>
#include <testsuite_hooks.h>
bool test01(void)
void
test01(void)
{
bool test = true;
const size_t n1 = 5;
// the other 22 member functions should be in here too...
// test()
// the other 22 member functions should be in here too...
try {
std::bitset<n1> five_bits;
bool unused = five_bits.test(n1); // should throw
......@@ -43,12 +41,7 @@ bool test01(void)
catch(...) {
VERIFY( false );
}
#ifdef DEBUG_ASSERT
assert(test);
#endif
return test;
VERIFY( test );
}
int main()
......
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