This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] stdexcept, stringfwd
- To: gcc-patches at gcc dot gnu dot org
- Subject: [v3] stdexcept, stringfwd
- From: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Wed, 7 Feb 2001 12:21:30 -0800
This patch cleans up the stdexcept bits, as a preliminary measure to
getting -fno-exceptions to work with v3.
2001-02-07 Benjamin Kosnik <bkoz@redhat.com>
Clean up stdexcept.
* include/bits/stringfwd.h: New file.
* include/bits/stl_string_fwd.h: Remove.
* include/bits/localefwd.h: Remove declaration for allocator.
* include/bits/std_iosfwd: Same.
* include/bits/std_string.h: Include it.
* include/bits/std_ios.h: Remove include.
* include/bits/basic_string.h: Tweak.
* libsupc++/new: Format.
* src/Makefile.am (base_headers): Add stringfwd.h, remove
stl_string_fwd.h
* src/Makefile.in: Regenerate.
* include/bits/std_stdexcept.h: Rewrite.
* src/stdexcept.cc: Same.
Index: include/bits/basic_string.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/bits/basic_string.h,v
retrieving revision 1.3
diff -c -p -r1.3 basic_string.h
*** basic_string.h 2001/01/12 21:24:15 1.3
--- basic_string.h 2001/02/07 20:04:49
*************** namespace std {
*** 1028,1034 ****
inline basic_istream<_CharT,_Traits>&
getline(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Alloc>& __str);
-
} // namespace std
#endif /* _CPP_BITS_STRING_H */
--- 1028,1033 ----
Index: include/bits/localefwd.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/bits/localefwd.h,v
retrieving revision 1.10
diff -c -p -r1.10 localefwd.h
*** localefwd.h 2001/02/03 08:33:35 1.10
--- localefwd.h 2001/02/07 20:04:50
*************** namespace std
*** 79,86 ****
};
// 22.1.1 Locale
! template<typename _Tp> class allocator;
! template<typename _Tp, typename _Alloc> class vector;
class locale;
// 22.1.3 Convenience interfaces
--- 79,86 ----
};
// 22.1.1 Locale
! template<typename _Tp, typename _Alloc>
! class vector;
class locale;
// 22.1.3 Convenience interfaces
Index: include/bits/std_ios.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/bits/std_ios.h,v
retrieving revision 1.2
diff -c -p -r1.2 std_ios.h
*** std_ios.h 2000/10/10 23:50:38 1.2
--- std_ios.h 2001/02/07 20:04:50
***************
*** 1,6 ****
// Iostreams base classes -*- C++ -*-
! // Copyright (C) 1997-1999 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
--- 1,6 ----
// Iostreams base classes -*- C++ -*-
! // 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,43 ****
#include <bits/std_iosfwd.h>
#include <exception> // For ios_base::failure
#include <bits/char_traits.h> // For char_traits, streamoff, streamsize, fpos
- #include <bits/stl_string_fwd.h>// For string.
#include <bits/std_cstdio.h> // For SEEK_SET, SEEK_CUR, SEEK_END
#include <bits/localefwd.h> // For class locale
#include <bits/ios_base.h> // For ios_base declarations.
--- 37,42 ----
Index: include/bits/std_iosfwd.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/bits/std_iosfwd.h,v
retrieving revision 1.1
diff -c -p -r1.1 std_iosfwd.h
*** std_iosfwd.h 2000/10/05 11:27:01 1.1
--- std_iosfwd.h 2001/02/07 20:04:50
***************
*** 36,48 ****
#include <bits/c++config.h>
#include <bits/std_cwchar.h> // For mbstate_t
! namespace std {
!
! // Generic declarations.
! template<typename _CharT> struct char_traits;
! template<typename _Alloc> class allocator;
!
// Forward declarations
template<> class char_traits<char>;
#ifdef _GLIBCPP_USE_WCHAR_T
--- 36,45 ----
#include <bits/c++config.h>
#include <bits/std_cwchar.h> // For mbstate_t
+ #include <bits/stringfwd.h> // For string forward declarations.
! namespace std
! {
// Forward declarations
template<> class char_traits<char>;
#ifdef _GLIBCPP_USE_WCHAR_T
*************** namespace std {
*** 50,102 ****
#endif
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_ios;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_streambuf;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_istream;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_ostream;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_iostream;
template<typename _CharT, typename _Traits = char_traits<_CharT>,
typename _Alloc = allocator<_CharT> >
! class basic_stringbuf;
template<typename _CharT, typename _Traits = char_traits<_CharT>,
typename _Alloc = allocator<_CharT> >
! class basic_istringstream;
template<typename _CharT, typename _Traits = char_traits<_CharT>,
typename _Alloc = allocator<_CharT> >
! class basic_ostringstream;
template<typename _CharT, typename _Traits = char_traits<_CharT>,
typename _Alloc = allocator<_CharT> >
! class basic_stringstream;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_filebuf;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_ifstream;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_ofstream;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_fstream;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class istreambuf_iterator;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class ostreambuf_iterator;
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
// Not included.
--- 47,99 ----
#endif
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_ios;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_streambuf;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_istream;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_ostream;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_iostream;
template<typename _CharT, typename _Traits = char_traits<_CharT>,
typename _Alloc = allocator<_CharT> >
! class basic_stringbuf;
template<typename _CharT, typename _Traits = char_traits<_CharT>,
typename _Alloc = allocator<_CharT> >
! class basic_istringstream;
template<typename _CharT, typename _Traits = char_traits<_CharT>,
typename _Alloc = allocator<_CharT> >
! class basic_ostringstream;
template<typename _CharT, typename _Traits = char_traits<_CharT>,
typename _Alloc = allocator<_CharT> >
! class basic_stringstream;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_filebuf;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_ifstream;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_ofstream;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class basic_fstream;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class istreambuf_iterator;
template<typename _CharT, typename _Traits = char_traits<_CharT> >
! class ostreambuf_iterator;
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
// Not included.
*************** namespace std {
*** 144,157 ****
typedef basic_ofstream<wchar_t> wofstream;
typedef basic_fstream<wchar_t> wfstream;
#endif
-
} // namespace std
#endif // _CPP_IOSFWD
-
-
-
-
-
-
-
--- 141,146 ----
Index: include/bits/std_stdexcept.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/bits/std_stdexcept.h,v
retrieving revision 1.2
diff -c -p -r1.2 std_stdexcept.h
*** std_stdexcept.h 2000/10/10 23:50:38 1.2
--- std_stdexcept.h 2001/02/07 20:04:50
***************
*** 1,90 ****
! /*
! * Copyright (c) 1997
! * Silicon Graphics Computer Systems, Inc.
! *
! * 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 _CPP_STDEXCEPT
! #define _CPP_STDEXCEPT 1
#include <exception>
!
! #if defined(__STL_USE_EXCEPTIONS) || \
! !(defined(_MIPS_SIM) && defined(_ABIO32) && _MIPS_SIM == _ABIO32)
!
! #include <bits/stl_string_fwd.h>
!
! __STL_BEGIN_NAMESPACE
! class __Named_exception : public exception {
! public:
! __Named_exception(const string& __str);
! virtual const char* what() const __STL_NOTHROW { return _M_name; }
!
! private:
! enum { _S_bufsize = 256 };
! char _M_name[_S_bufsize];
! };
!
! class logic_error : public __Named_exception {
! public:
! logic_error(const string& __s) : __Named_exception(__s) {}
! };
!
! class runtime_error : public __Named_exception {
! public:
! runtime_error(const string& __s) : __Named_exception(__s) {}
! };
!
! class domain_error : public logic_error {
! public:
! domain_error(const string& __arg) : logic_error(__arg) {}
! };
!
! class invalid_argument : public logic_error {
! public:
! invalid_argument(const string& __arg) : logic_error(__arg) {}
! };
!
! class length_error : public logic_error {
! public:
! length_error(const string& __arg) : logic_error(__arg) {}
! };
!
! class out_of_range : public logic_error {
! public:
! out_of_range(const string& __arg) : logic_error(__arg) {}
! };
!
! class range_error : public runtime_error {
! public:
! range_error(const string& __arg) : runtime_error(__arg) {}
! };
!
! class overflow_error : public runtime_error {
! public:
! overflow_error(const string& __arg) : runtime_error(__arg) {}
! };
!
! class underflow_error : public runtime_error {
! public:
! underflow_error(const string& __arg) : runtime_error(__arg) {}
! };
!
! __STL_END_NAMESPACE
!
! #endif /* Not o32, and no exceptions */
!
! #endif /* _CPP_STDEXCEPT */
!
! // Local Variables:
! // mode:C++
! // End:
--- 1,115 ----
! // Standard exception classes -*- C++ -*-
+ // 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
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ // GNU General Public License for more details.
+
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING. If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+
+ // As a special exception, you may use this file as part of a free software
+ // library without restriction. Specifically, if other files instantiate
+ // templates or use macros or inline functions from this file, or you compile
+ // this file and link it with other files to produce an executable, this
+ // file does not by itself cause the resulting executable to be covered by
+ // the GNU General Public License. This exception does not however
+ // invalidate any other reasons why the executable file might be covered by
+ // the GNU General Public License.
+
+ //
+ // ISO C++ 19.1 Exception classes
+ //
+
#ifndef _CPP_STDEXCEPT
! #define _CPP_STDEXCEPT 1
#include <exception>
! #include <bits/stringfwd.h>
! namespace std
! {
! class logic_error : public exception
! {
! const string& _M_msg;
!
! public:
! explicit
! logic_error(const string& __arg);
!
! virtual
! ~logic_error() throw();
!
! virtual const char*
! what() const throw();
! };
!
! class domain_error : public logic_error
! {
! public:
! explicit domain_error(const string& __arg);
! };
!
! class invalid_argument : public logic_error
! {
! public:
! explicit invalid_argument(const string& __arg);
! };
!
! class length_error : public logic_error
! {
! public:
! explicit length_error(const string& __arg);
! };
!
! class out_of_range : public logic_error
! {
! public:
! explicit out_of_range(const string& __arg);
! };
!
! class runtime_error : public exception
! {
! const string& _M_msg;
!
! public:
! explicit
! runtime_error(const string& __arg);
!
! virtual
! ~runtime_error() throw();
!
! virtual const char*
! what() const throw();
! };
!
! class range_error : public runtime_error
! {
! public:
! explicit range_error(const string& __arg);
! };
!
! class overflow_error : public runtime_error
! {
! public:
! explicit overflow_error(const string& __arg);
! };
!
! class underflow_error : public runtime_error
! {
! public:
! explicit underflow_error(const string& __arg);
! };
! } // namespace std
+ #endif // _CPP_STDEXCEPT
Index: include/bits/std_string.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/bits/std_string.h,v
retrieving revision 1.2
diff -c -p -r1.2 std_string.h
*** std_string.h 2001/01/04 04:21:41 1.2
--- std_string.h 2001/02/07 20:04:51
***************
*** 35,45 ****
#define _CPP_STRING 1
#include <bits/c++config.h>
! #include <bits/stl_string_fwd.h>
! #include <bits/std_iterator.h>
#include <bits/char_traits.h>
#include <bits/type_traits.h>
! #include <bits/std_iosfwd.h> // for operators >>, <<, and getline decls
#include <bits/basic_string.h>
#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
--- 35,46 ----
#define _CPP_STRING 1
#include <bits/c++config.h>
! #include <bits/stringfwd.h>
#include <bits/char_traits.h>
+ #include <bits/std_iterator.h>
+ #include <bits/std_memory.h> // For allocator.
#include <bits/type_traits.h>
! #include <bits/std_iosfwd.h> // For operators >>, <<, and getline decls.
#include <bits/basic_string.h>
#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
Index: libsupc++/new
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/libsupc++/new,v
retrieving revision 1.2
diff -c -p -r1.2 new
*** new 2000/10/21 16:50:28 1.2
--- new 2001/02/07 20:04:52
***************
*** 1,6 ****
// The -*- C++ -*- dynamic memory management header.
- // Copyright (C) 1994, 1996, 1997, 1998, 2000 Free Software Foundation
// This file is part of GNU CC.
//
// GNU CC is free software; you can redistribute it and/or modify
--- 1,7 ----
// The -*- C++ -*- dynamic memory management header.
+ // Copyright (C) 1994, 1996, 1997, 1998, 2000, 2001 Free Software Foundation
+
// This file is part of GNU CC.
//
// GNU CC is free software; you can redistribute it and/or modify
***************
*** 35,66 ****
#include <exception>
extern "C++" {
-
- namespace std {
! class bad_alloc : public exception {
public:
virtual const char* what() const throw() { return "bad_alloc"; }
};
! struct nothrow_t {};
extern const nothrow_t nothrow;
typedef void (*new_handler)();
! new_handler set_new_handler (new_handler);
!
} // namespace std
! // replaceable signatures
! void *operator new (std::size_t) throw (std::bad_alloc);
! void *operator new[] (std::size_t) throw (std::bad_alloc);
! void operator delete (void *) throw();
! void operator delete[] (void *) throw();
! void *operator new (std::size_t, const std::nothrow_t&) throw();
! void *operator new[] (std::size_t, const std::nothrow_t&) throw();
! void operator delete (void *, const std::nothrow_t&) throw();
! void operator delete[] (void *, const std::nothrow_t&) throw();
! // default placement versions of operator new
inline void *operator new(std::size_t, void *place) throw() { return place; }
inline void *operator new[](std::size_t, void *place) throw() { return place; }
} // extern "C++"
--- 36,67 ----
#include <exception>
extern "C++" {
! namespace std
! {
! class bad_alloc : public exception
! {
public:
virtual const char* what() const throw() { return "bad_alloc"; }
};
! struct nothrow_t { };
extern const nothrow_t nothrow;
typedef void (*new_handler)();
! new_handler set_new_handler(new_handler);
} // namespace std
! // Replaceable signatures.
! void *operator new(std::size_t) throw (std::bad_alloc);
! void *operator new[](std::size_t) throw (std::bad_alloc);
! void operator delete(void *) throw();
! void operator delete[](void *) throw();
! void *operator new(std::size_t, const std::nothrow_t&) throw();
! void *operator new[](std::size_t, const std::nothrow_t&) throw();
! void operator delete(void *, const std::nothrow_t&) throw();
! void operator delete[](void *, const std::nothrow_t&) throw();
! // Default placement versions of operator new.
inline void *operator new(std::size_t, void *place) throw() { return place; }
inline void *operator new[](std::size_t, void *place) throw() { return place; }
} // extern "C++"
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/src/Makefile.am,v
retrieving revision 1.70
diff -c -p -r1.70 Makefile.am
*** Makefile.am 2001/02/07 01:54:21 1.70
--- Makefile.am 2001/02/07 20:04:53
*************** INCLUDES = \
*** 66,72 ****
base_headers = \
bits/cpp_type_traits.h bits/char_traits.h bits/codecvt.h \
! bits/std_string.h bits/basic_string.h bits/basic_string.tcc \
bits/generic_shadow.h bits/std_utility.h \
bits/std_complex.h \
bits/valarray_array.h bits/valarray_array.tcc bits/valarray_meta.h \
--- 66,73 ----
base_headers = \
bits/cpp_type_traits.h bits/char_traits.h bits/codecvt.h \
! bits/stringfwd.h bits/std_string.h bits/basic_string.h \
! bits/basic_string.tcc \
bits/generic_shadow.h bits/std_utility.h \
bits/std_complex.h \
bits/valarray_array.h bits/valarray_array.tcc bits/valarray_meta.h \
*************** base_headers = \
*** 94,100 ****
bits/stl_multimap.h bits/stl_multiset.h bits/stl_numeric.h \
bits/stl_pair.h bits/stl_queue.h bits/stl_raw_storage_iter.h \
bits/stl_relops.h bits/stl_set.h \
! bits/stl_stack.h bits/stl_string_fwd.h bits/stl_tempbuf.h \
bits/stl_tree.h bits/stl_uninitialized.h bits/stl_vector.h \
bits/type_traits.h bits/stl_range_errors.h bits/std_algorithm.h \
bits/concept_checks.h bits/container_concepts.h \
--- 95,101 ----
bits/stl_multimap.h bits/stl_multiset.h bits/stl_numeric.h \
bits/stl_pair.h bits/stl_queue.h bits/stl_raw_storage_iter.h \
bits/stl_relops.h bits/stl_set.h \
! bits/stl_stack.h bits/stl_tempbuf.h \
bits/stl_tree.h bits/stl_uninitialized.h bits/stl_vector.h \
bits/type_traits.h bits/stl_range_errors.h bits/std_algorithm.h \
bits/concept_checks.h bits/container_concepts.h \
Index: src/Makefile.inIndex: src/stdexcept.cc
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/src/stdexcept.cc,v
retrieving revision 1.1
diff -c -p -r1.1 stdexcept.cc
*** stdexcept.cc 2000/04/21 20:33:33 1.1
--- stdexcept.cc 2001/02/07 20:04:55
***************
*** 1,6 ****
// Methods for Exception Support for -*- C++ -*-
! // Copyright (C) 1997-1999 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
--- 1,6 ----
// Methods for Exception Support for -*- C++ -*-
! // Copyright (C) 1997, 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
***************
*** 27,54 ****
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
- // Written by Mike Stump based upon the specification in the 20 September 1994
- // C++ working paper, ANSI document X3J16/94-0158.
-
//
// ISO C++ 14882: 19.1 Exception classes
//
#include <bits/std_string.h>
#include <bits/std_stdexcept.h>
#include <bits/stl_range_errors.h>
! // To break the circularity with the <stdexcept> and <string> header we
! // define two functions which throw exceptions as a direct call would do.
! namespace std {
! __Named_exception::__Named_exception(const string& __str)
! {
! strncpy(_M_name, __str.c_str(), _S_bufsize);
! _M_name[_S_bufsize - 1] = '\0';
! }
void
__out_of_range(const char *str)
{ throw out_of_range(str); }
--- 27,85 ----
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
//
// ISO C++ 14882: 19.1 Exception classes
//
#include <bits/std_string.h>
#include <bits/std_stdexcept.h>
+ #if 1
#include <bits/stl_range_errors.h>
+ #endif
+
+ namespace std
+ {
+ logic_error::logic_error(const string& __arg)
+ : exception(), _M_msg(__arg) { }
+
+ logic_error::~logic_error() throw() { };
+
+ const char*
+ logic_error::what() const throw()
+ { return _M_msg.c_str(); }
+
+ domain_error::domain_error(const string& __arg)
+ : logic_error(__arg) { }
+
+ invalid_argument::invalid_argument(const string& __arg)
+ : logic_error(__arg) { }
! length_error::length_error(const string& __arg)
! : logic_error(__arg) { }
! out_of_range::out_of_range(const string& __arg)
! : logic_error(__arg) { }
! runtime_error::runtime_error(const string& __arg)
! : exception(), _M_msg(__arg) { }
+ runtime_error::~runtime_error() throw() { };
+
+ const char*
+ runtime_error::what() const throw()
+ { return _M_msg.c_str(); }
+
+ range_error::range_error(const string& __arg)
+ : runtime_error(__arg) { }
+
+ overflow_error::overflow_error(const string& __arg)
+ : runtime_error(__arg) { }
+
+ underflow_error::underflow_error(const string& __arg)
+ : runtime_error(__arg) { }
+
+ #if 1
+ // XXX need to deal with this.
void
__out_of_range(const char *str)
{ throw out_of_range(str); }
*************** namespace std {
*** 66,73 ****
void
__stl_throw_length_error(const char* __msg)
{ throw length_error(__msg); }
!
! } //namespace std
--- 97,104 ----
void
__stl_throw_length_error(const char* __msg)
{ throw length_error(__msg); }
! #endif
! } // namespace std