diff options
Diffstat (limited to 'libstdc++-v3/include/bits')
-rw-r--r-- | libstdc++-v3/include/bits/basic_ios.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/basic_string.h | 13 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/basic_string.tcc | 174 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/c++config | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/fstream.tcc | 6 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/functexcept.h (renamed from libstdc++-v3/include/bits/exception_support.h) | 75 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/istream.tcc | 64 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/locale_facets.tcc | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/localefwd.h | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/ostream.tcc | 32 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/std_deque.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/std_iosfwd.h | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/std_vector.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_config.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_deque.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_range_errors.h | 74 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_vector.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/streambuf.tcc | 2 |
18 files changed, 210 insertions, 264 deletions
diff --git a/libstdc++-v3/include/bits/basic_ios.h b/libstdc++-v3/include/bits/basic_ios.h index 7cac68b74c2..a6a6a87296f 100644 --- a/libstdc++-v3/include/bits/basic_ios.h +++ b/libstdc++-v3/include/bits/basic_ios.h @@ -1,6 +1,6 @@ // Iostreams base classes -*- C++ -*- -// Copyright (C) 1997-1999 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2001 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 @@ -105,7 +105,7 @@ namespace std { else _M_streambuf_state = __state | badbit; if ((this->rdstate() & this->exceptions())) - throw failure("basic_ios::clear(iostate) caused exception"); + __throw_ios_failure("basic_ios::clear(iostate) caused exception"); } inline void diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index b678dd27fd3..c173d56c987 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -34,7 +34,6 @@ #ifndef _CPP_BITS_STRING_H #define _CPP_BITS_STRING_H 1 -#include <bits/exception_support.h> #include <bits/atomicity.h> namespace std { @@ -261,7 +260,8 @@ namespace std { iterator _M_check(size_type __pos) const { - __OUTOFRANGE(__pos > this->size()); + if (__pos > this->size()) + __throw_out_of_range("basic_string::_M_check"); return _M_ibegin() + __pos; } @@ -432,14 +432,16 @@ namespace std { const_reference at(size_type __n) const { - __OUTOFRANGE(__n >= this->size()); + if (__n >= this->size()) + __throw_out_of_range("basic_string::at"); return _M_data()[__n]; } reference at(size_type __n) { - __OUTOFRANGE(__n >= size()); + if (__n >= size()) + __throw_out_of_range("basic_string::at"); _M_leak(); return _M_data()[__n]; } @@ -809,7 +811,8 @@ namespace std { basic_string substr(size_type __pos = 0, size_type __n = npos) const { - __OUTOFRANGE(__pos > this->size()); + if (__pos > this->size()) + __throw_out_of_range("basic_string::substr"); return basic_string(*this, __pos, __n); } diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index 27b0faddd8c..ef26ea3c9fa 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -87,44 +87,46 @@ namespace std _Rep* __r = _Rep::_S_create(__i, __a); traits_type::copy(__r->_M_refdata(), __buf, __i); __r->_M_length = __i; - try { - // NB: this loop looks precisely this way because - // it avoids comparing __beg != __end any more - // than strictly necessary; != might be expensive! - for (;;) - { - _CharT* __p = __r->_M_refdata() + __r->_M_length; - _CharT* __last = __r->_M_refdata() + __r->_M_capacity; - for (;;) - { - if (__beg == __end) - { - __r->_M_length = __p - __r->_M_refdata(); - *__p = _Rep::_S_terminal; // grrr. - return __r->_M_refdata(); - } - if (__p == __last) - break; - *__p++ = *__beg; - ++__beg; - } - // Allocate more space. - size_type __len = __p - __r->_M_refdata(); - _Rep* __another = _Rep::_S_create(__len + 1, __a); - traits_type::copy(__another->_M_refdata(), - __r->_M_refdata(), __len); - __r->_M_destroy(__a); - __r = __another; - __r->_M_length = __len; - } - } - catch (...) { + try + { + // NB: this loop looks precisely this way because + // it avoids comparing __beg != __end any more + // than strictly necessary; != might be expensive! + for (;;) + { + _CharT* __p = __r->_M_refdata() + __r->_M_length; + _CharT* __last = __r->_M_refdata() + __r->_M_capacity; + for (;;) + { + if (__beg == __end) + { + __r->_M_length = __p - __r->_M_refdata(); + *__p = _Rep::_S_terminal; // grrr. + return __r->_M_refdata(); + } + if (__p == __last) + break; + *__p++ = *__beg; + ++__beg; + } + // Allocate more space. + size_type __len = __p - __r->_M_refdata(); + _Rep* __another = _Rep::_S_create(__len + 1, __a); + traits_type::copy(__another->_M_refdata(), + __r->_M_refdata(), __len); + __r->_M_destroy(__a); + __r = __another; + __r->_M_length = __len; + } + } + catch(...) + { __r->_M_destroy(__a); - throw; - } + __throw_exception_again; + } return 0; } - + template<typename _CharT, typename _Traits, typename _Alloc> template <class _InIter> _CharT* @@ -139,13 +141,13 @@ namespace std // Check for out_of_range and length_error exceptions. _Rep* __r = _Rep::_S_create(__dnew, __a); - try { - _S_copy_chars(__r->_M_refdata(), __beg, __end); - } - catch (...) { - __r->_M_destroy(__a); - throw; - } + try + { _S_copy_chars(__r->_M_refdata(), __beg, __end); } + catch(...) + { + __r->_M_destroy(__a); + __throw_exception_again; + } __r->_M_length = __dnew; __r->_M_refdata()[__dnew] = _Rep::_S_terminal; // grrr. @@ -162,14 +164,16 @@ namespace std // Check for out_of_range and length_error exceptions. _Rep* __r = _Rep::_S_create(__n, __a); - try { - if (__n) - traits_type::assign(__r->_M_refdata(), __n, __c); - } - catch (...) { - __r->_M_destroy(__a); - throw; - } + try + { + if (__n) + traits_type::assign(__r->_M_refdata(), __n, __c); + } + catch(...) + { + __r->_M_destroy(__a); + __throw_exception_again; + } __r->_M_length = __n; __r->_M_refdata()[__n] = _Rep::_S_terminal; // grrr return __r->_M_refdata(); @@ -276,17 +280,19 @@ namespace std // Must reallocate. allocator_type __a = get_allocator(); _Rep* __r = _Rep::_S_create(__new_size, __a); - try { - if (__pos) - traits_type::copy(__r->_M_refdata(), _M_data(), __pos); - if (__how_much) - traits_type::copy(__r->_M_refdata() + __pos + __len2, - __src, __how_much); - } - catch (...) { - __r->_M_dispose(get_allocator()); - throw; - } + try + { + if (__pos) + traits_type::copy(__r->_M_refdata(), _M_data(), __pos); + if (__how_much) + traits_type::copy(__r->_M_refdata() + __pos + __len2, + __src, __how_much); + } + catch(...) + { + __r->_M_dispose(get_allocator()); + __throw_exception_again; + } _M_rep()->_M_dispose(__a); _M_data(__r->_M_refdata()); } @@ -307,7 +313,8 @@ namespace std { if (__res > this->capacity() || _M_rep()->_M_is_shared()) { - __LENGTHERROR(__res > this->max_size()); + if (__res > this->max_size()) + __throw_length_error("basic_string::reserve"); allocator_type __a = get_allocator(); _CharT* __tmp = _M_rep()->_M_clone(__a, __res - this->size()); _M_rep()->_M_dispose(__a); @@ -351,13 +358,14 @@ namespace std basic_string<_CharT, _Traits, _Alloc>::_Rep:: _S_create(size_t __capacity, const _Alloc& __alloc) { + typedef basic_string<_CharT, _Traits, _Alloc> __string_type; #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS // 83. String::npos vs. string::max_size() - typedef basic_string<_CharT, _Traits, _Alloc> __string_type; - __LENGTHERROR(__capacity > _S_max_size); + if (__capacity > _S_max_size) #else - __LENGTHERROR(__capacity == npos); + if (__capacity == npos) #endif + __throw_length_error("basic_string::_S_create"); // NB: Need an array of char_type[__capacity], plus a // terminating null char_type() element, plus enough for the @@ -381,13 +389,13 @@ namespace std _Rep* __r = _Rep::_S_create(_M_length + __res, __alloc); if (_M_length) { - try { - traits_type::copy(__r->_M_refdata(), _M_refdata(), _M_length); - } - catch (...) { - __r->_M_destroy(__alloc); - throw; - } + try + { traits_type::copy(__r->_M_refdata(), _M_refdata(), _M_length); } + catch(...) + { + __r->_M_destroy(__alloc); + __throw_exception_again; + } } __r->_M_length = _M_length; return __r->_M_refdata(); @@ -410,7 +418,8 @@ namespace std void basic_string<_CharT, _Traits, _Alloc>::resize(size_type __n, _CharT __c) { - __LENGTHERROR(__n > max_size()); + if (__n > max_size()) + __throw_length_error("basic_string::resize"); size_type __size = this->size(); if (__size < __n) this->append(__n - __size, __c); @@ -441,7 +450,8 @@ namespace std size_type __dmax = this->max_size(); size_type __dnew = static_cast<size_type>(distance(__k1, __k2)); - __LENGTHERROR(__dmax <= __dnew); + if (__dmax <= __dnew) + __throw_length_error("basic_string::_M_replace"); size_type __off = __i1 - _M_ibegin(); _M_mutate(__off, __dold, __dnew); // Invalidated __i1, __i2 @@ -551,7 +561,8 @@ namespace std { size_type __n1 = __i2 - __i1; size_type __off1 = __i1 - _M_ibegin(); - __LENGTHERROR(max_size() - (this->size() - __n1) <= __n2); + if (max_size() - (this->size() - __n1) <= __n2) + __throw_length_error("basic_string::replace"); _M_mutate (__off1, __n1, __n2); // Invalidated __i1, __i2 if (__n2) @@ -564,7 +575,8 @@ namespace std basic_string<_CharT, _Traits, _Alloc>:: copy(_CharT* __s, size_type __n, size_type __pos) const { - __OUTOFRANGE(__pos > this->size()); + if (__pos > this->size()) + __throw_out_of_range("basic_string::copy"); if (__n > this->size() - __pos) __n = this->size() - __pos; @@ -751,7 +763,8 @@ namespace std { size_type __size = this->size(); size_type __osize = __str.size(); - __OUTOFRANGE(__pos > __size); + if (__pos > __size) + __throw_out_of_range("basic_string::compare"); size_type __rsize= min(__size - __pos, __n); size_type __len = min(__rsize, __osize); @@ -769,8 +782,8 @@ namespace std { size_type __size = this->size(); size_type __osize = __str.size(); - __OUTOFRANGE(__pos1 > __size); - __OUTOFRANGE(__pos2 > __osize); + if (__pos1 > __size || __pos2 > __osize) + __throw_out_of_range("basic_string::compare"); size_type __rsize = min(__size - __pos1, __n1); size_type __rosize = min(__osize - __pos2, __n2); @@ -803,7 +816,8 @@ namespace std size_type __n2) const { size_type __size = this->size(); - __OUTOFRANGE(__pos > __size); + if (__pos > __size) + __throw_out_of_range("basic_string::compare"); size_type __osize = min(traits_type::length(__s), __n2); size_type __rsize = min(__size - __pos, __n1); diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 30fc80456e5..d47ce425028 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -36,12 +36,6 @@ // The current version of the C++ library in compressed ISO date format. #define __GLIBCPP__ 20010102 -// This flag controls the error handling in string, and perhaps other -// bits as time goes on: check out bits/basic_string.h for more -// info. It also helps alleviate the circular dependency between -// string and exception. -# define _GLIBCPP_USE_EXCEPTIONS 1 - // This is necessary until GCC supports separate template // compilation. #define _GLIBCPP_NO_TEMPLATE_EXPORT 1 diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc index f1ffda23eee..5898a21bc90 100644 --- a/libstdc++-v3/include/bits/fstream.tcc +++ b/libstdc++-v3/include/bits/fstream.tcc @@ -49,7 +49,7 @@ namespace std catch(...) { delete _M_file; - throw; + __throw_exception_again; } } } @@ -67,7 +67,7 @@ namespace std catch(...) { delete [] _M_buf; - throw; + __throw_exception_again; } // Allocate pback buffer. @@ -76,7 +76,7 @@ namespace std catch(...) { delete [] _M_pback; - throw; + __throw_exception_again; } } } diff --git a/libstdc++-v3/include/bits/exception_support.h b/libstdc++-v3/include/bits/functexcept.h index e4d033c9ada..a808a16e5ac 100644 --- a/libstdc++-v3/include/bits/exception_support.h +++ b/libstdc++-v3/include/bits/functexcept.h @@ -1,6 +1,6 @@ -// Methods and support infrastructure for exceptions -*- C++ -*- +// Function-Based Exception Support -*- C++ -*- -// Copyright (C) 2000 Free Software Foundation, Inc. +// Copyright (C) 2001 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 @@ -28,52 +28,57 @@ // the GNU General Public License. // -// ISO C++ 14882: 15 Exception handling +// ISO C++ 14882: 19.1 Exception classes // -// This file declares functions whose only purpose is to throw an -// exception. They help break a circularity between <string> and -// <stdexcept>. See src/stdexcept.cc, where these functions are -// defined. - -// XXX: These functions serve a similar purpose to those in -// stl/bits/stl_range_errors.h . Eventually the two approaches should -// be merged. - -#ifndef _CPP_EXCEPTION_SUPPORT_H -#define _CPP_EXCEPTION_SUPPORT_H 1 - -namespace std { - -#if _GLIBCPP_USE_EXCEPTIONS - // Internal functions for string implementation. - extern void __out_of_range(const char *__str); - extern void __length_error(const char *__str); - -# define __OUTOFRANGE(__cond) \ - do { if (__cond) __out_of_range(#__cond); } while (0) -# define __LENGTHERROR(__cond) \ - do { if (__cond) __length_error(#__cond); } while (0) -#else -# include <bits/std_cassert.h> -# define __OUTOFRANGE(__cond) assert(!(__cond)) -# define __LENGTHERROR(__cond) assert(!(__cond)) -#endif - -} // namespace std - -#endif /* _CPP_EXCEPTION_SUPPORT_H */ +#include <exception_defines.h> +namespace std +{ + // Helper for exception objects in <except> + void + __throw_bad_exception(void); + // Helper for exception objects in <new> + void + __throw_bad_alloc(void); + // Helper for exception objects in <typeinfo> + void + __throw_bad_cast(void); + void + __throw_bad_typeid(void); + // Helpers for exception objects in <stdexcept> + void + __throw_logic_error(const char* __s); + void + __throw_domain_error(const char* __s); + void + __throw_invalid_argument(const char* __s); + void + __throw_length_error(const char* __s); + void + __throw_out_of_range(const char* __s); + void + __throw_runtime_error(const char* __s); + void + __throw_range_error(const char* __s); + void + __throw_overflow_error(const char* __s); + void + __throw_underflow_error(const char* __s); + // Helpers for exception objects in basic_ios + void + __throw_ios_failure(const char* __s); +} // namespace std diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc index a8da096ae06..571af891a73 100644 --- a/libstdc++-v3/include/bits/istream.tcc +++ b/libstdc++-v3/include/bits/istream.tcc @@ -92,7 +92,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -114,7 +114,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -136,7 +136,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -160,7 +160,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -184,7 +184,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -208,7 +208,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -232,7 +232,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -256,7 +256,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -280,7 +280,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -304,7 +304,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -329,7 +329,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -353,7 +353,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -378,7 +378,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -402,7 +402,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -426,7 +426,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -450,7 +450,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -495,7 +495,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return __c; @@ -527,7 +527,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -568,7 +568,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } *__s = char_type(NULL); @@ -664,7 +664,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } *__s = char_type(NULL); @@ -708,7 +708,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -732,7 +732,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return __c; @@ -776,7 +776,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } } @@ -813,7 +813,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } } @@ -841,7 +841,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } else @@ -869,7 +869,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } else @@ -899,7 +899,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return __ret; @@ -923,7 +923,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return __ret; @@ -950,7 +950,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -976,7 +976,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -999,7 +999,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. __in.setstate(ios_base::badbit); if ((__in.exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } else @@ -1059,7 +1059,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. __in.setstate(ios_base::badbit); if ((__in.exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } if (!__extracted) diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc index 8d02641b580..38c4c0ccf1e 100644 --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -75,7 +75,7 @@ namespace std __vec_facet* __facet = __loc._M_impl->_M_facets; const locale::facet* __fp = (*__facet)[__i]; if (__fp == 0 || __i >= __facet->size()) - throw bad_cast(); + __throw_bad_cast(); return static_cast<const _Facet&>(*__fp); } @@ -1098,7 +1098,7 @@ namespace std } catch (...) { __io.flags(__fmt); - throw; + __throw_exception_again; } } diff --git a/libstdc++-v3/include/bits/localefwd.h b/libstdc++-v3/include/bits/localefwd.h index 5e08c7ec8af..17a2ec23974 100644 --- a/libstdc++-v3/include/bits/localefwd.h +++ b/libstdc++-v3/include/bits/localefwd.h @@ -35,10 +35,11 @@ #define _CPP_BITS_LOCCORE_H 1 #include <bits/c++config.h> +#include <bits/c++locale.h> // Defines __c_locale. #include <bits/std_climits.h> // For CHAR_BIT #include <bits/std_string.h> // For string #include <bits/std_cctype.h> // For isspace, etc. -#include <bits/c++locale.h> // Defines __c_locale. +#include <bits/functexcept.h> namespace std { diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc index b6b27bfa8aa..db6a09ec0f0 100644 --- a/libstdc++-v3/include/bits/ostream.tcc +++ b/libstdc++-v3/include/bits/ostream.tcc @@ -59,7 +59,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -81,7 +81,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -103,7 +103,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -125,7 +125,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -155,7 +155,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -177,7 +177,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -206,7 +206,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -228,7 +228,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -251,7 +251,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -273,7 +273,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -295,7 +295,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return *this; @@ -512,7 +512,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. __out.setstate(ios_base::badbit); if ((__out.exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return __out; @@ -545,7 +545,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. __out.setstate(ios_base::badbit); if ((__out.exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return __out; @@ -577,7 +577,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. __out.setstate(ios_base::badbit); if ((__out.exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return __out; @@ -620,7 +620,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. __out.setstate(ios_base::badbit); if ((__out.exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return __out; @@ -653,7 +653,7 @@ namespace std { // Turn this on without causing an ios::failure to be thrown. __out.setstate(ios_base::badbit); if ((__out.exceptions() & ios_base::badbit) != 0) - throw; + __throw_exception_again; } } return __out; diff --git a/libstdc++-v3/include/bits/std_deque.h b/libstdc++-v3/include/bits/std_deque.h index 574ab313755..9276294f9b7 100644 --- a/libstdc++-v3/include/bits/std_deque.h +++ b/libstdc++-v3/include/bits/std_deque.h @@ -27,7 +27,7 @@ #ifndef _CPP_DEQUE #define _CPP_DEQUE 1 -#include <bits/stl_range_errors.h> +#include <bits/functexcept.h> #include <bits/stl_algobase.h> #include <bits/stl_alloc.h> #include <bits/stl_construct.h> diff --git a/libstdc++-v3/include/bits/std_iosfwd.h b/libstdc++-v3/include/bits/std_iosfwd.h index 15631a29e2b..dc28c863606 100644 --- a/libstdc++-v3/include/bits/std_iosfwd.h +++ b/libstdc++-v3/include/bits/std_iosfwd.h @@ -1,6 +1,6 @@ // Forwarding declarations -*- C++ -*- -// Copyright (C) 1997-1999 Free Software Foundation, Inc. +// Copyright (C) 1997, 1998, 1999, 2001 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 @@ -37,6 +37,7 @@ #include <bits/c++config.h> #include <bits/std_cwchar.h> // For mbstate_t #include <bits/stringfwd.h> // For string forward declarations. +#include <bits/functexcept.h> namespace std { diff --git a/libstdc++-v3/include/bits/std_vector.h b/libstdc++-v3/include/bits/std_vector.h index 08ac4bd69de..e3613c383d1 100644 --- a/libstdc++-v3/include/bits/std_vector.h +++ b/libstdc++-v3/include/bits/std_vector.h @@ -27,7 +27,7 @@ #ifndef _CPP_VECTOR #define _CPP_VECTOR 1 -#include <bits/stl_range_errors.h> +#include <bits/functexcept.h> #include <bits/stl_algobase.h> #include <bits/stl_alloc.h> #include <bits/stl_construct.h> diff --git a/libstdc++-v3/include/bits/stl_config.h b/libstdc++-v3/include/bits/stl_config.h index d5301e2a5a3..6fe8f3046bf 100644 --- a/libstdc++-v3/include/bits/stl_config.h +++ b/libstdc++-v3/include/bits/stl_config.h @@ -265,7 +265,9 @@ # define __SGI_STL_USE_AUTO_PTR_CONVERSIONS # define __STL_HAS_NAMESPACES # define __STL_USE_NAMESPACES -# define __STL_USE_EXCEPTIONS +# ifdef __EXCEPTIONS +# define __STL_USE_EXCEPTIONS +# endif # define __STL_THROW_RANGE_ERRORS # define __STL_CAN_THROW_RANGE_ERRORS # define __STL_USE_STD_ALLOCATORS diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index 0ad596eb3b9..aea97ec7711 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -499,7 +499,7 @@ public: // Basic accessors #ifdef __STL_THROW_RANGE_ERRORS void _M_range_check(size_type __n) const { if (__n >= this->size()) - __stl_throw_range_error("deque"); + __throw_range_error("deque"); } reference at(size_type __n) diff --git a/libstdc++-v3/include/bits/stl_range_errors.h b/libstdc++-v3/include/bits/stl_range_errors.h deleted file mode 100644 index c5ddfe63cbb..00000000000 --- a/libstdc++-v3/include/bits/stl_range_errors.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 1999 - * Silicon Graphics - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Silicon Graphics makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef __STL_RANGE_ERRORS_H -#define __STL_RANGE_ERRORS_H - -// A few places in the STL throw range errors, using standard exception -// classes defined in <stdexcept>. This header file provides functions -// to throw those exception objects. - -// __STL_DONT_THROW_RANGE_ERRORS is a hook so that users can disable -// this exception throwing. - -#include <bits/stl_config.h> - -#if defined(__STL_CAN_THROW_RANGE_ERRORS) && \ - defined(__STL_USE_EXCEPTIONS) && \ - !defined(__STL_DONT_THROW_RANGE_ERRORS) -# define __STL_THROW_RANGE_ERRORS -#endif - -// For the SGI 7.3 compiler, declare these functions here and define them -// elsewhere. -#if defined(__STL_THROW_RANGE_ERRORS) && \ - defined(__sgi) && !defined(__GNUC__) && \ - _COMPILER_VERSION >= 730 && defined(_STANDARD_C_PLUS_PLUS) \ - || defined(__GNUC__) && defined(__STL_THROW_RANGE_ERRORS) - -__STL_BEGIN_NAMESPACE -void __stl_throw_range_error(const char* __msg); -void __stl_throw_length_error(const char* __msg); -__STL_END_NAMESPACE - -// For other compilers where we're throwing range errors, include the -// stdexcept header and throw the appropriate exceptions directly. -#elif defined(__STL_THROW_RANGE_ERRORS) - -#include <bits/std_stdexcept.h> - -__STL_BEGIN_NAMESPACE -inline void __stl_throw_range_error(const char* __msg) - { throw range_error(__msg); } -inline void __stl_throw_length_error(const char* __msg) - { throw length_error(__msg); } -__STL_END_NAMESPACE - -// Otherwise, define inline functions that do nothing. -#else - -__STL_BEGIN_NAMESPACE -inline void __stl_throw_range_error(const char*) {} -inline void __stl_throw_length_error(const char*) {} -__STL_END_NAMESPACE - -#endif - -#endif /* __STL_RANGE_ERRORS_H */ - -// Local Variables: -// mode:C++ -// End: - - diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 0727df6fac1..0c2997579e3 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -31,7 +31,7 @@ #ifndef __SGI_STL_INTERNAL_VECTOR_H #define __SGI_STL_INTERNAL_VECTOR_H -#include <bits/exception_support.h> +#include <bits/functexcept.h> #include <bits/concept_checks.h> @@ -231,7 +231,7 @@ public: #ifdef __STL_THROW_RANGE_ERRORS void _M_range_check(size_type __n) const { if (__n >= this->size()) - __out_of_range("vector"); + __throw_out_of_range("vector"); } reference at(size_type __n) diff --git a/libstdc++-v3/include/bits/streambuf.tcc b/libstdc++-v3/include/bits/streambuf.tcc index 85111508699..a4dfaab91bb 100644 --- a/libstdc++-v3/include/bits/streambuf.tcc +++ b/libstdc++-v3/include/bits/streambuf.tcc @@ -215,7 +215,7 @@ namespace std { } catch(exception& __fail) { if ((__ios.exceptions() & ios_base::failbit) != 0) - throw; + __throw_exception_again; } return __ret; } |