+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
#include <stdexcept>
#include <utility>
#include <tr1/random>
+#include <bits/functexcept.h>
_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:
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));
}
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)
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());
}
}
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());
}
}
throw_allocator_base::throw_conditionally()
{
if (_S_g.get_prob() < _S_throw_prob)
- throw forced_exception_error();
+ __throw_forced_exception_error();
}
void
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();
{
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__));
{
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
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
#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.
// 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
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&);
};
/**
{
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();
};
{
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();
};
// -*- 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
#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
// -*- 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
#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
-// 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
#include <iostream>
#include <sstream>
#include <ext/mt_allocator.h>
+#include <bits/functexcept.h>
// libstdc++/22309
extern "C" void
{
try
{
- throw std::bad_exception();
+ std::__throw_bad_exception();
}
catch (const std::exception& e)
{ }
}
// Randomly throw. See if other threads cleanup.
- throw std::bad_exception();
+ std::__throw_bad_exception();
}