diff options
author | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-06-26 11:01:15 +0000 |
---|---|---|
committer | bkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-06-26 11:01:15 +0000 |
commit | 50e126daf85b76465ea2baa9cfabb809bcba4ab3 (patch) | |
tree | c08f612197e36b298606bc1f8799f4950b34b0ad /libstdc++-v3 | |
parent | 4eb7a440df01088f2e021f01ea051c1cf72c33cd (diff) | |
download | gcc-50e126daf85b76465ea2baa9cfabb809bcba4ab3.tar.gz |
2007-06-26 Benjamin Kosnik <bkoz@redhat.com>
* include/ext/throw_allocator.h: Fixes for -fno-exceptions.
* testsuite/util/testsuite_shared.cc: Same.
* testsuite/util/io/illegal_input_error.hpp: Same.
* testsuite/util/io/verified_cmd_line_input.cc: Same.
* libsupc++/typeinfo (type_info): Correct comment formatting,
clarify member access and public interface.
* libsupc++/exception: Less compressed comments.
* libsupc++/new: Same.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126016 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 12 | ||||
-rw-r--r-- | libstdc++-v3/include/ext/throw_allocator.h | 23 | ||||
-rw-r--r-- | libstdc++-v3/libsupc++/exception | 6 | ||||
-rw-r--r-- | libstdc++-v3/libsupc++/new | 8 | ||||
-rw-r--r-- | libstdc++-v3/libsupc++/typeinfo | 46 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/util/io/illegal_input_error.hpp | 19 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/util/io/verified_cmd_line_input.cc | 47 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/util/testsuite_shared.cc | 7 |
8 files changed, 100 insertions, 68 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1725e68143b..bfcfc777079 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +2007-06-26 Benjamin Kosnik <bkoz@redhat.com> + + * include/ext/throw_allocator.h: Fixes for -fno-exceptions. + * testsuite/util/testsuite_shared.cc: Same. + * testsuite/util/io/illegal_input_error.hpp: Same. + * testsuite/util/io/verified_cmd_line_input.cc: Same. + + * libsupc++/typeinfo (type_info): Correct comment formatting, + clarify member access and public interface. + * libsupc++/exception: Less compressed comments. + * libsupc++/new: Same. + 2007-06-18 Paolo Carlini <pcarlini@suse.de> * include/bits/stl_list.h: Rename guard macro consistently with diff --git a/libstdc++-v3/include/ext/throw_allocator.h b/libstdc++-v3/include/ext/throw_allocator.h index 240a3ccbe4f..9a3dbef32fd 100644 --- a/libstdc++-v3/include/ext/throw_allocator.h +++ b/libstdc++-v3/include/ext/throw_allocator.h @@ -63,6 +63,7 @@ #include <stdexcept> #include <utility> #include <tr1/random> +#include <bits/functexcept.h> _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) @@ -82,10 +83,20 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) std::tr1::mt19937 _M_generator; }; - struct forced_exception_error : public std::exception { }; + // Substitute for concurrence_error object in the case of -fno-exceptions. + inline void + __throw_forced_exception_error() + { +#if __EXCEPTIONS + throw forced_exception_error(); +#else + __builtin_abort(); +#endif + } + class throw_allocator_base { public: @@ -329,7 +340,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) error += '\n'; print_to_string(error, make_entry(p, size)); print_to_string(error, *found_it); - throw std::logic_error(error); + std::__throw_logic_error(error.c_str()); } _S_map.insert(make_entry(p, size)); } @@ -355,7 +366,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) error += "null erase!"; error += '\n'; print_to_string(error, make_entry(p, size)); - throw std::logic_error(error); + std::__throw_logic_error(error.c_str()); } if (found_it->second.second != size) @@ -365,7 +376,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) error += '\n'; print_to_string(error, make_entry(p, size)); print_to_string(error, *found_it); - throw std::logic_error(error); + std::__throw_logic_error(error.c_str()); } } @@ -386,7 +397,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) std::string error("throw_allocator_base::check_allocated by label "); error += '\n'; error += found; - throw std::logic_error(error); + std::__throw_logic_error(error.c_str()); } } @@ -394,7 +405,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) throw_allocator_base::throw_conditionally() { if (_S_g.get_prob() < _S_throw_prob) - throw forced_exception_error(); + __throw_forced_exception_error(); } void diff --git a/libstdc++-v3/libsupc++/exception b/libstdc++-v3/libsupc++/exception index 2046300581c..a7e2db78dd1 100644 --- a/libstdc++-v3/libsupc++/exception +++ b/libstdc++-v3/libsupc++/exception @@ -58,6 +58,7 @@ namespace std public: exception() throw() { } virtual ~exception() throw(); + /** Returns a C-style character string describing the general cause * of the current error. */ virtual const char* what() const throw(); @@ -69,26 +70,31 @@ namespace std { public: bad_exception() throw() { } + // This declaration is not useless: // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 virtual ~bad_exception() throw(); + // See comment in eh_exception.cc. virtual const char* what() const throw(); }; /// If you write a replacement %terminate handler, it must be of this type. typedef void (*terminate_handler) (); + /// If you write a replacement %unexpected handler, it must be of this type. typedef void (*unexpected_handler) (); /// Takes a new handler function as an argument, returns the old function. terminate_handler set_terminate(terminate_handler) throw(); + /** The runtime will call this function if %exception handling must be * abandoned for any reason. It can also be called by the user. */ void terminate() __attribute__ ((__noreturn__)); /// Takes a new handler function as an argument, returns the old function. unexpected_handler set_unexpected(unexpected_handler) throw(); + /** The runtime will call this function if an %exception is thrown which * violates the function's %exception specification. */ void unexpected() __attribute__ ((__noreturn__)); diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new index 26898bfc6fc..a821783b14a 100644 --- a/libstdc++-v3/libsupc++/new +++ b/libstdc++-v3/libsupc++/new @@ -59,19 +59,25 @@ namespace std { public: bad_alloc() throw() { } + // This declaration is not useless: // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 virtual ~bad_alloc() throw(); + // See comment in eh_exception.cc. virtual const char* what() const throw(); }; struct nothrow_t { }; + extern const nothrow_t nothrow; + /** If you write your own error handler to be called by @c new, it must * be of this type. */ typedef void (*new_handler)(); - /// Takes a replacement handler as the argument, returns the previous handler. + + /// Takes a replacement handler as the argument, returns the + /// previous handler. new_handler set_new_handler(new_handler) throw(); } // namespace std diff --git a/libstdc++-v3/libsupc++/typeinfo b/libstdc++-v3/libsupc++/typeinfo index 3abf0dfc17a..cfcbbcc0896 100644 --- a/libstdc++-v3/libsupc++/typeinfo +++ b/libstdc++-v3/libsupc++/typeinfo @@ -93,25 +93,12 @@ namespace std class type_info { public: - /** Destructor. Being the first non-inline virtual function, this + /** Destructor first. Being the first non-inline virtual function, this * controls in which translation unit the vtable is emitted. The * compiler makes use of that information to know where to emit * the runtime-mandated type_info structures in the new-abi. */ virtual ~type_info(); - private: - /// Assigning type_info is not supported. Made private. - type_info& operator=(const type_info&); - type_info(const type_info&); - - protected: - const char *__name; - - protected: - explicit type_info(const char *__n): __name(__n) { } - - public: - // the public interface /** Returns an @e implementation-defined byte string; this is not * portable between compilers! */ const char* name() const @@ -119,6 +106,7 @@ namespace std #if !__GXX_TYPEINFO_EQUALITY_INLINE bool before(const type_info& __arg) const; + // In old abi, or when weak symbols are not supported, there can // be multiple instances of a type_info object for one // type. Uniqueness must use the _name value, not object address. @@ -133,19 +121,13 @@ namespace std // and therefore address comparisons are sufficient. bool before(const type_info& __arg) const { return __name < __arg.__name; } + bool operator==(const type_info& __arg) const { return __name == __arg.__name; } #endif bool operator!=(const type_info& __arg) const { return !operator==(__arg); } - // the internal interface - public: - // return true if this is a pointer type of some kind - virtual bool __is_pointer_p() const; - // return true if this is a function type - virtual bool __is_function_p() const; - // Try and catch a thrown type. Store an adjusted pointer to the // caught type in THR_OBJ. If THR_TYPE is not a pointer type, then // THR_OBJ points to the thrown object. If THR_TYPE is a pointer @@ -155,9 +137,25 @@ namespace std virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj, unsigned __outer) const; - // internally used during catch matching + // Internally used during catch matching virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target, void **__obj_ptr) const; + + // Return true if this is a pointer type of some kind + virtual bool __is_pointer_p() const; + + // Return true if this is a function type + virtual bool __is_function_p() const; + + protected: + const char *__name; + + explicit type_info(const char *__n): __name(__n) { } + + private: + /// Assigning type_info is not supported. + type_info& operator=(const type_info&); + type_info(const type_info&); }; /** @@ -169,9 +167,11 @@ namespace std { public: bad_cast() throw() { } + // This declaration is not useless: // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 virtual ~bad_cast() throw(); + // See comment in eh_exception.cc. virtual const char* what() const throw(); }; @@ -181,9 +181,11 @@ namespace std { public: bad_typeid () throw() { } + // This declaration is not useless: // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 virtual ~bad_typeid() throw(); + // See comment in eh_exception.cc. virtual const char* what() const throw(); }; diff --git a/libstdc++-v3/testsuite/util/io/illegal_input_error.hpp b/libstdc++-v3/testsuite/util/io/illegal_input_error.hpp index 3e786d457f8..63675f9850c 100644 --- a/libstdc++-v3/testsuite/util/io/illegal_input_error.hpp +++ b/libstdc++-v3/testsuite/util/io/illegal_input_error.hpp @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007 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 @@ -47,17 +47,26 @@ #ifndef PB_DS_ILLEGAL_INPUT_EX_HPP #define PB_DS_ILLEGAL_INPUT_EX_HPP +#include <exception> + namespace pb_ds { - namespace test { - - class illegal_input_error + class illegal_input_error : public std::exception { }; + // Substitute for concurrence_error object in the case of -fno-exceptions. + inline void + __throw_illegal_input_error() + { +#if __EXCEPTIONS + throw illegal_input_error(); +#else + __builtin_abort(); +#endif + } } // namespace test - } // namespace pb_ds #endif // #ifndef PB_DS_ILLEGAL_INPUT_EX_HPP diff --git a/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.cc b/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.cc index 7b004a565d4..c24cd6fc10e 100644 --- a/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.cc +++ b/libstdc++-v3/testsuite/util/io/verified_cmd_line_input.cc @@ -1,6 +1,6 @@ // -*- C++ -*- -// Copyright (C) 2005, 2006 Free Software Foundation, Inc. +// Copyright (C) 2005, 2006, 2007 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 @@ -48,84 +48,69 @@ #include <limits.h> #include <utility> #include <stdlib.h> +#include <bits/functexcept.h> namespace pb_ds { - namespace test { - void verify_argc(size_t given, size_t required) { if (given != required) - throw illegal_input_error(); + __throw_illegal_input_error(); } void verify_prob(double prob) { if (prob < 0 || prob > 1) - throw illegal_input_error(); + __throw_illegal_input_error(); } std::string get_cmd_line_str(int argc, char* a_p_argv[], int argn) { if (argc <= argn) - throw illegal_input_error(); - + __throw_illegal_input_error(); const std::string ret(a_p_argv[argn]); - - return (ret); + return ret; } double get_cmd_line_prob(int argc, char* a_p_argv[], int argn) { if (argc <= argn) - throw illegal_input_error(); - + __throw_illegal_input_error(); const double ret = ::atof(a_p_argv[argn]); - verify_prob(ret); - - return (ret); + return ret; } size_t get_cmd_line_size(int argc, char* a_p_argv[], int argn) { if (argc <= argn) - throw illegal_input_error(); - + __throw_illegal_input_error(); const size_t ret = static_cast<size_t>(::atoi(a_p_argv[argn])); - - return (ret); + return ret; } bool get_cmd_line_bool(int argc, char* a_p_argv[], int argn) { if (argc <= argn) - throw illegal_input_error(); + __throw_illegal_input_error(); const std::string opt(a_p_argv[argn]); - if (opt.size() != 1) - throw illegal_input_error(); - + __throw_illegal_input_error(); if (opt[0] == 't') - return (true); - + return true; if (opt[0] == 'f') - return (false); - - throw illegal_input_error(); - - return (false); + return false; + __throw_illegal_input_error(); + return false; } - } // namespace test - } // namespace pb_ds diff --git a/libstdc++-v3/testsuite/util/testsuite_shared.cc b/libstdc++-v3/testsuite/util/testsuite_shared.cc index d651442ed03..cf09c2d3f16 100644 --- a/libstdc++-v3/testsuite/util/testsuite_shared.cc +++ b/libstdc++-v3/testsuite/util/testsuite_shared.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. +// Copyright (C) 2004, 2005, 2006, 2007 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 @@ -21,6 +21,7 @@ #include <iostream> #include <sstream> #include <ext/mt_allocator.h> +#include <bits/functexcept.h> // libstdc++/22309 extern "C" void @@ -43,7 +44,7 @@ try_throw_exception() { try { - throw std::bad_exception(); + std::__throw_bad_exception(); } catch (const std::exception& e) { } @@ -68,5 +69,5 @@ try_function_random_fail() } // Randomly throw. See if other threads cleanup. - throw std::bad_exception(); + std::__throw_bad_exception(); } |