This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] consistent naming of internal exceptions


as discussed.

tested x86/linux

2003-04-28  Benjamin Kosnik  <bkoz at redhat dot com>

	* src/localename.cc: Standardize exception strings.
	* src/locale.cc: Same.
	* src/ios.cc: Same.
	* include/bits/basic_string.tcc: Same.
	* include/bits/basic_ios.tcc: Same.
	* include/std/std_bitset.h: Same.
	* include/ext/ropeimpl.h: Same.
	* include/bits/stl_vector.h: Same.
	* include/bits/stl_deque.h: Same.
	* include/bits/stl_bvector.h: Same.
	* config/locale/generic/c_locale.cc: Same.
	* config/locale/gnu/c_locale.cc: Same.
	* config/locale/ieee_1003.1-2001/codecvt_specializations.h: Same.

	* testsuite/testsuite_hooks.cc (__gnu_cxx_test): Modify.

Index: config/locale/generic/c_locale.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/locale/generic/c_locale.cc,v
retrieving revision 1.9
diff -c -p -r1.9 c_locale.cc
*** config/locale/generic/c_locale.cc	28 Apr 2003 03:41:48 -0000	1.9
--- config/locale/generic/c_locale.cc	28 Apr 2003 22:10:56 -0000
*************** namespace std 
*** 215,223 ****
    locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s, 
  				    __c_locale)
    {
      __cloc = NULL;
      if (strcmp(__s, "C"))
!       __throw_runtime_error("attempt to create locale from unhandled name in generic implementation; see http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html";);
    }
  
    void
--- 215,226 ----
    locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s, 
  				    __c_locale)
    {
+     // Currently, the generic model only supports the "C" locale.
+     // See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
      __cloc = NULL;
      if (strcmp(__s, "C"))
!       __throw_runtime_error("locale::facet::_S_create_c_locale "
! 			    "name not valid");
    }
  
    void
Index: config/locale/gnu/c_locale.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/locale/gnu/c_locale.cc,v
retrieving revision 1.9
diff -c -p -r1.9 c_locale.cc
*** config/locale/gnu/c_locale.cc	28 Apr 2003 03:41:48 -0000	1.9
--- config/locale/gnu/c_locale.cc	28 Apr 2003 22:10:56 -0000
*************** namespace std 
*** 172,178 ****
      if (!__cloc)
        {
  	// This named locale is not supported by the underlying OS.
! 	__throw_runtime_error("attempt to create locale from unknown name");
        }
    }
    
--- 172,179 ----
      if (!__cloc)
        {
  	// This named locale is not supported by the underlying OS.
! 	__throw_runtime_error("locale::facet::_S_create_c_locale "
! 			      "name not valid");
        }
    }
    
Index: config/locale/ieee_1003.1-2001/codecvt_specializations.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/locale/ieee_1003.1-2001/codecvt_specializations.h,v
retrieving revision 1.8
diff -c -p -r1.8 codecvt_specializations.h
*** config/locale/ieee_1003.1-2001/codecvt_specializations.h	27 Apr 2003 19:51:25 -0000	1.8
--- config/locale/ieee_1003.1-2001/codecvt_specializations.h	28 Apr 2003 22:10:57 -0000
***************
*** 130,142 ****
  	{
  	  _M_in_desc = iconv_open(_M_int_enc, _M_ext_enc);
  	  if (_M_in_desc == __err)
! 	    __throw_runtime_error("creating iconv input descriptor failed.");
  	}
        if (!_M_out_desc)
  	{
  	  _M_out_desc = iconv_open(_M_ext_enc, _M_int_enc);
  	  if (_M_out_desc == __err)
! 	    __throw_runtime_error("creating iconv output descriptor failed.");
  	}
      }
  
--- 130,144 ----
  	{
  	  _M_in_desc = iconv_open(_M_int_enc, _M_ext_enc);
  	  if (_M_in_desc == __err)
! 	    __throw_runtime_error("__enc_traits::_M_init "
! 				  "creating iconv input descriptor failed");
  	}
        if (!_M_out_desc)
  	{
  	  _M_out_desc = iconv_open(_M_ext_enc, _M_int_enc);
  	  if (_M_out_desc == __err)
! 	    __throw_runtime_error("__enc_traits::_M_init "
! 				  "creating iconv output descriptor failed");
  	}
      }
  
Index: include/bits/basic_ios.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/basic_ios.tcc,v
retrieving revision 1.19
diff -c -p -r1.19 basic_ios.tcc
*** include/bits/basic_ios.tcc	18 Feb 2003 05:45:06 -0000	1.19
--- include/bits/basic_ios.tcc	28 Apr 2003 22:10:58 -0000
*************** namespace std
*** 43,49 ****
        else
  	  _M_streambuf_state = __state | badbit;
        if ((this->rdstate() & this->exceptions()))
! 	__throw_ios_failure("basic_ios::clear(iostate) caused exception");
      }
    
    template<typename _CharT, typename _Traits>
--- 43,49 ----
        else
  	  _M_streambuf_state = __state | badbit;
        if ((this->rdstate() & this->exceptions()))
! 	__throw_ios_failure("basic_ios::clear");
      }
    
    template<typename _CharT, typename _Traits>
Index: include/bits/basic_string.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/basic_string.tcc,v
retrieving revision 1.34
diff -c -p -r1.34 basic_string.tcc
*** include/bits/basic_string.tcc	27 Apr 2003 17:20:42 -0000	1.34
--- include/bits/basic_string.tcc	28 Apr 2003 22:10:58 -0000
*************** namespace std
*** 142,148 ****
  
  	// NB: Not required, but considered best practice.
  	if (__builtin_expect(__beg == _InIter(), 0))
! 	  __throw_logic_error("attempt to create string with null pointer");
  
  	size_type __dnew = static_cast<size_type>(std::distance(__beg, __end));
  	
--- 142,148 ----
  
  	// NB: Not required, but considered best practice.
  	if (__builtin_expect(__beg == _InIter(), 0))
! 	  __throw_logic_error("basic_string::_S_construct NULL not valid");
  
  	size_type __dnew = static_cast<size_type>(std::distance(__beg, __end));
  	
Index: include/bits/stl_bvector.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_bvector.h,v
retrieving revision 1.21
diff -c -p -r1.21 stl_bvector.h
*** include/bits/stl_bvector.h	28 Apr 2003 21:03:18 -0000	1.21
--- include/bits/stl_bvector.h	28 Apr 2003 22:11:00 -0000
*************** template <typename _Alloc> 
*** 480,486 ****
    
      void _M_range_check(size_type __n) const {
        if (__n >= this->size())
!         __throw_out_of_range(__N("vector<bool>"));
      }
    
      reference at(size_type __n)
--- 480,486 ----
    
      void _M_range_check(size_type __n) const {
        if (__n >= this->size())
!         __throw_out_of_range(__N("vector<bool>::_M_range_check"));
      }
    
      reference at(size_type __n)
Index: include/bits/stl_deque.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_deque.h,v
retrieving revision 1.36
diff -c -p -r1.36 stl_deque.h
*** include/bits/stl_deque.h	28 Apr 2003 21:03:18 -0000	1.36
--- include/bits/stl_deque.h	28 Apr 2003 22:11:01 -0000
*************** namespace std
*** 940,946 ****
      _M_range_check(size_type __n) const
      {
        if (__n >= this->size())
!         __throw_out_of_range(__N("std::deque [] access out of range"));
      }
    
    public:
--- 940,946 ----
      _M_range_check(size_type __n) const
      {
        if (__n >= this->size())
!         __throw_out_of_range(__N("deque::_M_range_check"));
      }
    
    public:
Index: include/bits/stl_vector.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_vector.h,v
retrieving revision 1.35
diff -c -p -r1.35 stl_vector.h
*** include/bits/stl_vector.h	28 Apr 2003 21:03:18 -0000	1.35
--- include/bits/stl_vector.h	28 Apr 2003 22:11:03 -0000
*************** namespace std
*** 524,530 ****
        _M_range_check(size_type __n) const
        {
  	if (__n >= this->size())
! 	  __throw_out_of_range(__N("std::vector [] access out of range"));
        }
        
      public:
--- 524,530 ----
        _M_range_check(size_type __n) const
        {
  	if (__n >= this->size())
! 	  __throw_out_of_range(__N("vector::_M_range_check"));
        }
        
      public:
Index: include/ext/ropeimpl.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/ext/ropeimpl.h,v
retrieving revision 1.17
diff -c -p -r1.17 ropeimpl.h
*** include/ext/ropeimpl.h	16 Jan 2003 20:30:26 -0000	1.17
--- include/ext/ropeimpl.h	28 Apr 2003 22:11:05 -0000
*************** rope<_CharT,_Alloc>::_S_balance(_RopeRep
*** 1121,1127 ****
        }
  
      if (__result->_M_depth > _RopeRep::_S_max_rope_depth)
!       __throw_length_error("rope too long");
      return(__result);
  }
  
--- 1121,1127 ----
        }
  
      if (__result->_M_depth > _RopeRep::_S_max_rope_depth)
!       __throw_length_error("rope::_S_balance");
      return(__result);
  }
  
Index: include/std/std_bitset.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/std/std_bitset.h,v
retrieving revision 1.14
diff -c -p -r1.14 std_bitset.h
*** include/std/std_bitset.h	28 Apr 2003 21:03:18 -0000	1.14
--- include/std/std_bitset.h	28 Apr 2003 22:11:05 -0000
*************** namespace std
*** 264,270 ****
      {
        for (size_t __i = 1; __i < _Nw; ++__i)
  	if (_M_w[__i])
! 	  __throw_overflow_error(__N("bitset value is too large to fit in unsigned long"));
        return _M_w[0];
      }
  
--- 264,270 ----
      {
        for (size_t __i = 1; __i < _Nw; ++__i)
  	if (_M_w[__i])
! 	  __throw_overflow_error(__N("_Base_bitset::_M_do_to_ulong"));
        return _M_w[0];
      }
  
*************** namespace std
*** 466,472 ****
        // localized to this single should-never-get-this-far function.
        _WordT&
        _M_getword(size_t) const
!       { __throw_out_of_range(__N("bitset is zero-length")); return *new _WordT; }
  
        _WordT
        _M_hiword() const { return 0; }
--- 466,475 ----
        // localized to this single should-never-get-this-far function.
        _WordT&
        _M_getword(size_t) const
!       { 
! 	__throw_out_of_range(__N("_Base_bitset::_M_getword")); 
! 	return *new _WordT; 
!       }
  
        _WordT
        _M_hiword() const { return 0; }
*************** namespace std
*** 706,713 ****
  		      size_t __pos = 0) : _Base()
        {
  	if (__pos > __s.size())
! 	  __throw_out_of_range("bitset -- initial position is larger than "
! 	                       "the string itself");
  	_M_copy_from_string(__s, __pos,
  			    basic_string<_CharT, _Traits, _Alloc>::npos);
        }
--- 709,715 ----
  		      size_t __pos = 0) : _Base()
        {
  	if (__pos > __s.size())
! 	  __throw_out_of_range("bitset::bitset initial position not valid");
  	_M_copy_from_string(__s, __pos,
  			    basic_string<_CharT, _Traits, _Alloc>::npos);
        }
*************** namespace std
*** 726,733 ****
  	     size_t __pos, size_t __n) : _Base()
        {
  	if (__pos > __s.size())
! 	  __throw_out_of_range("bitset -- initial position is larger than "
! 	                       "the string itself");
  	_M_copy_from_string(__s, __pos, __n);
        }
  
--- 728,734 ----
  	     size_t __pos, size_t __n) : _Base()
        {
  	if (__pos > __s.size())
! 	  __throw_out_of_range("bitset::bitset initial position not valid");
  	_M_copy_from_string(__s, __pos, __n);
        }
  
*************** namespace std
*** 862,868 ****
      set(size_t __pos, bool __val = true)
      {
        if (__pos >= _Nb)
! 	__throw_out_of_range(__N("bitset::set() argument too large"));
        return _Unchecked_set(__pos, __val);
      }
  
--- 863,869 ----
      set(size_t __pos, bool __val = true)
      {
        if (__pos >= _Nb)
! 	__throw_out_of_range(__N("bitset::set"));
        return _Unchecked_set(__pos, __val);
      }
  
*************** namespace std
*** 887,893 ****
      reset(size_t __pos)
      {
        if (__pos >= _Nb)
! 	__throw_out_of_range(__N("bitset::reset() argument too large"));
        return _Unchecked_reset(__pos);
      }
  
--- 888,894 ----
      reset(size_t __pos)
      {
        if (__pos >= _Nb)
! 	__throw_out_of_range(__N("bitset::reset"));
        return _Unchecked_reset(__pos);
      }
  
*************** namespace std
*** 911,917 ****
      flip(size_t __pos)
      {
        if (__pos >= _Nb)
! 	__throw_out_of_range(__N("bitset::flip() argument too large"));
        return _Unchecked_flip(__pos);
      }
  
--- 912,918 ----
      flip(size_t __pos)
      {
        if (__pos >= _Nb)
! 	__throw_out_of_range(__N("bitset::flip"));
        return _Unchecked_flip(__pos);
      }
  
*************** namespace std
*** 1014,1020 ****
      test(size_t __pos) const
      {
        if (__pos >= _Nb)
! 	__throw_out_of_range(__N("bitset::test() argument too large"));
        return _Unchecked_test(__pos);
      }
  
--- 1015,1021 ----
      test(size_t __pos) const
      {
        if (__pos >= _Nb)
! 	__throw_out_of_range(__N("bitset::test"));
        return _Unchecked_test(__pos);
      }
  
*************** namespace std
*** 1083,1090 ****
  	      set(__i);
  	      break;
  	    default:
! 	      __throw_invalid_argument("bitset -- string contains characters "
! 	                               "which are neither 0 nor 1");
  	    }
  	}
      }
--- 1084,1090 ----
  	      set(__i);
  	      break;
  	    default:
! 	      __throw_invalid_argument("bitset::_M_copy_from_string");
  	    }
  	}
      }
Index: src/ios.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/ios.cc,v
retrieving revision 1.41
diff -c -p -r1.41 ios.cc
*** src/ios.cc	28 Apr 2003 17:15:00 -0000	1.41
--- src/ios.cc	28 Apr 2003 22:11:06 -0000
*************** namespace std 
*** 279,285 ****
  	      {
  		_M_streambuf_state |= badbit;
  		if (_M_streambuf_state & _M_exception)
! 		  __throw_ios_failure("ios_base::_M_grow_words failure");
  		return _M_word_zero;
  	      }
  	    for (int i = 0; i < _M_word_size; i++) 
--- 279,286 ----
  	      {
  		_M_streambuf_state |= badbit;
  		if (_M_streambuf_state & _M_exception)
! 		  __throw_ios_failure("ios_base::_M_grow_words "
! 				      "allocation failed");
  		return _M_word_zero;
  	      }
  	    for (int i = 0; i < _M_word_size; i++) 
*************** namespace std 
*** 294,300 ****
  	  {
  	    _M_streambuf_state |= badbit;
  	    if (_M_streambuf_state & _M_exception)
! 	      __throw_ios_failure("ios_base::_M_grow_words failure");
  	    return _M_word_zero;
  	  }
        }
--- 295,301 ----
  	  {
  	    _M_streambuf_state |= badbit;
  	    if (_M_streambuf_state & _M_exception)
! 	      __throw_ios_failure("ios_base::_M_grow_words ix not valid");
  	    return _M_word_zero;
  	  }
        }
Index: src/locale.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/locale.cc,v
retrieving revision 1.80
diff -c -p -r1.80 locale.cc
*** src/locale.cc	28 Apr 2003 03:41:49 -0000	1.80
--- src/locale.cc	28 Apr 2003 22:11:07 -0000
*************** namespace std 
*** 279,285 ****
  	  }
        }
      else
!       __throw_runtime_error("attempt to create locale from NULL name");
    }
  
    locale::locale(const locale& __base, const char* __s, category __cat)
--- 279,285 ----
  	  }
        }
      else
!       __throw_runtime_error("locale::locale NULL not valid");
    }
  
    locale::locale(const locale& __base, const char* __s, category __cat)
*************** namespace std 
*** 434,440 ****
  	    __ret = all;
  	    break;
  	  default:
! 	    __throw_runtime_error("bad locale category");
  	  }
        }
      return __ret;
--- 434,441 ----
  	    __ret = all;
  	    break;
  	  default:
! 	    __throw_runtime_error("locale::_S_normalize_category "
! 				  "category not found");
  	  }
        }
      return __ret;
Index: src/localename.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/localename.cc,v
retrieving revision 1.38
diff -c -p -r1.38 localename.cc
*** src/localename.cc	28 Apr 2003 03:41:49 -0000	1.38
--- src/localename.cc	28 Apr 2003 22:11:07 -0000
*************** namespace std
*** 321,327 ****
    {
      size_t __index = __idp->_M_id();
      if ((__index > (__imp->_M_facets_size - 1)) || !__imp->_M_facets[__index])
!       __throw_runtime_error("no locale facet");
      _M_install_facet(__idp, __imp->_M_facets[__index]); 
    }
  
--- 321,327 ----
    {
      size_t __index = __idp->_M_id();
      if ((__index > (__imp->_M_facets_size - 1)) || !__imp->_M_facets[__index])
!       __throw_runtime_error("locale::_Impl::_M_replace_facet");
      _M_install_facet(__idp, __imp->_M_facets[__index]); 
    }
  
Index: testsuite/testsuite_hooks.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/testsuite_hooks.cc,v
retrieving revision 1.12
diff -c -p -r1.12 testsuite_hooks.cc
*** testsuite/testsuite_hooks.cc	15 Apr 2003 06:36:26 -0000	1.12
--- testsuite/testsuite_hooks.cc	28 Apr 2003 22:11:07 -0000
*************** namespace __gnu_cxx_test
*** 198,208 ****
        }
      catch (std::runtime_error& ex)
        {
! 	// Thrown by generic implemenation.
! 	if (std::strstr(ex.what(), "unhandled name in generic implementation"))
! 	  exit(0);
! 	// Thrown by gnu implemenation.
! 	else if (std::strstr(ex.what(), "unknown name"))
  	  exit(0);
  	else
  	  throw;
--- 198,205 ----
        }
      catch (std::runtime_error& ex)
        {
! 	// Thrown by generic and gnu implemenation if named locale fails.
! 	if (std::strstr(ex.what(), "name not valid"))
  	  exit(0);
  	else
  	  throw;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]