2 |
7u83 |
1 |
/*
|
6 |
7u83 |
2 |
* Copyright (c) 2002-2006 The TenDRA Project <http://www.tendra.org/>.
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
*
|
|
|
5 |
* Redistribution and use in source and binary forms, with or without
|
|
|
6 |
* modification, are permitted provided that the following conditions are met:
|
|
|
7 |
*
|
|
|
8 |
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
9 |
* this list of conditions and the following disclaimer.
|
|
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
11 |
* this list of conditions and the following disclaimer in the documentation
|
|
|
12 |
* and/or other materials provided with the distribution.
|
|
|
13 |
* 3. Neither the name of The TenDRA Project nor the names of its contributors
|
|
|
14 |
* may be used to endorse or promote products derived from this software
|
|
|
15 |
* without specific, prior written permission.
|
|
|
16 |
*
|
|
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
|
|
18 |
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
19 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
20 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
|
|
21 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
22 |
* EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
23 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
24 |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
25 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
26 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
27 |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
28 |
*
|
|
|
29 |
* $Id$
|
|
|
30 |
*/
|
|
|
31 |
/*
|
2 |
7u83 |
32 |
Crown Copyright (c) 1997
|
6 |
7u83 |
33 |
|
2 |
7u83 |
34 |
This TenDRA(r) Computer Program is subject to Copyright
|
|
|
35 |
owned by the United Kingdom Secretary of State for Defence
|
|
|
36 |
acting through the Defence Evaluation and Research Agency
|
|
|
37 |
(DERA). It is made available to Recipients with a
|
|
|
38 |
royalty-free licence for its use, reproduction, transfer
|
|
|
39 |
to other parties and amendment for any purpose not excluding
|
|
|
40 |
product development provided that any such use et cetera
|
|
|
41 |
shall be deemed to be acceptance of the following conditions:-
|
6 |
7u83 |
42 |
|
2 |
7u83 |
43 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
44 |
reproduced upon any copies or amended versions of it;
|
6 |
7u83 |
45 |
|
2 |
7u83 |
46 |
(2) Any amended version of it shall be clearly marked to
|
|
|
47 |
show both the nature of and the organisation responsible
|
|
|
48 |
for the relevant amendment or amendments;
|
6 |
7u83 |
49 |
|
2 |
7u83 |
50 |
(3) Its onward transfer from a recipient to another
|
|
|
51 |
party shall be deemed to be that party's acceptance of
|
|
|
52 |
these conditions;
|
6 |
7u83 |
53 |
|
2 |
7u83 |
54 |
(4) DERA gives no warranty or assurance as to its
|
|
|
55 |
quality or suitability for any purpose and DERA accepts
|
|
|
56 |
no liability whatsoever in relation to any use to which
|
|
|
57 |
it may be put.
|
|
|
58 |
*/
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
#ifndef CONVERT_INCLUDED
|
|
|
62 |
#define CONVERT_INCLUDED
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
/*
|
|
|
66 |
TYPE REPRESENTING AN IMPLICIT CONVERSION SEQUENCE
|
|
|
67 |
|
|
|
68 |
This type is used to represent an implicit conversion sequence. The
|
|
|
69 |
main components are the two types being converted from and to, and
|
|
|
70 |
the overall rank of the conversion (see below). For user-defined
|
|
|
71 |
conversions, the conversion function used and the rank of the following
|
|
|
72 |
standard conversion are recorded. For base class and qualification
|
|
|
73 |
conversions the associated data is also recorded.
|
|
|
74 |
*/
|
|
|
75 |
|
|
|
76 |
typedef struct {
|
6 |
7u83 |
77 |
TYPE from, to;
|
|
|
78 |
unsigned rank;
|
|
|
79 |
unsigned std;
|
|
|
80 |
IDENTIFIER usr;
|
|
|
81 |
GRAPH base;
|
|
|
82 |
CV_SPEC qual;
|
|
|
83 |
} CONVERSION;
|
2 |
7u83 |
84 |
|
|
|
85 |
|
|
|
86 |
/*
|
|
|
87 |
TYPE CONVERSION DECLARATIONS
|
|
|
88 |
|
|
|
89 |
The routines in this module are concerned with the standard C and C++
|
|
|
90 |
type conversions.
|
|
|
91 |
*/
|
|
|
92 |
|
6 |
7u83 |
93 |
extern TYPE arith_type(TYPE, TYPE, EXP, EXP);
|
|
|
94 |
extern TYPE promote_type(TYPE);
|
|
|
95 |
extern TYPE unpromote_type(TYPE);
|
|
|
96 |
extern TYPE arg_promote_type(TYPE, ERROR *);
|
|
|
97 |
extern TYPE ptr_common_type(TYPE, TYPE, int, int *);
|
|
|
98 |
extern TYPE ptr_mem_common_type(TYPE, TYPE, int *);
|
|
|
99 |
extern TYPE common_type(TYPE, TYPE, int *);
|
|
|
100 |
extern unsigned check_qualifier(TYPE, TYPE, int);
|
|
|
101 |
extern int is_arg_promote(TYPE);
|
|
|
102 |
extern int qualifier_depth;
|
2 |
7u83 |
103 |
|
6 |
7u83 |
104 |
extern EXP convert_arith(TYPE, EXP, int, int);
|
|
|
105 |
extern EXP convert_bitfield(EXP);
|
|
|
106 |
extern EXP convert_boolean(EXP, unsigned, ERROR *);
|
|
|
107 |
extern EXP convert_array(EXP, int, ERROR *);
|
|
|
108 |
extern EXP convert_lvalue(EXP);
|
|
|
109 |
extern EXP convert_none(EXP);
|
|
|
110 |
extern EXP convert_const(EXP);
|
|
|
111 |
extern EXP convert_promote(TYPE, EXP);
|
|
|
112 |
extern EXP convert_ptr_common(TYPE, EXP, int, int);
|
|
|
113 |
extern EXP convert_ptr_mem_common(TYPE, EXP, int, int);
|
|
|
114 |
extern EXP convert_reference(EXP, int);
|
|
|
115 |
extern TYPE convert_qual_type(TYPE);
|
2 |
7u83 |
116 |
|
6 |
7u83 |
117 |
extern unsigned convert_seq(CONVERSION *, EXP, int, int);
|
|
|
118 |
extern unsigned std_convert_seq(CONVERSION *, EXP, int, int);
|
|
|
119 |
extern int compare_seq(CONVERSION *, CONVERSION *);
|
|
|
120 |
extern int is_ambiguous_func(IDENTIFIER);
|
2 |
7u83 |
121 |
|
|
|
122 |
|
|
|
123 |
/*
|
|
|
124 |
QUALIFICATION CONVERSION RULES
|
|
|
125 |
|
|
|
126 |
These values comprise the bitpattern returned by check_qualifier. They
|
|
|
127 |
indicate which of the conditions required by the qualifaction conversions
|
|
|
128 |
are satisfied by a particular pair of types. They are also used to
|
|
|
129 |
indicate whether the types are equal or equal functions.
|
|
|
130 |
*/
|
|
|
131 |
|
6 |
7u83 |
132 |
#define QUAL_SIMILAR ((unsigned)0x01)
|
|
|
133 |
#define QUAL_CONST ((unsigned)0x02)
|
|
|
134 |
#define QUAL_VOLATILE ((unsigned)0x04)
|
|
|
135 |
#define QUAL_ALL_CONST ((unsigned)0x08)
|
|
|
136 |
#define QUAL_EXACT ((unsigned)0x10)
|
|
|
137 |
#define QUAL_FUNC ((unsigned)0x20)
|
|
|
138 |
#define QUAL_TEMPL ((unsigned)0x40)
|
2 |
7u83 |
139 |
|
6 |
7u83 |
140 |
#define QUAL_CV ((unsigned)0x0e)
|
|
|
141 |
#define QUAL_OK ((unsigned)0x0f)
|
|
|
142 |
#define QUAL_EQUAL ((unsigned)0x1f)
|
|
|
143 |
#define QUAL_EQ_FUNC ((unsigned)0x3f)
|
2 |
7u83 |
144 |
|
|
|
145 |
|
|
|
146 |
/*
|
|
|
147 |
CONVERSION SEQUENCE RANKS
|
|
|
148 |
|
|
|
149 |
These values are used to indicate the various ranks of implicit
|
|
|
150 |
conversion sequences used within overload resolution. The upper byte
|
|
|
151 |
gives the conversion rank (the higher the value, the better the
|
|
|
152 |
conversion), while the lower byte gives further information on the
|
|
|
153 |
dominant conversion.
|
|
|
154 |
*/
|
|
|
155 |
|
6 |
7u83 |
156 |
#define CONV_EXACT ((unsigned)0x60)
|
2 |
7u83 |
157 |
|
6 |
7u83 |
158 |
#define CONV_QUAL ((unsigned)0x50)
|
|
|
159 |
#define CONV_STRING ((unsigned)0x51)
|
2 |
7u83 |
160 |
|
6 |
7u83 |
161 |
#define CONV_INT_PROM ((unsigned)0x40)
|
|
|
162 |
#define CONV_FLT_PROM ((unsigned)0x41)
|
|
|
163 |
#define CONV_BITFIELD ((unsigned)0x42)
|
2 |
7u83 |
164 |
|
6 |
7u83 |
165 |
#define CONV_INT_INT ((unsigned)0x30)
|
|
|
166 |
#define CONV_FLT_FLT ((unsigned)0x31)
|
|
|
167 |
#define CONV_INT_FLT ((unsigned)0x32)
|
|
|
168 |
#define CONV_FLT_INT ((unsigned)0x33)
|
|
|
169 |
#define CONV_PTR_BASE ((unsigned)0x34)
|
|
|
170 |
#define CONV_PTR_VOID ((unsigned)0x35)
|
|
|
171 |
#define CONV_PTR_BOTTOM ((unsigned)0x36)
|
|
|
172 |
#define CONV_PTR_NULL ((unsigned)0x37)
|
|
|
173 |
#define CONV_PTR_MEM_BASE ((unsigned)0x38)
|
|
|
174 |
#define CONV_PTR_MEM_NULL ((unsigned)0x39)
|
|
|
175 |
#define CONV_BASE ((unsigned)0x3a)
|
|
|
176 |
#define CONV_BOOL ((unsigned)0x3b)
|
2 |
7u83 |
177 |
|
6 |
7u83 |
178 |
#define CONV_USER ((unsigned)0x20)
|
|
|
179 |
#define CONV_USER_MULTI ((unsigned)0x21)
|
2 |
7u83 |
180 |
|
6 |
7u83 |
181 |
#define CONV_ELLIPSIS ((unsigned)0x10)
|
2 |
7u83 |
182 |
|
6 |
7u83 |
183 |
#define CONV_NONE ((unsigned)0x00)
|
|
|
184 |
#define CONV_NULL ((unsigned)0x01)
|
|
|
185 |
#define CONV_PTR_PTR ((unsigned)0x02)
|
|
|
186 |
#define CONV_PTR_PTR_ALIGN ((unsigned)0x03)
|
|
|
187 |
#define CONV_INT_PTR ((unsigned)0x04)
|
|
|
188 |
#define CONV_PTR_INT ((unsigned)0x05)
|
|
|
189 |
#define CONV_PTR_MEM_PTR_MEM ((unsigned)0x06)
|
|
|
190 |
#define CONV_PTR_MEM_FUNC ((unsigned)0x07)
|
|
|
191 |
#define CONV_FUNC ((unsigned)0x08)
|
|
|
192 |
#define CONV_ENUM ((unsigned)0x09)
|
2 |
7u83 |
193 |
|
6 |
7u83 |
194 |
#define CONV_REVERSE ((unsigned)0x80)
|
2 |
7u83 |
195 |
|
6 |
7u83 |
196 |
#define CONV_RANK(A) ((A) & 0x70)
|
2 |
7u83 |
197 |
|
|
|
198 |
|
|
|
199 |
/*
|
|
|
200 |
REFERENCE CONVERSION CONTEXTS
|
|
|
201 |
|
|
|
202 |
These values are used in convert_reference to indicate the various
|
|
|
203 |
contexts for reference conversion.
|
|
|
204 |
*/
|
|
|
205 |
|
|
|
206 |
#define REF_NORMAL 0
|
|
|
207 |
#define REF_FUNCTION 1
|
|
|
208 |
#define REF_ASSIGN 2
|
|
|
209 |
#define REF_ADDRESS 3
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
#endif
|