Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 243

Warning: Undefined variable $n in /usr/local/www/websvn.planix.org/include/diff_util.php on line 247

Warning: Undefined variable $m in /usr/local/www/websvn.planix.org/include/diff_util.php on line 251
WebSVN – tendra.SVN – Diff – /trunk/src/producers/common/construct/chktype.c – Rev 2 and 7

Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
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
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 58... Line 88...
58
#include "printf.h"
88
#include "printf.h"
59
#include "template.h"
89
#include "template.h"
60
#include "tok.h"
90
#include "tok.h"
61
#include "tokdef.h"
91
#include "tokdef.h"
62
#include "token.h"
92
#include "token.h"
63
 
93
 
64
 
94
 
65
/*
95
/*
66
    FIND A TYPE TAG
96
    FIND A TYPE TAG
67
 
97
 
68
    This routine finds the tag of the type t, ignoring any template
98
    This routine finds the tag of the type t, ignoring any template
69
    qualifiers.
99
    qualifiers.
70
*/
100
*/
71
 
101
 
72
unsigned type_tag
102
unsigned
73
    PROTO_N ( ( t ) )
-
 
74
    PROTO_T ( TYPE t )
103
type_tag(TYPE t)
75
{
104
{
76
    if ( !IS_NULL_type ( t ) ) {
105
	if (!IS_NULL_type(t)) {
77
	unsigned tag = TAG_type ( t ) ;
106
		unsigned tag = TAG_type(t);
78
	if ( tag == type_templ_tag ) {
107
		if (tag == type_templ_tag) {
79
	    TYPE s = DEREF_type ( type_templ_defn ( t ) ) ;
108
			TYPE s = DEREF_type(type_templ_defn(t));
80
	    tag = type_tag ( s ) ;
109
			tag = type_tag(s);
-
 
110
		}
-
 
111
		return (tag);
81
	}
112
	}
82
	return ( tag ) ;
-
 
83
    }
-
 
84
    return ( null_tag ) ;
113
	return (null_tag);
85
}
114
}
86
 
115
 
87
 
116
 
88
/*
117
/*
89
    FIND THE CATEGORY OF A TYPE
118
    FIND THE CATEGORY OF A TYPE
Line 92... Line 121...
92
    to by pt.  If this is a reference type then the result is the category
121
    to by pt.  If this is a reference type then the result is the category
93
    of the referenced type (which is always an lvalue).  If it is a tokenised
122
    of the referenced type (which is always an lvalue).  If it is a tokenised
94
    type then the token is expanded and returned via pt.
123
    type then the token is expanded and returned via pt.
95
*/
124
*/
96
 
125
 
97
unsigned type_category
126
unsigned
98
    PROTO_N ( ( pt ) )
-
 
99
    PROTO_T ( TYPE *pt )
127
type_category(TYPE *pt)
100
{
128
{
101
    TYPE t = *pt ;
129
	TYPE t = *pt;
102
    unsigned res = CTYPE_NONE ;
130
	unsigned res = CTYPE_NONE;
103
    if ( !IS_NULL_type ( t ) ) {
131
	if (!IS_NULL_type(t)) {
104
	CV_SPEC qual = DEREF_cv ( type_qual ( t ) ) ;
132
		CV_SPEC qual = DEREF_cv(type_qual(t));
105
	switch ( TAG_type ( t ) ) {
133
		switch (TAG_type(t)) {
106
 
-
 
107
	    case type_integer_tag : res = CTYPE_INTEGER ; break ;
134
		case type_integer_tag:
-
 
135
			res = CTYPE_INTEGER;
-
 
136
			break;
108
	    case type_floating_tag : res = CTYPE_FLOAT ; break ;
137
		case type_floating_tag:
-
 
138
			res = CTYPE_FLOAT;
-
 
139
			break;
109
	    case type_top_tag : res = CTYPE_VOID ; break ;
140
		case type_top_tag:
-
 
141
			res = CTYPE_VOID;
-
 
142
			break;
110
	    case type_bottom_tag : res = CTYPE_VOID ; break ;
143
		case type_bottom_tag:
-
 
144
			res = CTYPE_VOID;
-
 
145
			break;
111
	    case type_ptr_tag : res = CTYPE_PTR ; break ;
146
		case type_ptr_tag:
-
 
147
			res = CTYPE_PTR;
-
 
148
			break;
112
	    case type_ptr_mem_tag : res = CTYPE_PTR_MEM ; break ;
149
		case type_ptr_mem_tag:
-
 
150
			res = CTYPE_PTR_MEM;
-
 
151
			break;
113
	    case type_bitfield_tag : res = CTYPE_BITF ; break ;
152
		case type_bitfield_tag:
-
 
153
			res = CTYPE_BITF;
-
 
154
			break;
114
	    case type_compound_tag : res = CTYPE_CLASS ; break ;
155
		case type_compound_tag:
-
 
156
			res = CTYPE_CLASS;
-
 
157
			break;
115
	    case type_enumerate_tag : res = CTYPE_ENUM ; break ;
158
		case type_enumerate_tag:
-
 
159
			res = CTYPE_ENUM;
-
 
160
			break;
116
	    case type_error_tag : res = CTYPE_ERROR ; break ;
161
		case type_error_tag:
-
 
162
			res = CTYPE_ERROR;
117
 
163
			break;
118
	    case type_func_tag :
164
		case type_func_tag:
119
	    case type_array_tag : {
165
		case type_array_tag: {
120
		/* Allow for lvalue conversions */
166
			/* Allow for lvalue conversions */
121
		if ( qual & cv_lvalue ) res = CTYPE_PTR ;
167
			if (qual & cv_lvalue) {
-
 
168
				res = CTYPE_PTR;
-
 
169
			}
122
		break ;
170
			break;
123
	    }
171
		}
124
 
172
 
125
	    case type_ref_tag : {
173
		case type_ref_tag: {
126
		/* Deal with reference types */
174
			/* Deal with reference types */
127
		TYPE r = DEREF_type ( type_ref_sub ( t ) ) ;
175
			TYPE r = DEREF_type(type_ref_sub(t));
128
		TYPE s = r ;
176
			TYPE s = r;
129
		res = type_category ( &r ) ;
177
			res = type_category(&r);
130
		if ( !EQ_type ( r, s ) ) {
178
			if (!EQ_type(r, s)) {
131
		    MAKE_type_ref ( qual, r, r ) ;
179
				MAKE_type_ref(qual, r, r);
132
		    *pt = r ;
180
				*pt = r;
133
		}
181
			}
134
		break ;
182
			break;
135
	    }
183
		}
136
 
184
 
137
	    case type_token_tag : {
185
		case type_token_tag: {
138
		/* Deal with tokenised types */
186
			/* Deal with tokenised types */
139
		IDENTIFIER id = DEREF_id ( type_token_tok ( t ) ) ;
187
			IDENTIFIER id = DEREF_id(type_token_tok(t));
140
		DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
188
			DECL_SPEC ds = DEREF_dspec(id_storage(id));
141
		if ( ds & dspec_temp ) {
189
			if (ds & dspec_temp) {
142
		    /* Check for recursive tokens */
190
				/* Check for recursive tokens */
143
		    report ( crt_loc, ERR_token_recursive ( id ) ) ;
191
				report(crt_loc, ERR_token_recursive(id));
144
		} else {
192
			} else {
145
		    /* Expand token definition */
193
				/* Expand token definition */
146
		    TYPE r = expand_type ( t, 0 ) ;
194
				TYPE r = expand_type(t, 0);
147
		    if ( !EQ_type ( r, t ) ) {
195
				if (!EQ_type(r, t)) {
148
			COPY_dspec ( id_storage ( id ), ( ds | dspec_temp ) ) ;
196
					COPY_dspec(id_storage(id),
-
 
197
						   (ds | dspec_temp));
149
			res = type_category ( &r ) ;
198
					res = type_category(&r);
150
			COPY_dspec ( id_storage ( id ), ds ) ;
199
					COPY_dspec(id_storage(id), ds);
151
			*pt = r ;
200
					*pt = r;
152
		    } else {
201
				} else {
153
			if ( is_templ_param ( id ) && in_template_decl ) {
202
					if (is_templ_param(id) &&
-
 
203
					    in_template_decl) {
154
			    res |= CTYPE_TEMPL ;
204
						res |= CTYPE_TEMPL;
155
			}
205
					}
156
		    }
206
				}
157
		}
207
			}
158
		res |= CTYPE_TOKEN ;
208
			res |= CTYPE_TOKEN;
159
		break ;
209
			break;
160
	    }
210
		}
161
	}
211
		}
162
	if ( qual & cv_lvalue ) res |= CTYPE_LVALUE ;
212
		if (qual & cv_lvalue) {
-
 
213
			res |= CTYPE_LVALUE;
163
    }
214
		}
-
 
215
	}
164
    return ( res ) ;
216
	return (res);
165
}
217
}
166
 
218
 
167
 
219
 
168
/*
220
/*
169
    ARE TWO INTEGRAL TYPES EQUAL?
221
    ARE TWO INTEGRAL TYPES EQUAL?
170
 
222
 
171
    This routine checks whether the integral types s and t are equal.
223
    This routine checks whether the integral types s and t are equal.
172
*/
224
*/
173
 
225
 
174
int eq_itype
226
int
175
    PROTO_N ( ( s, t ) )
-
 
176
    PROTO_T ( INT_TYPE s X INT_TYPE t )
227
eq_itype(INT_TYPE s, INT_TYPE t)
177
{
228
{
178
    int eq = 0 ;
229
	int eq = 0;
179
    unsigned ns, nt ;
230
	unsigned ns, nt;
180
    if ( EQ_itype ( s, t ) ) return ( 1 ) ;
231
	if (EQ_itype(s, t)) {
-
 
232
		return (1);
-
 
233
	}
181
    if ( IS_NULL_itype ( s ) ) return ( 0 ) ;
234
	if (IS_NULL_itype(s)) {
-
 
235
		return (0);
-
 
236
	}
182
    if ( IS_NULL_itype ( t ) ) return ( 0 ) ;
237
	if (IS_NULL_itype(t)) {
-
 
238
		return (0);
-
 
239
	}
183
    s = expand_itype ( s ) ;
240
	s = expand_itype(s);
184
    t = expand_itype ( t ) ;
241
	t = expand_itype(t);
185
    if ( EQ_itype ( s, t ) ) return ( 1 ) ;
242
	if (EQ_itype(s, t)) {
-
 
243
		return (1);
-
 
244
	}
186
    ns = TAG_itype ( s ) ;
245
	ns = TAG_itype(s);
187
    nt = TAG_itype ( t ) ;
246
	nt = TAG_itype(t);
188
    if ( ns == nt ) {
247
	if (ns == nt) {
189
	ASSERT ( ORDER_itype == 6 ) ;
248
		ASSERT(ORDER_itype == 6);
190
	switch ( ns ) {
249
		switch (ns) {
191
	    case itype_basic_tag : {
250
		case itype_basic_tag: {
192
		/* Built-in types */
251
			/* Built-in types */
193
		BUILTIN_TYPE bs = DEREF_ntype ( itype_basic_no ( s ) ) ;
252
			BUILTIN_TYPE bs = DEREF_ntype(itype_basic_no(s));
194
		BUILTIN_TYPE bt = DEREF_ntype ( itype_basic_no ( t ) ) ;
253
			BUILTIN_TYPE bt = DEREF_ntype(itype_basic_no(t));
195
		if ( bs == bt ) eq = 1 ;
254
			if (bs == bt) {
-
 
255
				eq = 1;
-
 
256
			}
196
		break ;
257
			break;
197
	    }
258
		}
198
	    case itype_bitfield_tag : {
259
		case itype_bitfield_tag: {
199
		/* Bitfield types */
260
			/* Bitfield types */
200
		BASE_TYPE bs = DEREF_btype ( itype_bitfield_rep ( s ) ) ;
261
			BASE_TYPE bs = DEREF_btype(itype_bitfield_rep(s));
201
		BASE_TYPE bt = DEREF_btype ( itype_bitfield_rep ( t ) ) ;
262
			BASE_TYPE bt = DEREF_btype(itype_bitfield_rep(t));
202
		if ( bs == bt ) {
263
			if (bs == bt) {
203
		    NAT ms = DEREF_nat ( itype_bitfield_size ( s ) ) ;
264
				NAT ms = DEREF_nat(itype_bitfield_size(s));
204
		    NAT mt = DEREF_nat ( itype_bitfield_size ( t ) ) ;
265
				NAT mt = DEREF_nat(itype_bitfield_size(t));
205
		    if ( EQ_nat ( ms, mt ) || eq_nat ( ms, mt ) ) {
266
				if (EQ_nat(ms, mt) || eq_nat(ms, mt)) {
-
 
267
					TYPE ps =
206
			TYPE ps = DEREF_type ( itype_bitfield_sub ( s ) ) ;
268
					    DEREF_type(itype_bitfield_sub(s));
-
 
269
					TYPE pt =
207
			TYPE pt = DEREF_type ( itype_bitfield_sub ( t ) ) ;
270
					    DEREF_type(itype_bitfield_sub(t));
208
			eq = eq_type ( ps, pt ) ;
271
					eq = eq_type(ps, pt);
209
		    }
272
				}
210
		}
273
			}
211
		break ;
274
			break;
212
	    }
275
		}
213
	    case itype_promote_tag : {
276
		case itype_promote_tag: {
214
		/* Promotion types */
277
			/* Promotion types */
215
		s = DEREF_itype ( itype_promote_arg ( s ) ) ;
278
			s = DEREF_itype(itype_promote_arg(s));
216
		t = DEREF_itype ( itype_promote_arg ( t ) ) ;
279
			t = DEREF_itype(itype_promote_arg(t));
217
		eq = eq_itype ( s, t ) ;
280
			eq = eq_itype(s, t);
218
		break ;
281
			break;
219
	    }
282
		}
220
	    case itype_arith_tag : {
283
		case itype_arith_tag: {
221
		/* Arithmetic types */
284
			/* Arithmetic types */
222
		INT_TYPE s1 = DEREF_itype ( itype_arith_arg1 ( s ) ) ;
285
			INT_TYPE s1 = DEREF_itype(itype_arith_arg1(s));
223
		INT_TYPE s2 = DEREF_itype ( itype_arith_arg2 ( s ) ) ;
286
			INT_TYPE s2 = DEREF_itype(itype_arith_arg2(s));
224
		INT_TYPE t1 = DEREF_itype ( itype_arith_arg1 ( t ) ) ;
287
			INT_TYPE t1 = DEREF_itype(itype_arith_arg1(t));
225
		INT_TYPE t2 = DEREF_itype ( itype_arith_arg2 ( t ) ) ;
288
			INT_TYPE t2 = DEREF_itype(itype_arith_arg2(t));
226
		if ( eq_itype ( s1, t1 ) ) {
289
			if (eq_itype(s1, t1)) {
227
		    eq = eq_itype ( s2, t2 ) ;
290
				eq = eq_itype(s2, t2);
228
		} else if ( eq_itype ( s1, t2 ) ) {
291
			} else if (eq_itype(s1, t2)) {
229
		    eq = eq_itype ( s2, t1 ) ;
292
				eq = eq_itype(s2, t1);
230
		}
293
			}
231
		break ;
294
			break;
232
	    }
295
		}
233
	    case itype_literal_tag : {
296
		case itype_literal_tag: {
234
		/* Literal types */
297
			/* Literal types */
235
		int bs = DEREF_int ( itype_literal_spec ( s ) ) ;
298
			int bs = DEREF_int(itype_literal_spec(s));
236
		int bt = DEREF_int ( itype_literal_spec ( t ) ) ;
299
			int bt = DEREF_int(itype_literal_spec(t));
237
		IDENTIFIER is = DEREF_id ( itype_literal_tok ( s ) ) ;
300
			IDENTIFIER is = DEREF_id(itype_literal_tok(s));
238
		IDENTIFIER it = DEREF_id ( itype_literal_tok ( t ) ) ;
301
			IDENTIFIER it = DEREF_id(itype_literal_tok(t));
239
		NAT ms = DEREF_nat ( itype_literal_nat ( s ) ) ;
302
			NAT ms = DEREF_nat(itype_literal_nat(s));
240
		NAT mt = DEREF_nat ( itype_literal_nat ( t ) ) ;
303
			NAT mt = DEREF_nat(itype_literal_nat(t));
241
		if ( bs == bt && EQ_id ( is, it ) && eq_nat ( ms, mt ) ) {
304
			if (bs == bt && EQ_id(is, it) && eq_nat(ms, mt)) {
242
		    eq = 1 ;
305
				eq = 1;
243
		}
306
			}
244
		break ;
307
			break;
245
	    }
308
		}
246
	    case itype_token_tag : {
309
		case itype_token_tag: {
247
		/* Token applications */
310
			/* Token applications */
248
		IDENTIFIER is = DEREF_id ( itype_token_tok ( s ) ) ;
311
			IDENTIFIER is = DEREF_id(itype_token_tok(s));
249
		IDENTIFIER it = DEREF_id ( itype_token_tok ( t ) ) ;
312
			IDENTIFIER it = DEREF_id(itype_token_tok(t));
250
		LIST ( TOKEN ) ps = DEREF_list ( itype_token_args ( s ) ) ;
313
			LIST(TOKEN)ps = DEREF_list(itype_token_args(s));
251
		LIST ( TOKEN ) pt = DEREF_list ( itype_token_args ( t ) ) ;
314
			LIST(TOKEN)pt = DEREF_list(itype_token_args(t));
252
		eq = eq_token_args ( is, it, ps, pt ) ;
315
			eq = eq_token_args(is, it, ps, pt);
253
		break ;
316
			break;
254
	    }
317
		}
255
	}
318
		}
256
    }
319
	}
257
    return ( eq ) ;
320
	return (eq);
258
}
321
}
259
 
322
 
260
 
323
 
261
/*
324
/*
262
    ARE TWO FLOATING POINT TYPES EQUAL?
325
    ARE TWO FLOATING POINT TYPES EQUAL?
263
 
326
 
264
    This routine checks whether the floating point types s and t are equal.
327
    This routine checks whether the floating point types s and t are equal.
265
*/
328
*/
266
 
329
 
267
int eq_ftype
330
int
268
    PROTO_N ( ( s, t ) )
-
 
269
    PROTO_T ( FLOAT_TYPE s X FLOAT_TYPE t )
331
eq_ftype(FLOAT_TYPE s, FLOAT_TYPE t)
270
{
332
{
271
    int eq = 0 ;
333
	int eq = 0;
272
    unsigned ns, nt ;
334
	unsigned ns, nt;
273
    if ( EQ_ftype ( s, t ) ) return ( 1 ) ;
-
 
274
    if ( IS_NULL_ftype ( s ) ) return ( 0 ) ;
-
 
275
    if ( IS_NULL_ftype ( t ) ) return ( 0 ) ;
-
 
276
    ns = TAG_ftype ( s ) ;
-
 
277
    nt = TAG_ftype ( t ) ;
-
 
278
    if ( ns == nt ) {
-
 
279
	ASSERT ( ORDER_ftype == 4 ) ;
-
 
280
	switch ( ns ) {
-
 
281
	    case ftype_basic_tag : {
-
 
282
		/* Built-in types */
-
 
283
		BUILTIN_TYPE bs = DEREF_ntype ( ftype_basic_no ( s ) ) ;
-
 
284
		BUILTIN_TYPE bt = DEREF_ntype ( ftype_basic_no ( t ) ) ;
-
 
285
		if ( bs == bt ) eq = 1 ;
-
 
286
		break ;
-
 
287
	    }
-
 
288
	    case ftype_arg_promote_tag : {
-
 
289
		/* Argument promotion types */
-
 
290
		FLOAT_TYPE s1 = DEREF_ftype ( ftype_arg_promote_arg ( s ) ) ;
-
 
291
		FLOAT_TYPE t1 = DEREF_ftype ( ftype_arg_promote_arg ( t ) ) ;
-
 
292
		eq = eq_ftype ( s1, t1 ) ;
-
 
293
		break ;
-
 
294
	    }
-
 
295
	    case ftype_arith_tag : {
-
 
296
		/* Arithmetic types */
-
 
297
		FLOAT_TYPE s1 = DEREF_ftype ( ftype_arith_arg1 ( s ) ) ;
-
 
298
		FLOAT_TYPE s2 = DEREF_ftype ( ftype_arith_arg2 ( s ) ) ;
-
 
299
		FLOAT_TYPE t1 = DEREF_ftype ( ftype_arith_arg1 ( t ) ) ;
-
 
300
		FLOAT_TYPE t2 = DEREF_ftype ( ftype_arith_arg2 ( t ) ) ;
-
 
301
		if ( eq_ftype ( s1, t1 ) ) {
335
	if (EQ_ftype(s, t)) {
302
		    eq = eq_ftype ( s2, t2 ) ;
-
 
303
		} else if ( eq_ftype ( s1, t2 ) ) {
-
 
304
		    eq = eq_ftype ( s2, t1 ) ;
-
 
305
		}
-
 
306
		break ;
-
 
307
	    }
-
 
308
	    case ftype_token_tag : {
-
 
309
		/* Token applications */
-
 
310
		IDENTIFIER is = DEREF_id ( ftype_token_tok ( s ) ) ;
-
 
311
		IDENTIFIER it = DEREF_id ( ftype_token_tok ( t ) ) ;
-
 
312
		LIST ( TOKEN ) ps = DEREF_list ( ftype_token_args ( s ) ) ;
-
 
313
		LIST ( TOKEN ) pt = DEREF_list ( ftype_token_args ( t ) ) ;
-
 
314
		eq = eq_token_args ( is, it, ps, pt ) ;
-
 
315
		break ;
336
		return (1);
316
	    }
-
 
317
	}
337
	}
-
 
338
	if (IS_NULL_ftype(s)) {
-
 
339
		return (0);
-
 
340
	}
-
 
341
	if (IS_NULL_ftype(t)) {
-
 
342
		return (0);
-
 
343
	}
-
 
344
	ns = TAG_ftype(s);
-
 
345
	nt = TAG_ftype(t);
-
 
346
	if (ns == nt) {
-
 
347
		ASSERT(ORDER_ftype == 4);
-
 
348
		switch (ns) {
-
 
349
		case ftype_basic_tag: {
-
 
350
			/* Built-in types */
-
 
351
			BUILTIN_TYPE bs = DEREF_ntype(ftype_basic_no(s));
-
 
352
			BUILTIN_TYPE bt = DEREF_ntype(ftype_basic_no(t));
-
 
353
			if (bs == bt) {
-
 
354
				eq = 1;
-
 
355
			}
-
 
356
			break;
-
 
357
		}
-
 
358
		case ftype_arg_promote_tag: {
-
 
359
			/* Argument promotion types */
-
 
360
			FLOAT_TYPE s1 = DEREF_ftype(ftype_arg_promote_arg(s));
-
 
361
			FLOAT_TYPE t1 = DEREF_ftype(ftype_arg_promote_arg(t));
-
 
362
			eq = eq_ftype(s1, t1);
-
 
363
			break;
-
 
364
		}
-
 
365
		case ftype_arith_tag: {
-
 
366
			/* Arithmetic types */
-
 
367
			FLOAT_TYPE s1 = DEREF_ftype(ftype_arith_arg1(s));
-
 
368
			FLOAT_TYPE s2 = DEREF_ftype(ftype_arith_arg2(s));
-
 
369
			FLOAT_TYPE t1 = DEREF_ftype(ftype_arith_arg1(t));
-
 
370
			FLOAT_TYPE t2 = DEREF_ftype(ftype_arith_arg2(t));
-
 
371
			if (eq_ftype(s1, t1)) {
-
 
372
				eq = eq_ftype(s2, t2);
-
 
373
			} else if (eq_ftype(s1, t2)) {
-
 
374
				eq = eq_ftype(s2, t1);
318
    }
375
			}
-
 
376
			break;
-
 
377
		}
-
 
378
		case ftype_token_tag: {
-
 
379
			/* Token applications */
-
 
380
			IDENTIFIER is = DEREF_id(ftype_token_tok(s));
-
 
381
			IDENTIFIER it = DEREF_id(ftype_token_tok(t));
-
 
382
			LIST(TOKEN)ps = DEREF_list(ftype_token_args(s));
-
 
383
			LIST(TOKEN)pt = DEREF_list(ftype_token_args(t));
-
 
384
			eq = eq_token_args(is, it, ps, pt);
-
 
385
			break;
-
 
386
		}
-
 
387
		}
-
 
388
	}
319
    return ( eq ) ;
389
	return (eq);
320
}
390
}
321
 
391
 
322
 
392
 
323
/*
393
/*
324
    FIND THE CV-QUALIFIER FOR A TYPE
394
    FIND THE CV-QUALIFIER FOR A TYPE
325
 
395
 
326
    This routine finds the cv-qualifier for the type t.  In most cases this
396
    This routine finds the cv-qualifier for the type t.  In most cases this
327
    is trivial, but for arrays the qualifier is that of the subtype.
397
    is trivial, but for arrays the qualifier is that of the subtype.
328
*/
398
*/
329
 
399
 
330
CV_SPEC find_cv_qual
400
CV_SPEC
331
    PROTO_N ( ( t ) )
-
 
332
    PROTO_T ( TYPE t )
401
find_cv_qual(TYPE t)
333
{
402
{
334
    CV_SPEC qt = DEREF_cv ( type_qual ( t ) ) ;
403
	CV_SPEC qt = DEREF_cv(type_qual(t));
335
    while ( IS_type_array ( t ) ) {
404
	while (IS_type_array(t)) {
336
	CV_SPEC qs ;
405
		CV_SPEC qs;
337
	t = DEREF_type ( type_array_sub ( t ) ) ;
406
		t = DEREF_type(type_array_sub(t));
338
	qs = DEREF_cv ( type_qual ( t ) ) ;
407
		qs = DEREF_cv(type_qual(t));
339
	qt |= qs ;
408
		qt |= qs;
340
    }
409
	}
341
    return ( qt ) ;
410
	return (qt);
342
}
411
}
343
 
412
 
344
 
413
 
345
/*
414
/*
346
    IS ONE TYPE MORE CV-QUALIFIED THAN ANOTHER?
415
    IS ONE TYPE MORE CV-QUALIFIED THAN ANOTHER?
Line 349... Line 418...
349
    type t.  That is to say, if t is const then so is s, and if t is volatile
418
    type t.  That is to say, if t is const then so is s, and if t is volatile
350
    then so is s.  Otherwise it returns those cv-qualifiers for which s
419
    then so is s.  Otherwise it returns those cv-qualifiers for which s
351
    fails to be more qualified than t.
420
    fails to be more qualified than t.
352
*/
421
*/
353
 
422
 
354
CV_SPEC cv_compare
423
CV_SPEC
355
    PROTO_N ( ( s, t ) )
-
 
356
    PROTO_T ( TYPE s X TYPE t )
424
cv_compare(TYPE s, TYPE t)
357
{
425
{
358
    CV_SPEC qs = find_cv_qual ( s ) ;
426
	CV_SPEC qs = find_cv_qual(s);
359
    CV_SPEC qt = find_cv_qual ( t ) ;
427
	CV_SPEC qt = find_cv_qual(t);
360
    qs &= cv_qual ;
428
	qs &= cv_qual;
361
    qt &= cv_qual ;
429
	qt &= cv_qual;
362
    return ( qt & ~qs ) ;
430
	return (qt & ~qs);
363
}
431
}
364
 
432
 
365
 
433
 
366
/*
434
/*
367
    ARE TWO FUNCTION LINKAGE SPECIFIERS THE SAME?
435
    ARE TWO FUNCTION LINKAGE SPECIFIERS THE SAME?
368
 
436
 
369
    This routine compares the function linkage specifiers for the function
437
    This routine compares the function linkage specifiers for the function
370
    types s and t.
438
    types s and t.
371
*/
439
*/
372
 
440
 
373
static int eq_func_lang
441
static int
374
    PROTO_N ( ( s, t ) )
-
 
375
    PROTO_T ( TYPE s X TYPE t )
442
eq_func_lang(TYPE s, TYPE t)
376
{
443
{
377
    CV_SPEC qs = DEREF_cv ( type_func_mqual ( s ) ) ;
444
	CV_SPEC qs = DEREF_cv(type_func_mqual(s));
378
    CV_SPEC qt = DEREF_cv ( type_func_mqual ( t ) ) ;
445
	CV_SPEC qt = DEREF_cv(type_func_mqual(t));
379
    if ( qs != qt ) {
446
	if (qs != qt) {
380
	CV_SPEC ps = ( qs & cv_language ) ;
447
		CV_SPEC ps = (qs & cv_language);
381
	CV_SPEC pt = ( qt & cv_language ) ;
448
		CV_SPEC pt = (qt & cv_language);
382
	if ( ps != pt ) {
449
		if (ps != pt) {
383
	    if ( ps == cv_none ) {
450
			if (ps == cv_none) {
384
		if ( force_tokdef ) {
451
				if (force_tokdef) {
385
		    ps = pt ;
452
					ps = pt;
386
		    COPY_cv ( type_func_mqual ( s ), ( qs | ps ) ) ;
453
					COPY_cv(type_func_mqual(s), (qs | ps));
387
		} else {
454
				} else {
388
		    ps = cv_lang ;
455
					ps = cv_lang;
389
		}
456
				}
390
	    }
457
			}
391
	    if ( pt == cv_none ) {
458
			if (pt == cv_none) {
392
		if ( force_tokdef ) {
459
				if (force_tokdef) {
393
		    pt = ps ;
460
					pt = ps;
394
		    COPY_cv ( type_func_mqual ( t ), ( qt | pt ) ) ;
461
					COPY_cv(type_func_mqual(t), (qt | pt));
395
		} else {
462
				} else {
396
		    pt = cv_lang ;
463
					pt = cv_lang;
397
		}
464
				}
398
	    }
465
			}
399
	    if ( ps != pt ) return ( 0 ) ;
466
			if (ps != pt) {
-
 
467
				return (0);
-
 
468
			}
400
	}
469
		}
401
    }
470
	}
402
    return ( 1 ) ;
471
	return (1);
403
}
472
}
404
 
473
 
405
 
474
 
406
/*
475
/*
407
    ARE TWO FUNCTION TYPES EQUAL?
476
    ARE TWO FUNCTION TYPES EQUAL?
408
 
477
 
409
    This routine checks whether the function types s and t are equal.
478
    This routine checks whether the function types s and t are equal.
410
    Member function qualifiers are only considered if mq is true.
479
    Member function qualifiers are only considered if mq is true.
411
    If rf is true then any parameter of type 'X' is considered to match
480
    If rf is true then any parameter of type 'X' is considered to match
412
    one of type 'X &'.  The routine returns 3 if the types are precisely
481
    one of type 'X &'.  The routine returns 3 if the types are precisely
413
    equal, 2 if they differ only in the linkage specifier, 1 if they
482
    equal, 2 if they differ only in the linkage specifier, 1 if they
414
    differ only in the return type or in one of these reference
483
    differ only in the return type or in one of these reference
415
    equalities, and 0 otherwise.
484
    equalities, and 0 otherwise.
416
*/
485
*/
417
 
486
 
418
int eq_func_type
487
int
419
    PROTO_N ( ( s, t, mq, rf ) )
-
 
420
    PROTO_T ( TYPE s X TYPE t X int mq X int rf )
488
eq_func_type(TYPE s, TYPE t, int mq, int rf)
421
{
489
{
422
    int eq = 3 ;
490
	int eq = 3;
423
    int es, et ;
491
	int es, et;
424
    unsigned ns, nt ;
492
	unsigned ns, nt;
425
    LIST ( TYPE ) ls, lt ;
493
	LIST(TYPE)ls, lt;
426
 
494
 
427
    /* Check for obvious equality */
495
	/* Check for obvious equality */
428
    if ( EQ_type ( s, t ) ) return ( 3 ) ;
496
	if (EQ_type(s, t)) {
-
 
497
		return (3);
-
 
498
	}
429
    ns = TAG_type ( s ) ;
499
	ns = TAG_type(s);
430
    nt = TAG_type ( t ) ;
500
	nt = TAG_type(t);
431
    if ( ns != type_func_tag || nt != type_func_tag ) {
501
	if (ns != type_func_tag || nt != type_func_tag) {
432
	if ( ns == type_templ_tag && nt == type_templ_tag ) {
502
		if (ns == type_templ_tag && nt == type_templ_tag) {
433
	    /* Allow for template functions */
503
			/* Allow for template functions */
434
	    eq = eq_template ( s, t, 1, mq, rf ) ;
504
			eq = eq_template(s, t, 1, mq, rf);
435
	    return ( eq ) ;
505
			return (eq);
436
	} else {
506
		} else {
437
	    /* Otherwise just check type equality */
507
			/* Otherwise just check type equality */
438
	    eq = eq_type ( s, t ) ;
508
			eq = eq_type(s, t);
439
	    if ( eq == 1 ) return ( 3 ) ;
509
			if (eq == 1) {
-
 
510
				return (3);
-
 
511
			}
440
	    return ( 0 ) ;
512
			return (0);
441
	}
513
		}
442
    }
514
	}
443
 
515
 
444
    /* Check number of parameters */
516
	/* Check number of parameters */
445
    es = DEREF_int ( type_func_ellipsis ( s ) ) ;
517
	es = DEREF_int(type_func_ellipsis(s));
446
    et = DEREF_int ( type_func_ellipsis ( t ) ) ;
518
	et = DEREF_int(type_func_ellipsis(t));
447
    ls = DEREF_list ( type_func_ptypes ( s ) ) ;
519
	ls = DEREF_list(type_func_ptypes(s));
448
    lt = DEREF_list ( type_func_ptypes ( t ) ) ;
520
	lt = DEREF_list(type_func_ptypes(t));
449
    if ( es != et || LENGTH_list ( ls ) != LENGTH_list ( lt ) ) {
521
	if (es != et || LENGTH_list(ls)!= LENGTH_list(lt)) {
450
	return ( 0 ) ;
522
		return (0);
451
    }
523
	}
452
 
524
 
453
    /* Check parameter types */
525
	/* Check parameter types */
454
    while ( !IS_NULL_list ( ls ) ) {
526
	while (!IS_NULL_list(ls)) {
455
	/* Check next parameter */
527
		/* Check next parameter */
456
	TYPE as = DEREF_type ( HEAD_list ( ls ) ) ;
528
		TYPE as = DEREF_type(HEAD_list(ls));
457
	TYPE at = DEREF_type ( HEAD_list ( lt ) ) ;
529
		TYPE at = DEREF_type(HEAD_list(lt));
458
	if ( es & FUNC_PARAMS ) {
530
		if (es & FUNC_PARAMS) {
459
	    /* Compare unpromoted types */
531
			/* Compare unpromoted types */
460
	    as = unpromote_type ( as ) ;
532
			as = unpromote_type(as);
461
	    at = unpromote_type ( at ) ;
533
			at = unpromote_type(at);
462
	}
534
		}
463
	if ( rf ) {
535
		if (rf) {
464
	    /* Allow for references */
536
			/* Allow for references */
465
	    if ( IS_type_ref ( as ) ) {
537
			if (IS_type_ref(as)) {
466
		if ( !IS_type_ref ( at ) ) {
538
				if (!IS_type_ref(at)) {
467
		    as = DEREF_type ( type_ref_sub ( as ) ) ;
539
					as = DEREF_type(type_ref_sub(as));
468
		    eq = 1 ;
540
					eq = 1;
469
		}
541
				}
470
	    } else if ( IS_type_ref ( at ) ) {
542
			} else if (IS_type_ref(at)) {
471
		at = DEREF_type ( type_ref_sub ( at ) ) ;
543
				at = DEREF_type(type_ref_sub(at));
472
		eq = 1 ;
544
				eq = 1;
473
	    }
545
			}
474
	}
546
		}
475
	if ( eq_type ( as, at ) != 1 ) return ( 0 ) ;
547
		if (eq_type(as, at) != 1) {
-
 
548
			return (0);
-
 
549
		}
476
	if ( force_tokdef ) {
550
		if (force_tokdef) {
477
	    /* Preserve printf and scanf types */
551
			/* Preserve printf and scanf types */
478
	    if ( is_printf_type ( as ) ) {
552
			if (is_printf_type(as)) {
479
		IDENTIFIER id = DEREF_id ( type_name ( as ) ) ;
553
				IDENTIFIER id = DEREF_id(type_name(as));
480
		COPY_id ( type_name ( at ), id ) ;
554
				COPY_id(type_name(at), id);
481
	    } else if ( is_printf_type ( at ) ) {
555
			} else if (is_printf_type(at)) {
482
		IDENTIFIER id = DEREF_id ( type_name ( at ) ) ;
556
				IDENTIFIER id = DEREF_id(type_name(at));
483
		COPY_id ( type_name ( as ), id ) ;
557
				COPY_id(type_name(as), id);
-
 
558
			}
-
 
559
		}
-
 
560
		ls = TAIL_list(ls);
-
 
561
		lt = TAIL_list(lt);
-
 
562
	}
-
 
563
 
-
 
564
	/* Check return type */
-
 
565
	if (eq == 3) {
-
 
566
		TYPE rs = DEREF_type(type_func_ret(s));
-
 
567
		TYPE rt = DEREF_type(type_func_ret(t));
-
 
568
		if (eq_type(rt, rs)!= 1) {
-
 
569
			if (IS_type_top_etc(rs)) {
-
 
570
				/* Check for 'void' and 'bottom' */
-
 
571
				TYPE r = type_composite(rs, rt, 0, 1, KILL_err,
-
 
572
							0);
-
 
573
				if (IS_NULL_type(r)) {
-
 
574
					eq = 1;
484
	    }
575
				}
-
 
576
			} else {
-
 
577
				eq = 1;
-
 
578
			}
-
 
579
		}
485
	}
580
	}
486
	ls = TAIL_list ( ls ) ;
-
 
487
	lt = TAIL_list ( lt ) ;
-
 
488
    }
-
 
489
 
581
 
490
    /* Check return type */
582
	/* Check member qualifiers */
491
    if ( eq == 3 ) {
583
	if (eq) {
492
	TYPE rs = DEREF_type ( type_func_ret ( s ) ) ;
584
		CV_SPEC qs = DEREF_cv(type_func_mqual(s));
493
	TYPE rt = DEREF_type ( type_func_ret ( t ) ) ;
585
		CV_SPEC qt = DEREF_cv(type_func_mqual(t));
494
	if ( eq_type ( rt, rs ) != 1 ) {
586
		if (qs != qt) {
495
	    if ( IS_type_top_etc ( rs ) ) {
587
			if (mq && (qs & cv_qual)!= (qt & cv_qual)) {
-
 
588
				eq = 0;
496
		/* Check for 'void' and 'bottom' */
589
			} else if (!eq_func_lang(s, t)) {
497
		TYPE r = type_composite ( rs, rt, 0, 1, KILL_err, 0 ) ;
590
				/* Linkage specifiers don't match */
498
		if ( IS_NULL_type ( r ) ) eq = 1 ;
591
				if (eq == 3 && option(OPT_func_linkage)) {
499
	    } else {
592
					eq = 2;
500
		eq = 1 ;
593
				}
501
	    }
594
			}
-
 
595
		}
502
	}
596
	}
503
    }
-
 
504
 
-
 
505
    /* Check member qualifiers */
-
 
506
    if ( eq ) {
-
 
507
	CV_SPEC qs = DEREF_cv ( type_func_mqual ( s ) ) ;
-
 
508
	CV_SPEC qt = DEREF_cv ( type_func_mqual ( t ) ) ;
-
 
509
	if ( qs != qt ) {
-
 
510
	    if ( mq && ( qs & cv_qual ) != ( qt & cv_qual ) ) {
-
 
511
		eq = 0 ;
-
 
512
	    } else if ( !eq_func_lang ( s, t ) ) {
-
 
513
		/* Linkage specifiers don't match */
-
 
514
		if ( eq == 3 && option ( OPT_func_linkage ) ) eq = 2 ;
-
 
515
	    }
-
 
516
	}
-
 
517
    }
-
 
518
    return ( eq ) ;
597
	return (eq);
519
}
598
}
520
 
599
 
521
 
600
 
522
/*
601
/*
523
    CHECK EQUALITY OF NESTED TEMPLATE CLASS
602
    CHECK EQUALITY OF NESTED TEMPLATE CLASS
524
 
603
 
525
    This routine checks whether the instance s of a nested class or
604
    This routine checks whether the instance s of a nested class or
526
    enumeration type of a template class equals the type tid.
605
    enumeration type of a template class equals the type tid.
527
*/
606
*/
528
 
607
 
529
static int eq_instance
608
static int
530
    PROTO_N ( ( s, tid ) )
-
 
531
    PROTO_T ( TYPE s X IDENTIFIER tid )
609
eq_instance(TYPE s, IDENTIFIER tid)
532
{
610
{
533
    if ( IS_type_instance ( s ) ) {
611
	if (IS_type_instance(s)) {
534
	IDENTIFIER sid = DEREF_id ( type_instance_id ( s ) ) ;
612
		IDENTIFIER sid = DEREF_id(type_instance_id(s));
535
	if ( EQ_id ( sid, tid ) ) {
613
		if (EQ_id(sid, tid)) {
536
	    CLASS_TYPE cs, ct ;
614
			CLASS_TYPE cs, ct;
537
	    sid = DEREF_id ( type_name ( s ) ) ;
615
			sid = DEREF_id(type_name(s));
538
	    if ( EQ_id ( sid, tid ) ) return ( 1 ) ;
616
			if (EQ_id(sid, tid)) {
-
 
617
				return (1);
-
 
618
			}
539
	    cs = parent_class ( sid ) ;
619
			cs = parent_class(sid);
540
	    ct = parent_class ( tid ) ;
620
			ct = parent_class(tid);
541
	    if ( IS_NULL_ctype ( cs ) ) return ( 0 ) ;
621
			if (IS_NULL_ctype(cs)) {
-
 
622
				return (0);
-
 
623
			}
542
	    if ( IS_NULL_ctype ( ct ) ) return ( 0 ) ;
624
			if (IS_NULL_ctype(ct)) {
-
 
625
				return (0);
-
 
626
			}
543
	    return ( eq_ctype ( cs, ct ) ) ;
627
			return (eq_ctype(cs, ct));
-
 
628
		}
544
	}
629
	}
545
    }
-
 
546
    return ( 0 ) ;
630
	return (0);
547
}
631
}
548
 
632
 
549
 
633
 
550
/*
634
/*
551
    CHECK EQUALITY OF CLASS TYPES
635
    CHECK EQUALITY OF CLASS TYPES
552
 
636
 
553
    This routine checks for equality of the class types cs and ct.
637
    This routine checks for equality of the class types cs and ct.
554
*/
638
*/
555
 
639
 
556
int eq_ctype
640
int
557
    PROTO_N ( ( cs, ct ) )
-
 
558
    PROTO_T ( CLASS_TYPE cs X CLASS_TYPE ct )
641
eq_ctype(CLASS_TYPE cs, CLASS_TYPE ct)
559
{
642
{
560
    if ( EQ_ctype ( cs, ct ) ) {
643
	if (EQ_ctype(cs, ct)) {
561
	/* Simple class equality */
644
		/* Simple class equality */
562
	return ( 1 ) ;
645
		return (1);
563
    }
646
	}
564
    if ( !IS_NULL_ctype ( cs ) && !IS_NULL_ctype ( ct ) ) {
647
	if (!IS_NULL_ctype(cs) && !IS_NULL_ctype(ct)) {
565
	TYPE s = DEREF_type ( ctype_form ( cs ) ) ;
648
		TYPE s = DEREF_type(ctype_form(cs));
566
	TYPE t = DEREF_type ( ctype_form ( ct ) ) ;
649
		TYPE t = DEREF_type(ctype_form(ct));
567
	if ( !IS_NULL_type ( s ) || !IS_NULL_type ( t ) ) {
650
		if (!IS_NULL_type(s) || !IS_NULL_type(t)) {
568
	    /* Allow for template classes */
651
			/* Allow for template classes */
569
	    unsigned ns, nt ;
652
			unsigned ns, nt;
-
 
653
			if (IS_NULL_type(s)) {
570
	    if ( IS_NULL_type ( s ) ) s = make_class_type ( cs ) ;
654
				s = make_class_type(cs);
-
 
655
			}
-
 
656
			if (IS_NULL_type(t)) {
571
	    if ( IS_NULL_type ( t ) ) t = make_class_type ( ct ) ;
657
				t = make_class_type(ct);
-
 
658
			}
572
	    ns = TAG_type ( s ) ;
659
			ns = TAG_type(s);
573
	    nt = TAG_type ( t ) ;
660
			nt = TAG_type(t);
574
	    if ( ns != nt ) {
661
			if (ns != nt) {
575
		if ( ns == type_instance_tag ) {
662
				if (ns == type_instance_tag) {
-
 
663
					IDENTIFIER tid =
576
		    IDENTIFIER tid = DEREF_id ( ctype_name ( ct ) ) ;
664
					    DEREF_id(ctype_name(ct));
577
		    if ( eq_instance ( s, tid ) ) return ( 1 ) ;
665
					if (eq_instance(s, tid)) {
-
 
666
						return (1);
-
 
667
					}
578
		}
668
				}
579
		if ( nt == type_instance_tag ) {
669
				if (nt == type_instance_tag) {
-
 
670
					IDENTIFIER sid =
580
		    IDENTIFIER sid = DEREF_id ( ctype_name ( cs ) ) ;
671
					    DEREF_id(ctype_name(cs));
581
		    if ( eq_instance ( t, sid ) ) return ( 1 ) ;
672
					if (eq_instance(t, sid)) {
-
 
673
						return (1);
-
 
674
					}
582
		}
675
				}
583
	    }
676
			}
584
	    return ( eq_type ( s, t ) ) ;
677
			return (eq_type(s, t));
585
	}
678
		}
586
	if ( force_merge ) {
679
		if (force_merge) {
587
	    /* Allow for merging of type names */
680
			/* Allow for merging of type names */
588
	    IDENTIFIER sid = DEREF_id ( ctype_name ( cs ) ) ;
681
			IDENTIFIER sid = DEREF_id(ctype_name(cs));
589
	    IDENTIFIER tid = DEREF_id ( ctype_name ( ct ) ) ;
682
			IDENTIFIER tid = DEREF_id(ctype_name(ct));
590
	    return ( merge_type ( sid, tid ) ) ;
683
			return (merge_type(sid, tid));
591
	}
684
		}
592
    }
-
 
593
    return ( 0 ) ;
-
 
594
}
-
 
595
 
-
 
596
 
-
 
597
/*
-
 
598
    CHECK EQUALITY OF ENUMERATION TYPES
-
 
599
 
-
 
600
    This routine checks for equality of the enumeration types es and et.
-
 
601
*/
-
 
602
 
-
 
603
int eq_etype
-
 
604
    PROTO_N ( ( es, et ) )
-
 
605
    PROTO_T ( ENUM_TYPE es X ENUM_TYPE et )
-
 
606
{
-
 
607
    if ( EQ_etype ( es, et ) ) {
-
 
608
	/* Simple equality */
-
 
609
	return ( 1 ) ;
-
 
610
    }
-
 
611
    if ( !IS_NULL_etype ( es ) && !IS_NULL_etype ( et ) ) {
-
 
612
	TYPE s = DEREF_type ( etype_form ( es ) ) ;
-
 
613
	TYPE t = DEREF_type ( etype_form ( et ) ) ;
-
 
614
	if ( !IS_NULL_type ( s ) && !IS_NULL_type ( t ) ) {
-
 
615
	    return ( eq_type ( s, t ) ) ;
-
 
616
	}
685
	}
-
 
686
	return (0);
-
 
687
}
-
 
688
 
-
 
689
 
-
 
690
/*
617
	if ( !IS_NULL_type ( s ) ) {
691
    CHECK EQUALITY OF ENUMERATION TYPES
-
 
692
 
618
	    IDENTIFIER tid = DEREF_id ( etype_name ( et ) ) ;
693
    This routine checks for equality of the enumeration types es and et.
-
 
694
*/
-
 
695
 
-
 
696
int
-
 
697
eq_etype(ENUM_TYPE es, ENUM_TYPE et)
-
 
698
{
619
	    return ( eq_instance ( s, tid ) ) ;
699
	if (EQ_etype(es, et)) {
-
 
700
		/* Simple equality */
-
 
701
		return (1);
620
	}
702
	}
-
 
703
	if (!IS_NULL_etype(es) && !IS_NULL_etype(et)) {
-
 
704
		TYPE s = DEREF_type(etype_form(es));
-
 
705
		TYPE t = DEREF_type(etype_form(et));
-
 
706
		if (!IS_NULL_type(s) && !IS_NULL_type(t)) {
-
 
707
			return (eq_type(s, t));
-
 
708
		}
-
 
709
		if (!IS_NULL_type(s)) {
-
 
710
			IDENTIFIER tid = DEREF_id(etype_name(et));
-
 
711
			return (eq_instance(s, tid));
-
 
712
		}
621
	if ( !IS_NULL_type ( t ) ) {
713
		if (!IS_NULL_type(t)) {
622
	    IDENTIFIER sid = DEREF_id ( etype_name ( es ) ) ;
714
			IDENTIFIER sid = DEREF_id(etype_name(es));
623
	    return ( eq_instance ( t, sid ) ) ;
715
			return (eq_instance(t, sid));
-
 
716
		}
-
 
717
		if (force_merge) {
-
 
718
			/* Allow for merging of type names */
-
 
719
			IDENTIFIER sid = DEREF_id(etype_name(es));
-
 
720
			IDENTIFIER tid = DEREF_id(etype_name(et));
-
 
721
			return (merge_type(sid, tid));
-
 
722
		}
624
	}
723
	}
625
	if ( force_merge ) {
-
 
626
	    /* Allow for merging of type names */
-
 
627
	    IDENTIFIER sid = DEREF_id ( etype_name ( es ) ) ;
-
 
628
	    IDENTIFIER tid = DEREF_id ( etype_name ( et ) ) ;
-
 
629
	    return ( merge_type ( sid, tid ) ) ;
-
 
630
	}
-
 
631
    }
-
 
632
    return ( 0 ) ;
724
	return (0);
633
}
725
}
634
 
726
 
635
 
727
 
636
/*
728
/*
637
    CHECK TYPE EQUALITY
729
    CHECK TYPE EQUALITY
638
 
730
 
639
    This is an auxiliary routine used by eq_type_qual which checks the
731
    This is an auxiliary routine used by eq_type_qual which checks the
640
    types s and t for equality ignoring qualifiers according to the
732
    types s and t for equality ignoring qualifiers according to the
641
    value of qu.  If either s or t is a template type and force_template
733
    value of qu.  If either s or t is a template type and force_template
642
    is true then 1 is returned if the types are precisely equal, 2 is
734
    is true then 1 is returned if the types are precisely equal, 2 is
643
    returned if t is a specialisation of s, 3 if s is a specialisation
735
    returned if t is a specialisation of s, 3 if s is a specialisation
644
    of t, 4 if each is a specialisation of the other (but they are not
736
    of t, 4 if each is a specialisation of the other (but they are not
645
    equal) and 0 otherwise.
737
    equal) and 0 otherwise.
646
*/
738
*/
647
 
739
 
648
static int eq_type_aux
740
static int
649
    PROTO_N ( ( s, t, qu ) )
-
 
650
    PROTO_T ( TYPE s X TYPE t X int qu )
741
eq_type_aux(TYPE s, TYPE t, int qu)
651
{
742
{
652
    /* Check for obvious equality */
743
	/* Check for obvious equality */
653
    unsigned ns, nt ;
744
	unsigned ns, nt;
654
    if ( EQ_type ( s, t ) ) return ( 1 ) ;
745
	if (EQ_type(s, t)) {
-
 
746
		return (1);
-
 
747
	}
655
    if ( IS_NULL_type ( s ) ) return ( 0 ) ;
748
	if (IS_NULL_type(s)) {
-
 
749
		return (0);
-
 
750
	}
656
    if ( IS_NULL_type ( t ) ) return ( 0 ) ;
751
	if (IS_NULL_type(t)) {
-
 
752
		return (0);
-
 
753
	}
657
 
754
 
658
    /* Tags should be equal */
755
	/* Tags should be equal */
659
    ns = TAG_type ( s ) ;
756
	ns = TAG_type(s);
660
    nt = TAG_type ( t ) ;
757
	nt = TAG_type(t);
661
    if ( ns != nt ) {
758
	if (ns != nt) {
662
	if ( ns == type_templ_tag && force_template ) {
759
		if (ns == type_templ_tag && force_template) {
663
	    /* Allow for template types */
760
			/* Allow for template types */
664
	    if ( deduce_template ( s, t, qu ) ) return ( 2 ) ;
761
			if (deduce_template(s, t, qu)) {
-
 
762
				return (2);
-
 
763
			}
665
	}
764
		}
666
	if ( nt == type_templ_tag && force_template ) {
765
		if (nt == type_templ_tag && force_template) {
667
	    /* Allow for template types */
766
			/* Allow for template types */
668
	    if ( deduce_template ( t, s, qu ) ) return ( 3 ) ;
767
			if (deduce_template(t, s, qu)) {
-
 
768
				return (3);
-
 
769
			}
669
	}
770
		}
670
	return ( 0 ) ;
771
		return (0);
671
    }
772
	}
672
 
773
 
673
    /* Qualifiers should be equal */
774
	/* Qualifiers should be equal */
674
    if ( qu == 0 ) {
775
	if (qu == 0) {
675
	CV_SPEC qs = DEREF_cv ( type_qual ( s ) ) ;
776
		CV_SPEC qs = DEREF_cv(type_qual(s));
676
	CV_SPEC qt = DEREF_cv ( type_qual ( t ) ) ;
777
		CV_SPEC qt = DEREF_cv(type_qual(t));
677
	if ( qs != qt ) {
778
		if (qs != qt) {
678
	    /* Try again allowing for lvalues */
779
			/* Try again allowing for lvalues */
679
	    qs &= cv_qual ;
780
			qs &= cv_qual;
680
	    qt &= cv_qual ;
781
			qt &= cv_qual;
681
	    if ( qs != qt ) return ( 0 ) ;
782
			if (qs != qt) {
-
 
783
				return (0);
-
 
784
			}
682
	}
785
		}
683
    }
786
	}
684
 
787
 
685
    /* Check on type components */
788
	/* Check on type components */
686
    ASSERT ( ORDER_type == 18 ) ;
789
	ASSERT(ORDER_type == 18);
687
    switch ( ns ) {
790
	switch (ns) {
688
 
791
 
689
	case type_integer_tag : {
792
	case type_integer_tag: {
690
	    /* Check integer types */
793
		/* Check integer types */
691
	    INT_TYPE is = DEREF_itype ( type_integer_rep ( s ) ) ;
794
		INT_TYPE is = DEREF_itype(type_integer_rep(s));
692
	    INT_TYPE it = DEREF_itype ( type_integer_rep ( t ) ) ;
795
		INT_TYPE it = DEREF_itype(type_integer_rep(t));
693
	    if ( EQ_itype ( is, it ) ) return ( 1 ) ;
796
		if (EQ_itype(is, it)) {
-
 
797
			return (1);
-
 
798
		}
694
	    return ( eq_itype ( is, it ) ) ;
799
		return (eq_itype(is, it));
695
	}
800
	}
696
 
801
 
697
	case type_floating_tag : {
802
	case type_floating_tag: {
698
	    /* Check floating types */
803
		/* Check floating types */
699
	    FLOAT_TYPE fs = DEREF_ftype ( type_floating_rep ( s ) ) ;
804
		FLOAT_TYPE fs = DEREF_ftype(type_floating_rep(s));
700
	    FLOAT_TYPE ft = DEREF_ftype ( type_floating_rep ( t ) ) ;
805
		FLOAT_TYPE ft = DEREF_ftype(type_floating_rep(t));
701
	    if ( EQ_ftype ( fs, ft ) ) return ( 1 ) ;
806
		if (EQ_ftype(fs, ft)) {
-
 
807
			return (1);
-
 
808
		}
702
	    return ( eq_ftype ( fs, ft ) ) ;
809
		return (eq_ftype(fs, ft));
703
	}
810
	}
704
 
811
 
705
	case type_ptr_tag : {
812
	case type_ptr_tag: {
706
	    /* Check pointer sub-types */
813
		/* Check pointer sub-types */
707
	    s = DEREF_type ( type_ptr_sub ( s ) ) ;
814
		s = DEREF_type(type_ptr_sub(s));
708
	    t = DEREF_type ( type_ptr_sub ( t ) ) ;
815
		t = DEREF_type(type_ptr_sub(t));
709
	    if ( qu == 1 ) qu = 0 ;
816
		if (qu == 1) {
-
 
817
			qu = 0;
-
 
818
		}
710
	    return ( eq_type_qual ( s, t, qu ) ) ;
819
		return (eq_type_qual(s, t, qu));
711
	}
820
	}
712
 
821
 
713
	case type_ref_tag : {
822
	case type_ref_tag: {
714
	    /* Check reference sub-types */
823
		/* Check reference sub-types */
715
	    s = DEREF_type ( type_ref_sub ( s ) ) ;
824
		s = DEREF_type(type_ref_sub(s));
716
	    t = DEREF_type ( type_ref_sub ( t ) ) ;
825
		t = DEREF_type(type_ref_sub(t));
717
	    return ( eq_type_qual ( s, t, qu ) ) ;
826
		return (eq_type_qual(s, t, qu));
718
	}
827
	}
719
 
828
 
720
#if LANGUAGE_CPP
829
#if LANGUAGE_CPP
825
 
981
 
826
	case type_instance_tag : {
982
	case type_dummy_tag: {
827
	    /* Check instance types */
983
		/* Check dummy types */
828
	    IDENTIFIER is = DEREF_id ( type_instance_id ( s ) ) ;
-
 
829
	    IDENTIFIER it = DEREF_id ( type_instance_id ( t ) ) ;
-
 
830
	    if ( EQ_id ( is, it ) ) {
-
 
831
		/* Derived from same member */
-
 
832
		CLASS_TYPE cs, ct ;
-
 
833
		is = DEREF_id ( type_name ( s ) ) ;
984
		int is = DEREF_int(type_dummy_tok(s));
834
		it = DEREF_id ( type_name ( t ) ) ;
985
		int it = DEREF_int(type_dummy_tok(t));
835
		if ( EQ_id ( is, it ) ) return ( 1 ) ;
-
 
836
		cs = parent_class ( is ) ;
-
 
837
		ct = parent_class ( it ) ;
-
 
838
		if ( IS_NULL_ctype ( cs ) ) return ( 0 ) ;
-
 
839
		if ( IS_NULL_ctype ( ct ) ) return ( 0 ) ;
-
 
840
		return ( eq_ctype ( cs, ct ) ) ;
-
 
841
	    }
-
 
842
	    return ( 0 ) ;
986
		return (is == it);
843
	}
987
	}
844
 
-
 
845
	case type_dummy_tag : {
-
 
846
	    /* Check dummy types */
-
 
847
	    int is = DEREF_int ( type_dummy_tok ( s ) ) ;
-
 
848
	    int it = DEREF_int ( type_dummy_tok ( t ) ) ;
-
 
849
	    return ( is == it ) ;
-
 
850
	}
988
	}
851
    }
-
 
852
    /* Simple types compare equal */
989
	/* Simple types compare equal */
853
    return ( 1 ) ;
990
	return (1);
854
}
991
}
855
 
992
 
856
 
993
 
857
/*
994
/*
858
    UNIFY TWO TYPES
995
    UNIFY TWO TYPES
859
 
996
 
860
    This routine unifies the types s and t by defining tokens if necessary.
997
    This routine unifies the types s and t by defining tokens if necessary.
861
    cv gives the type qualifiers which are in t but not in s.  It returns
998
    cv gives the type qualifiers which are in t but not in s.  It returns
862
    true if a value is assigned to a token.
999
    true if a value is assigned to a token.
863
*/
1000
*/
864
 
1001
 
865
int unify_type
1002
int
866
    PROTO_N ( ( s, t, cv, qual ) )
-
 
867
    PROTO_T ( TYPE s X TYPE t X CV_SPEC cv X int qual )
1003
unify_type(TYPE s, TYPE t, CV_SPEC cv, int qual)
868
{
1004
{
869
    IDENTIFIER id ;
1005
	IDENTIFIER id;
870
    LIST ( TOKEN ) args ;
1006
	LIST(TOKEN)args;
871
    unsigned tag = TAG_type ( s ) ;
1007
	unsigned tag = TAG_type(s);
872
    switch ( tag ) {
1008
	switch (tag) {
873
	case type_integer_tag : {
1009
	case type_integer_tag: {
874
	    /* Integral types */
1010
		/* Integral types */
875
	    INT_TYPE is = DEREF_itype ( type_integer_rep ( s ) ) ;
1011
		INT_TYPE is = DEREF_itype(type_integer_rep(s));
876
	    switch ( TAG_itype ( is ) ) {
1012
		switch (TAG_itype(is)) {
877
		case itype_basic_tag : {
1013
		case itype_basic_tag: {
878
		    /* Built-in integral types */
1014
			/* Built-in integral types */
879
		    BUILTIN_TYPE n = DEREF_ntype ( itype_basic_no ( is ) ) ;
1015
			BUILTIN_TYPE n = DEREF_ntype(itype_basic_no(is));
880
		    id = get_special ( base_token [n].tok, 0 ) ;
1016
			id = get_special(base_token[n].tok, 0);
881
		    if ( IS_NULL_id ( id ) ) return ( 0 ) ;
1017
			if (IS_NULL_id(id)) {
-
 
1018
				return (0);
-
 
1019
			}
882
		    args = NULL_list ( TOKEN ) ;
1020
			args = NULL_list(TOKEN);
883
		    break ;
1021
			break;
884
		}
1022
		}
885
		case itype_token_tag : {
1023
		case itype_token_tag: {
886
		    /* Tokenised integral types */
1024
			/* Tokenised integral types */
887
		    id = DEREF_id ( itype_token_tok ( is ) ) ;
1025
			id = DEREF_id(itype_token_tok(is));
888
		    args = DEREF_list ( itype_token_args ( is ) ) ;
1026
			args = DEREF_list(itype_token_args(is));
889
		    break ;
1027
			break;
890
		}
1028
		}
891
		default : {
1029
		default:
892
		    /* Other integral types */
1030
			/* Other integral types */
893
		    return ( 0 ) ;
1031
			return (0);
894
		}
1032
		}
895
	    }
-
 
896
	    break ;
1033
		break;
897
	}
1034
	}
898
	case type_floating_tag : {
1035
	case type_floating_tag: {
899
	    /* Floating types */
1036
		/* Floating types */
900
	    FLOAT_TYPE fs = DEREF_ftype ( type_floating_rep ( s ) ) ;
1037
		FLOAT_TYPE fs = DEREF_ftype(type_floating_rep(s));
901
	    if ( IS_ftype_token ( fs ) ) {
1038
		if (IS_ftype_token(fs)) {
902
		id = DEREF_id ( ftype_token_tok ( fs ) ) ;
1039
			id = DEREF_id(ftype_token_tok(fs));
903
		args = DEREF_list ( ftype_token_args ( fs ) ) ;
1040
			args = DEREF_list(ftype_token_args(fs));
904
		break ;
1041
			break;
905
	    }
1042
		}
906
	    return ( 0 ) ;
1043
		return (0);
907
	}
1044
	}
908
	case type_compound_tag : {
1045
	case type_compound_tag: {
909
	    /* Class types */
1046
		/* Class types */
910
	    CLASS_TYPE cs = DEREF_ctype ( type_compound_defn ( s ) ) ;
1047
		CLASS_TYPE cs = DEREF_ctype(type_compound_defn(s));
911
	    CLASS_INFO ci = DEREF_cinfo ( ctype_info ( cs ) ) ;
1048
		CLASS_INFO ci = DEREF_cinfo(ctype_info(cs));
912
	    if ( ci & cinfo_token ) {
1049
		if (ci & cinfo_token) {
913
		TYPE r = DEREF_type ( ctype_form ( cs ) ) ;
1050
			TYPE r = DEREF_type(ctype_form(cs));
914
		if ( !IS_NULL_type ( r ) && IS_type_token ( r ) ) {
1051
			if (!IS_NULL_type(r) && IS_type_token(r)) {
915
		    id = DEREF_id ( type_token_tok ( r ) ) ;
1052
				id = DEREF_id(type_token_tok(r));
916
		    args = DEREF_list ( type_token_args ( r ) ) ;
1053
				args = DEREF_list(type_token_args(r));
917
		    break ;
1054
				break;
918
		}
1055
			}
919
	    }
1056
		}
920
	    return ( 0 ) ;
1057
		return (0);
921
	}
1058
	}
922
	case type_token_tag : {
1059
	case type_token_tag: {
923
	    /* Tokenised types */
1060
		/* Tokenised types */
924
	    id = DEREF_id ( type_token_tok ( s ) ) ;
1061
		id = DEREF_id(type_token_tok(s));
925
	    args = DEREF_list ( type_token_args ( s ) ) ;
1062
		args = DEREF_list(type_token_args(s));
926
	    break ;
1063
		break;
927
	}
1064
	}
928
	default : {
1065
	default:
929
	    /* Other types */
1066
		/* Other types */
930
	    return ( 0 ) ;
1067
		return (0);
931
	}
1068
	}
932
    }
-
 
933
    if ( defining_token ( id ) ) {
1069
	if (defining_token(id)) {
934
	TOKEN sort ;
1070
		TOKEN sort;
935
	if ( IS_NULL_list ( args ) ) {
1071
		if (IS_NULL_list(args)) {
936
	    t = qualify_type ( t, cv, 0 ) ;
1072
			t = qualify_type(t, cv, 0);
937
	    return ( define_type_token ( id, t, qual ) ) ;
1073
			return (define_type_token(id, t, qual));
938
	}
1074
		}
939
	sort = DEREF_tok ( id_token_sort ( id ) ) ;
1075
		sort = DEREF_tok(id_token_sort(id));
940
	if ( IS_tok_class ( sort ) && IS_type_compound ( t ) ) {
1076
		if (IS_tok_class(sort) && IS_type_compound(t)) {
941
	    /* Check for template template parameters */
1077
			/* Check for template template parameters */
942
	    CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
1078
			CLASS_TYPE ct = DEREF_ctype(type_compound_defn(t));
943
	    TYPE r = DEREF_type ( ctype_form ( ct ) ) ;
1079
			TYPE r = DEREF_type(ctype_form(ct));
944
	    if ( !IS_NULL_type ( r ) && IS_type_token ( r ) ) {
1080
			if (!IS_NULL_type(r) && IS_type_token(r)) {
945
		IDENTIFIER tid = DEREF_id ( type_token_tok ( r ) ) ;
1081
				IDENTIFIER tid = DEREF_id(type_token_tok(r));
946
		if ( IS_id_class_name ( tid ) ) {
1082
				if (IS_id_class_name(tid)) {
947
		    LIST ( TOKEN ) targs ;
1083
					LIST(TOKEN)targs;
948
		    targs = DEREF_list ( type_token_args ( r ) ) ;
1084
					targs = DEREF_list(type_token_args(r));
949
		    if ( eq_token_args ( tid, tid, args, targs ) ) {
1085
					if (eq_token_args(tid, tid, args, targs)) {
950
			return ( define_templ_token ( id, tid ) ) ;
1086
						return (define_templ_token(id, tid));
951
		    }
1087
					}
-
 
1088
				}
952
		}
1089
			}
953
	    }
1090
		}
954
	}
1091
	}
955
    }
-
 
956
    if ( expand_tokdef ) {
1092
	if (expand_tokdef) {
957
	/* Expand token definitions */
1093
		/* Expand token definitions */
958
	TOKEN sort = find_tokdef ( id ) ;
1094
		TOKEN sort = find_tokdef(id);
959
	if ( !IS_NULL_tok ( sort ) && IS_tok_type ( sort ) ) {
1095
		if (!IS_NULL_tok(sort) && IS_tok_type(sort)) {
960
	    TYPE r = DEREF_type ( tok_type_value ( sort ) ) ;
1096
			TYPE r = DEREF_type(tok_type_value(sort));
961
	    if ( !IS_NULL_type ( r ) && eq_type ( r, t ) ) return ( 1 ) ;
1097
			if (!IS_NULL_type(r) && eq_type(r, t)) {
-
 
1098
				return (1);
-
 
1099
			}
-
 
1100
		}
962
	}
1101
	}
963
    }
-
 
964
    return ( 0 ) ;
1102
	return (0);
965
}
1103
}
966
 
1104
 
967
 
1105
 
968
/*
1106
/*
969
    CAN TWO TYPES BE UNIFIED?
1107
    CAN TWO TYPES BE UNIFIED?
970
 
1108
 
971
    This routine checks whether the type s can be unified with t or vice
1109
    This routine checks whether the type s can be unified with t or vice
972
    versa using token definitions.
1110
    versa using token definitions.
973
*/
1111
*/
974
 
1112
 
975
static int unify_types
1113
static int
976
    PROTO_N ( ( s, t, qu ) )
-
 
977
    PROTO_T ( TYPE s X TYPE t X int qu )
1114
unify_types(TYPE s, TYPE t, int qu)
978
{
1115
{
979
    if ( force_tokdef || force_template || expand_tokdef ) {
1116
	if (force_tokdef || force_template || expand_tokdef) {
980
	CV_SPEC qs, qt ;
1117
		CV_SPEC qs, qt;
981
	CV_SPEC rs, rt ;
1118
		CV_SPEC rs, rt;
982
	if ( IS_NULL_type ( s ) ) return ( 0 ) ;
1119
		if (IS_NULL_type(s)) {
-
 
1120
			return (0);
-
 
1121
		}
983
	if ( IS_NULL_type ( t ) ) return ( 0 ) ;
1122
		if (IS_NULL_type(t)) {
-
 
1123
			return (0);
-
 
1124
		}
984
	qs = DEREF_cv ( type_qual ( s ) ) ;
1125
		qs = DEREF_cv(type_qual(s));
985
	qt = DEREF_cv ( type_qual ( t ) ) ;
1126
		qt = DEREF_cv(type_qual(t));
986
	qs &= cv_qual ;
1127
		qs &= cv_qual;
987
	qt &= cv_qual ;
1128
		qt &= cv_qual;
988
	rs = ( qs & ~qt ) ;
1129
		rs = (qs & ~qt);
989
	rt = ( qt & ~qs ) ;
1130
		rt = (qt & ~qs);
990
	if ( rs == cv_none || qu ) {
1131
		if (rs == cv_none || qu) {
991
	    if ( unify_type ( s, t, rt, 0 ) ) return ( 1 ) ;
1132
			if (unify_type(s, t, rt, 0)) {
-
 
1133
				return (1);
-
 
1134
			}
992
	}
1135
		}
993
	if ( rt == cv_none || qu ) {
1136
		if (rt == cv_none || qu) {
994
	    if ( unify_type ( t, s, rs, 0 ) ) return ( 1 ) ;
1137
			if (unify_type(t, s, rs, 0)) {
-
 
1138
				return (1);
-
 
1139
			}
995
	}
1140
		}
996
    }
1141
	}
997
    return ( 0 ) ;
1142
	return (0);
998
}
1143
}
999
 
1144
 
1000
 
1145
 
1001
/*
1146
/*
1002
    ARE TWO TYPES EQUAL?
1147
    ARE TWO TYPES EQUAL?
1003
 
1148
 
1004
    This routine checks whether the types s and t are equal (excluding
1149
    This routine checks whether the types s and t are equal (excluding
1005
    lvalue qualifiers).  If qu is 1 then the top level qualifiers
1150
    lvalue qualifiers).  If qu is 1 then the top level qualifiers
1006
    are completely ignored, if it is 2 all qualifiers are ignored.
1151
    are completely ignored, if it is 2 all qualifiers are ignored.
1007
    The return values are as in eq_type_aux.  The routine is usually
1152
    The return values are as in eq_type_aux.  The routine is usually
1008
    accessed through the macros eq_type and eq_type_unqual.
1153
    accessed through the macros eq_type and eq_type_unqual.
1009
*/
1154
*/
1010
 
1155
 
1011
int eq_type_qual
1156
int
1012
    PROTO_N ( ( s, t, qu ) )
-
 
1013
    PROTO_T ( TYPE s X TYPE t X int qu )
1157
eq_type_qual(TYPE s, TYPE t, int qu)
1014
{
1158
{
1015
    int eq ;
1159
	int eq;
1016
    if ( EQ_type ( s, t ) ) return ( 1 ) ;
1160
	if (EQ_type(s, t)) {
-
 
1161
		return (1);
-
 
1162
	}
1017
    eq = eq_type_aux ( s, t, qu ) ;
1163
	eq = eq_type_aux(s, t, qu);
-
 
1164
	if (eq == 0) {
1018
    if ( eq == 0 ) eq = unify_types ( s, t, qu ) ;
1165
		eq = unify_types(s, t, qu);
-
 
1166
	}
1019
    return ( eq ) ;
1167
	return (eq);
1020
}
1168
}
1021
 
1169
 
1022
 
1170
 
1023
/*
1171
/*
1024
    IS THE OFFSET OF TWO TYPES EQUAL?
1172
    IS THE OFFSET OF TWO TYPES EQUAL?
Line 1028... Line 1176...
1028
    has the same size and alignment requirements.  Note that the value 6
1176
    has the same size and alignment requirements.  Note that the value 6
1029
    is used in the builtin_casts table to indicate integral types which
1177
    is used in the builtin_casts table to indicate integral types which
1030
    are equivalent in this way.
1178
    are equivalent in this way.
1031
*/
1179
*/
1032
 
1180
 
1033
int eq_type_offset
1181
int
1034
    PROTO_N ( ( s, t ) )
-
 
1035
    PROTO_T ( TYPE s X TYPE t )
1182
eq_type_offset(TYPE s, TYPE t)
1036
{
1183
{
1037
    unsigned ns = TAG_type ( s ) ;
1184
	unsigned ns = TAG_type(s);
1038
    unsigned nt = TAG_type ( t ) ;
1185
	unsigned nt = TAG_type(t);
1039
    if ( ns != nt ) return ( 0 ) ;
1186
	if (ns != nt) {
1040
    if ( ns == type_integer_tag ) {
-
 
1041
	INT_TYPE is = DEREF_itype ( type_integer_rep ( s ) ) ;
-
 
1042
	INT_TYPE it = DEREF_itype ( type_integer_rep ( t ) ) ;
-
 
1043
	if ( IS_itype_basic ( is ) && IS_itype_basic ( it ) ) {
-
 
1044
	    BUILTIN_TYPE bs = DEREF_ntype ( itype_basic_no ( is ) ) ;
-
 
1045
	    BUILTIN_TYPE bt = DEREF_ntype ( itype_basic_no ( it ) ) ;
-
 
1046
	    if ( bs == bt ) return ( 1 ) ;
-
 
1047
	    if ( builtin_cast ( bs, bt ) == 6 ) return ( 1 ) ;
-
 
1048
	    return ( 0 ) ;
1187
		return (0);
1049
	}
1188
	}
-
 
1189
	if (ns == type_integer_tag) {
-
 
1190
		INT_TYPE is = DEREF_itype(type_integer_rep(s));
-
 
1191
		INT_TYPE it = DEREF_itype(type_integer_rep(t));
-
 
1192
		if (IS_itype_basic(is) && IS_itype_basic(it)) {
-
 
1193
			BUILTIN_TYPE bs = DEREF_ntype(itype_basic_no(is));
-
 
1194
			BUILTIN_TYPE bt = DEREF_ntype(itype_basic_no(it));
-
 
1195
			if (bs == bt) {
-
 
1196
				return (1);
1050
    }
1197
			}
-
 
1198
			if (builtin_cast(bs, bt) == 6) {
-
 
1199
				return (1);
-
 
1200
			}
-
 
1201
			return (0);
-
 
1202
		}
-
 
1203
	}
1051
    return ( eq_type_unqual ( s, t ) ) ;
1204
	return (eq_type_unqual(s, t));
1052
}
1205
}
1053
 
1206
 
1054
 
1207
 
1055
/*
1208
/*
1056
    FIND THE COMPOSITE OF TWO FUNCTION TYPES
1209
    FIND THE COMPOSITE OF TWO FUNCTION TYPES
1057
 
1210
 
1058
    This routine finds the composite type (in the C sense) of the function
1211
    This routine finds the composite type (in the C sense) of the function
1059
    types s and t.  eq gives the result of a previous call to eq_func_type.
1212
    types s and t.  eq gives the result of a previous call to eq_func_type.
1060
    If the types are compatible then a new composite function type, based
1213
    If the types are compatible then a new composite function type, based
1061
    on s, is returned.  Otherwise the null type is returned.
1214
    on s, is returned.  Otherwise the null type is returned.
1062
*/
1215
*/
1063
 
1216
 
1064
#if LANGUAGE_C
1217
#if LANGUAGE_C
1065
 
1218
 
1066
static TYPE func_composite
1219
static TYPE
1067
    PROTO_N ( ( s, t, eq, err, mk ) )
-
 
1068
    PROTO_T ( TYPE s X TYPE t X int eq X ERROR *err X int mk )
1220
func_composite(TYPE s, TYPE t, int eq, ERROR *err, int mk)
1069
{
1221
{
1070
    TYPE rs, rt ;
1222
	TYPE rs, rt;
1071
    CV_SPEC qs, qt ;
1223
	CV_SPEC qs, qt;
1072
    TYPE mt = NULL_type ;
1224
	TYPE mt = NULL_type;
1073
    int es = DEREF_int ( type_func_ellipsis ( s ) ) ;
1225
	int es = DEREF_int(type_func_ellipsis(s));
1074
    NAMESPACE ns = DEREF_nspace ( type_func_pars ( s ) ) ;
1226
	NAMESPACE ns = DEREF_nspace(type_func_pars(s));
1075
    LIST ( TYPE ) ps = DEREF_list ( type_func_ptypes ( s ) ) ;
1227
	LIST(TYPE)ps = DEREF_list(type_func_ptypes(s));
1076
    LIST ( TYPE ) pt = DEREF_list ( type_func_mtypes ( s ) ) ;
1228
	LIST(TYPE)pt = DEREF_list(type_func_mtypes(s));
1077
    LIST ( IDENTIFIER ) pids = DEREF_list ( type_func_pids ( s ) ) ;
1229
	LIST(IDENTIFIER)pids = DEREF_list(type_func_pids(s));
1078
 
1230
 
1079
    /* Check parameter types */
1231
	/* Check parameter types */
-
 
1232
	if (!EQ_list(ps, pt)) {
1080
    if ( !EQ_list ( ps, pt ) ) mt = DEREF_type ( HEAD_list ( pt ) ) ;
1233
		mt = DEREF_type(HEAD_list(pt));
-
 
1234
	}
1081
    if ( eq == 0 ) {
1235
	if (eq == 0) {
1082
	int et = DEREF_int ( type_func_ellipsis ( t ) ) ;
1236
		int et = DEREF_int(type_func_ellipsis(t));
1083
	if ( es & FUNC_NO_PARAMS ) {
1237
		if (es & FUNC_NO_PARAMS) {
1084
	    /* s has no parameter information - swap types */
1238
			/* s has no parameter information - swap types */
1085
	    if ( et != FUNC_NO_PARAMS ) {
1239
			if (et != FUNC_NO_PARAMS) {
1086
		ps = DEREF_list ( type_func_ptypes ( t ) ) ;
1240
				ps = DEREF_list(type_func_ptypes(t));
1087
		ns = DEREF_nspace ( type_func_pars ( t ) ) ;
1241
				ns = DEREF_nspace(type_func_pars(t));
1088
		pids = DEREF_list ( type_func_pids ( t ) ) ;
1242
				pids = DEREF_list(type_func_pids(t));
1089
		es = et ;
1243
				es = et;
1090
		et = FUNC_NO_PARAMS ;
1244
				et = FUNC_NO_PARAMS;
1091
	    }
-
 
1092
	}
-
 
1093
	if ( et & FUNC_NO_PARAMS ) {
-
 
1094
	    /* One type has no parameter information */
-
 
1095
	    if ( es & FUNC_ELLIPSIS ) {
-
 
1096
		OPTION opt = option ( OPT_ellipsis_extra ) ;
-
 
1097
		add_error ( err, ERR_dcl_fct_compat_ellipsis () ) ;
-
 
1098
		if ( opt == OPTION_DISALLOW ) return ( NULL_type ) ;
-
 
1099
	    }
-
 
1100
	    if ( !( es & FUNC_WEAK ) ) {
-
 
1101
		pt = ps ;
-
 
1102
		while ( !IS_NULL_list ( pt ) ) {
-
 
1103
		    TYPE at = DEREF_type ( HEAD_list ( pt ) ) ;
-
 
1104
		    if ( !is_arg_promote ( at ) ) {
-
 
1105
			OPTION opt = option ( OPT_func_incompat ) ;
-
 
1106
			add_error ( err, ERR_dcl_fct_compat_prom ( at ) ) ;
-
 
1107
			if ( opt == OPTION_DISALLOW ) return ( NULL_type ) ;
-
 
1108
		    }
-
 
1109
		    pt = TAIL_list ( pt ) ;
-
 
1110
		}
1245
			}
1111
	    }
-
 
1112
 
-
 
1113
	} else {
-
 
1114
	    /* Both types have parameter information */
-
 
1115
	    int prom = 0 ;
-
 
1116
	    int force = force_tokdef ;
-
 
1117
	    LIST ( TYPE ) pr = NULL_list ( TYPE ) ;
-
 
1118
	    pt = DEREF_list ( type_func_ptypes ( t ) ) ;
-
 
1119
	    if ( es & FUNC_ELLIPSIS ) {
-
 
1120
		if ( et & FUNC_ELLIPSIS ) {
-
 
1121
		    /* Both functions have ellipsis */
-
 
1122
		    /* EMPTY */
-
 
1123
		} else {
-
 
1124
		    /* One function has ellipsis */
-
 
1125
		    OPTION opt = option ( OPT_ellipsis_extra ) ;
-
 
1126
		    add_error ( err, ERR_dcl_fct_compat_ellipsis () ) ;
-
 
1127
		    if ( opt == OPTION_DISALLOW ) return ( NULL_type ) ;
-
 
1128
		    et |= FUNC_ELLIPSIS ;
-
 
1129
		}
1246
		}
1130
	    } else {
-
 
1131
		if ( et & FUNC_ELLIPSIS ) {
1247
		if (et & FUNC_NO_PARAMS) {
1132
		    /* One function has ellipsis */
1248
			/* One type has no parameter information */
1133
		    OPTION opt = option ( OPT_ellipsis_extra ) ;
-
 
1134
		    add_error ( err, ERR_dcl_fct_compat_ellipsis () ) ;
-
 
1135
		    if ( opt == OPTION_DISALLOW ) return ( NULL_type ) ;
-
 
1136
		    es |= FUNC_ELLIPSIS ;
1249
			if (es & FUNC_ELLIPSIS) {
1137
		} else {
-
 
1138
		    /* Neither function has ellipsis */
-
 
1139
		    if ( LENGTH_list ( ps ) != LENGTH_list ( pt ) ) {
-
 
1140
			return ( NULL_type ) ;
-
 
1141
		    }
-
 
1142
		}
-
 
1143
	    }
-
 
1144
	    if ( es & FUNC_PARAMS ) prom++ ;
-
 
1145
	    if ( et & FUNC_PARAMS ) prom++ ;
-
 
1146
	    while ( !IS_NULL_list ( ps ) && !IS_NULL_list ( pt ) ) {
-
 
1147
		TYPE ar ;
-
 
1148
		TYPE as = DEREF_type ( HEAD_list ( ps ) ) ;
-
 
1149
		TYPE at = DEREF_type ( HEAD_list ( pt ) ) ;
-
 
1150
		if ( prom == 2 ) {
-
 
1151
		    /* Compare unpromoted types */
-
 
1152
		    as = unpromote_type ( as ) ;
-
 
1153
		    at = unpromote_type ( at ) ;
-
 
1154
		}
-
 
1155
		ar = type_composite ( as, at, 0, 1, err, mk ) ;
-
 
1156
		if ( IS_NULL_type ( ar ) ) {
-
 
1157
		    /* Check for specified compatible types */
-
 
1158
		    ar = eq_argument ( as, at, 1 ) ;
-
 
1159
		    if ( IS_NULL_type ( ar ) && prom == 1 ) {
-
 
1160
			if ( es & FUNC_PARAMS ) as = unpromote_type ( as ) ;
-
 
1161
			if ( et & FUNC_PARAMS ) at = unpromote_type ( at ) ;
-
 
1162
			ar = eq_argument ( as, at, 0 ) ;
-
 
1163
			if ( !IS_NULL_type ( ar ) ) {
-
 
1164
			    OPTION opt = option ( OPT_func_incompat ) ;
1250
				OPTION opt = option(OPT_ellipsis_extra);
1165
			    ERROR err2 = ERR_dcl_fct_compat_prom ( as ) ;
1251
				add_error(err, ERR_dcl_fct_compat_ellipsis());
1166
			    add_error ( err, err2 ) ;
-
 
1167
			    if ( opt == OPTION_DISALLOW ) ar = NULL_type ;
1252
				if (opt == OPTION_DISALLOW) {
1168
			}
-
 
1169
		    }
-
 
1170
		    if ( IS_NULL_type ( ar ) ) {
-
 
1171
			DESTROY_list ( pr, SIZE_type ) ;
-
 
1172
			return ( NULL_type ) ;
1253
					return (NULL_type);
1173
		    }
-
 
1174
		}
1254
				}
1175
		if ( mk ) {
-
 
1176
		    if ( force ) {
-
 
1177
			/* Preserve printf and scanf types */
-
 
1178
			if ( is_printf_type ( as ) ) {
-
 
1179
			    IDENTIFIER id = DEREF_id ( type_name ( as ) ) ;
-
 
1180
			    COPY_id ( type_name ( ar ), id ) ;
-
 
1181
			} else if ( is_printf_type ( at ) ) {
-
 
1182
			    IDENTIFIER id = DEREF_id ( type_name ( at ) ) ;
-
 
1183
			    COPY_id ( type_name ( ar ), id ) ;
-
 
1184
			}
1255
			}
1260
}
1446
}
1261
 
1447
 
1262
#endif
1448
#endif
1263
 
1449
 
1264
 
1450
 
Line 1277... Line 1463...
1277
    indicate that differing qualifiers are allowed.  In C++ the qualifiers
1463
    indicate that differing qualifiers are allowed.  In C++ the qualifiers
1278
    are allowed at any level; in C qual gives the maximum depth.  Type
1464
    are allowed at any level; in C qual gives the maximum depth.  Type
1279
    qualifiers at the top level are handled by adding an error to err.
1465
    qualifiers at the top level are handled by adding an error to err.
1280
*/
1466
*/
1281
 
1467
 
1282
TYPE type_composite
1468
TYPE
1283
    PROTO_N ( ( s, t, qual, depth, err, mk ) )
-
 
1284
    PROTO_T ( TYPE s X TYPE t X int qual X int depth X ERROR *err X int mk )
1469
type_composite(TYPE s, TYPE t, int qual, int depth, ERROR *err, int mk)
1285
{
1470
{
1286
    TYPE r = s ;
1471
	TYPE r = s;
1287
    int eq = 1 ;
1472
	int eq = 1;
1288
    int checked = 0 ;
1473
	int checked = 0;
1289
    unsigned ns, nt ;
1474
	unsigned ns, nt;
1290
    CV_SPEC qr, qs, qt ;
1475
	CV_SPEC qr, qs, qt;
1291
 
1476
 
1292
    /* Check for obvious equality */
1477
	/* Check for obvious equality */
1293
    if ( EQ_type ( s, t ) ) return ( s ) ;
1478
	if (EQ_type(s, t)) {
-
 
1479
		return (s);
-
 
1480
	}
1294
    if ( IS_NULL_type ( s ) ) return ( NULL_type ) ;
1481
	if (IS_NULL_type(s)) {
-
 
1482
		return (NULL_type);
-
 
1483
	}
1295
    if ( IS_NULL_type ( t ) ) return ( NULL_type ) ;
1484
	if (IS_NULL_type(t)) {
-
 
1485
		return (NULL_type);
-
 
1486
	}
1296
 
1487
 
1297
    /* Compare type qualifiers */
1488
	/* Compare type qualifiers */
1298
    ns = TAG_type ( s ) ;
1489
	ns = TAG_type(s);
1299
    nt = TAG_type ( t ) ;
1490
	nt = TAG_type(t);
1300
    qs = DEREF_cv ( type_qual ( s ) ) ;
1491
	qs = DEREF_cv(type_qual(s));
1301
    qt = DEREF_cv ( type_qual ( t ) ) ;
1492
	qt = DEREF_cv(type_qual(t));
1302
    qr = ( qs | qt ) ;
1493
	qr = (qs | qt);
1303
    if ( qs != qt && qual <= 0 ) {
1494
	if (qs != qt && qual <= 0) {
1304
	/* Qualifiers should be equal up to lvalues */
1495
		/* Qualifiers should be equal up to lvalues */
1305
	CV_SPEC rs = ( qs & cv_qual ) ;
1496
		CV_SPEC rs = (qs & cv_qual);
1306
	CV_SPEC rt = ( qt & cv_qual ) ;
1497
		CV_SPEC rt = (qt & cv_qual);
1307
	if ( rs != rt ) {
1498
		if (rs != rt) {
1308
	    OPTION opt ;
1499
			OPTION opt;
1309
	    if ( unify_types ( s, t, 0 ) ) {
1500
			if (unify_types(s, t, 0)) {
1310
		/* Can happen with token definitions */
1501
				/* Can happen with token definitions */
-
 
1502
				if (mk) {
1311
		if ( mk ) r = qualify_type ( r, qr, 0 ) ;
1503
					r = qualify_type(r, qr, 0);
-
 
1504
				}
1312
		return ( r ) ;
1505
				return (r);
1313
	    }
1506
			}
1314
	    opt = option ( OPT_type_qual_incompat ) ;
1507
			opt = option(OPT_type_qual_incompat);
1315
	    if ( opt == OPTION_DISALLOW ) goto return_lab ;
1508
			if (opt == OPTION_DISALLOW) {
-
 
1509
				goto return_lab;
-
 
1510
			}
1316
	    add_error ( err, ERR_basic_link_qual ( rs, rt ) ) ;
1511
			add_error(err, ERR_basic_link_qual(rs, rt));
-
 
1512
		}
1317
	}
1513
	}
1318
    }
-
 
1319
#if LANGUAGE_C
1514
#if LANGUAGE_C
1320
    qual-- ;
1515
	qual--;
1321
#endif
1516
#endif
1322
 
1517
 
1323
    /* Check on type components */
1518
	/* Check on type components */
1324
    if ( ns == nt ) {
1519
	if (ns == nt) {
1325
	switch ( ns ) {
1520
		switch (ns) {
-
 
1521
		case type_ptr_tag:
-
 
1522
		case type_ref_tag: {
-
 
1523
			/* Check pointer sub-types */
-
 
1524
			TYPE pr;
-
 
1525
			TYPE ps = DEREF_type(type_ptr_etc_sub(s));
-
 
1526
			TYPE pt = DEREF_type(type_ptr_etc_sub(t));
-
 
1527
			pr = type_composite(ps, pt, qual, depth + 1, err, mk);
-
 
1528
			if (IS_NULL_type(pr)) {
-
 
1529
				/* Check for generic pointer types */
-
 
1530
				OPTION opt = option(OPT_gen_ptr_char);
-
 
1531
				if (opt == OPTION_DISALLOW) {
-
 
1532
					return (NULL_type);
-
 
1533
				}
-
 
1534
				if (IS_type_top_etc(ps)) {
-
 
1535
					if (eq_type_unqual(pt, type_char)) {
-
 
1536
						CV_SPEC cv = DEREF_cv(type_qual(pt));
-
 
1537
						pt = qualify_type(ps, cv, 0);
-
 
1538
						add_error(err, ERR_conv_ptr_gen(t));
-
 
1539
					} else {
-
 
1540
						return (NULL_type);
-
 
1541
					}
-
 
1542
				} else if (IS_type_top_etc(pt)) {
-
 
1543
					if (eq_type_unqual(ps, type_char)) {
-
 
1544
						CV_SPEC cv = DEREF_cv(type_qual(ps));
-
 
1545
						ps = qualify_type(pt, cv, 0);
-
 
1546
						add_error(err, ERR_conv_ptr_gen(s));
-
 
1547
					} else {
-
 
1548
						return (NULL_type);
-
 
1549
					}
-
 
1550
				} else {
-
 
1551
					return (NULL_type);
-
 
1552
				}
-
 
1553
				pr = type_composite(ps, pt, qual, depth + 1, err, mk);
-
 
1554
				if (IS_NULL_type(pr)) {
-
 
1555
					return (NULL_type);
-
 
1556
				}
-
 
1557
			}
-
 
1558
			if (mk) {
-
 
1559
				if (EQ_type(pr, ps) && qr == qs) {
-
 
1560
					return (s);
-
 
1561
				}
-
 
1562
				if (EQ_type(pr, pt) && qr == qt) {
-
 
1563
					return (t);
-
 
1564
				}
-
 
1565
				MAKE_type_ptr_etc(ns, qr, pr, r);
-
 
1566
			}
-
 
1567
			return (r);
-
 
1568
		}
-
 
1569
 
-
 
1570
#if LANGUAGE_CPP
-
 
1571
		case type_ptr_mem_tag: {
-
 
1572
			/* Check pointer to member class types */
-
 
1573
			TYPE ps, pt, pr;
-
 
1574
			CLASS_TYPE cs = DEREF_ctype(type_ptr_mem_of(s));
-
 
1575
			CLASS_TYPE ct = DEREF_ctype(type_ptr_mem_of(t));
-
 
1576
			if (!eq_ctype(cs, ct)) {
-
 
1577
				return (NULL_type);
-
 
1578
			}
1326
 
1579
 
1327
	    case type_ptr_tag :
-
 
1328
	    case type_ref_tag : {
-
 
1329
		/* Check pointer sub-types */
1580
			/* Check pointer to member sub-types */
1330
		TYPE pr ;
-
 
1331
		TYPE ps = DEREF_type ( type_ptr_etc_sub ( s ) ) ;
1581
			ps = DEREF_type(type_ptr_mem_sub(s));
1332
		TYPE pt = DEREF_type ( type_ptr_etc_sub ( t ) ) ;
1582
			pt = DEREF_type(type_ptr_mem_sub(t));
1333
		pr = type_composite ( ps, pt, qual, depth + 1, err, mk ) ;
1583
			pr = type_composite(ps, pt, qual, depth + 1, err, mk);
1334
		if ( IS_NULL_type ( pr ) ) {
1584
			if (IS_NULL_type(pr)) {
1335
		    /* Check for generic pointer types */
-
 
1336
		    OPTION opt = option ( OPT_gen_ptr_char ) ;
-
 
1337
		    if ( opt == OPTION_DISALLOW ) return ( NULL_type ) ;
-
 
1338
		    if ( IS_type_top_etc ( ps ) ) {
-
 
1339
			if ( eq_type_unqual ( pt, type_char ) ) {
-
 
1340
			    CV_SPEC cv = DEREF_cv ( type_qual ( pt ) ) ;
-
 
1341
			    pt = qualify_type ( ps, cv, 0 ) ;
-
 
1342
			    add_error ( err, ERR_conv_ptr_gen ( t ) ) ;
-
 
1343
			} else {
-
 
1344
			    return ( NULL_type ) ;
1585
				return (NULL_type);
1345
			}
1586
			}
1346
		    } else if ( IS_type_top_etc ( pt ) ) {
1587
			if (mk) {
1347
			if ( eq_type_unqual ( ps, type_char ) ) {
1588
				if (EQ_type(pr, ps) && qr == qt) {
1348
			    CV_SPEC cv = DEREF_cv ( type_qual ( ps ) ) ;
1589
					return (s);
-
 
1590
				}
1349
			    ps = qualify_type ( pt, cv, 0 ) ;
1591
				if (EQ_type(pr, pt) && qr == qs) {
1350
			    add_error ( err, ERR_conv_ptr_gen ( s ) ) ;
1592
					return (t);
1351
			} else {
1593
				}
1352
			    return ( NULL_type ) ;
1594
				MAKE_type_ptr_mem(qr, cs, pr, r);
1353
			}
1595
			}
1354
		    } else {
-
 
1355
			return ( NULL_type ) ;
1596
			return (r);
1356
		    }
-
 
1357
		    pr = type_composite ( ps, pt, qual, depth + 1, err, mk ) ;
-
 
1358
		    if ( IS_NULL_type ( pr ) ) return ( NULL_type ) ;
-
 
1359
		}
1597
		}
1360
		if ( mk ) {
-
 
1361
		    if ( EQ_type ( pr, ps ) && qr == qs ) return ( s ) ;
-
 
1362
		    if ( EQ_type ( pr, pt ) && qr == qt ) return ( t ) ;
-
 
1363
		    MAKE_type_ptr_etc ( ns, qr, pr, r ) ;
-
 
1364
		}
-
 
1365
		return ( r ) ;
-
 
1366
	    }
1598
#endif
1367
 
-
 
1368
#if LANGUAGE_CPP
-
 
1369
	    case type_ptr_mem_tag : {
-
 
1370
		/* Check pointer to member class types */
-
 
1371
		TYPE ps, pt, pr ;
-
 
1372
		CLASS_TYPE cs = DEREF_ctype ( type_ptr_mem_of ( s ) ) ;
-
 
1373
		CLASS_TYPE ct = DEREF_ctype ( type_ptr_mem_of ( t ) ) ;
-
 
1374
		if ( !eq_ctype ( cs, ct ) ) return ( NULL_type ) ;
-
 
1375
 
1599
 
-
 
1600
		case type_array_tag: {
1376
		/* Check pointer to member sub-types */
1601
			/* Check array sub-types */
-
 
1602
			TYPE pr;
-
 
1603
			NAT ms, mt, mr;
1377
		ps = DEREF_type ( type_ptr_mem_sub ( s ) ) ;
1604
			TYPE ps = DEREF_type(type_array_sub(s));
1378
		pt = DEREF_type ( type_ptr_mem_sub ( t ) ) ;
1605
			TYPE pt = DEREF_type(type_array_sub(t));
1379
		pr = type_composite ( ps, pt, qual, depth + 1, err, mk ) ;
1606
			pr = type_composite(ps, pt, qual, depth + 1, err, mk);
1380
		if ( IS_NULL_type ( pr ) ) return ( NULL_type ) ;
1607
			if (IS_NULL_type(pr)) {
1381
		if ( mk ) {
-
 
1382
		    if ( EQ_type ( pr, ps ) && qr == qt ) return ( s ) ;
-
 
1383
		    if ( EQ_type ( pr, pt ) && qr == qs ) return ( t ) ;
-
 
1384
		    MAKE_type_ptr_mem ( qr, cs, pr, r ) ;
-
 
1385
		}
-
 
1386
		return ( r ) ;
1608
				return (NULL_type);
1387
	    }
1609
			}
1388
#endif
-
 
1389
 
1610
 
1390
	    case type_array_tag : {
-
 
1391
		/* Check array sub-types */
-
 
1392
		TYPE pr ;
-
 
1393
		NAT ms, mt, mr ;
-
 
1394
		TYPE ps = DEREF_type ( type_array_sub ( s ) ) ;
-
 
1395
		TYPE pt = DEREF_type ( type_array_sub ( t ) ) ;
-
 
1396
		pr = type_composite ( ps, pt, qual, depth + 1, err, mk ) ;
-
 
1397
		if ( IS_NULL_type ( pr ) ) return ( NULL_type ) ;
-
 
1398
 
-
 
1399
		/* Check array bounds */
1611
			/* Check array bounds */
1400
		ms = DEREF_nat ( type_array_size ( s ) ) ;
1612
			ms = DEREF_nat(type_array_size(s));
1401
		mt = DEREF_nat ( type_array_size ( t ) ) ;
1613
			mt = DEREF_nat(type_array_size(t));
1402
		if ( EQ_nat ( ms, mt ) || eq_nat ( ms, mt ) ) {
1614
			if (EQ_nat(ms, mt) || eq_nat(ms, mt)) {
1403
		    /* Equal bounds */
1615
				/* Equal bounds */
1404
		    if ( EQ_type ( pr, ps ) && qr == qs ) return ( s ) ;
1616
				if (EQ_type(pr, ps) && qr == qs) {
1405
		    if ( EQ_type ( pr, pt ) && qr == qt ) return ( t ) ;
-
 
1406
		    mr = ms ;
1617
					return (s);
-
 
1618
				}
1407
		} else if ( IS_NULL_nat ( ms ) ) {
1619
				if (EQ_type(pr, pt) && qr == qt) {
1408
		    /* s unbounded, t bounded */
-
 
1409
#if LANGUAGE_CPP
1620
					return (t);
1410
		    if ( depth ) return ( NULL_type ) ;
-
 
1411
#endif
1621
				}
1412
		    if ( EQ_type ( pr, pt ) && qr == qt ) return ( t ) ;
-
 
1413
		    mr = mt ;
1622
				mr = ms;
1414
		} else if ( IS_NULL_nat ( mt ) ) {
1623
			} else if (IS_NULL_nat(ms)) {
1415
		    /* s bounded, t unbounded */
1624
				/* s unbounded, t bounded */
1416
#if LANGUAGE_CPP
1625
#if LANGUAGE_CPP
-
 
1626
				if (depth) {
1417
		    if ( depth ) return ( NULL_type ) ;
1627
					return (NULL_type);
-
 
1628
				}
1418
#endif
1629
#endif
1419
		    if ( EQ_type ( pr, ps ) && qr == qs ) return ( s ) ;
1630
				if (EQ_type(pr, pt) && qr == qt) {
1420
		    mr = ms ;
1631
					return (t);
1421
		} else {
1632
				}
1422
		    /* Unequal bounds - check for error propagation */
-
 
1423
		    if ( is_error_nat ( ms ) ) {
-
 
1424
			mr = mt ;
1633
				mr = mt;
1425
		    } else if ( is_error_nat ( mt ) ) {
1634
			} else if (IS_NULL_nat(mt)) {
-
 
1635
				/* s bounded, t unbounded */
1426
			mr = ms ;
1636
#if LANGUAGE_CPP
1427
		    } else {
1637
				if (depth) {
1428
			return ( NULL_type ) ;
1638
					return (NULL_type);
1429
		    }
1639
				}
1430
		}
1640
#endif
1431
		if ( mk ) {
-
 
1432
		    MAKE_type_array ( qr, pr, mr, r ) ;
1641
				if (EQ_type(pr, ps) && qr == qs) {
1433
		}
-
 
1434
		return ( r ) ;
1642
					return (s);
1435
	    }
1643
				}
1436
 
-
 
1437
	    case type_func_tag : {
-
 
1438
		/* Check function types */
-
 
1439
		int ret = eq_func_type ( s, t, 1, 0 ) ;
-
 
1440
#if LANGUAGE_C
1644
				mr = ms;
1441
		if ( ret < 2 ) {
1645
			} else {
1442
		    r = func_composite ( s, t, ret, err, mk ) ;
1646
				/* Unequal bounds - check for error
1443
		    return ( r ) ;
1647
				 * propagation */
1444
		}
-
 
1445
#else
-
 
1446
		if ( ret < 2 ) {
1648
				if (is_error_nat(ms)) {
1447
		    eq = 0 ;
1649
					mr = mt;
1448
		} else if ( depth && ret == 2 ) {
1650
				} else if (is_error_nat(mt)) {
1449
		    /* Differ in language specifiers */
-
 
1450
		    eq = 0 ;
1651
					mr = ms;
1451
		}
1652
				} else {
1452
#endif
-
 
1453
		checked = 1 ;
1653
					return (NULL_type);
1454
		break ;
1654
				}
1455
	    }
1655
			}
1456
 
-
 
1457
#if LANGUAGE_C
1656
			if (mk) {
1458
	    case type_enumerate_tag : {
-
 
1459
		/* Check C enumeration types */
-
 
1460
		ENUM_TYPE es = DEREF_etype ( type_enumerate_defn ( s ) ) ;
-
 
1461
		ENUM_TYPE et = DEREF_etype ( type_enumerate_defn ( t ) ) ;
-
 
1462
		TYPE ps = DEREF_type ( etype_rep ( es ) ) ;
-
 
1463
		TYPE pt = DEREF_type ( etype_rep ( et ) ) ;
-
 
1464
		eq = eq_type_unqual ( ps, pt ) ;
1657
				MAKE_type_array(qr, pr, mr, r);
1465
		checked = 1 ;
-
 
1466
		break ;
-
 
1467
	    }
1658
			}
1468
#endif
1659
			return (r);
1469
	}
1660
		}
1470
 
-
 
1471
    } else {
-
 
1472
 
1661
 
1473
	switch ( ns ) {
-
 
1474
	    case type_top_tag : {
1662
		case type_func_tag: {
1475
		/* Allow for 'void' and 'bottom' */
1663
			/* Check function types */
1476
		if ( nt == type_bottom_tag ) {
1664
			int ret = eq_func_type(s, t, 1, 0);
1477
		    checked = 1 ;
-
 
1478
		    r = t ;
-
 
1479
		}
-
 
1480
		break ;
-
 
1481
	    }
-
 
1482
	    case type_bottom_tag : {
-
 
1483
		/* Allow for 'void' and 'bottom' */
-
 
1484
		if ( nt == type_top_tag ) {
-
 
1485
		    checked = 1 ;
-
 
1486
		}
-
 
1487
		break ;
-
 
1488
	    }
-
 
1489
#if LANGUAGE_C
1665
#if LANGUAGE_C
-
 
1666
			if (ret < 2) {
-
 
1667
				r = func_composite(s, t, ret, err, mk);
-
 
1668
				return (r);
-
 
1669
			}
-
 
1670
#else
-
 
1671
			if (ret < 2) {
-
 
1672
				eq = 0;
-
 
1673
			} else if (depth && ret == 2) {
-
 
1674
				/* Differ in language specifiers */
-
 
1675
				eq = 0;
-
 
1676
			}
-
 
1677
#endif
-
 
1678
			checked = 1;
-
 
1679
			break;
-
 
1680
		}
-
 
1681
 
-
 
1682
#if LANGUAGE_C
-
 
1683
		case type_enumerate_tag: {
-
 
1684
			/* Check C enumeration types */
-
 
1685
			ENUM_TYPE es = DEREF_etype(type_enumerate_defn(s));
-
 
1686
			ENUM_TYPE et = DEREF_etype(type_enumerate_defn(t));
-
 
1687
			TYPE ps = DEREF_type(etype_rep(es));
-
 
1688
			TYPE pt = DEREF_type(etype_rep(et));
-
 
1689
			eq = eq_type_unqual(ps, pt);
-
 
1690
			checked = 1;
-
 
1691
			break;
-
 
1692
		}
-
 
1693
#endif
-
 
1694
		}
-
 
1695
	} else {
-
 
1696
		switch (ns) {
-
 
1697
		case type_top_tag: {
-
 
1698
			/* Allow for 'void' and 'bottom' */
-
 
1699
			if (nt == type_bottom_tag) {
-
 
1700
				checked = 1;
-
 
1701
				r = t;
-
 
1702
			}
-
 
1703
			break;
-
 
1704
		}
-
 
1705
		case type_bottom_tag: {
-
 
1706
			/* Allow for 'void' and 'bottom' */
-
 
1707
			if (nt == type_top_tag) {
-
 
1708
				checked = 1;
-
 
1709
			}
-
 
1710
			break;
-
 
1711
		}
-
 
1712
#if LANGUAGE_C
1490
	    case type_integer_tag : {
1713
		case type_integer_tag: {
1491
		if ( nt == type_enumerate_tag ) {
1714
			if (nt == type_enumerate_tag) {
1492
		    /* Check C enumeration types */
1715
				/* Check C enumeration types */
1493
		    TYPE pt ;
1716
				TYPE pt;
1494
		    ENUM_TYPE et ;
1717
				ENUM_TYPE et;
1495
		    et = DEREF_etype ( type_enumerate_defn ( t ) ) ;
1718
				et = DEREF_etype(type_enumerate_defn(t));
1496
		    pt = DEREF_type ( etype_rep ( et ) ) ;
1719
				pt = DEREF_type(etype_rep(et));
1497
		    eq = eq_type_unqual ( s, pt ) ;
1720
				eq = eq_type_unqual(s, pt);
1498
		    checked = 1 ;
1721
				checked = 1;
1499
		    r = t ;
1722
				r = t;
-
 
1723
			}
-
 
1724
			break;
-
 
1725
		}
-
 
1726
		case type_enumerate_tag: {
-
 
1727
			if (nt == type_integer_tag) {
-
 
1728
				/* Check C enumeration types */
-
 
1729
				TYPE ps;
-
 
1730
				ENUM_TYPE es;
-
 
1731
				es = DEREF_etype(type_enumerate_defn(s));
-
 
1732
				ps = DEREF_type(etype_rep(es));
-
 
1733
				eq = eq_type_unqual(ps, t);
-
 
1734
				checked = 1;
-
 
1735
			}
-
 
1736
			break;
-
 
1737
		}
-
 
1738
#endif
1500
		}
1739
		}
1501
		break ;
-
 
1502
	    }
-
 
1503
	    case type_enumerate_tag : {
-
 
1504
		if ( nt == type_integer_tag ) {
-
 
1505
		    /* Check C enumeration types */
-
 
1506
		    TYPE ps ;
-
 
1507
		    ENUM_TYPE es ;
-
 
1508
		    es = DEREF_etype ( type_enumerate_defn ( s ) ) ;
-
 
1509
		    ps = DEREF_type ( etype_rep ( es ) ) ;
-
 
1510
		    eq = eq_type_unqual ( ps, t ) ;
-
 
1511
		    checked = 1 ;
-
 
1512
		}
-
 
1513
		break ;
-
 
1514
	    }
-
 
1515
#endif
-
 
1516
	}
1740
	}
1517
    }
-
 
1518
 
1741
 
1519
    /* In other cases compatibility is equality */
1742
	/* In other cases compatibility is equality */
1520
    if ( eq ) {
1743
	if (eq) {
1521
	if ( !checked ) eq = eq_type_unqual ( s, t ) ;
-
 
1522
	if ( eq == 1 ) {
-
 
1523
	    if ( mk ) {
-
 
1524
		if ( ns == nt ) {
1744
		if (!checked) {
1525
		    if ( qr == qs ) return ( s ) ;
-
 
1526
		    if ( qr == qt ) return ( t ) ;
1745
			eq = eq_type_unqual(s, t);
1527
		}
1746
		}
-
 
1747
		if (eq == 1) {
-
 
1748
			if (mk) {
-
 
1749
				if (ns == nt) {
-
 
1750
					if (qr == qs) {
-
 
1751
						return (s);
-
 
1752
					}
-
 
1753
					if (qr == qt) {
-
 
1754
						return (t);
-
 
1755
					}
-
 
1756
				}
1528
		r = qualify_type ( r, qr, 0 ) ;
1757
				r = qualify_type(r, qr, 0);
1529
	    }
1758
			}
1530
	    return ( r ) ;
1759
			return (r);
1531
	}
1760
		}
1532
    }
1761
	}
1533
    return_lab : {
1762
return_lab:
1534
	if ( ns == type_error_tag ) return ( t ) ;
1763
	if (ns == type_error_tag) {
-
 
1764
		return (t);
-
 
1765
	}
1535
	if ( nt == type_error_tag ) return ( s ) ;
1766
	if (nt == type_error_tag) {
1536
	return ( NULL_type ) ;
1767
		return (s);
1537
    }
1768
	}
-
 
1769
	return (NULL_type);
1538
}
1770
}
1539
 
1771
 
1540
 
1772
 
1541
/*
1773
/*
1542
    ARE TWO TYPES COMPATIBLE?
1774
    ARE TWO TYPES COMPATIBLE?
1543
 
1775
 
1544
    This routine checks whether the types s and t are compatible, returning
1776
    This routine checks whether the types s and t are compatible, returning
1545
    the composite type if they are (or either s or t if mk is false).  If
1777
    the composite type if they are (or either s or t if mk is false).  If
1546
    the types are not compatible s is returned and an error is added to the
1778
    the types are not compatible s is returned and an error is added to the
1547
    end of err.  qual is as in type_composite.
1779
    end of err.  qual is as in type_composite.
1548
*/
1780
*/
1549
 
1781
 
1550
TYPE check_compatible
1782
TYPE
1551
    PROTO_N ( ( s, t, qual, err, mk ) )
-
 
1552
    PROTO_T ( TYPE s X TYPE t X int qual X ERROR *err X int mk )
1783
check_compatible(TYPE s, TYPE t, int qual, ERROR *err, int mk)
1553
{
1784
{
1554
    TYPE r ;
1785
	TYPE r;
1555
    force_tokdef++ ;
1786
	force_tokdef++;
1556
    r = type_composite ( s, t, qual, 0, err, mk ) ;
1787
	r = type_composite(s, t, qual, 0, err, mk);
1557
    if ( IS_NULL_type ( r ) ) {
1788
	if (IS_NULL_type(r)) {
1558
	add_error ( err, ERR_basic_link_incompat ( s, t ) ) ;
1789
		add_error(err, ERR_basic_link_incompat(s, t));
1559
	r = s ;
1790
		r = s;
1560
    }
1791
	}
1561
    force_tokdef-- ;
1792
	force_tokdef--;
1562
    return ( r ) ;
1793
	return (r);
1563
}
1794
}
1564
 
1795
 
1565
 
1796
 
1566
/*
1797
/*
1567
    IS A TYPE AN OBJECT TYPE?
1798
    IS A TYPE AN OBJECT TYPE?
1568
 
1799
 
1569
    C++ types are partitioned into object types, reference types and
1800
    C++ types are partitioned into object types, reference types and
1570
    function types.  Object types are further partitioned into complete
1801
    function types.  Object types are further partitioned into complete
1571
    and incomplete types.  This routine checks whether the type t is
1802
    and incomplete types.  This routine checks whether the type t is
1572
    an object type.  It returns an error if it isn't.
1803
    an object type.  It returns an error if it isn't.
1573
*/
1804
*/
1574
 
1805
 
1575
ERROR check_object
1806
ERROR
1576
    PROTO_N ( ( t ) )
-
 
1577
    PROTO_T ( TYPE t )
1807
check_object(TYPE t)
1578
{
1808
{
1579
    ERROR err = NULL_err ;
1809
	ERROR err = NULL_err;
1580
    switch ( TAG_type ( t ) ) {
1810
	switch (TAG_type(t)) {
1581
	case type_func_tag : {
1811
	case type_func_tag: {
1582
	    /* Function types are not object types */
1812
		/* Function types are not object types */
1583
	    err = ERR_basic_types_obj_func ( t ) ;
1813
		err = ERR_basic_types_obj_func(t);
-
 
1814
		break;
-
 
1815
	}
-
 
1816
	case type_ref_tag: {
-
 
1817
		/* Reference types are not object types */
-
 
1818
		err = ERR_basic_types_obj_ref(t);
1584
	    break ;
1819
		break;
1585
	}
1820
	}
1586
	case type_ref_tag : {
1821
	case type_templ_tag: {
1587
	    /* Reference types are not object types */
1822
		/* Check template types */
1588
	    err = ERR_basic_types_obj_ref ( t ) ;
1823
		TYPE s = DEREF_type(type_templ_defn(t));
-
 
1824
		err = check_object(s);
1589
	    break ;
1825
		break;
1590
	}
1826
	}
1591
	case type_templ_tag : {
-
 
1592
	    /* Check template types */
-
 
1593
	    TYPE s = DEREF_type ( type_templ_defn ( t ) ) ;
-
 
1594
	    err = check_object ( s ) ;
-
 
1595
	    break ;
-
 
1596
	}
1827
	}
1597
    }
-
 
1598
    return ( err ) ;
1828
	return (err);
1599
}
1829
}
1600
 
1830
 
1601
 
1831
 
1602
/*
1832
/*
1603
    IS A TYPE AN ABSTRACT CLASS?
1833
    IS A TYPE AN ABSTRACT CLASS?
Line 1605... Line 1835...
1605
    This routine checks whether the type t is an abstract class type.
1835
    This routine checks whether the type t is an abstract class type.
1606
    It returns an error if it is.  It also checks for arrays of abstract
1836
    It returns an error if it is.  It also checks for arrays of abstract
1607
    types, although it shouldn't be possible to construct these.
1837
    types, although it shouldn't be possible to construct these.
1608
*/
1838
*/
1609
 
1839
 
1610
ERROR check_abstract
1840
ERROR
1611
    PROTO_N ( ( t ) )
-
 
1612
    PROTO_T ( TYPE t )
1841
check_abstract(TYPE t)
1613
{
1842
{
1614
    ERROR err = NULL_err ;
1843
	ERROR err = NULL_err;
1615
    switch ( TAG_type ( t ) ) {
1844
	switch (TAG_type(t)) {
1616
	case type_compound_tag : {
1845
	case type_compound_tag: {
1617
	    /* Check for abstract classes */
1846
		/* Check for abstract classes */
1618
	    CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
1847
		CLASS_TYPE ct = DEREF_ctype(type_compound_defn(t));
1619
	    CLASS_INFO ci = DEREF_cinfo ( ctype_info ( ct ) ) ;
1848
		CLASS_INFO ci = DEREF_cinfo(ctype_info(ct));
1620
	    if ( ci & cinfo_abstract ) {
1849
		if (ci & cinfo_abstract) {
1621
		err = class_info ( ct, cinfo_abstract, 1 ) ;
1850
			err = class_info(ct, cinfo_abstract, 1);
1622
	    }
1851
		}
-
 
1852
		break;
-
 
1853
	}
-
 
1854
	case type_array_tag: {
-
 
1855
		/* Check for abstract arrays */
-
 
1856
		TYPE s = DEREF_type(type_array_sub(t));
-
 
1857
		err = check_abstract(s);
1623
	    break ;
1858
		break;
1624
	}
1859
	}
1625
	case type_array_tag : {
1860
	case type_templ_tag: {
1626
	    /* Check for abstract arrays */
1861
		/* Check template types */
1627
	    TYPE s = DEREF_type ( type_array_sub ( t ) ) ;
1862
		TYPE s = DEREF_type(type_templ_defn(t));
1628
	    err = check_abstract ( s ) ;
1863
		err = check_abstract(s);
1629
	    break ;
1864
		break;
1630
	}
1865
	}
1631
	case type_templ_tag : {
-
 
1632
	    /* Check template types */
-
 
1633
	    TYPE s = DEREF_type ( type_templ_defn ( t ) ) ;
-
 
1634
	    err = check_abstract ( s ) ;
-
 
1635
	    break ;
-
 
1636
	}
1866
	}
1637
    }
-
 
1638
    return ( err ) ;
1867
	return (err);
1639
}
1868
}
1640
 
1869
 
1641
 
1870
 
1642
/*
1871
/*
1643
    IS A TYPE INCOMPLETE?
1872
    IS A TYPE INCOMPLETE?
1644
 
1873
 
1645
    This routine checks whether the type t is an incomplete object type.
1874
    This routine checks whether the type t is an incomplete object type.
1646
    It returns an error if it is.
1875
    It returns an error if it is.
1647
*/
1876
*/
1648
 
1877
 
1649
ERROR check_incomplete
1878
ERROR
1650
    PROTO_N ( ( t ) )
-
 
1651
    PROTO_T ( TYPE t )
1879
check_incomplete(TYPE t)
1652
{
1880
{
1653
    ERROR err = NULL_err ;
1881
	ERROR err = NULL_err;
1654
    switch ( TAG_type ( t ) ) {
1882
	switch (TAG_type(t)) {
1655
	case type_top_tag :
1883
	case type_top_tag:
1656
	case type_bottom_tag : {
1884
	case type_bottom_tag: {
1657
	    /* void and bottom are incomplete */
1885
		/* void and bottom are incomplete */
1658
	    err = ERR_basic_types_incompl ( t ) ;
1886
		err = ERR_basic_types_incompl(t);
1659
	    break ;
1887
		break;
1660
	}
1888
	}
1661
	case type_array_tag : {
1889
	case type_array_tag: {
1662
	    /* Check for incomplete arrays */
1890
		/* Check for incomplete arrays */
1663
	    NAT n = DEREF_nat ( type_array_size ( t ) ) ;
1891
		NAT n = DEREF_nat(type_array_size(t));
1664
	    if ( IS_NULL_nat ( n ) ) {
1892
		if (IS_NULL_nat(n)) {
1665
		err = ERR_basic_types_incompl ( t ) ;
1893
			err = ERR_basic_types_incompl(t);
1666
	    } else {
1894
		} else {
1667
		TYPE s = DEREF_type ( type_array_sub ( t ) ) ;
1895
			TYPE s = DEREF_type(type_array_sub(t));
1668
		err = check_incomplete ( s ) ;
1896
			err = check_incomplete(s);
1669
	    }
1897
		}
-
 
1898
		break;
-
 
1899
	}
-
 
1900
	case type_compound_tag: {
-
 
1901
		/* Check for incomplete classes */
-
 
1902
		CLASS_TYPE ct = DEREF_ctype(type_compound_defn(t));
-
 
1903
		CLASS_INFO ci = DEREF_cinfo(ctype_info(ct));
-
 
1904
		if (!(ci & cinfo_defined)) {
-
 
1905
			complete_class(ct, 1);
-
 
1906
			ci = DEREF_cinfo(ctype_info(ct));
-
 
1907
		}
-
 
1908
		if (!(ci & cinfo_complete)) {
-
 
1909
			err = ERR_basic_types_incompl(t);
-
 
1910
		}
1670
	    break ;
1911
		break;
1671
	}
1912
	}
1672
	case type_compound_tag : {
1913
	case type_enumerate_tag: {
1673
	    /* Check for incomplete classes */
1914
		/* Check for incomplete enumerations */
1674
	    CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
1915
		ENUM_TYPE et = DEREF_etype(type_enumerate_defn(t));
1675
	    CLASS_INFO ci = DEREF_cinfo ( ctype_info ( ct ) ) ;
1916
		CLASS_INFO ei = DEREF_cinfo(etype_info(et));
1676
	    if ( !( ci & cinfo_defined ) ) {
-
 
1677
		complete_class ( ct, 1 ) ;
-
 
1678
		ci = DEREF_cinfo ( ctype_info ( ct ) ) ;
-
 
1679
	    }
-
 
1680
	    if ( !( ci & cinfo_complete ) ) {
1917
		if (!(ei & cinfo_complete)) {
1681
		err = ERR_basic_types_incompl ( t ) ;
1918
			err = ERR_basic_types_incompl(t);
1682
	    }
1919
		}
1683
	    break ;
1920
		break;
1684
	}
1921
	}
1685
	case type_enumerate_tag : {
1922
	case type_templ_tag: {
1686
	    /* Check for incomplete enumerations */
1923
		/* Check template types */
1687
	    ENUM_TYPE et = DEREF_etype ( type_enumerate_defn ( t ) ) ;
1924
		TYPE s = DEREF_type(type_templ_defn(t));
1688
	    CLASS_INFO ei = DEREF_cinfo ( etype_info ( et ) ) ;
-
 
1689
	    if ( !( ei & cinfo_complete ) ) {
-
 
1690
		err = ERR_basic_types_incompl ( t ) ;
1925
		err = check_incomplete(s);
1691
	    }
-
 
1692
	    break ;
1926
		break;
1693
	}
1927
	}
1694
	case type_templ_tag : {
-
 
1695
	    /* Check template types */
-
 
1696
	    TYPE s = DEREF_type ( type_templ_defn ( t ) ) ;
-
 
1697
	    err = check_incomplete ( s ) ;
-
 
1698
	    break ;
-
 
1699
	}
1928
	}
1700
    }
-
 
1701
    return ( err ) ;
1929
	return (err);
1702
}
1930
}
1703
 
1931
 
1704
 
1932
 
1705
/*
1933
/*
1706
    IS A TYPE A COMPLETE OBJECT TYPE?
1934
    IS A TYPE A COMPLETE OBJECT TYPE?
1707
 
1935
 
1708
    This routine checks whether the type t is a complete object type.  It
1936
    This routine checks whether the type t is a complete object type.  It
1709
    returns an error if it isn't.
1937
    returns an error if it isn't.
1710
*/
1938
*/
1711
 
1939
 
1712
ERROR check_complete
1940
ERROR
1713
    PROTO_N ( ( t ) )
-
 
1714
    PROTO_T ( TYPE t )
1941
check_complete(TYPE t)
1715
{
1942
{
1716
    ERROR err = check_object ( t ) ;
1943
	ERROR err = check_object(t);
1717
    if ( IS_NULL_err ( err ) ) {
1944
	if (IS_NULL_err(err)) {
1718
	err = check_incomplete ( t ) ;
1945
		err = check_incomplete(t);
1719
	if ( !IS_NULL_err ( err ) ) {
1946
		if (!IS_NULL_err(err)) {
1720
	    err = concat_error ( err, ERR_basic_types_obj_incompl () ) ;
1947
			err = concat_error(err, ERR_basic_types_obj_incompl());
1721
	}
1948
		}
1722
    }
1949
	}
1723
    return ( err ) ;
1950
	return (err);
1724
}
1951
}
1725
 
1952
 
1726
 
1953
 
1727
/*
1954
/*
1728
    IS A TYPE A POINTER TO A COMPLETE OBJECT TYPE?
1955
    IS A TYPE A POINTER TO A COMPLETE OBJECT TYPE?
1729
 
1956
 
1730
    This routine checks whether the type t is a pointer to a complete
1957
    This routine checks whether the type t is a pointer to a complete
1731
    object type, adding an error to err.  It returns the type pointed to.
1958
    object type, adding an error to err.  It returns the type pointed to.
1732
*/
1959
*/
1733
 
1960
 
1734
TYPE check_pointer
1961
TYPE
1735
    PROTO_N ( ( t, err ) )
-
 
1736
    PROTO_T ( TYPE t X ERROR *err )
1962
check_pointer(TYPE t, ERROR *err)
1737
{
1963
{
1738
    TYPE s ;
1964
	TYPE s;
1739
    switch ( TAG_type ( t ) ) {
1965
	switch (TAG_type(t)) {
1740
	case type_ptr_tag : {
1966
	case type_ptr_tag: {
1741
	    /* Pointer type */
1967
		/* Pointer type */
1742
	    s = DEREF_type ( type_ptr_sub ( t ) ) ;
1968
		s = DEREF_type(type_ptr_sub(t));
1743
	    break ;
-
 
1744
	}
-
 
1745
	case type_array_tag : {
-
 
1746
	    /* Allow for array-to-pointer conversion */
-
 
1747
	    s = DEREF_type ( type_array_sub ( t ) ) ;
-
 
1748
	    break ;
1969
		break;
1749
	}
1970
	}
-
 
1971
	case type_array_tag: {
-
 
1972
		/* Allow for array-to-pointer conversion */
-
 
1973
		s = DEREF_type(type_array_sub(t));
-
 
1974
		break;
-
 
1975
	}
1750
	case type_func_tag : {
1976
	case type_func_tag: {
1751
	    /* Allow for function-to-pointer conversion */
1977
		/* Allow for function-to-pointer conversion */
1752
	    s = t ;
1978
		s = t;
1753
	    break ;
1979
		break;
-
 
1980
	}
-
 
1981
	case type_ref_tag: {
-
 
1982
		/* Reference type */
-
 
1983
		t = DEREF_type(type_ref_sub(t));
-
 
1984
		s = check_pointer(t, err);
-
 
1985
		return (s);
-
 
1986
	}
-
 
1987
	default:
-
 
1988
		/* Shouldn't happen */
-
 
1989
		return (t);
1754
	}
1990
	}
1755
	case type_ref_tag : {
-
 
1756
	    /* Reference type */
-
 
1757
	    t = DEREF_type ( type_ref_sub ( t ) ) ;
-
 
1758
	    s = check_pointer ( t, err ) ;
-
 
1759
	    return ( s ) ;
-
 
1760
	}
-
 
1761
	default : {
-
 
1762
	    /* Shouldn't happen */
-
 
1763
	    return ( t ) ;
-
 
1764
	}
-
 
1765
    }
-
 
1766
    if ( err != KILL_err ) {
1991
	if (err != KILL_err) {
1767
	switch ( TAG_type ( s ) ) {
1992
		switch (TAG_type(s)) {
1768
	    case type_top_tag :
1993
		case type_top_tag:
1769
	    case type_bottom_tag : {
1994
		case type_bottom_tag: {
1770
		add_error ( err, ERR_basic_types_obj_void ( t ) ) ;
1995
			add_error(err, ERR_basic_types_obj_void(t));
1771
		break ;
1996
			break;
1772
	    }
1997
		}
1773
	    default : {
1998
		default:
1774
		add_error ( err, check_complete ( s ) ) ;
1999
			add_error(err, check_complete(s));
1775
		break ;
2000
			break;
1776
	    }
2001
		}
1777
	}
2002
	}
1778
    }
-
 
1779
    return ( s ) ;
2003
	return (s);
1780
}
2004
}
1781
 
2005
 
1782
 
2006
 
1783
/*
2007
/*
1784
    IS A TYPE MODIFIABLE?
2008
    IS A TYPE MODIFIABLE?
Line 1787... Line 2011...
1787
    modifiable lvalue.  If it is then the null error is returned, otherwise
2011
    modifiable lvalue.  If it is then the null error is returned, otherwise
1788
    a sequence of errors giving the reasons why t is not modifiable is
2012
    a sequence of errors giving the reasons why t is not modifiable is
1789
    returned.
2013
    returned.
1790
*/
2014
*/
1791
 
2015
 
1792
ERROR check_modifiable
2016
ERROR
1793
    PROTO_N ( ( t, a ) )
-
 
1794
    PROTO_T ( TYPE t X EXP a )
2017
check_modifiable(TYPE t, EXP a)
1795
{
2018
{
1796
    ERROR err ;
2019
	ERROR err;
1797
    unsigned tag = TAG_type ( t ) ;
2020
	unsigned tag = TAG_type(t);
1798
    CV_SPEC qual = DEREF_cv ( type_qual ( t ) ) ;
2021
	CV_SPEC qual = DEREF_cv(type_qual(t));
1799
    if ( qual & cv_lvalue ) {
2022
	if (qual & cv_lvalue) {
1800
	while ( tag == type_templ_tag ) {
2023
		while (tag == type_templ_tag) {
1801
	    t = DEREF_type ( type_templ_defn ( t ) ) ;
2024
			t = DEREF_type(type_templ_defn(t));
1802
	    tag = TAG_type ( t ) ;
2025
			tag = TAG_type(t);
1803
	}
2026
		}
1804
	if ( tag == type_func_tag ) {
2027
		if (tag == type_func_tag) {
1805
	    /* Function types are not modifiable */
2028
			/* Function types are not modifiable */
1806
	    err = ERR_basic_lval_mod_func () ;
2029
			err = ERR_basic_lval_mod_func();
1807
	} else if ( tag == type_array_tag ) {
2030
		} else if (tag == type_array_tag) {
1808
	    /* Array types are not modifiable */
2031
			/* Array types are not modifiable */
1809
	    err = ERR_basic_lval_mod_array () ;
2032
			err = ERR_basic_lval_mod_array();
1810
	} else {
2033
		} else {
1811
	    err = check_complete ( t ) ;
2034
			err = check_complete(t);
1812
	    if ( !IS_NULL_err ( err ) ) {
2035
			if (!IS_NULL_err(err)) {
1813
		/* Incomplete types are not modifiable */
2036
				/* Incomplete types are not modifiable */
1814
		err = concat_error ( err, ERR_basic_lval_mod_incompl () ) ;
2037
				err = concat_error(err, ERR_basic_lval_mod_incompl());
1815
	    } else if ( qual & cv_const ) {
2038
			} else if (qual & cv_const) {
1816
		/* const objects are not modifiable */
2039
				/* const objects are not modifiable */
1817
		err = ERR_basic_lval_mod_const () ;
2040
				err = ERR_basic_lval_mod_const();
1818
	    } else if ( tag == type_compound_tag ) {
2041
			} else if (tag == type_compound_tag) {
1819
		CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
2042
				CLASS_TYPE ct = DEREF_ctype(type_compound_defn(t));
1820
		CLASS_INFO ci = DEREF_cinfo ( ctype_info ( ct ) ) ;
2043
				CLASS_INFO ci = DEREF_cinfo(ctype_info(ct));
1821
		if ( ci & cinfo_const ) {
2044
				if (ci & cinfo_const) {
1822
		    /* Objects with const members are not modifiable */
2045
					/* Objects with const members are not modifiable */
1823
		    err = ERR_basic_lval_mod_member ( t ) ;
2046
					err = ERR_basic_lval_mod_member(t);
1824
		}
2047
				}
1825
	    } else if ( tag == type_integer_tag ) {
2048
			} else if (tag == type_integer_tag) {
1826
		if ( option ( OPT_const_string ) && cv_string == cv_none ) {
2049
				if (option(OPT_const_string) && cv_string == cv_none) {
1827
		    EXP b = NULL_exp ;
2050
					EXP b = NULL_exp;
1828
		    DECL_SPEC ds = find_exp_linkage ( a, &b, 1 ) ;
2051
					DECL_SPEC ds = find_exp_linkage(a, &b, 1);
1829
		    if ( ds & dspec_pure ) {
2052
					if (ds & dspec_pure) {
1830
			/* String literals are not modifiable */
2053
						/* String literals are not modifiable */
1831
			err = ERR_conv_array_str_mod () ;
2054
						err = ERR_conv_array_str_mod();
1832
		    }
2055
					}
-
 
2056
				}
-
 
2057
			}
-
 
2058
		}
-
 
2059
	} else {
-
 
2060
		/* rvalues are not modifiable */
-
 
2061
		if (tag == type_error_tag) {
-
 
2062
			err = NULL_err;
-
 
2063
		} else {
-
 
2064
			err = ERR_basic_lval_not();
-
 
2065
			err = concat_error(err, ERR_basic_lval_mod_rvalue());
1833
		}
2066
		}
1834
	    }
-
 
1835
	}
-
 
1836
    } else {
-
 
1837
	/* rvalues are not modifiable */
-
 
1838
	if ( tag == type_error_tag ) {
-
 
1839
	    err = NULL_err ;
-
 
1840
	} else {
-
 
1841
	    err = ERR_basic_lval_not () ;
-
 
1842
	    err = concat_error ( err, ERR_basic_lval_mod_rvalue () ) ;
-
 
1843
	}
2067
	}
1844
    }
-
 
1845
    return ( err ) ;
2068
	return (err);
1846
}
2069
}
1847
 
2070
 
1848
 
2071
 
1849
/*
2072
/*
1850
    DOES A TYPE HAVE LINKAGE?
2073
    DOES A TYPE HAVE LINKAGE?
1851
 
2074
 
1852
    This routine returns true if the type t has external linkage and is
2075
    This routine returns true if the type t has external linkage and is
1853
    not an anonymous type.  Not all the cases are fully checked yet.
2076
    not an anonymous type.  Not all the cases are fully checked yet.
1854
*/
2077
*/
1855
 
2078
 
1856
int is_global_type
2079
int
1857
    PROTO_N ( ( t ) )
-
 
1858
    PROTO_T ( TYPE t )
2080
is_global_type(TYPE t)
1859
{
2081
{
1860
    if ( !IS_NULL_type ( t ) ) {
2082
	if (!IS_NULL_type(t)) {
1861
	ASSERT ( ORDER_type == 18 ) ;
2083
		ASSERT(ORDER_type == 18);
1862
	switch ( TAG_type ( t ) ) {
2084
		switch (TAG_type(t)) {
1863
	    case type_ptr_tag : {
2085
		case type_ptr_tag: {
1864
		TYPE s = DEREF_type ( type_ptr_sub ( t ) ) ;
2086
			TYPE s = DEREF_type(type_ptr_sub(t));
1865
		return ( is_global_type ( s ) ) ;
2087
			return (is_global_type(s));
1866
	    }
2088
		}
1867
	    case type_ref_tag : {
2089
		case type_ref_tag: {
1868
		TYPE s = DEREF_type ( type_ref_sub ( t ) ) ;
2090
			TYPE s = DEREF_type(type_ref_sub(t));
1869
		return ( is_global_type ( s ) ) ;
2091
			return (is_global_type(s));
1870
	    }
2092
		}
1871
#if LANGUAGE_CPP
2093
#if LANGUAGE_CPP
1872
	    case type_ptr_mem_tag : {
2094
		case type_ptr_mem_tag: {
1873
		TYPE s = DEREF_type ( type_ptr_mem_sub ( t ) ) ;
2095
			TYPE s = DEREF_type(type_ptr_mem_sub(t));
1874
		CLASS_TYPE ct = DEREF_ctype ( type_ptr_mem_of ( t ) ) ;
2096
			CLASS_TYPE ct = DEREF_ctype(type_ptr_mem_of(t));
1875
		IDENTIFIER id = DEREF_id ( ctype_name ( ct ) ) ;
2097
			IDENTIFIER id = DEREF_id(ctype_name(ct));
1876
		HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
2098
			HASHID nm = DEREF_hashid(id_name(id));
1877
		DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
2099
			DECL_SPEC ds = DEREF_dspec(id_storage(id));
1878
		if ( !( ds & dspec_extern ) ) return ( 0 ) ;
2100
			if (!(ds & dspec_extern)) {
-
 
2101
				return (0);
-
 
2102
			}
1879
		if ( IS_hashid_anon ( nm ) ) return ( 0 ) ;
2103
			if (IS_hashid_anon(nm)) {
-
 
2104
				return (0);
-
 
2105
			}
1880
		return ( is_global_type ( s ) ) ;
2106
			return (is_global_type(s));
1881
	    }
2107
		}
1882
#endif
2108
#endif
1883
	    case type_func_tag : {
2109
		case type_func_tag: {
1884
		TYPE r = DEREF_type ( type_func_ret ( t ) ) ;
2110
			TYPE r = DEREF_type(type_func_ret(t));
1885
		LIST ( TYPE ) p = DEREF_list ( type_func_ptypes ( t ) ) ;
2111
			LIST(TYPE)p = DEREF_list(type_func_ptypes(t));
1886
		if ( !is_global_type ( r ) ) return ( 0 ) ;
2112
			if (!is_global_type(r)) {
-
 
2113
				return (0);
-
 
2114
			}
1887
		while ( !IS_NULL_list ( p ) ) {
2115
			while (!IS_NULL_list(p)) {
1888
		    TYPE s = DEREF_type ( HEAD_list ( p ) ) ;
2116
				TYPE s = DEREF_type(HEAD_list(p));
1889
		    if ( !is_global_type ( s ) ) return ( 0 ) ;
2117
				if (!is_global_type(s)) {
-
 
2118
					return (0);
-
 
2119
				}
1890
		    p = TAIL_list ( p ) ;
2120
				p = TAIL_list(p);
-
 
2121
			}
-
 
2122
			break;
-
 
2123
		}
-
 
2124
		case type_array_tag: {
-
 
2125
			TYPE s = DEREF_type(type_array_sub(t));
-
 
2126
			return (is_global_type(s));
-
 
2127
		}
-
 
2128
		case type_compound_tag: {
-
 
2129
			CLASS_TYPE ct = DEREF_ctype(type_compound_defn(t));
-
 
2130
			IDENTIFIER id = DEREF_id(ctype_name(ct));
-
 
2131
			DECL_SPEC ds = DEREF_dspec(id_storage(id));
-
 
2132
			HASHID nm = DEREF_hashid(id_name(id));
-
 
2133
			if (!(ds & dspec_extern)) {
-
 
2134
				return (0);
-
 
2135
			}
-
 
2136
			if (IS_hashid_anon(nm)) {
-
 
2137
				return (0);
-
 
2138
			}
-
 
2139
			break;
-
 
2140
		}
-
 
2141
		case type_enumerate_tag: {
-
 
2142
			ENUM_TYPE et = DEREF_etype(type_enumerate_defn(t));
-
 
2143
			IDENTIFIER id = DEREF_id(etype_name(et));
-
 
2144
			DECL_SPEC ds = DEREF_dspec(id_storage(id));
-
 
2145
			HASHID nm = DEREF_hashid(id_name(id));
-
 
2146
			if (!(ds & dspec_extern)) {
-
 
2147
				return (0);
-
 
2148
			}
-
 
2149
			if (IS_hashid_anon(nm)) {
-
 
2150
				return (0);
-
 
2151
			}
-
 
2152
			break;
-
 
2153
		}
-
 
2154
		case type_templ_tag: {
-
 
2155
			TYPE s = DEREF_type(type_templ_defn(t));
-
 
2156
			return (is_global_type(s));
-
 
2157
		}
1891
		}
2158
		}
1892
		break ;
-
 
1893
	    }
-
 
1894
	    case type_array_tag : {
-
 
1895
		TYPE s = DEREF_type ( type_array_sub ( t ) ) ;
-
 
1896
		return ( is_global_type ( s ) ) ;
-
 
1897
	    }
-
 
1898
	    case type_compound_tag : {
-
 
1899
		CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
-
 
1900
		IDENTIFIER id = DEREF_id ( ctype_name ( ct ) ) ;
-
 
1901
		DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
-
 
1902
		HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
-
 
1903
		if ( !( ds & dspec_extern ) ) return ( 0 ) ;
-
 
1904
		if ( IS_hashid_anon ( nm ) ) return ( 0 ) ;
-
 
1905
		break ;
-
 
1906
	    }
-
 
1907
	    case type_enumerate_tag : {
-
 
1908
		ENUM_TYPE et = DEREF_etype ( type_enumerate_defn ( t ) ) ;
-
 
1909
		IDENTIFIER id = DEREF_id ( etype_name ( et ) ) ;
-
 
1910
		DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
-
 
1911
		HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
-
 
1912
		if ( !( ds & dspec_extern ) ) return ( 0 ) ;
-
 
1913
		if ( IS_hashid_anon ( nm ) ) return ( 0 ) ;
-
 
1914
		break ;
-
 
1915
	    }
-
 
1916
	    case type_templ_tag : {
-
 
1917
		TYPE s = DEREF_type ( type_templ_defn ( t ) ) ;
-
 
1918
		return ( is_global_type ( s ) ) ;
-
 
1919
	    }
-
 
1920
	}
2159
	}
1921
    }
-
 
1922
    return ( 1 ) ;
2160
	return (1);
1923
}
2161
}