gcc50/csu: Skip depends step to avoid possible race
[dragonfly.git] / contrib / gcc-4.4 / libstdc++-v3 / libsupc++ / typeinfo
1 // RTTI support for -*- C++ -*-
2 // Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3 // 2003, 2004, 2005, 2006, 2007, 2009
4 // Free Software Foundation
5 //
6 // This file is part of GCC.
7 //
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 3, or (at your option)
11 // any later version.
12 // 
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.
17 // 
18 // Under Section 7 of GPL version 3, you are granted additional
19 // permissions described in the GCC Runtime Library Exception, version
20 // 3.1, as published by the Free Software Foundation.
21
22 // You should have received a copy of the GNU General Public License and
23 // a copy of the GCC Runtime Library Exception along with this program;
24 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
25 // <http://www.gnu.org/licenses/>.
26
27 /** @file typeinfo
28  *  This is a Standard C++ Library header.
29  */
30
31 #ifndef _TYPEINFO
32 #define _TYPEINFO
33
34 #include <exception>
35
36 #pragma GCC visibility push(default)
37
38 extern "C++" {
39
40 namespace __cxxabiv1
41 {
42   class __class_type_info;
43 } // namespace __cxxabiv1
44
45 // Determine whether typeinfo names for the same type are merged (in which
46 // case comparison can just compare pointers) or not (in which case
47 // strings must be compared and g++.dg/abi/local1.C will fail), and
48 // whether comparison is to be implemented inline or not.  By default we
49 // use inline pointer comparison if weak symbols are available, and
50 // out-of-line strcmp if not.  Out-of-line pointer comparison is used
51 // where the object files are to be portable to multiple systems, some of
52 // which may not be able to use pointer comparison, but the particular
53 // system for which libstdc++ is being built can use pointer comparison;
54 // in particular for most ARM EABI systems, where the ABI specifies
55 // out-of-line comparison.  Inline strcmp is not currently supported.  The
56 // compiler's target configuration can override the defaults by defining
57 // __GXX_TYPEINFO_EQUALITY_INLINE to 1 or 0 to indicate whether or not
58 // comparison is inline, and __GXX_MERGED_TYPEINFO_NAMES to 1 or 0 to
59 // indicate whether or not pointer comparison can be used.
60
61 #ifndef __GXX_MERGED_TYPEINFO_NAMES
62   #if !__GXX_WEAK__
63     // If weak symbols are not supported, typeinfo names are not merged.
64     #define __GXX_MERGED_TYPEINFO_NAMES 0
65   #else
66     // On platforms that support weak symbols, typeinfo names are merged.
67     #define __GXX_MERGED_TYPEINFO_NAMES 1
68   #endif
69 #endif
70
71 // By default follow the same rules as for __GXX_MERGED_TYPEINFO_NAMES.
72 #ifndef __GXX_TYPEINFO_EQUALITY_INLINE
73   #if !__GXX_WEAK__
74     #define __GXX_TYPEINFO_EQUALITY_INLINE 0
75   #else
76     #define __GXX_TYPEINFO_EQUALITY_INLINE 1
77   #endif
78 #endif
79
80 namespace std 
81 {
82   /**
83    *  @brief  Part of RTTI.
84    *
85    *  The @c type_info class describes type information generated by
86    *  an implementation.
87   */
88   class type_info 
89   {
90   public:
91     /** Destructor first. Being the first non-inline virtual function, this
92      *  controls in which translation unit the vtable is emitted. The
93      *  compiler makes use of that information to know where to emit
94      *  the runtime-mandated type_info structures in the new-abi.  */
95     virtual ~type_info();
96
97     /** Returns an @e implementation-defined byte string; this is not
98      *  portable between compilers!  */
99     const char* name() const
100     { return __name; }
101
102 #if !__GXX_TYPEINFO_EQUALITY_INLINE
103     bool before(const type_info& __arg) const;
104
105     // In old abi, or when weak symbols are not supported, there can
106     // be multiple instances of a type_info object for one
107     // type. Uniqueness must use the _name value, not object address.
108     bool operator==(const type_info& __arg) const;
109 #else
110   #if !__GXX_MERGED_TYPEINFO_NAMES
111     #error "Inline implementation of type_info comparision requires merging of type_info objects"
112   #endif
113     /** Returns true if @c *this precedes @c __arg in the implementation's
114      *  collation order.  */
115     // In new abi we can rely on type_info's NTBS being unique,
116     // and therefore address comparisons are sufficient.
117     bool before(const type_info& __arg) const
118     { return __name < __arg.__name; }
119
120     bool operator==(const type_info& __arg) const
121     { return __name == __arg.__name; }
122 #endif
123     bool operator!=(const type_info& __arg) const
124     { return !operator==(__arg); }
125
126     // Return true if this is a pointer type of some kind
127     virtual bool __is_pointer_p() const;
128
129     // Return true if this is a function type
130     virtual bool __is_function_p() const;
131
132     // Try and catch a thrown type. Store an adjusted pointer to the
133     // caught type in THR_OBJ. If THR_TYPE is not a pointer type, then
134     // THR_OBJ points to the thrown object. If THR_TYPE is a pointer
135     // type, then THR_OBJ is the pointer itself. OUTER indicates the
136     // number of outer pointers, and whether they were const
137     // qualified.
138     virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj,
139                             unsigned __outer) const;
140
141     // Internally used during catch matching
142     virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target,
143                              void **__obj_ptr) const;
144
145   protected:
146     const char *__name;
147     
148     explicit type_info(const char *__n): __name(__n) { }
149     
150   private:
151     /// Assigning type_info is not supported.
152     type_info& operator=(const type_info&);
153     type_info(const type_info&);
154   };
155
156   /**
157    *  @brief  Thrown during incorrect typecasting.
158    *  @ingroup exceptions
159    *
160    *  If you attempt an invalid @c dynamic_cast expression, an instance of
161    *  this class (or something derived from this class) is thrown.  */
162   class bad_cast : public exception 
163   {
164   public:
165     bad_cast() throw() { }
166
167     // This declaration is not useless:
168     // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
169     virtual ~bad_cast() throw();
170
171     // See comment in eh_exception.cc.
172     virtual const char* what() const throw();
173   };
174   
175   /** 
176    *  @brief Thrown when a NULL pointer in a @c typeid expression is used.
177    *  @ingroup exceptions
178    */
179   class bad_typeid : public exception 
180   {
181   public:
182     bad_typeid () throw() { }
183
184     // This declaration is not useless:
185     // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
186     virtual ~bad_typeid() throw();
187
188     // See comment in eh_exception.cc.
189     virtual const char* what() const throw();
190   };
191 } // namespace std
192
193 #pragma GCC visibility pop
194
195 } // extern "C++"
196 #endif