1 // RTTI support for -*- C++ -*-
2 // Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 // 2003, 2004, 2005, 2006, 2007
4 // Free Software Foundation
6 // This file is part of GCC.
8 // GCC is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2, or (at your option)
13 // GCC is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with GCC; see the file COPYING. If not, write to
20 // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301, USA.
23 // As a special exception, you may use this file as part of a free software
24 // library without restriction. Specifically, if other files instantiate
25 // templates or use macros or inline functions from this file, or you compile
26 // this file and link it with other files to produce an executable, this
27 // file does not by itself cause the resulting executable to be covered by
28 // the GNU General Public License. This exception does not however
29 // invalidate any other reasons why the executable file might be covered by
30 // the GNU General Public License.
33 * This is a Standard C++ Library header.
41 #pragma GCC visibility push(default)
47 class __class_type_info;
48 } // namespace __cxxabiv1
50 #ifndef __GXX_MERGED_TYPEINFO_NAMES
52 // If weak symbols are not supported, typeinfo names are not merged.
53 #define __GXX_MERGED_TYPEINFO_NAMES 0
55 // On platforms that support weak symbols, typeinfo names are merged.
56 #define __GXX_MERGED_TYPEINFO_NAMES 1
63 * @brief Part of RTTI.
65 * The @c type_info class describes type information generated by
71 /** Destructor first. Being the first non-inline virtual function, this
72 * controls in which translation unit the vtable is emitted. The
73 * compiler makes use of that information to know where to emit
74 * the runtime-mandated type_info structures in the new-abi. */
77 /** Returns an @e implementation-defined byte string; this is not
78 * portable between compilers! */
79 const char* name() const
82 #if !__GXX_MERGED_TYPEINFO_NAMES
83 bool before(const type_info& __arg) const;
85 // In old abi, or when weak symbols are not supported, there can
86 // be multiple instances of a type_info object for one
87 // type. Uniqueness must use the _name value, not object address.
88 bool operator==(const type_info& __arg) const;
90 /** Returns true if @c *this precedes @c __arg in the implementation's
92 // In new abi we can rely on type_info's NTBS being unique,
93 // and therefore address comparisons are sufficient.
94 bool before(const type_info& __arg) const
95 { return __name < __arg.__name; }
97 bool operator==(const type_info& __arg) const
98 { return __name == __arg.__name; }
100 bool operator!=(const type_info& __arg) const
101 { return !operator==(__arg); }
103 // Return true if this is a pointer type of some kind
104 virtual bool __is_pointer_p() const;
106 // Return true if this is a function type
107 virtual bool __is_function_p() const;
109 // Try and catch a thrown type. Store an adjusted pointer to the
110 // caught type in THR_OBJ. If THR_TYPE is not a pointer type, then
111 // THR_OBJ points to the thrown object. If THR_TYPE is a pointer
112 // type, then THR_OBJ is the pointer itself. OUTER indicates the
113 // number of outer pointers, and whether they were const
115 virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj,
116 unsigned __outer) const;
118 // Internally used during catch matching
119 virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target,
120 void **__obj_ptr) const;
125 explicit type_info(const char *__n): __name(__n) { }
128 /// Assigning type_info is not supported.
129 type_info& operator=(const type_info&);
130 type_info(const type_info&);
134 * @brief Thrown during incorrect typecasting.
136 * If you attempt an invalid @c dynamic_cast expression, an instance of
137 * this class (or something derived from this class) is thrown. */
138 class bad_cast : public exception
141 bad_cast() throw() { }
143 // This declaration is not useless:
144 // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
145 virtual ~bad_cast() throw();
147 // See comment in eh_exception.cc.
148 virtual const char* what() const throw();
151 /** If you use a NULL pointer in a @c typeid expression, this is thrown. */
152 class bad_typeid : public exception
155 bad_typeid () throw() { }
157 // This declaration is not useless:
158 // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
159 virtual ~bad_typeid() throw();
161 // See comment in eh_exception.cc.
162 virtual const char* what() const throw();
166 #pragma GCC visibility pop