throw_allocator.h: Fixes for -fno-exceptions.
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. From-SVN: r126016
This commit is contained in:
parent
12c7b51e3e
commit
949d9ae181
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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__));
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue