2000-10-11 01:43:26 +02:00
|
|
|
// RTTI support for -*- C++ -*-
|
2007-02-01 14:36:51 +01:00
|
|
|
// Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
2010-02-18 18:58:53 +01:00
|
|
|
// 2003, 2004, 2005, 2006, 2007, 2009, 2010
|
2002-01-09 21:39:27 +01:00
|
|
|
// Free Software Foundation
|
2001-02-16 01:44:44 +01:00
|
|
|
//
|
Makefile.am, [...]: Replace "GNU CC" with "GCC".
2003-05-24 Nathanael Nerode <neroden@gcc.gnu.org>
* libsupc++/Makefile.am, libsupc++/cxxabi.h, libsupc++/del_op.cc,
libsupc++/del_opnt.cc, libsupc++/del_opv.cc, libsupc++/del_opvnt.cc,
libsupc++/eh_alloc.cc, libsupc++/eh_aux_runtime.cc,
libsupc++/eh_catch.cc, libsupc++/eh_exception.cc,
libsupc++/eh_globals.cc, libsupc++/eh_personality.cc,
libsupc++/eh_term_handler.cc, libsupc++/eh_terminate.cc,
libsupc++/eh_throw.cc, libsupc++/eh_type.cc,
libsupc++/eh_unex_handler.cc, libsupc++/exception,
libsupc++/new, libsupc++/new_handler.cc, libsupc++/new_op.cc,
libsupc++/new_opnt.cc, libsupc++/new_opv.cc, libsupc++/new_opvnt.cc,
libsupc++/pure.cc, libsupc++/tinfo.cc, libsupc++/tinfo2.cc,
libsupc++/typeinfo, libsupc++/unwind-cxx.h, libsupc++/vec.cc:
Replace "GNU CC" with "GCC".
From-SVN: r67155
2003-05-24 18:22:03 +02:00
|
|
|
// This file is part of GCC.
|
2000-10-11 01:43:26 +02:00
|
|
|
//
|
Makefile.am, [...]: Replace "GNU CC" with "GCC".
2003-05-24 Nathanael Nerode <neroden@gcc.gnu.org>
* libsupc++/Makefile.am, libsupc++/cxxabi.h, libsupc++/del_op.cc,
libsupc++/del_opnt.cc, libsupc++/del_opv.cc, libsupc++/del_opvnt.cc,
libsupc++/eh_alloc.cc, libsupc++/eh_aux_runtime.cc,
libsupc++/eh_catch.cc, libsupc++/eh_exception.cc,
libsupc++/eh_globals.cc, libsupc++/eh_personality.cc,
libsupc++/eh_term_handler.cc, libsupc++/eh_terminate.cc,
libsupc++/eh_throw.cc, libsupc++/eh_type.cc,
libsupc++/eh_unex_handler.cc, libsupc++/exception,
libsupc++/new, libsupc++/new_handler.cc, libsupc++/new_op.cc,
libsupc++/new_opnt.cc, libsupc++/new_opv.cc, libsupc++/new_opvnt.cc,
libsupc++/pure.cc, libsupc++/tinfo.cc, libsupc++/tinfo2.cc,
libsupc++/typeinfo, libsupc++/unwind-cxx.h, libsupc++/vec.cc:
Replace "GNU CC" with "GCC".
From-SVN: r67155
2003-05-24 18:22:03 +02:00
|
|
|
// GCC is free software; you can redistribute it and/or modify
|
2000-10-11 01:43:26 +02:00
|
|
|
// it under the terms of the GNU General Public License as published by
|
2009-04-09 17:00:19 +02:00
|
|
|
// the Free Software Foundation; either version 3, or (at your option)
|
2000-10-11 01:43:26 +02:00
|
|
|
// any later version.
|
|
|
|
//
|
Makefile.am, [...]: Replace "GNU CC" with "GCC".
2003-05-24 Nathanael Nerode <neroden@gcc.gnu.org>
* libsupc++/Makefile.am, libsupc++/cxxabi.h, libsupc++/del_op.cc,
libsupc++/del_opnt.cc, libsupc++/del_opv.cc, libsupc++/del_opvnt.cc,
libsupc++/eh_alloc.cc, libsupc++/eh_aux_runtime.cc,
libsupc++/eh_catch.cc, libsupc++/eh_exception.cc,
libsupc++/eh_globals.cc, libsupc++/eh_personality.cc,
libsupc++/eh_term_handler.cc, libsupc++/eh_terminate.cc,
libsupc++/eh_throw.cc, libsupc++/eh_type.cc,
libsupc++/eh_unex_handler.cc, libsupc++/exception,
libsupc++/new, libsupc++/new_handler.cc, libsupc++/new_op.cc,
libsupc++/new_opnt.cc, libsupc++/new_opv.cc, libsupc++/new_opvnt.cc,
libsupc++/pure.cc, libsupc++/tinfo.cc, libsupc++/tinfo2.cc,
libsupc++/typeinfo, libsupc++/unwind-cxx.h, libsupc++/vec.cc:
Replace "GNU CC" with "GCC".
From-SVN: r67155
2003-05-24 18:22:03 +02:00
|
|
|
// GCC is distributed in the hope that it will be useful,
|
2000-10-11 01:43:26 +02:00
|
|
|
// 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.
|
|
|
|
//
|
2009-04-09 17:00:19 +02:00
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
|
|
// 3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
2000-10-11 01:43:26 +02:00
|
|
|
|
2001-07-11 21:35:49 +02:00
|
|
|
/** @file typeinfo
|
2006-11-29 21:59:22 +01:00
|
|
|
* This is a Standard C++ Library header.
|
2001-07-11 21:35:49 +02:00
|
|
|
*/
|
|
|
|
|
2003-07-05 06:05:45 +02:00
|
|
|
#ifndef _TYPEINFO
|
|
|
|
#define _TYPEINFO
|
2000-10-11 01:43:26 +02:00
|
|
|
|
2010-02-18 18:58:53 +01:00
|
|
|
#pragma GCC system_header
|
|
|
|
|
2000-10-11 01:43:26 +02:00
|
|
|
#include <exception>
|
|
|
|
|
2004-08-03 08:45:54 +02:00
|
|
|
#pragma GCC visibility push(default)
|
|
|
|
|
2000-10-11 01:43:26 +02:00
|
|
|
extern "C++" {
|
|
|
|
|
|
|
|
namespace __cxxabiv1
|
|
|
|
{
|
|
|
|
class __class_type_info;
|
|
|
|
} // namespace __cxxabiv1
|
|
|
|
|
2006-11-13 14:10:17 +01:00
|
|
|
// Determine whether typeinfo names for the same type are merged (in which
|
2009-07-23 01:03:22 +02:00
|
|
|
// case comparison can just compare pointers) or not (in which case strings
|
|
|
|
// must be compared), and whether comparison is to be implemented inline or
|
|
|
|
// not. We used to do inline pointer comparison by default if weak symbols
|
|
|
|
// are available, but even with weak symbols sometimes names are not merged
|
|
|
|
// when objects are loaded with RTLD_LOCAL, so now we always use strcmp by
|
|
|
|
// default. For ABI compatibility, we do the strcmp inline if weak symbols
|
|
|
|
// are available, and out-of-line if not. Out-of-line pointer comparison
|
|
|
|
// is used where the object files are to be portable to multiple systems,
|
|
|
|
// some of which may not be able to use pointer comparison, but the
|
|
|
|
// particular system for which libstdc++ is being built can use pointer
|
|
|
|
// comparison; in particular for most ARM EABI systems, where the ABI
|
|
|
|
// specifies out-of-line comparison. The compiler's target configuration
|
|
|
|
// can override the defaults by defining __GXX_TYPEINFO_EQUALITY_INLINE to
|
|
|
|
// 1 or 0 to indicate whether or not comparison is inline, and
|
|
|
|
// __GXX_MERGED_TYPEINFO_NAMES to 1 or 0 to indicate whether or not pointer
|
|
|
|
// comparison can be used.
|
2006-11-13 14:10:17 +01:00
|
|
|
|
2004-09-03 02:43:59 +02:00
|
|
|
#ifndef __GXX_MERGED_TYPEINFO_NAMES
|
2009-07-23 01:03:22 +02:00
|
|
|
// By default, typeinfo names are not merged.
|
|
|
|
#define __GXX_MERGED_TYPEINFO_NAMES 0
|
2001-02-04 09:37:50 +01:00
|
|
|
#endif
|
|
|
|
|
2009-07-23 01:03:22 +02:00
|
|
|
// By default follow the old inline rules to avoid ABI changes.
|
2006-11-13 14:10:17 +01:00
|
|
|
#ifndef __GXX_TYPEINFO_EQUALITY_INLINE
|
|
|
|
#if !__GXX_WEAK__
|
|
|
|
#define __GXX_TYPEINFO_EQUALITY_INLINE 0
|
|
|
|
#else
|
|
|
|
#define __GXX_TYPEINFO_EQUALITY_INLINE 1
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2001-01-17 08:44:57 +01:00
|
|
|
namespace std
|
|
|
|
{
|
abi.txt: New file.
2002-07-20 Phil Edwards <pme@gcc.gnu.org>
* docs/html/abi.txt: New file.
* docs/html/23_containers/howto.html: Tweak vector-overhead text.
* docs/html/ext/lwg-active.html, docs/html/ext/lwg-defects.html:
Import from upstream, R22.
* include/bits/char_traits.h, include/bits/stl_iterator.h,
include/bits/stl_iterator_base_types.h, libsupc++/exception,
libsupc++/new, libsupc++/typeinfo: Use @brief markup.
* include/bits/deque.tcc, include/bits/stl_alloc.h,
include/bits/stl_deque.h, include/bits/stl_list.h: Postpone removal
of deprecated functions until 3.4. (Same timeframe, different text.)
* include/bits/stl_vector.h: Ditto. Also do the same cleanups that
the other sequence classes received.
From-SVN: r55602
2002-07-20 08:26:27 +02:00
|
|
|
/**
|
|
|
|
* @brief Part of RTTI.
|
|
|
|
*
|
|
|
|
* The @c type_info class describes type information generated by
|
2001-07-11 21:35:49 +02:00
|
|
|
* an implementation.
|
abi.txt: New file.
2002-07-20 Phil Edwards <pme@gcc.gnu.org>
* docs/html/abi.txt: New file.
* docs/html/23_containers/howto.html: Tweak vector-overhead text.
* docs/html/ext/lwg-active.html, docs/html/ext/lwg-defects.html:
Import from upstream, R22.
* include/bits/char_traits.h, include/bits/stl_iterator.h,
include/bits/stl_iterator_base_types.h, libsupc++/exception,
libsupc++/new, libsupc++/typeinfo: Use @brief markup.
* include/bits/deque.tcc, include/bits/stl_alloc.h,
include/bits/stl_deque.h, include/bits/stl_list.h: Postpone removal
of deprecated functions until 3.4. (Same timeframe, different text.)
* include/bits/stl_vector.h: Ditto. Also do the same cleanups that
the other sequence classes received.
From-SVN: r55602
2002-07-20 08:26:27 +02:00
|
|
|
*/
|
2001-01-17 08:44:57 +01:00
|
|
|
class type_info
|
|
|
|
{
|
|
|
|
public:
|
2007-06-26 13:01:15 +02:00
|
|
|
/** Destructor first. Being the first non-inline virtual function, this
|
2001-07-11 21:35:49 +02:00
|
|
|
* 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. */
|
2001-01-17 08:44:57 +01:00
|
|
|
virtual ~type_info();
|
|
|
|
|
2001-09-26 01:51:17 +02:00
|
|
|
/** Returns an @e implementation-defined byte string; this is not
|
2001-07-11 21:35:49 +02:00
|
|
|
* portable between compilers! */
|
2001-01-17 08:44:57 +01:00
|
|
|
const char* name() const
|
2009-10-30 23:23:59 +01:00
|
|
|
{ return __name[0] == '*' ? __name + 1 : __name; }
|
2000-10-11 01:43:26 +02:00
|
|
|
|
2006-11-13 14:10:17 +01:00
|
|
|
#if !__GXX_TYPEINFO_EQUALITY_INLINE
|
2001-02-04 09:37:50 +01:00
|
|
|
// 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.
|
2009-07-23 01:03:22 +02:00
|
|
|
bool before(const type_info& __arg) const;
|
2001-02-04 09:37:50 +01:00
|
|
|
bool operator==(const type_info& __arg) const;
|
2000-10-11 01:43:26 +02:00
|
|
|
#else
|
2006-11-13 14:10:17 +01:00
|
|
|
#if !__GXX_MERGED_TYPEINFO_NAMES
|
ChangeLog, [...]: Fix spelling errors.
* ChangeLog, docs/doxygen/maint.cfg.in, docs/doxygen/user.cfg.in,
docs/doxygen/doxygroups.cc, docs/doxygen/Intro.3,
docs/html/17_intro/BUGS, docs/html/17_intro/C++STYLE,
docs/html/17_intro/CHECKLIST, docs/html/17_intro/DESIGN,
docs/html/17_intro/howto.html, docs/html/17_intro/porting.html,
docs/html/17_intro/porting.texi, docs/html/18_support/howto.html,
docs/html/19_diagnostics/howto.html, docs/html/20_util/howto.html,
docs/html/21_strings/howto.html,
docs/html/23_containers/howto.html,
docs/html/26_numerics/howto.html, docs/html/27_io/howto.html,
docs/html/27_io/binary_iostreams_kuehl.txt,
docs/html/ext/sgiexts.html, docs/html/faq/index.html,
docs/html/faq/index.txt, testsuite/24_iterators/iterator.cc,
include/bits/basic_file.h, include/bits/locale_facets.h,
include/bits/locale_facets.tcc, include/bits/std_sstream.h,
include/ext/ropeimpl.h, include/ext/stl_rope.h,
libsupc++/tinfo.cc, libsupc++/cxxabi.h, libsupc++/typeinfo,
libsupc++/eh_throw.cc, acinclude.m4, aclocal.m4, configure,
configure.target, ChangeLog-2000: Fix spelling errors.
From-SVN: r47291
2001-11-23 17:29:02 +01:00
|
|
|
/** Returns true if @c *this precedes @c __arg in the implementation's
|
2001-07-11 21:35:49 +02:00
|
|
|
* collation order. */
|
2009-07-23 01:03:22 +02:00
|
|
|
// Even with the new abi, on systems that support dlopen
|
|
|
|
// we can run into cases where type_info names aren't merged,
|
|
|
|
// so we still need to do string comparison.
|
|
|
|
bool before(const type_info& __arg) const
|
2009-10-30 23:23:59 +01:00
|
|
|
{ return (__name[0] == '*' && __arg.__name[0] == '*')
|
|
|
|
? __name < __arg.__name
|
|
|
|
: __builtin_strcmp (__name, __arg.__name) < 0; }
|
2009-07-23 01:03:22 +02:00
|
|
|
|
|
|
|
bool operator==(const type_info& __arg) const
|
|
|
|
{
|
|
|
|
return ((__name == __arg.__name)
|
2009-10-30 23:23:59 +01:00
|
|
|
|| (__name[0] != '*' &&
|
|
|
|
__builtin_strcmp (__name, __arg.__name) == 0));
|
2009-07-23 01:03:22 +02:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
// On some targets we can rely on type_info's NTBS being unique,
|
2001-01-17 08:44:57 +01:00
|
|
|
// and therefore address comparisons are sufficient.
|
|
|
|
bool before(const type_info& __arg) const
|
2000-10-11 01:43:26 +02:00
|
|
|
{ return __name < __arg.__name; }
|
2007-06-26 13:01:15 +02:00
|
|
|
|
2001-01-17 08:44:57 +01:00
|
|
|
bool operator==(const type_info& __arg) const
|
2000-10-11 01:43:26 +02:00
|
|
|
{ return __name == __arg.__name; }
|
2009-07-23 01:03:22 +02:00
|
|
|
#endif
|
2001-02-04 09:37:50 +01:00
|
|
|
#endif
|
2001-01-17 08:44:57 +01:00
|
|
|
bool operator!=(const type_info& __arg) const
|
|
|
|
{ return !operator==(__arg); }
|
2007-10-07 01:40:32 +02:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2001-01-17 08:44:57 +01:00
|
|
|
// 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
|
|
|
|
// type, then THR_OBJ is the pointer itself. OUTER indicates the
|
|
|
|
// number of outer pointers, and whether they were const
|
|
|
|
// qualified.
|
|
|
|
virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj,
|
|
|
|
unsigned __outer) const;
|
|
|
|
|
2007-06-26 13:01:15 +02:00
|
|
|
// Internally used during catch matching
|
2001-01-17 08:44:57 +01:00
|
|
|
virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target,
|
|
|
|
void **__obj_ptr) const;
|
2007-06-26 13:01:15 +02:00
|
|
|
|
|
|
|
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&);
|
2001-01-17 08:44:57 +01:00
|
|
|
};
|
|
|
|
|
abi.txt: New file.
2002-07-20 Phil Edwards <pme@gcc.gnu.org>
* docs/html/abi.txt: New file.
* docs/html/23_containers/howto.html: Tweak vector-overhead text.
* docs/html/ext/lwg-active.html, docs/html/ext/lwg-defects.html:
Import from upstream, R22.
* include/bits/char_traits.h, include/bits/stl_iterator.h,
include/bits/stl_iterator_base_types.h, libsupc++/exception,
libsupc++/new, libsupc++/typeinfo: Use @brief markup.
* include/bits/deque.tcc, include/bits/stl_alloc.h,
include/bits/stl_deque.h, include/bits/stl_list.h: Postpone removal
of deprecated functions until 3.4. (Same timeframe, different text.)
* include/bits/stl_vector.h: Ditto. Also do the same cleanups that
the other sequence classes received.
From-SVN: r55602
2002-07-20 08:26:27 +02:00
|
|
|
/**
|
|
|
|
* @brief Thrown during incorrect typecasting.
|
2009-02-21 01:45:21 +01:00
|
|
|
* @ingroup exceptions
|
abi.txt: New file.
2002-07-20 Phil Edwards <pme@gcc.gnu.org>
* docs/html/abi.txt: New file.
* docs/html/23_containers/howto.html: Tweak vector-overhead text.
* docs/html/ext/lwg-active.html, docs/html/ext/lwg-defects.html:
Import from upstream, R22.
* include/bits/char_traits.h, include/bits/stl_iterator.h,
include/bits/stl_iterator_base_types.h, libsupc++/exception,
libsupc++/new, libsupc++/typeinfo: Use @brief markup.
* include/bits/deque.tcc, include/bits/stl_alloc.h,
include/bits/stl_deque.h, include/bits/stl_list.h: Postpone removal
of deprecated functions until 3.4. (Same timeframe, different text.)
* include/bits/stl_vector.h: Ditto. Also do the same cleanups that
the other sequence classes received.
From-SVN: r55602
2002-07-20 08:26:27 +02:00
|
|
|
*
|
|
|
|
* If you attempt an invalid @c dynamic_cast expression, an instance of
|
2001-07-11 21:35:49 +02:00
|
|
|
* this class (or something derived from this class) is thrown. */
|
2001-01-17 08:44:57 +01:00
|
|
|
class bad_cast : public exception
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bad_cast() throw() { }
|
2007-06-26 13:01:15 +02:00
|
|
|
|
2002-01-10 00:31:57 +01:00
|
|
|
// This declaration is not useless:
|
|
|
|
// http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
|
2002-01-09 21:39:27 +01:00
|
|
|
virtual ~bad_cast() throw();
|
2007-06-26 13:01:15 +02:00
|
|
|
|
2007-02-01 14:36:51 +01:00
|
|
|
// See comment in eh_exception.cc.
|
|
|
|
virtual const char* what() const throw();
|
2001-01-17 08:44:57 +01:00
|
|
|
};
|
|
|
|
|
2009-02-21 01:45:21 +01:00
|
|
|
/**
|
|
|
|
* @brief Thrown when a NULL pointer in a @c typeid expression is used.
|
|
|
|
* @ingroup exceptions
|
|
|
|
*/
|
2001-01-17 08:44:57 +01:00
|
|
|
class bad_typeid : public exception
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bad_typeid () throw() { }
|
2007-06-26 13:01:15 +02:00
|
|
|
|
2002-01-10 00:31:57 +01:00
|
|
|
// This declaration is not useless:
|
|
|
|
// http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
|
2002-01-09 21:39:27 +01:00
|
|
|
virtual ~bad_typeid() throw();
|
2007-06-26 13:01:15 +02:00
|
|
|
|
2007-02-01 14:36:51 +01:00
|
|
|
// See comment in eh_exception.cc.
|
|
|
|
virtual const char* what() const throw();
|
2001-01-17 08:44:57 +01:00
|
|
|
};
|
2000-10-11 01:43:26 +02:00
|
|
|
} // namespace std
|
|
|
|
|
2004-08-03 08:45:54 +02:00
|
|
|
#pragma GCC visibility pop
|
|
|
|
|
2000-10-11 01:43:26 +02:00
|
|
|
} // extern "C++"
|
|
|
|
#endif
|