Commit d34786e3 by Benjamin Kosnik Committed by Benjamin Kosnik

ios_base.h (ios_base::failure): Tighten up throw specs.


2001-01-16  Benjamin Kosnik  <bkoz@redhat.com>

	libstdc++/1605
	* include/bits/ios_base.h (ios_base::failure): Tighten up throw specs.
	* src/ios.cc (ios_base::failure): Make definitions match.
        * libsupc++/typeinfo (class bad_typeid): Add throw specs.
        (class bad_cast): Same.
        * libsupc++/exception (class exception): Add throw specs.
        * libsupc++/exception_support.cc (set_terminate): Add throw specs.
        (set_unexpected): Same.
        (uncaught_exception): Same.
        (what): Same.

	* docs/html/17_intro/C++STYLE (classname): Fix.

From-SVN: r39087
parent 5fdfba85
2001-01-16 Benjamin Kosnik <bkoz@redhat.com>
libstdc++/1605
* include/bits/ios_base.h (ios_base::failure): Tighten up throw specs.
* src/ios.cc (ios_base::failure): Make definitions match.
* libsupc++/typeinfo (class bad_typeid): Add throw specs.
(class bad_cast): Same.
* libsupc++/exception (class exception): Add throw specs.
* libsupc++/exception_support.cc (set_terminate): Add throw specs.
(set_unexpected): Same.
(uncaught_exception): Same.
(what): Same.
* docs/html/17_intro/C++STYLE (classname): Fix.
2001-01-16 Mark Mitchell <mark@codesourcery.com> 2001-01-16 Mark Mitchell <mark@codesourcery.com>
* src/gen-num-limits.cc (INSTANTIATIONS): New macro. * src/gen-num-limits.cc (INSTANTIATIONS): New macro.
......
...@@ -99,8 +99,8 @@ Notable areas of divergence from what may be previous local practice ...@@ -99,8 +99,8 @@ Notable areas of divergence from what may be previous local practice
07. Member initialization lists 07. Member initialization lists
All one line, separate from class name. All one line, separate from class name.
gribble::gribble() : gribble::gribble()
_M_private_data(0), _M_more_stuff(0), _M_helper(0); : _M_private_data(0), _M_more_stuff(0), _M_helper(0);
{ } { }
-NOT- -NOT-
gribble::gribble() : _M_private_data(0), _M_more_stuff(0), _M_helper(0); gribble::gribble() : _M_private_data(0), _M_more_stuff(0), _M_helper(0);
......
...@@ -146,10 +146,10 @@ namespace std { ...@@ -146,10 +146,10 @@ namespace std {
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
// Can't do exception(_msg) as defined in 27.4.2.1.1 // Can't do exception(_msg) as defined in 27.4.2.1.1
explicit explicit
failure(const string& __str); failure(const string& __str) throw();
virtual virtual
~failure(); ~failure() throw();
virtual const char* virtual const char*
what() const throw(); what() const throw();
......
// Exception Handling support header for -*- C++ -*- // Exception Handling support header for -*- C++ -*-
// Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation
// Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001 Free Software Foundation
// This file is part of GNU CC. // This file is part of GNU CC.
// //
...@@ -34,30 +35,33 @@ ...@@ -34,30 +35,33 @@
extern "C++" { extern "C++" {
namespace std { namespace std
{
class exception
{
public:
exception() throw() { }
virtual ~exception() throw() { }
virtual const char* what() const throw();
};
class exception { class bad_exception : public exception
public: {
exception () { } public:
virtual ~exception () { } bad_exception() throw() { }
virtual const char* what () const; virtual ~bad_exception() throw() { }
}; };
class bad_exception : public exception { typedef void (*terminate_handler) ();
public: typedef void (*unexpected_handler) ();
bad_exception () { }
virtual ~bad_exception () { }
};
typedef void (*terminate_handler) (); terminate_handler set_terminate(terminate_handler) throw();
typedef void (*unexpected_handler) (); void terminate() __attribute__ ((__noreturn__));
terminate_handler set_terminate (terminate_handler); unexpected_handler set_unexpected(unexpected_handler) throw();
void terminate () __attribute__ ((__noreturn__)); void unexpected() __attribute__ ((__noreturn__));
unexpected_handler set_unexpected (unexpected_handler);
void unexpected () __attribute__ ((__noreturn__));
bool uncaught_exception ();
bool uncaught_exception() throw();
} // namespace std } // namespace std
} // extern "C++" } // extern "C++"
......
// Functions for Exception Support for -*- C++ -*- // Functions for Exception Support for -*- C++ -*-
// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation
// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000,
// 2001 Free Software Foundation
// This file is part of GNU CC. // This file is part of GNU CC.
...@@ -56,7 +58,7 @@ static std::unexpected_handler __unexpected_func __attribute__((__noreturn__)) ...@@ -56,7 +58,7 @@ static std::unexpected_handler __unexpected_func __attribute__((__noreturn__))
= __default_unexpected; = __default_unexpected;
std::terminate_handler std::terminate_handler
std::set_terminate (std::terminate_handler func) std::set_terminate (std::terminate_handler func) throw()
{ {
std::terminate_handler old = __terminate_func; std::terminate_handler old = __terminate_func;
...@@ -65,7 +67,7 @@ std::set_terminate (std::terminate_handler func) ...@@ -65,7 +67,7 @@ std::set_terminate (std::terminate_handler func)
} }
std::unexpected_handler std::unexpected_handler
std::set_unexpected (std::unexpected_handler func) std::set_unexpected (std::unexpected_handler func) throw()
{ {
std::unexpected_handler old = __unexpected_func; std::unexpected_handler old = __unexpected_func;
...@@ -374,14 +376,15 @@ THROW_BAD_TYPEID () ...@@ -374,14 +376,15 @@ THROW_BAD_TYPEID ()
/* Has the current exception been caught? */ /* Has the current exception been caught? */
bool bool
std::uncaught_exception () std::uncaught_exception () throw()
{ {
cp_eh_info *p = CP_EH_INFO; cp_eh_info *p = CP_EH_INFO;
return p && ! p->caught; return p && ! p->caught;
} }
const char * std::exception:: const char *
what () const std::exception::
what () const throw()
{ {
return typeid (*this).name (); return typeid (*this).name ();
} }
...@@ -48,86 +48,90 @@ namespace __cxxabiv1 ...@@ -48,86 +48,90 @@ namespace __cxxabiv1
} // namespace __cxxabiv1 } // namespace __cxxabiv1
#endif #endif
namespace std { namespace std
{
class type_info { class type_info
public: {
// Destructor. Being the first non-inline virtual function, this controls in public:
// which translation unit the vtable is emitted. The compiler makes use of // Destructor. Being the first non-inline virtual function, this
// that information to know where to emit the runtime-mandated type_info // controls in which translation unit the vtable is emitted. The
// structures in the new-abi. // compiler makes use of that information to know where to emit
virtual ~type_info (); // the runtime-mandated type_info structures in the new-abi.
virtual ~type_info();
private:
// Assigning type_info is not supported. made private. private:
type_info& operator= (const type_info&); // Assigning type_info is not supported. made private.
type_info (const type_info&); type_info& operator=(const type_info&);
type_info(const type_info&);
protected:
const char *__name; protected:
const char *__name;
protected:
explicit type_info (const char *__n): __name (__n) { } protected:
explicit type_info(const char *__n): __name(__n) { }
public:
// the public interface public:
// the public interface
#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 #if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100
// In old abi, there can be multiple instances of a type_info object for one // In old abi, there can be multiple instances of a type_info
// type. Uniqueness must use the _name value, not object address. // object for one type. Uniqueness must use the _name value, not
bool before (const type_info& arg) const; // object address.
const char* name () const bool before(const type_info& arg) const;
const char* name() const
{ return __name; } { return __name; }
bool operator== (const type_info& __arg) const; bool operator==(const type_info& __arg) const;
bool operator!= (const type_info& __arg) const bool operator!=(const type_info& __arg) const
{ return !operator== (__arg); } { return !operator==(__arg); }
#else #else
// In new abi we can rely on type_info's NTBS being unique, // In new abi we can rely on type_info's NTBS being unique,
// and therefore address comparisons are sufficient. // and therefore address comparisons are sufficient.
bool before (const type_info& __arg) const bool before(const type_info& __arg) const
{ return __name < __arg.__name; } { return __name < __arg.__name; }
const char* name () const const char* name() const
{ return __name; } { return __name; }
bool operator== (const type_info& __arg) const bool operator==(const type_info& __arg) const
{ return __name == __arg.__name; } { return __name == __arg.__name; }
bool operator!= (const type_info& __arg) const bool operator!=(const type_info& __arg) const
{ return !operator== (__arg); } { return !operator==(__arg); }
#endif #endif
// the internal interface // the internal interface
#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100 #if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
public: public:
// return true if this is a pointer type of some kind // return true if this is a pointer type of some kind
virtual bool __is_pointer_p () const; virtual bool __is_pointer_p() const;
// return true if this is a function type // return true if this is a function type
virtual bool __is_function_p () const; virtual bool __is_function_p() const;
// Try and catch a thrown type. Store an adjusted pointer to the caught type // Try and catch a thrown type. Store an adjusted pointer to the
// in THR_OBJ. If THR_TYPE is not a pointer type, then THR_OBJ points to the // caught type in THR_OBJ. If THR_TYPE is not a pointer type, then
// thrown object. If THR_TYPE is a pointer type, then THR_OBJ is the pointer // THR_OBJ points to the thrown object. If THR_TYPE is a pointer
// itself. OUTER indicates the number of outer pointers, and whether they // type, then THR_OBJ is the pointer itself. OUTER indicates the
// were const qualified. // number of outer pointers, and whether they were const
virtual bool __do_catch (const type_info *__thr_type, void **__thr_obj, // qualified.
unsigned __outer) const; virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj,
unsigned __outer) const;
// internally used during catch matching
virtual bool __do_upcast (const __cxxabiv1::__class_type_info *__target, // internally used during catch matching
void **__obj_ptr) const; virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target,
void **__obj_ptr) const;
#endif #endif
}; };
class bad_cast : public exception { class bad_cast : public exception
public: {
bad_cast() { } public:
virtual ~bad_cast() { } bad_cast() throw() { }
}; virtual ~bad_cast() throw() { }
};
class bad_typeid : public exception {
public: class bad_typeid : public exception
bad_typeid () { } {
virtual ~bad_typeid () { } public:
}; bad_typeid () throw() { }
virtual ~bad_typeid () throw() { }
};
} // namespace std } // namespace std
} // extern "C++" } // extern "C++"
......
...@@ -120,13 +120,13 @@ namespace std ...@@ -120,13 +120,13 @@ namespace std
wostream wclog(NULL); wostream wclog(NULL);
#endif #endif
ios_base::failure::failure(const string& __str) ios_base::failure::failure(const string& __str) throw()
{ {
strncpy(_M_name, __str.c_str(), _M_bufsize); strncpy(_M_name, __str.c_str(), _M_bufsize);
_M_name[_M_bufsize - 1] = '\0'; _M_name[_M_bufsize - 1] = '\0';
} }
ios_base::failure::~failure() ios_base::failure::~failure() throw()
{ } { }
const char* const char*
......
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