cdce3.C: Test long double math functions for large_long_double target only.
[gcc.git] / libstdc++-v3 / libsupc++ / class_type_info.cc
1 // Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2007
2 // Free Software Foundation
3 //
4 // This file is part of GCC.
5 //
6 // GCC is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2, or (at your option)
9 // any later version.
10
11 // GCC is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15
16 // You should have received a copy of the GNU General Public License
17 // along with GCC; see the file COPYING. If not, write to
18 // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19 // Boston, MA 02110-1301, USA.
20
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline enums from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
29
30 #include "tinfo.h"
31
32 namespace __cxxabiv1 {
33
34 __class_type_info::
35 ~__class_type_info ()
36 {}
37
38 bool __class_type_info::
39 __do_catch (const type_info *thr_type,
40 void **thr_obj,
41 unsigned outer) const
42 {
43 if (*this == *thr_type)
44 return true;
45 if (outer >= 4)
46 // Neither `A' nor `A *'.
47 return false;
48 return thr_type->__do_upcast (this, thr_obj);
49 }
50
51 bool __class_type_info::
52 __do_upcast (const __class_type_info *dst_type,
53 void **obj_ptr) const
54 {
55 __upcast_result result (__vmi_class_type_info::__flags_unknown_mask);
56
57 __do_upcast (dst_type, *obj_ptr, result);
58 if (!contained_public_p (result.part2dst))
59 return false;
60 *obj_ptr = const_cast <void *> (result.dst_ptr);
61 return true;
62 }
63
64 __class_type_info::__sub_kind __class_type_info::
65 __do_find_public_src (ptrdiff_t,
66 const void *obj_ptr,
67 const __class_type_info *,
68 const void *src_ptr) const
69 {
70 if (src_ptr == obj_ptr)
71 // Must be our type, as the pointers match.
72 return __contained_public;
73 return __not_contained;
74 }
75
76 bool __class_type_info::
77 __do_dyncast (ptrdiff_t,
78 __sub_kind access_path,
79 const __class_type_info *dst_type,
80 const void *obj_ptr,
81 const __class_type_info *src_type,
82 const void *src_ptr,
83 __dyncast_result &__restrict result) const
84 {
85 if (obj_ptr == src_ptr && *this == *src_type)
86 {
87 // The src object we started from. Indicate how we are accessible from
88 // the most derived object.
89 result.whole2src = access_path;
90 return false;
91 }
92 if (*this == *dst_type)
93 {
94 result.dst_ptr = obj_ptr;
95 result.whole2dst = access_path;
96 result.dst2src = __not_contained;
97 return false;
98 }
99 return false;
100 }
101
102 bool __class_type_info::
103 __do_upcast (const __class_type_info *dst, const void *obj,
104 __upcast_result &__restrict result) const
105 {
106 if (*this == *dst)
107 {
108 result.dst_ptr = obj;
109 result.base_type = nonvirtual_base_type;
110 result.part2dst = __contained_public;
111 return true;
112 }
113 return false;
114 }
115
116 }