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

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 – /branches/tendra5/src/producers/common/construct/copy.c – Rev 5 and 6

Subversion Repositories tendra.SVN

Rev

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

Rev 5 Rev 6
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 86... Line 116...
86
    cast.  Otherwise the null expression is returned.  The copying
116
    cast.  Otherwise the null expression is returned.  The copying
87
    routines work perfectly well for such implicit casts however
117
    routines work perfectly well for such implicit casts however
88
    spotting them early can help to give a context to any error message.
118
    spotting them early can help to give a context to any error message.
89
*/
119
*/
90
 
120
 
91
EXP implicit_cast_exp
121
EXP
92
    PROTO_N ( ( e ) )
-
 
93
    PROTO_T ( EXP e )
122
implicit_cast_exp(EXP e)
94
{
123
{
95
    if ( !IS_NULL_exp ( e ) ) {
124
	if (!IS_NULL_exp(e)) {
96
	unsigned tag = TAG_exp ( e ) ;
125
		unsigned tag = TAG_exp(e);
97
	if ( tag == exp_op_tag ) {
126
		if (tag == exp_op_tag) {
98
	    /* Check for implicit conversions */
127
			/* Check for implicit conversions */
99
	    int op = DEREF_int ( exp_op_lex ( e ) ) ;
128
			int op = DEREF_int(exp_op_lex(e));
100
	    if ( op == lex_implicit ) {
129
			if (op == lex_implicit) {
101
		EXP a = DEREF_exp ( exp_op_arg1 ( e ) ) ;
130
				EXP a = DEREF_exp(exp_op_arg1(e));
102
		return ( a ) ;
131
				return (a);
103
	    }
132
			}
104
	}
133
		}
105
	if ( tag == exp_aggregate_tag || tag == exp_nof_tag ) {
134
		if (tag == exp_aggregate_tag || tag == exp_nof_tag) {
106
	    /* Check for aggregate initialisers */
135
			/* Check for aggregate initialisers */
107
	    return ( e ) ;
136
			return (e);
108
	}
137
		}
109
    }
138
	}
110
    return ( NULL_exp ) ;
139
	return (NULL_exp);
111
}
140
}
112
 
141
 
113
 
142
 
114
/*
143
/*
115
    COPY A VARIABLE DEFINITION
144
    COPY A VARIABLE DEFINITION
116
 
145
 
117
    This routine defines the variable or static data member id to be e.
146
    This routine defines the variable or static data member id to be e.
118
*/
147
*/
119
 
148
 
120
static void copy_variable
149
static void
121
    PROTO_N ( ( id, e ) )
-
 
122
    PROTO_T ( IDENTIFIER id X EXP e )
150
copy_variable(IDENTIFIER id, EXP e)
123
{
151
{
124
    EXP d ;
152
	EXP d;
125
    TYPE t1 = DEREF_type ( id_variable_etc_type ( id ) ) ;
153
	TYPE t1 = DEREF_type(id_variable_etc_type(id));
126
    TYPE t2 = expand_type ( t1, 1 ) ;
154
	TYPE t2 = expand_type(t1, 1);
127
    if ( IS_NULL_exp ( e ) ) {
155
	if (IS_NULL_exp(e)) {
128
	/* Empty initialiser */
156
		/* Empty initialiser */
129
	DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
157
		DECL_SPEC ds = DEREF_dspec(id_storage(id));
130
	if ( ( ds & dspec_temp ) && ( ds & dspec_explicit ) ) {
158
		if ((ds & dspec_temp) && (ds & dspec_explicit)) {
131
	    /* Explicitly initialised temporary */
159
			/* Explicitly initialised temporary */
132
	    /* EMPTY */
160
			/* EMPTY */
-
 
161
		} else {
-
 
162
			e = init_general(t2, e, id, LANGUAGE_C);
-
 
163
		}
133
	} else {
164
	} else {
-
 
165
		EXP a = implicit_cast_exp(e);
-
 
166
		if (!IS_NULL_exp(a)) {
-
 
167
			/* Implicit cast initialiser */
-
 
168
			a = copy_exp(a, t1, t2);
134
	    e = init_general ( t2, e, id, LANGUAGE_C ) ;
169
			e = init_general(t2, a, id, 0);
-
 
170
		} else {
-
 
171
			/* Simple initialiser */
-
 
172
			e = copy_exp(e, t1, t2);
-
 
173
			e = dynamic_init(id, NULL_string, e);
-
 
174
		}
-
 
175
		e = check_init(e);
135
	}
176
	}
136
    } else {
-
 
137
	EXP a = implicit_cast_exp ( e ) ;
-
 
138
	if ( !IS_NULL_exp ( a ) ) {
-
 
139
	    /* Implicit cast initialiser */
-
 
140
	    a = copy_exp ( a, t1, t2 ) ;
-
 
141
	    e = init_general ( t2, a, id, 0 ) ;
-
 
142
	} else {
-
 
143
	    /* Simple initialiser */
-
 
144
	    e = copy_exp ( e, t1, t2 ) ;
-
 
145
	    e = dynamic_init ( id, NULL_string, e ) ;
-
 
146
	}
-
 
147
	e = check_init ( e ) ;
-
 
148
    }
-
 
149
    d = destroy_general ( t2, id ) ;
177
	d = destroy_general(t2, id);
150
    COPY_exp ( id_variable_etc_term ( id ), d ) ;
178
	COPY_exp(id_variable_etc_term(id), d);
151
    COPY_exp ( id_variable_etc_init ( id ), e ) ;
179
	COPY_exp(id_variable_etc_init(id), e);
152
    return ;
180
	return;
153
}
181
}
154
 
182
 
155
 
183
 
156
/*
184
/*
157
    COPY A LOCAL VARIABLE
185
    COPY A LOCAL VARIABLE
158
 
186
 
159
    This routine copies the local variable id.
187
    This routine copies the local variable id.
160
*/
188
*/
161
 
189
 
162
static IDENTIFIER copy_local
190
static
163
    PROTO_N ( ( id ) )
-
 
164
    PROTO_T ( IDENTIFIER id )
191
IDENTIFIER copy_local(IDENTIFIER id)
165
{
192
{
166
    IDENTIFIER cid = copy_id ( id, 2 ) ;
193
	IDENTIFIER cid = copy_id(id, 2);
167
    COPY_id ( id_alias ( id ), cid ) ;
194
	COPY_id(id_alias(id), cid);
168
    DEREF_loc ( id_loc ( id ), crt_loc ) ;
195
	DEREF_loc(id_loc(id), crt_loc);
169
    decl_loc = crt_loc ;
196
	decl_loc = crt_loc;
170
    if ( IS_id_variable ( cid ) ) {
197
	if (IS_id_variable(cid)) {
171
	EXP e = DEREF_exp ( id_variable_init ( cid ) ) ;
198
		EXP e = DEREF_exp(id_variable_init(cid));
172
	copy_variable ( cid, e ) ;
199
		copy_variable(cid, e);
173
    }
200
	}
174
    return ( cid ) ;
201
	return (cid);
175
}
202
}
176
 
203
 
177
 
204
 
178
/*
205
/*
179
    COPY A TYPE OFFSET
206
    COPY A TYPE OFFSET
180
 
207
 
181
    This routine copies the offset for the type t.  The result must be a
208
    This routine copies the offset for the type t.  The result must be a
182
    complete object type.
209
    complete object type.
183
*/
210
*/
184
 
211
 
185
static TYPE copy_type_offset
212
static TYPE
186
    PROTO_N ( ( t, op ) )
-
 
187
    PROTO_T ( TYPE t X int op )
213
copy_type_offset(TYPE t, int op)
188
{
214
{
189
    TYPE s = expand_type ( t, 1 ) ;
215
	TYPE s = expand_type(t, 1);
190
    if ( !EQ_type ( s, t ) ) {
216
	if (!EQ_type(s, t)) {
191
	ERROR err = check_complete ( s ) ;
217
		ERROR err = check_complete(s);
192
	if ( !IS_NULL_err ( err ) ) {
218
		if (!IS_NULL_err(err)) {
193
	    err = concat_error ( err, ERR_expr_add_incompl ( op ) ) ;
219
			err = concat_error(err, ERR_expr_add_incompl(op));
194
	    report ( crt_loc, err ) ;
220
			report(crt_loc, err);
195
	}
221
		}
196
    }
222
	}
197
    return ( s ) ;
223
	return (s);
198
}
224
}
329
/*
356
/*
330
    COPY A LIST OF OFFSETS
357
    COPY A LIST OF OFFSETS
331
 
358
 
332
    This routine copies the list of offsets p.
359
    This routine copies the list of offsets p.
333
*/
360
*/
334
 
361
 
335
static LIST ( OFFSET ) copy_off_list
362
static LIST(OFFSET)
336
    PROTO_N ( ( p ) )
-
 
337
    PROTO_T ( LIST ( OFFSET ) p )
363
copy_off_list(LIST(OFFSET) p)
338
{
364
{
339
    LIST ( OFFSET ) q = NULL_list ( OFFSET ) ;
365
	LIST(OFFSET)q = NULL_list(OFFSET);
340
    while ( !IS_NULL_list ( p ) ) {
366
	while (!IS_NULL_list(p)) {
341
	OFFSET off = DEREF_off ( HEAD_list ( p ) ) ;
367
		OFFSET off = DEREF_off(HEAD_list(p));
342
	off = copy_offset ( off, lex_plus ) ;
368
		off = copy_offset(off, lex_plus);
343
	CONS_off ( off, q, q ) ;
369
		CONS_off(off, q, q);
344
	p = TAIL_list ( p ) ;
370
		p = TAIL_list(p);
345
    }
371
	}
346
    return ( REVERSE_list ( q ) ) ;
372
	return (REVERSE_list(q));
347
}
373
}
348
 
374
 
349
 
375
 
350
/*
376
/*
351
    COPY A LIST OF EXPRESSIONS
377
    COPY A LIST OF EXPRESSIONS
352
 
378
 
353
    This routine copies the list of expressions p.
379
    This routine copies the list of expressions p.
354
*/
380
*/
355
 
381
 
356
LIST ( EXP ) copy_exp_list
382
LIST(EXP)
357
    PROTO_N ( ( p, t1, t2 ) )
-
 
358
    PROTO_T ( LIST ( EXP ) p X TYPE t1 X TYPE t2 )
383
copy_exp_list(LIST(EXP) p, TYPE t1, TYPE t2)
359
{
384
{
360
    LIST ( EXP ) q = NULL_list ( EXP ) ;
385
	LIST(EXP)q = NULL_list(EXP);
361
    while ( !IS_NULL_list ( p ) ) {
386
	while (!IS_NULL_list(p)) {
362
	EXP e = DEREF_exp ( HEAD_list ( p ) ) ;
387
		EXP e = DEREF_exp(HEAD_list(p));
363
	e = copy_exp ( e, t1, t2 ) ;
388
		e = copy_exp(e, t1, t2);
364
	CONS_exp ( e, q, q ) ;
389
		CONS_exp(e, q, q);
365
	p = TAIL_list ( p ) ;
390
		p = TAIL_list(p);
366
    }
391
	}
367
    return ( REVERSE_list ( q ) ) ;
392
	return (REVERSE_list(q));
368
}
393
}
369
 
394
 
370
 
395
 
371
/*
396
/*
372
    COPY A FUNCTION EXPRESSION
397
    COPY A FUNCTION EXPRESSION
373
 
398
 
374
    This routine copies the function expression e.  Any name look-ups
399
    This routine copies the function expression e.  Any name look-ups
375
    are postponed until make_func_exp.
400
    are postponed until make_func_exp.
376
*/
401
*/
377
 
402
 
378
EXP copy_func_exp
403
EXP
379
    PROTO_N ( ( e, t1, t2 ) )
-
 
380
    PROTO_T ( EXP e X TYPE t1 X TYPE t2 )
404
copy_func_exp(EXP e, TYPE t1, TYPE t2)
381
{
405
{
382
    if ( !IS_NULL_exp ( e ) ) {
406
	if (!IS_NULL_exp(e)) {
383
	unsigned tag = TAG_exp ( e ) ;
407
		unsigned tag = TAG_exp(e);
384
	TYPE t = DEREF_type ( exp_type ( e ) ) ;
408
		TYPE t = DEREF_type(exp_type(e));
385
	if ( !EQ_type ( t, t1 ) ) {
409
		if (!EQ_type(t, t1)) {
386
	    /* Expand type if necessary */
410
			/* Expand type if necessary */
387
	    t1 = t ;
411
			t1 = t;
388
	    t2 = expand_type ( t, 1 ) ;
412
			t2 = expand_type(t, 1);
389
	}
413
		}
390
	switch ( tag ) {
414
		switch (tag) {
391
	    case exp_identifier_tag :
415
		case exp_identifier_tag:
392
	    case exp_member_tag :
416
		case exp_member_tag:
393
	    case exp_ambiguous_tag : {
417
		case exp_ambiguous_tag: {
394
		/* Identifier expressions */
418
			/* Identifier expressions */
395
		IDENTIFIER id ;
419
			IDENTIFIER id;
396
		QUALIFIER qual ;
420
			QUALIFIER qual;
397
		id = DEREF_id ( exp_identifier_etc_id ( e ) ) ;
421
			id = DEREF_id(exp_identifier_etc_id(e));
398
		qual = DEREF_qual ( exp_identifier_etc_qual ( e ) ) ;
422
			qual = DEREF_qual(exp_identifier_etc_qual(e));
399
		MAKE_exp_identifier_etc ( tag, t2, id, qual, e ) ;
423
			MAKE_exp_identifier_etc(tag, t2, id, qual, e);
400
		break ;
424
			break;
401
	    }
425
		}
402
	    case exp_undeclared_tag : {
426
		case exp_undeclared_tag: {
403
		/* Undeclared identifiers */
427
			/* Undeclared identifiers */
404
		IDENTIFIER id ;
428
			IDENTIFIER id;
405
		QUALIFIER qual ;
429
			QUALIFIER qual;
406
		id = DEREF_id ( exp_undeclared_id ( e ) ) ;
430
			id = DEREF_id(exp_undeclared_id(e));
407
		qual = DEREF_qual ( exp_undeclared_qual ( e ) ) ;
431
			qual = DEREF_qual(exp_undeclared_qual(e));
408
		MAKE_exp_identifier ( type_func_void, id, qual, e ) ;
432
			MAKE_exp_identifier(type_func_void, id, qual, e);
409
		break ;
433
			break;
410
	    }
434
		}
411
	    case exp_paren_tag : {
435
		case exp_paren_tag: {
412
		/* Parenthesised expressions */
436
			/* Parenthesised expressions */
413
		EXP a = DEREF_exp ( exp_paren_arg ( e ) ) ;
437
			EXP a = DEREF_exp(exp_paren_arg(e));
414
		a = copy_func_exp ( a, t1, t2 ) ;
438
			a = copy_func_exp(a, t1, t2);
415
		if ( !IS_NULL_exp ( a ) ) {
439
			if (!IS_NULL_exp(a)) {
416
		    t2 = DEREF_type ( exp_type ( a ) ) ;
440
				t2 = DEREF_type(exp_type(a));
-
 
441
			}
-
 
442
			MAKE_exp_paren(t2, a, e);
-
 
443
			break;
-
 
444
		}
-
 
445
		case exp_address_tag: {
-
 
446
			/* Address expressions */
-
 
447
			EXP a = DEREF_exp(exp_address_arg(e));
-
 
448
			a = copy_func_exp(a, t1, t2);
-
 
449
			MAKE_exp_address(t2, a, e);
-
 
450
			break;
-
 
451
		}
-
 
452
		case exp_address_mem_tag: {
-
 
453
			/* Member address expressions */
-
 
454
			EXP a = DEREF_exp(exp_address_mem_arg(e));
-
 
455
			int paren = DEREF_int(exp_address_mem_paren(e));
-
 
456
			a = copy_func_exp(a, t1, t2);
-
 
457
			MAKE_exp_address_mem(t2, a, paren, e);
-
 
458
			break;
-
 
459
		}
-
 
460
		case exp_op_tag: {
-
 
461
			/* Check for undetermined address expressions */
-
 
462
			int op = DEREF_int(exp_op_lex(e));
-
 
463
			EXP a = DEREF_exp(exp_op_arg1(e));
-
 
464
			EXP b = DEREF_exp(exp_op_arg2(e));
-
 
465
			if (op == lex_and_H1 && IS_NULL_exp(b)) {
-
 
466
				a = copy_func_exp(a, t1, t2);
-
 
467
				e = make_ref_exp(a, 0);
-
 
468
				break;
-
 
469
			}
-
 
470
			e = copy_exp(e, t1, t2);
-
 
471
			break;
-
 
472
		}
-
 
473
		default : {
-
 
474
			/* Other expressions */
-
 
475
			e = copy_exp(e, t1, t2);
-
 
476
			break;
417
		}
477
		}
418
		MAKE_exp_paren ( t2, a, e ) ;
-
 
419
		break ;
-
 
420
	    }
-
 
421
	    case exp_address_tag : {
-
 
422
		/* Address expressions */
-
 
423
		EXP a = DEREF_exp ( exp_address_arg ( e ) ) ;
-
 
424
		a = copy_func_exp ( a, t1, t2 ) ;
-
 
425
		MAKE_exp_address ( t2, a, e ) ;
-
 
426
		break ;
-
 
427
	    }
-
 
428
	    case exp_address_mem_tag : {
-
 
429
		/* Member address expressions */
-
 
430
		EXP a = DEREF_exp ( exp_address_mem_arg ( e ) ) ;
-
 
431
		int paren = DEREF_int ( exp_address_mem_paren ( e ) ) ;
-
 
432
		a = copy_func_exp ( a, t1, t2 ) ;
-
 
433
		MAKE_exp_address_mem ( t2, a, paren, e ) ;
-
 
434
		break ;
-
 
435
	    }
-
 
436
	    case exp_op_tag : {
-
 
437
		/* Check for undetermined address expressions */
-
 
438
		int op = DEREF_int ( exp_op_lex ( e ) ) ;
-
 
439
		EXP a = DEREF_exp ( exp_op_arg1 ( e ) ) ;
-
 
440
		EXP b = DEREF_exp ( exp_op_arg2 ( e ) ) ;
-
 
441
		if ( op == lex_and_H1 && IS_NULL_exp ( b ) ) {
-
 
442
		    a = copy_func_exp ( a, t1, t2 ) ;
-
 
443
		    e = make_ref_exp ( a, 0 ) ;
-
 
444
		    break ;
-
 
445
		}
478
		}
446
		e = copy_exp ( e, t1, t2 ) ;
-
 
447
		break ;
-
 
448
	    }
-
 
449
	    default : {
-
 
450
		/* Other expressions */
-
 
451
		e = copy_exp ( e, t1, t2 ) ;
-
 
452
		break ;
-
 
453
	    }
-
 
454
	}
479
	}
455
    }
-
 
456
    return ( e ) ;
480
	return (e);
457
}
481
}
458
 
482
 
459
 
483
 
460
/*
484
/*
461
    COPY A LIST OF FUNCTION ARGUMENTS
485
    COPY A LIST OF FUNCTION ARGUMENTS
462
 
486
 
463
    This routine copies the list of function arguments p.  id gives the
487
    This routine copies the list of function arguments p.  id gives the
464
    function name (for error reporting purposes).
488
    function name (for error reporting purposes).
465
*/
489
*/
466
 
490
 
467
static LIST ( EXP ) copy_func_args
491
static LIST(EXP)
468
    PROTO_N ( ( p, id ) )
-
 
469
    PROTO_T ( LIST ( EXP ) p X IDENTIFIER id )
492
copy_func_args(LIST(EXP)p, IDENTIFIER id)
470
{
493
{
471
    unsigned n = 1 ;
494
	unsigned n = 1;
472
    LIST ( EXP ) q = NULL_list ( EXP ) ;
495
	LIST(EXP)q = NULL_list(EXP);
473
    while ( !IS_NULL_list ( p ) ) {
496
	while (!IS_NULL_list(p)) {
474
	EXP e = DEREF_exp ( HEAD_list ( p ) ) ;
497
		EXP e = DEREF_exp(HEAD_list(p));
475
	EXP a = implicit_cast_exp ( e ) ;
498
		EXP a = implicit_cast_exp(e);
476
	if ( !IS_NULL_exp ( a ) ) {
499
		if (!IS_NULL_exp(a)) {
477
	    /* Do implicit argument conversion */
500
			/* Do implicit argument conversion */
478
	    TYPE t ;
501
			TYPE t;
479
	    ERROR err = NULL_err ;
502
			ERROR err = NULL_err;
480
	    a = copy_exp ( a, NULL_type, NULL_type ) ;
503
			a = copy_exp(a, NULL_type, NULL_type);
481
	    t = DEREF_type ( exp_type ( a ) ) ;
504
			t = DEREF_type(exp_type(a));
482
	    e = init_assign ( t, cv_none, a, &err ) ;
505
			e = init_assign(t, cv_none, a, &err);
483
	    if ( !IS_NULL_err ( err ) ) {
506
			if (!IS_NULL_err(err)) {
484
		err = init_error ( err, 0 ) ;
507
				err = init_error(err, 0);
485
		err = concat_error ( err, ERR_expr_call_arg ( n ) ) ;
508
				err = concat_error(err, ERR_expr_call_arg(n));
486
		if ( !IS_NULL_id ( id ) ) {
509
				if (!IS_NULL_id(id)) {
487
		    err = concat_error ( ERR_expr_call_func ( id ), err ) ;
510
					err = concat_error(ERR_expr_call_func(id), err);
-
 
511
				}
-
 
512
				report(crt_loc, err);
-
 
513
			}
-
 
514
		} else {
-
 
515
			/* Simple argument copy */
-
 
516
			e = copy_exp(e, NULL_type, NULL_type);
488
		}
517
		}
489
		report ( crt_loc, err ) ;
518
		CONS_exp(e, q, q);
490
	    }
519
		n++;
491
	} else {
520
		p = TAIL_list(p);
492
	    /* Simple argument copy */
-
 
493
	    e = copy_exp ( e, NULL_type, NULL_type ) ;
-
 
494
	}
521
	}
495
	CONS_exp ( e, q, q ) ;
-
 
496
	n++ ;
-
 
497
	p = TAIL_list ( p ) ;
-
 
498
    }
-
 
499
    return ( REVERSE_list ( q ) ) ;
522
	return (REVERSE_list(q));
500
}
523
}
501
 
524
 
502
 
525
 
503
/*
526
/*
504
    COPY A LABEL
527
    COPY A LABEL
505
 
528
 
506
    This routine finds the copy of the label lab in the current label
529
    This routine finds the copy of the label lab in the current label
507
    namespace, copying it if necessary.  If def is true then the labelled
530
    namespace, copying it if necessary.  If def is true then the labelled
508
    statement is also copied.
531
    statement is also copied.
509
*/
532
*/
510
 
533
 
511
static IDENTIFIER copy_label
534
static IDENTIFIER
512
    PROTO_N ( ( lab, def ) )
-
 
513
    PROTO_T ( IDENTIFIER lab X int def )
535
copy_label(IDENTIFIER lab, int def)
514
{
536
{
515
    IDENTIFIER nlab = lab ;
537
	IDENTIFIER nlab = lab;
516
    if ( !IS_NULL_id ( nlab ) ) {
538
	if (!IS_NULL_id(nlab)) {
517
	NAMESPACE ns = label_namespace ;
539
		NAMESPACE ns = label_namespace;
518
	if ( !IS_NULL_nspace ( ns ) ) {
540
		if (!IS_NULL_nspace(ns)) {
519
	    /* Look up name in label namespace */
541
			/* Look up name in label namespace */
520
	    HASHID nm = DEREF_hashid ( id_name ( lab ) ) ;
542
			HASHID nm = DEREF_hashid(id_name(lab));
521
	    MEMBER mem = search_member ( ns, nm, 1 ) ;
543
			MEMBER mem = search_member(ns, nm, 1);
522
	    nlab = DEREF_id ( member_id ( mem ) ) ;
544
			nlab = DEREF_id(member_id(mem));
523
	    if ( IS_NULL_id ( nlab ) ) {
545
			if (IS_NULL_id(nlab)) {
524
		/* Create new label */
546
				/* Create new label */
525
		int op = DEREF_int ( id_label_op ( lab ) ) ;
547
				int op = DEREF_int(id_label_op(lab));
526
		IDENTIFIER alab = DEREF_id ( id_alias ( lab ) ) ;
548
				IDENTIFIER alab = DEREF_id(id_alias(lab));
527
		DECL_SPEC ds = DEREF_dspec ( id_storage ( lab ) ) ;
549
				DECL_SPEC ds = DEREF_dspec(id_storage(lab));
528
		DEREF_loc ( id_loc ( lab ), crt_loc ) ;
550
				DEREF_loc(id_loc(lab), crt_loc);
529
		ds &= ~dspec_temp ;
551
				ds &= ~dspec_temp;
530
		MAKE_id_label ( nm, ds, ns, crt_loc, op, nlab ) ;
552
				MAKE_id_label(nm, ds, ns, crt_loc, op, nlab);
531
		if ( !EQ_id ( lab, alab ) ) {
553
				if (!EQ_id(lab, alab)) {
532
		    alab = copy_label ( alab, 0 ) ;
554
					alab = copy_label(alab, 0);
533
		    COPY_id ( id_alias ( nlab ), alab ) ;
555
					COPY_id(id_alias(nlab), alab);
534
		}
556
				}
535
		COPY_id ( member_id ( mem ), nlab ) ;
557
				COPY_id(member_id(mem), nlab);
536
	    }
558
			}
537
	}
559
		}
538
	if ( def ) {
560
		if (def) {
539
	    EXP e = DEREF_exp ( id_label_stmt ( lab ) ) ;
561
			EXP e = DEREF_exp(id_label_stmt(lab));
540
	    if ( !IS_NULL_exp ( e ) ) {
562
			if (!IS_NULL_exp(e)) {
541
		/* Copy labelled statement */
563
				/* Copy labelled statement */
542
		TYPE t = DEREF_type ( exp_type ( e ) ) ;
564
				TYPE t = DEREF_type(exp_type(e));
543
		EXP a = DEREF_exp ( exp_label_stmt_body ( e ) ) ;
565
				EXP a = DEREF_exp(exp_label_stmt_body(e));
-
 
566
				IDENTIFIER elab =
544
		IDENTIFIER elab = DEREF_id ( exp_label_stmt_next ( e ) ) ;
567
				    DEREF_id(exp_label_stmt_next(e));
545
		elab = copy_label ( elab, 0 ) ;
568
				elab = copy_label(elab, 0);
546
		a = copy_exp ( a, type_void, type_void ) ;
569
				a = copy_exp(a, type_void, type_void);
547
		MAKE_exp_label_stmt ( t, nlab, a, e ) ;
570
				MAKE_exp_label_stmt(t, nlab, a, e);
548
		COPY_id ( exp_label_stmt_next ( e ), elab ) ;
571
				COPY_id(exp_label_stmt_next(e), elab);
549
		COPY_exp ( id_label_stmt ( nlab ), e ) ;
572
				COPY_exp(id_label_stmt(nlab), e);
550
		set_parent_stmt ( a, e ) ;
573
				set_parent_stmt(a, e);
551
	    }
574
			}
552
	    DEREF_loc ( id_loc ( lab ), crt_loc ) ;
575
			DEREF_loc(id_loc(lab), crt_loc);
553
	}
576
		}
554
    }
577
	}
555
    return ( nlab ) ;
578
	return (nlab);
556
}
579
}
557
 
580
 
558
 
581
 
559
/*
582
/*
560
    SET JUMP JOIN STATEMENTS
583
    SET JUMP JOIN STATEMENTS
561
 
584
 
562
    This routine sets the join field for all jumps to the label lab to
585
    This routine sets the join field for all jumps to the label lab to
563
    be e.
586
    be e.
564
*/
587
*/
565
 
588
 
566
static void set_jump_joins
589
static void
567
    PROTO_N ( ( lab, e ) )
-
 
568
    PROTO_T ( IDENTIFIER lab X EXP e )
590
set_jump_joins(IDENTIFIER lab, EXP e)
569
{
591
{
570
    EXP a = DEREF_exp ( id_label_gotos ( lab ) ) ;
592
	EXP a = DEREF_exp(id_label_gotos(lab));
571
    while ( !IS_NULL_exp ( a ) && IS_exp_goto_stmt ( a ) ) {
593
	while (!IS_NULL_exp(a) && IS_exp_goto_stmt(a)) {
572
	COPY_exp ( exp_goto_stmt_join ( a ), e ) ;
594
		COPY_exp(exp_goto_stmt_join(a), e);
573
	a = DEREF_exp ( exp_goto_stmt_next ( a ) ) ;
595
		a = DEREF_exp(exp_goto_stmt_next(a));
574
    }
596
	}
575
    return ;
597
	return;
576
}
598
}
577
 
599
 
578
 
600
 
579
/*
601
/*
580
    COPY A SWITCH STATEMENT
602
    COPY A SWITCH STATEMENT
581
 
603
 
582
    This routine copies the switch statement e.
604
    This routine copies the switch statement e.
583
*/
605
*/
584
 
606
 
585
static EXP copy_switch_stmt
607
static EXP
586
    PROTO_N ( ( e, t1, t2 ) )
-
 
587
    PROTO_T ( EXP e X TYPE t1 X TYPE t2 )
608
copy_switch_stmt(EXP e, TYPE t1, TYPE t2)
588
{
609
{
589
    /* Decompose switch statement */
610
	/* Decompose switch statement */
590
    int changed = 0 ;
611
	int changed = 0;
591
    LIST ( NAT ) an = NULL_list ( NAT ) ;
612
	LIST(NAT)an = NULL_list(NAT);
592
    LIST ( IDENTIFIER ) al = NULL_list ( IDENTIFIER ) ;
613
	LIST(IDENTIFIER)al = NULL_list(IDENTIFIER);
593
    EXP c = DEREF_exp ( exp_switch_stmt_control ( e ) ) ;
614
	EXP c = DEREF_exp(exp_switch_stmt_control(e));
594
    EXP a = DEREF_exp ( exp_switch_stmt_body ( e ) ) ;
615
	EXP a = DEREF_exp(exp_switch_stmt_body(e));
595
    int exhaust = DEREF_int ( exp_switch_stmt_exhaust ( e ) ) ;
616
	int exhaust = DEREF_int(exp_switch_stmt_exhaust(e));
596
    IDENTIFIER blab = DEREF_id ( exp_switch_stmt_break_lab ( e ) ) ;
617
	IDENTIFIER blab = DEREF_id(exp_switch_stmt_break_lab(e));
597
    IDENTIFIER dlab = DEREF_id ( exp_switch_stmt_default_lab ( e ) ) ;
618
	IDENTIFIER dlab = DEREF_id(exp_switch_stmt_default_lab(e));
598
    LIST ( NAT ) cn = DEREF_list ( exp_switch_stmt_cases ( e ) ) ;
619
	LIST(NAT)cn = DEREF_list(exp_switch_stmt_cases(e));
599
    LIST ( IDENTIFIER ) cl = DEREF_list ( exp_switch_stmt_case_labs ( e ) ) ;
620
	LIST(IDENTIFIER)cl = DEREF_list(exp_switch_stmt_case_labs(e));
600
 
-
 
601
    /* Copy basic components */
-
 
602
    c = copy_exp ( c, type_sint, type_sint ) ;
-
 
603
    blab = copy_label ( blab, 1 ) ;
-
 
604
    a = copy_exp ( a, t1, t2 ) ;
-
 
605
    MAKE_exp_switch_stmt ( t2, c, a, exhaust, blab, e ) ;
-
 
606
    set_jump_joins ( blab, e ) ;
-
 
607
    set_parent_stmt ( a, e ) ;
-
 
608
 
621
 
-
 
622
	/* Copy basic components */
-
 
623
	c = copy_exp(c, type_sint, type_sint);
-
 
624
	blab = copy_label(blab, 1);
-
 
625
	a = copy_exp(a, t1, t2);
-
 
626
	MAKE_exp_switch_stmt(t2, c, a, exhaust, blab, e);
-
 
627
	set_jump_joins(blab, e);
-
 
628
	set_parent_stmt(a, e);
-
 
629
 
609
    /* Copy cases */
630
	/* Copy cases */
610
    while ( !IS_NULL_list ( cn ) ) {
631
	while (!IS_NULL_list(cn)) {
611
	ERROR err = NULL_err ;
632
		ERROR err = NULL_err;
612
	NAT n = DEREF_nat ( HEAD_list ( cn ) ) ;
633
		NAT n = DEREF_nat(HEAD_list(cn));
613
	IDENTIFIER clab = DEREF_id ( HEAD_list ( cl ) ) ;
634
		IDENTIFIER clab = DEREF_id(HEAD_list(cl));
614
	NAT m = expand_nat ( n, 1, 0, &err ) ;
635
		NAT m = expand_nat(n, 1, 0, &err);
615
	if ( !EQ_nat ( n, m ) ) {
636
		if (!EQ_nat(n, m)) {
616
	    if ( !IS_NULL_err ( err ) ) {
637
			if (!IS_NULL_err(err)) {
617
		err = concat_error ( err, ERR_stmt_switch_case_const () ) ;
638
				err = concat_error(err, ERR_stmt_switch_case_const());
618
		report ( crt_loc, err ) ;
639
				report(crt_loc, err);
619
	    }
640
			}
620
	    changed = 1 ;
641
			changed = 1;
-
 
642
		}
-
 
643
		clab = copy_label(clab, 0);
-
 
644
		COPY_exp(id_label_gotos(clab), e);
-
 
645
		if (changed) {
-
 
646
			IDENTIFIER plab = find_case(an, al, m);
-
 
647
			if (!IS_NULL_id(plab) && !is_error_nat(m)) {
-
 
648
				/* New duplicate case created */
-
 
649
				LOCATION loc;
-
 
650
				PTR(LOCATION)ploc = id_loc(plab);
-
 
651
				DEREF_loc(id_loc(clab), loc);
-
 
652
				report(loc, ERR_stmt_switch_case_dup(m, ploc));
-
 
653
			}
-
 
654
		}
-
 
655
		CONS_id(clab, al, al);
-
 
656
		CONS_nat(m, an, an);
-
 
657
		cl = TAIL_list(cl);
-
 
658
		cn = TAIL_list(cn);
621
	}
659
	}
622
	clab = copy_label ( clab, 0 ) ;
660
	an = REVERSE_list(an);
623
	COPY_exp ( id_label_gotos ( clab ), e ) ;
-
 
624
	if ( changed ) {
661
	al = REVERSE_list(al);
625
	    IDENTIFIER plab = find_case ( an, al, m ) ;
662
	COPY_list(exp_switch_stmt_cases(e), an);
626
	    if ( !IS_NULL_id ( plab ) && !is_error_nat ( m ) ) {
-
 
627
		/* New duplicate case created */
663
	COPY_list(exp_switch_stmt_case_labs(e), al);
628
		LOCATION loc ;
664
	if (!IS_NULL_id(dlab)) {
629
		PTR ( LOCATION ) ploc = id_loc ( plab ) ;
665
		dlab = copy_label(dlab, 0);
630
		DEREF_loc ( id_loc ( clab ), loc ) ;
666
		COPY_exp(id_label_gotos(dlab), e);
631
		report ( loc, ERR_stmt_switch_case_dup ( m, ploc ) ) ;
667
		COPY_id(exp_switch_stmt_default_lab(e), dlab);
632
            }
-
 
633
	}
668
	}
634
	CONS_id ( clab, al, al ) ;
-
 
635
	CONS_nat ( m, an, an ) ;
-
 
636
	cl = TAIL_list ( cl ) ;
-
 
637
	cn = TAIL_list ( cn ) ;
-
 
638
    }
-
 
639
    an = REVERSE_list ( an ) ;
-
 
640
    al = REVERSE_list ( al ) ;
-
 
641
    COPY_list ( exp_switch_stmt_cases ( e ), an ) ;
-
 
642
    COPY_list ( exp_switch_stmt_case_labs ( e ), al ) ;
-
 
643
    if ( !IS_NULL_id ( dlab ) ) {
-
 
644
	dlab = copy_label ( dlab, 0 ) ;
-
 
645
	COPY_exp ( id_label_gotos ( dlab ), e ) ;
-
 
646
	COPY_id ( exp_switch_stmt_default_lab ( e ), dlab ) ;
-
 
647
    }
-
 
648
    e = solve_switch ( e ) ;
669
	e = solve_switch (e);
649
    return ( e ) ;
670
	return (e);
650
}
671
}
651
 
672
 
652
 
673
 
653
/*
674
/*
654
    COPY A TRY BLOCK
675
    COPY A TRY BLOCK
655
 
676
 
656
    This routine copies the try block e.
677
    This routine copies the try block e.
657
*/
678
*/
658
 
679
 
659
#if LANGUAGE_CPP
680
#if LANGUAGE_CPP
660
 
681
 
661
static EXP copy_try_stmt
682
static EXP
662
    PROTO_N ( ( e, t1, t2 ) )
-
 
663
    PROTO_T ( EXP e X TYPE t1 X TYPE t2 )
683
copy_try_stmt(EXP e, TYPE t1, TYPE t2)
664
{
684
{
665
    int empty = 1 ;
685
	int empty = 1;
666
    int changed = 0 ;
686
	int changed = 0;
667
    EXP a = DEREF_exp ( exp_try_block_body ( e ) ) ;
687
	EXP a = DEREF_exp(exp_try_block_body(e));
668
    LIST ( EXP ) h = DEREF_list ( exp_try_block_handlers ( e ) ) ;
688
	LIST(EXP)h = DEREF_list(exp_try_block_handlers(e));
669
    LIST ( TYPE ) s = DEREF_list ( exp_try_block_htypes ( e ) ) ;
689
	LIST(TYPE)s = DEREF_list(exp_try_block_htypes(e));
670
    LIST ( TYPE ) t = DEREF_list ( exp_try_block_ttypes ( e ) ) ;
690
	LIST(TYPE)t = DEREF_list(exp_try_block_ttypes(e));
671
    LIST ( LOCATION ) tl = DEREF_list ( exp_try_block_tlocs ( e ) ) ;
691
	LIST(LOCATION)tl = DEREF_list(exp_try_block_tlocs(e));
672
    LIST ( LOCATION ) sl = NULL_list ( LOCATION ) ;
692
	LIST(LOCATION)sl = NULL_list(LOCATION);
673
    EXP b = DEREF_exp ( exp_try_block_ellipsis ( e ) ) ;
693
	EXP b = DEREF_exp(exp_try_block_ellipsis(e));
674
    int func = DEREF_int ( exp_try_block_func ( e ) ) ;
694
	int func = DEREF_int(exp_try_block_func(e));
675
    e = begin_try_stmt ( func ) ;
695
	e = begin_try_stmt(func);
676
    t = expand_exceptions ( t, 1, &changed ) ;
696
	t = expand_exceptions(t, 1, &changed);
677
    while ( !IS_NULL_list ( tl ) ) {
697
	while (!IS_NULL_list(tl)) {
678
	LOCATION loc ;
698
		LOCATION loc;
679
	DEREF_loc ( HEAD_list ( tl ), loc ) ;
699
		DEREF_loc(HEAD_list(tl), loc);
680
	CONS_loc ( loc, sl, sl ) ;
700
		CONS_loc(loc, sl, sl);
681
	tl = TAIL_list ( tl ) ;
701
		tl = TAIL_list(tl);
682
    }
702
	}
683
    sl = REVERSE_list ( sl ) ;
703
	sl = REVERSE_list(sl);
684
    COPY_list ( exp_try_block_ttypes ( e ), t ) ;
704
	COPY_list(exp_try_block_ttypes(e), t);
685
    COPY_list ( exp_try_block_tlocs ( e ), sl ) ;
705
	COPY_list(exp_try_block_tlocs(e), sl);
686
    a = copy_exp ( a, t1, t2 ) ;
706
	a = copy_exp(a, t1, t2);
687
    e = cont_try_stmt ( e, a ) ;
707
	e = cont_try_stmt(e, a);
688
    h = copy_exp_list ( h, t1, t2 ) ;
708
	h = copy_exp_list(h, t1, t2);
689
    s = expand_exceptions ( s, 1, &changed ) ;
709
	s = expand_exceptions(s, 1, &changed);
690
    b = copy_exp ( b, t1, t2 ) ;
710
	b = copy_exp(b, t1, t2);
691
    COPY_list ( exp_try_block_handlers ( e ), h ) ;
711
	COPY_list(exp_try_block_handlers(e), h);
692
    COPY_list ( exp_try_block_htypes ( e ), s ) ;
712
	COPY_list(exp_try_block_htypes(e), s);
693
    COPY_exp ( exp_try_block_ellipsis ( e ), b ) ;
713
	COPY_exp(exp_try_block_ellipsis(e), b);
694
    while ( !IS_NULL_list ( h ) ) {
714
	while (!IS_NULL_list(h)) {
695
	EXP c = DEREF_exp ( HEAD_list ( h ) ) ;
715
		EXP c = DEREF_exp(HEAD_list(h));
696
	set_parent_stmt ( c, e ) ;
716
		set_parent_stmt(c, e);
697
	empty = 0 ;
717
		empty = 0;
698
	h = TAIL_list ( h ) ;
718
		h = TAIL_list(h);
699
    }
719
	}
700
    set_parent_stmt ( b, e ) ;
720
	set_parent_stmt(b, e);
701
    if ( !IS_NULL_exp ( b ) && IS_exp_handler ( b ) ) empty = 0 ;
721
	if (!IS_NULL_exp(b) && IS_exp_handler(b)) {
-
 
722
		empty = 0;
-
 
723
	}
702
    e = end_try_stmt ( e, empty ) ;
724
	e = end_try_stmt(e, empty);
703
    return ( e ) ;
725
	return (e);
704
}
726
}
705
 
727
 
706
#endif
728
#endif
707
 
729
 
708
 
730
 
709
/*
731
/*
710
    COPY A BLOCK DECLARATION
732
    COPY A BLOCK DECLARATION
Line 712... Line 734...
712
    This routine copies the object id declared in block scope.  This is
734
    This routine copies the object id declared in block scope.  This is
713
    primarily to handle local classes and the like, local variables being
735
    primarily to handle local classes and the like, local variables being
714
    handled by copy_local when their declaration is encountered.
736
    handled by copy_local when their declaration is encountered.
715
*/
737
*/
716
 
738
 
717
static void copy_local_decl
739
static void
718
    PROTO_N ( ( id ) )
-
 
719
    PROTO_T ( IDENTIFIER id )
740
copy_local_decl(IDENTIFIER id)
720
{
741
{
721
    switch ( TAG_id ( id ) ) {
742
	switch (TAG_id(id)) {
722
	case id_variable_tag : {
743
	case id_variable_tag: {
723
	    /* Local variable declaration */
744
		/* Local variable declaration */
724
	    DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
745
		DECL_SPEC ds = DEREF_dspec(id_storage(id));
725
	    if ( ds & dspec_linkage ) {
746
		if (ds & dspec_linkage) {
726
		IDENTIFIER pid ;
747
			IDENTIFIER pid;
727
		TYPE t = DEREF_type ( id_variable_type ( id ) ) ;
748
			TYPE t = DEREF_type(id_variable_type(id));
728
		t = expand_type ( t, 1 ) ;
749
			t = expand_type(t, 1);
729
		pid = make_object_decl ( dspec_extern, t, id, 0 ) ;
750
			pid = make_object_decl(dspec_extern, t, id, 0);
730
		pid = DEREF_id ( id_alias ( pid ) ) ;
751
			pid = DEREF_id(id_alias(pid));
731
		COPY_id ( id_alias ( id ), pid ) ;
752
			COPY_id(id_alias(id), pid);
732
	    }
-
 
733
	    break ;
-
 
734
	}
753
		}
735
	case id_function_tag : {
-
 
736
	    /* Local function declaration */
-
 
737
	    IDENTIFIER pid ;
-
 
738
	    TYPE t = DEREF_type ( id_function_type ( id ) ) ;
-
 
739
	    IDENTIFIER over = DEREF_id ( id_function_over ( id ) ) ;
-
 
740
	    if ( !IS_NULL_id ( over ) ) {
-
 
741
		copy_local_decl ( over ) ;
-
 
742
	    }
-
 
743
	    t = expand_type ( t, 1 ) ;
-
 
744
	    pid = make_func_decl ( dspec_extern, t, id, 0 ) ;
-
 
745
	    pid = DEREF_id ( id_alias ( pid ) ) ;
-
 
746
	    COPY_id ( id_alias ( id ), pid ) ;
-
 
747
	    break ;
754
		break;
748
	}
755
	}
749
	case id_class_name_tag : {
756
	case id_function_tag: {
750
	    /* Local class */
757
		/* Local function declaration */
751
	    TYPE t = DEREF_type ( id_class_name_defn ( id ) ) ;
-
 
752
	    if ( IS_type_compound ( t ) ) {
-
 
753
		/* Can't be a template class */
758
		IDENTIFIER pid;
754
		CLASS_TYPE ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
759
		TYPE t = DEREF_type(id_function_type(id));
755
		CLASS_INFO ci = DEREF_cinfo ( ctype_info ( ct ) ) ;
760
		IDENTIFIER over = DEREF_id(id_function_over(id));
756
		if ( ci & cinfo_force_copy ) {
761
		if (!IS_NULL_id(over)) {
757
		    TYPE s ;
762
			copy_local_decl(over);
758
		    CLASS_TYPE cs ;
763
		}
759
		    COPY_type ( ctype_form ( ct ), NULL_type ) ;
764
		t = expand_type(t, 1);
760
		    s = copy_class ( t, dspec_none ) ;
765
		pid = make_func_decl(dspec_extern, t, id, 0);
761
		    cs = DEREF_ctype ( type_compound_defn ( s ) ) ;
766
		pid = DEREF_id(id_alias(pid));
762
		    COPY_type ( ctype_form ( ct ), s ) ;
767
		COPY_id(id_alias(id), pid);
763
		    copy_members ( cs, ct, cinfo_none, 1 ) ;
-
 
764
		}
-
 
765
	    }
-
 
766
	    break ;
768
		break;
767
	}
769
	}
768
	case id_enumerator_tag : {
770
	case id_class_name_tag: {
-
 
771
		/* Local class */
-
 
772
		TYPE t = DEREF_type(id_class_name_defn(id));
-
 
773
		if (IS_type_compound(t)) {
769
	    /* Check enumerator values */
774
			/* Can't be a template class */
-
 
775
			CLASS_TYPE ct = DEREF_ctype(type_compound_defn(t));
-
 
776
			CLASS_INFO ci = DEREF_cinfo(ctype_info(ct));
-
 
777
			if (ci & cinfo_force_copy) {
-
 
778
				TYPE s;
-
 
779
				CLASS_TYPE cs;
-
 
780
				COPY_type(ctype_form(ct), NULL_type);
-
 
781
				s = copy_class(t, dspec_none);
-
 
782
				cs = DEREF_ctype(type_compound_defn(s));
770
	    IGNORE copy_id ( id, 2 ) ;
783
				COPY_type(ctype_form(ct), s);
-
 
784
				copy_members(cs, ct, cinfo_none, 1);
-
 
785
			}
-
 
786
		}
771
	    break ;
787
		break;
772
	}
788
	}
-
 
789
	case id_enumerator_tag:
-
 
790
		/* Check enumerator values */
-
 
791
		IGNORE copy_id(id, 2);
-
 
792
		break;
773
    }
793
	}
774
    return ;
794
	return;
775
}
795
}
776
 
796
 
777
 
797
 
778
/*
798
/*
779
    COPY A COMPOUND STATEMENT
799
    COPY A COMPOUND STATEMENT
780
 
800
 
781
    This routine copies the compound statement e.
801
    This routine copies the compound statement e.
782
*/
802
*/
783
 
803
 
784
static EXP copy_compound_stmt
804
static EXP
785
    PROTO_N ( ( e, t1, t2 ) )
-
 
786
    PROTO_T ( EXP e X TYPE t1 X TYPE t2 )
805
copy_compound_stmt(EXP e, TYPE t1, TYPE t2)
787
{
806
{
788
    int block = DEREF_int ( exp_sequence_block ( e ) ) ;
807
	int block = DEREF_int(exp_sequence_block(e));
789
    NAMESPACE pns = DEREF_nspace ( exp_sequence_decl ( e ) ) ;
808
	NAMESPACE pns = DEREF_nspace(exp_sequence_decl(e));
790
    LIST ( EXP ) p = DEREF_list ( exp_sequence_first ( e ) ) ;
809
	LIST(EXP)p = DEREF_list(exp_sequence_first(e));
791
 
810
 
792
    /* Copy the dummy first statement */
811
	/* Copy the dummy first statement */
793
    LIST ( EXP ) q ;
812
	LIST(EXP)q;
794
    EXP a = DEREF_exp ( HEAD_list ( p ) ) ;
813
	EXP a = DEREF_exp(HEAD_list(p));
-
 
814
	if (!IS_NULL_exp(a)) {
795
    if ( !IS_NULL_exp ( a ) ) a = copy_exp ( a, t1, t2 ) ;
815
		a = copy_exp(a, t1, t2);
-
 
816
	}
796
    CONS_exp ( a, NULL_list ( EXP ), q ) ;
817
	CONS_exp(a, NULL_list(EXP), q);
797
    p = TAIL_list ( p ) ;
818
	p = TAIL_list(p);
798
 
819
 
799
    /* Create the compound statement */
820
	/* Create the compound statement */
800
    MAKE_exp_sequence ( t2, q, q, NULL_nspace, block, e ) ;
821
	MAKE_exp_sequence(t2, q, q, NULL_nspace, block, e);
801
    if ( !IS_NULL_list ( p ) ) {
822
	if (!IS_NULL_list(p)) {
802
	/* Construct namespace for copied block */
823
		/* Construct namespace for copied block */
803
	MEMBER mem = NULL_member ;
824
		MEMBER mem = NULL_member;
804
	NAMESPACE ns = make_namespace ( crt_func_id, nspace_block_tag, 0 ) ;
825
		NAMESPACE ns = make_namespace(crt_func_id, nspace_block_tag, 0);
805
	COPY_nspace ( exp_sequence_decl ( e ), ns ) ;
826
		COPY_nspace(exp_sequence_decl(e), ns);
806
	push_namespace ( ns ) ;
827
		push_namespace(ns);
807
 
828
 
808
	/* Copy members of block namespace */
829
		/* Copy members of block namespace */
809
	if ( !IS_NULL_nspace ( pns ) ) {
830
		if (!IS_NULL_nspace(pns)) {
810
	    MEMBER mem2 = DEREF_member ( nspace_last ( pns ) ) ;
831
			MEMBER mem2 = DEREF_member(nspace_last(pns));
811
	    while ( !IS_NULL_member ( mem2 ) ) {
832
			while (!IS_NULL_member(mem2)) {
812
		IDENTIFIER id = DEREF_id ( member_id ( mem2 ) ) ;
833
				IDENTIFIER id = DEREF_id(member_id(mem2));
813
		IDENTIFIER alt = DEREF_id ( member_alt ( mem2 ) ) ;
834
				IDENTIFIER alt = DEREF_id(member_alt(mem2));
814
		if ( !IS_NULL_id ( id ) ) {
835
				if (!IS_NULL_id(id)) {
815
		    copy_local_decl ( id ) ;
836
					copy_local_decl(id);
816
		}
837
				}
817
		if ( !IS_NULL_id ( alt ) && !EQ_id ( id, alt ) ) {
838
				if (!IS_NULL_id(alt) && !EQ_id(id, alt)) {
818
		    copy_local_decl ( alt ) ;
839
					copy_local_decl(alt);
-
 
840
				}
-
 
841
				mem2 = DEREF_member(member_next(mem2));
-
 
842
			}
-
 
843
		}
-
 
844
 
-
 
845
		/* Copy list of components */
-
 
846
		while (!IS_NULL_list(p)) {
-
 
847
			MEMBER mem2;
-
 
848
			LIST(EXP)r;
-
 
849
			a = DEREF_exp(HEAD_list(p));
-
 
850
			a = copy_exp(a, t1, t2);
-
 
851
			mem2 = DEREF_member(nspace_last(ns));
-
 
852
			if (!EQ_member(mem2, mem)) {
-
 
853
				/* Introduced new temporary variables */
-
 
854
				a = make_temp_decl(mem2, mem, a);
-
 
855
				mem = mem2;
-
 
856
			}
-
 
857
			set_parent_stmt(a, e);
-
 
858
			CONS_exp(a, NULL_list(EXP), r);
-
 
859
			COPY_list(PTR_TAIL_list(q), r);
-
 
860
			q = r;
-
 
861
			p = TAIL_list(p);
819
		}
862
		}
-
 
863
 
820
		mem2 = DEREF_member ( member_next ( mem2 ) ) ;
864
		/* Update compound statement */
821
	    }
865
		IGNORE pop_namespace();
-
 
866
		COPY_member(nspace_prev(ns), mem);
-
 
867
		COPY_list(exp_sequence_last(e), q);
822
	}
868
	}
823
 
-
 
824
	/* Copy list of components */
-
 
825
	while ( !IS_NULL_list ( p ) ) {
-
 
826
	    MEMBER mem2 ;
-
 
827
	    LIST ( EXP ) r ;
-
 
828
	    a = DEREF_exp ( HEAD_list ( p ) ) ;
-
 
829
	    a = copy_exp ( a, t1, t2 ) ;
-
 
830
	    mem2 = DEREF_member ( nspace_last ( ns ) ) ;
-
 
831
	    if ( !EQ_member ( mem2, mem ) ) {
-
 
832
		/* Introduced new temporary variables */
-
 
833
		a = make_temp_decl ( mem2, mem, a ) ;
-
 
834
		mem = mem2 ;
-
 
835
	    }
-
 
836
	    set_parent_stmt ( a, e ) ;
-
 
837
	    CONS_exp ( a, NULL_list ( EXP ), r ) ;
-
 
838
	    COPY_list ( PTR_TAIL_list ( q ), r ) ;
-
 
839
	    q = r ;
-
 
840
	    p = TAIL_list ( p ) ;
-
 
841
	}
-
 
842
 
-
 
843
	/* Update compound statement */
-
 
844
	IGNORE pop_namespace () ;
-
 
845
	COPY_member ( nspace_prev ( ns ), mem ) ;
-
 
846
	COPY_list ( exp_sequence_last ( e ), q ) ;
-
 
847
    }
-
 
848
    return ( e ) ;
869
	return (e);
849
}
870
}
850
 
871
 
851
 
872
 
852
/*
873
/*
853
    LISTS OF DUMMY EXPRESSIONS
874
    LISTS OF DUMMY EXPRESSIONS
Line 855... Line 876...
855
    Dummy expressions are used to point to a component of a complex
876
    Dummy expressions are used to point to a component of a complex
856
    expression.  These lists are used to hold all the dummy expressions to
877
    expression.  These lists are used to hold all the dummy expressions to
857
    be copied by copy_exp.  They are updated as they are copied.
878
    be copied by copy_exp.  They are updated as they are copied.
858
*/
879
*/
859
 
880
 
860
static LIST ( EXP ) input_dummy_exps = NULL_list ( EXP ) ;
881
static LIST(EXP) input_dummy_exps = NULL_list(EXP);
861
static LIST ( EXP ) output_dummy_exps = NULL_list ( EXP ) ;
882
static LIST(EXP) output_dummy_exps = NULL_list(EXP);
862
 
883
 
863
 
884
 
864
/*
885
/*
865
    ADD A DUMMY EXPRESSION TO THE LIST
886
    ADD A DUMMY EXPRESSION TO THE LIST
866
 
887
 
867
    This routine adds the expression e to the lists of dummy expressions.
888
    This routine adds the expression e to the lists of dummy expressions.
868
*/
889
*/
869
 
890
 
870
static void save_dummy_exp
891
static void
871
    PROTO_N ( ( e ) )
-
 
872
    PROTO_T ( EXP e )
892
save_dummy_exp(EXP e)
873
{
893
{
874
    CONS_exp ( e, input_dummy_exps, input_dummy_exps ) ;
894
	CONS_exp(e, input_dummy_exps, input_dummy_exps);
875
    CONS_exp ( NULL_exp, output_dummy_exps, output_dummy_exps ) ;
895
	CONS_exp(NULL_exp, output_dummy_exps, output_dummy_exps);
876
    return ;
896
	return;
877
}
897
}
878
 
898
 
879
 
899
 
880
/*
900
/*
881
    REMOVE A DUMMY EXPRESSION FROM THE LIST
901
    REMOVE A DUMMY EXPRESSION FROM THE LIST
882
 
902
 
883
    This routine removes an expression from the lists of dummy expressions.
903
    This routine removes an expression from the lists of dummy expressions.
884
    It returns the copied values.
904
    It returns the copied values.
885
*/
905
*/
886
 
906
 
887
static EXP restore_dummy_exp
907
static EXP
888
    PROTO_Z ()
908
restore_dummy_exp(void)
889
{
909
{
890
    EXP a, b ;
910
	EXP a, b;
891
    DESTROY_CONS_exp ( destroy, a, input_dummy_exps, input_dummy_exps ) ;
911
	DESTROY_CONS_exp(destroy, a, input_dummy_exps, input_dummy_exps);
892
    DESTROY_CONS_exp ( destroy, b, output_dummy_exps, output_dummy_exps ) ;
912
	DESTROY_CONS_exp(destroy, b, output_dummy_exps, output_dummy_exps);
893
    if ( IS_NULL_exp ( b ) && !IS_NULL_exp ( a ) ) {
913
	if (IS_NULL_exp(b) && !IS_NULL_exp(a)) {
894
	/* Do a straight copy if not copied already */
914
		/* Do a straight copy if not copied already */
895
	b = copy_exp ( a, NULL_type, NULL_type ) ;
915
		b = copy_exp(a, NULL_type, NULL_type);
896
    }
916
	}
897
    return ( b ) ;
917
	return (b);
898
}
918
}
899
 
919
 
900
 
920
 
901
/*
921
/*
902
    COPY A DUMMY EXPRESSION
922
    COPY A DUMMY EXPRESSION
903
 
923
 
904
    This routine copies the dummy expression e, including updating the lists
924
    This routine copies the dummy expression e, including updating the lists
905
    of dummy expressions.
925
    of dummy expressions.
906
*/
926
*/
907
 
927
 
908
static EXP copy_dummy_exp
928
static EXP
909
    PROTO_N ( ( e, t1, t2 ) )
-
 
910
    PROTO_T ( EXP e X TYPE t1 X TYPE t2 )
929
copy_dummy_exp(EXP e, TYPE t1, TYPE t2)
911
{
930
{
912
    EXP f ;
931
	EXP f;
913
    LIST ( EXP ) p = input_dummy_exps ;
932
	LIST(EXP)p = input_dummy_exps;
914
    LIST ( EXP ) q = output_dummy_exps ;
933
	LIST(EXP)q = output_dummy_exps;
915
    EXP a = DEREF_exp ( exp_dummy_value ( e ) ) ;
934
	EXP a = DEREF_exp(exp_dummy_value(e));
916
    ulong_type no = DEREF_ulong ( exp_dummy_no ( e ) ) ;
935
	ulong_type no = DEREF_ulong(exp_dummy_no(e));
917
    OFFSET off = DEREF_off ( exp_dummy_off ( e ) ) ;
936
	OFFSET off = DEREF_off(exp_dummy_off(e));
918
    int virt = DEREF_int ( exp_dummy_virt ( e ) ) ;
937
	int virt = DEREF_int(exp_dummy_virt(e));
919
    int cont = DEREF_int ( exp_dummy_cont ( e ) ) ;
938
	int cont = DEREF_int(exp_dummy_cont(e));
920
    a = copy_exp ( a, t1, t2 ) ;
939
	a = copy_exp(a, t1, t2);
921
    off = copy_offset ( off, lex_plus ) ;
940
	off = copy_offset(off, lex_plus);
922
    MAKE_exp_dummy ( t2, a, no, off, cont, f ) ;
941
	MAKE_exp_dummy(t2, a, no, off, cont, f);
923
    COPY_int ( exp_dummy_virt ( f ), virt ) ;
942
	COPY_int(exp_dummy_virt(f), virt);
924
    while ( !IS_NULL_list ( p ) ) {
943
	while (!IS_NULL_list(p)) {
925
	EXP b = DEREF_exp ( HEAD_list ( p ) ) ;
944
		EXP b = DEREF_exp(HEAD_list(p));
926
	if ( EQ_exp ( b, e ) ) {
945
		if (EQ_exp(b, e)) {
927
	    /* Update output lists */
946
			/* Update output lists */
928
	    COPY_exp ( HEAD_list ( q ), f ) ;
947
			COPY_exp(HEAD_list(q), f);
929
	}
948
		}
930
	q = TAIL_list ( q ) ;
949
		q = TAIL_list(q);
931
	p = TAIL_list ( p ) ;
950
		p = TAIL_list(p);
932
    }
951
	}
933
    return ( f ) ;
952
	return (f);
934
}
953
}
935
 
954
 
936
 
955
 
937
/*
956
/*
938
    COPY AN EXPRESSION
957
    COPY AN EXPRESSION
939
 
958
 
940
    This routine copies the expression e, expanding any template parameters
959
    This routine copies the expression e, expanding any template parameters
941
    and tokens.  It is used in the instantiation of template functions.
960
    and tokens.  It is used in the instantiation of template functions.
942
    t1 and t2 are used to prevent repeated type expansions.  t1 gives the
961
    t1 and t2 are used to prevent repeated type expansions.  t1 gives the
943
    previous expression type and t2 gives its expanded form.
962
    previous expression type and t2 gives its expanded form.
1337
	}
1474
	}
1338
	case exp_dynamic_tag : {
1475
	case exp_decl_stmt_tag: {
1339
	    /* Dynamic initialiser expressions */
1476
		/* Declaration statements */
-
 
1477
		IDENTIFIER id = DEREF_id(exp_decl_stmt_id(e));
-
 
1478
		IDENTIFIER aid = DEREF_id(id_alias(id));
-
 
1479
		IDENTIFIER cid = copy_local(id);
1340
	    EXP a = DEREF_exp ( exp_dynamic_arg ( e ) ) ;
1480
		EXP a = DEREF_exp(exp_decl_stmt_body(e));
1341
	    a = copy_exp ( a, t1, t2 ) ;
1481
		a = copy_exp(a, t1, t2);
1342
	    MAKE_exp_dynamic ( t2, a, e ) ;
1482
		MAKE_exp_decl_stmt(t2, cid, a, e);
-
 
1483
		set_parent_stmt(a, e);
-
 
1484
		COPY_id(id_alias(id), aid);
1343
	    break ;
1485
		break;
1344
	}
1486
	}
1345
	case exp_aggregate_tag : {
1487
	case exp_if_stmt_tag: {
1346
	    /* Aggregate initialisers */
1488
		/* Conditional statements */
-
 
1489
		EXP c = DEREF_exp(exp_if_stmt_cond(e));
1347
	    LIST ( EXP ) args = DEREF_list ( exp_aggregate_args ( e ) ) ;
1490
		EXP a = DEREF_exp(exp_if_stmt_true_code(e));
-
 
1491
		EXP b = DEREF_exp(exp_if_stmt_false_code(e));
1348
	    LIST ( OFFSET ) offs = DEREF_list ( exp_aggregate_offs ( e ) ) ;
1492
		IDENTIFIER lab = DEREF_id(exp_if_stmt_label(e));
-
 
1493
		c = copy_exp(c, type_bool, type_bool);
-
 
1494
		lab = copy_label(lab, 1);
1349
	    args = copy_exp_list ( args, t1, t2 ) ;
1495
		a = copy_exp(a, t1, t2);
1350
	    offs = copy_off_list ( offs ) ;
1496
		b = copy_exp(b, t1, t2);
1351
	    MAKE_exp_aggregate ( t2, args, offs, e ) ;
1497
		MAKE_exp_if_stmt(t2, c, a, b, lab, e);
-
 
1498
		set_parent_stmt(a, e);
-
 
1499
		set_parent_stmt(b, e);
1352
	    break ;
1500
		break;
1353
	}
1501
	}
1354
	case exp_initialiser_tag : {
1502
	case exp_while_stmt_tag: {
1355
	    /* Constructor initialisers */
-
 
1356
	    int kind = DEREF_int ( exp_initialiser_kind ( e ) ) ;
-
 
1357
	    if ( kind ) {
-
 
1358
		/* Copy ctor-initialiser */
1503
		/* While statements */
1359
		e = copy_ctor ( e, kind ) ;
-
 
1360
	    } else {
-
 
1361
		unsigned nv, nb ;
-
 
1362
		LIST ( EXP ) args ;
1504
		LIST(IDENTIFIER)pids;
1363
		LIST ( OFFSET ) offs ;
1505
		EXP c = DEREF_exp(exp_while_stmt_cond(e));
1364
		args = DEREF_list ( exp_initialiser_args ( e ) ) ;
1506
		EXP a = DEREF_exp(exp_while_stmt_body(e));
1365
		offs = DEREF_list ( exp_initialiser_offs ( e ) ) ;
1507
		IDENTIFIER blab = DEREF_id(exp_while_stmt_break_lab(e));
1366
		nv = DEREF_unsigned ( exp_initialiser_virt ( e ) ) ;
1508
		IDENTIFIER clab = DEREF_id(exp_while_stmt_cont_lab(e));
1367
		nb = DEREF_unsigned ( exp_initialiser_base ( e ) ) ;
1509
		IDENTIFIER llab = DEREF_id(exp_while_stmt_loop_lab(e));
1368
		args = copy_exp_list ( args, t1, t2 ) ;
1510
		c = copy_exp(c, type_bool, type_bool);
1369
		offs = copy_off_list ( offs ) ;
1511
		blab = copy_label(blab, 1);
1370
		MAKE_exp_initialiser ( t2, args, offs, kind, nv, nb, e ) ;
-
 
1371
	    }
-
 
1372
	    break ;
1512
		clab = copy_label(clab, 1);
1373
	}
-
 
1374
	case exp_nof_tag : {
1513
		llab = copy_label(llab, 1);
1375
	    /* Array initialisers */
1514
		pids = DEREF_list(exp_while_stmt_cond_id(e));
1376
	    ERROR err = NULL_err ;
1515
		a = copy_exp(a, t1, t2);
1377
	    EXP a = DEREF_exp ( exp_nof_start ( e ) ) ;
1516
		MAKE_exp_while_stmt(t2, c, blab, clab, llab, e);
1378
	    EXP b = DEREF_exp ( exp_nof_pad ( e ) ) ;
1517
		COPY_exp(exp_while_stmt_body(e), a);
1379
	    EXP c = DEREF_exp ( exp_nof_end ( e ) ) ;
1518
		set_jump_joins(blab, e);
1380
	    NAT n = DEREF_nat ( exp_nof_size ( e ) ) ;
1519
		set_jump_joins(clab, e);
1381
	    NAT m = expand_nat ( n, 1, 0, &err ) ;
1520
		set_parent_stmt(a, e);
1382
	    a = copy_exp ( a, t1, t2 ) ;
1521
		if (!IS_NULL_list(pids)) {
-
 
1522
			LIST(IDENTIFIER)qids = NULL_list(IDENTIFIER);
1383
	    if ( !EQ_nat ( n, m ) ) {
1523
			while (!IS_NULL_list(pids)) {
1384
		if ( !IS_NULL_err ( err ) ) report ( crt_loc, err ) ;
1524
				IDENTIFIER id = DEREF_id(HEAD_list(pids));
1385
		if ( is_zero_nat ( m ) ) {
1525
				id = DEREF_id(id_alias(id));
1386
		    /* No extra elements */
1526
				CONS_id(id, qids, qids);
1387
		    e = a ;
1527
				pids = TAIL_list(pids);
-
 
1528
			}
1388
		    break ;
1529
			qids = REVERSE_list(qids);
-
 
1530
			COPY_list(exp_while_stmt_cond_id(e), qids);
1389
		}
1531
		}
1390
		if ( is_negative_nat ( m ) ) {
-
 
1391
		    /* Number of extra elements has gone negative */
-
 
1392
		    report ( crt_loc, ERR_dcl_init_aggr_excess ( t2 ) ) ;
-
 
1393
		    e = a ;
-
 
1394
		    break ;
1532
		break;
1395
		}
-
 
1396
	    }
-
 
1397
	    b = copy_exp ( b, t1, t2 ) ;
-
 
1398
	    c = copy_exp ( c, t1, t2 ) ;
-
 
1399
	    MAKE_exp_nof ( t2, a, m, b, c, e ) ;
-
 
1400
	    break ;
-
 
1401
	}
-
 
1402
	case exp_comma_tag : {
-
 
1403
	    /* Comma expressions */
-
 
1404
	    LIST ( EXP ) args = DEREF_list ( exp_comma_args ( e ) ) ;
-
 
1405
	    args = copy_exp_list ( args, t1, t2 ) ;
-
 
1406
	    MAKE_exp_comma ( t2, args, e ) ;
-
 
1407
	    break ;
-
 
1408
	}
-
 
1409
	case exp_set_tag : {
-
 
1410
	    /* Variable set expressions */
-
 
1411
	    EXP a = DEREF_exp ( exp_set_arg ( e ) ) ;
-
 
1412
	    a = copy_exp ( a, t1, t2 ) ;
-
 
1413
	    MAKE_exp_set ( t2, a, e ) ;
-
 
1414
	    break ;
-
 
1415
	}
-
 
1416
	case exp_unused_tag : {
-
 
1417
	    /* Variable unset expressions */
-
 
1418
	    EXP a = DEREF_exp ( exp_unused_arg ( e ) ) ;
-
 
1419
	    a = copy_exp ( a, t1, t2 ) ;
-
 
1420
	    MAKE_exp_unused ( t2, a, e ) ;
-
 
1421
	    break ;
-
 
1422
	}
1533
	}
1423
	case exp_reach_tag : {
1534
	case exp_do_stmt_tag: {
1424
	    /* Reached statements */
1535
		/* Do statements */
-
 
1536
		EXP c = DEREF_exp(exp_do_stmt_cond(e));
1425
	    EXP a = DEREF_exp ( exp_reach_body ( e ) ) ;
1537
		EXP a = DEREF_exp(exp_do_stmt_body(e));
-
 
1538
		IDENTIFIER blab = DEREF_id(exp_do_stmt_break_lab(e));
-
 
1539
		IDENTIFIER clab = DEREF_id(exp_do_stmt_cont_lab(e));
-
 
1540
		IDENTIFIER llab = DEREF_id(exp_do_stmt_loop_lab(e));
-
 
1541
		blab = copy_label(blab, 1);
-
 
1542
		clab = copy_label(clab, 1);
-
 
1543
		llab = copy_label(llab, 1);
1426
	    a = copy_exp ( a, t1, t2 ) ;
1544
		a = copy_exp(a, t1, t2);
-
 
1545
		c = copy_exp(c, type_bool, type_bool);
1427
	    MAKE_exp_reach ( t2, a, e ) ;
1546
		MAKE_exp_do_stmt(t2, c, blab, clab, llab, e);
-
 
1547
		COPY_exp(exp_do_stmt_body(e), a);
-
 
1548
		set_jump_joins(blab, e);
-
 
1549
		set_jump_joins(clab, e);
1428
	    set_parent_stmt ( a, e ) ;
1550
		set_parent_stmt(a, e);
1429
	    break ;
1551
		break;
1430
	}
1552
	}
1431
	case exp_unreach_tag : {
1553
	case exp_switch_stmt_tag: {
1432
	    /* Unreached statements */
1554
		/* Switch statements */
1433
	    EXP a = DEREF_exp ( exp_unreach_body ( e ) ) ;
-
 
1434
	    a = copy_exp ( a, t1, t2 ) ;
1555
		e = copy_switch_stmt(e, t1, t2);
1435
	    MAKE_exp_unreach ( t2, a, e ) ;
-
 
1436
	    set_parent_stmt ( a, e ) ;
-
 
1437
	    break ;
1556
		break;
1438
	}
1557
	}
1439
	case exp_sequence_tag : {
1558
	case exp_hash_if_tag: {
1440
	    /* Block statements */
1559
		/* Target dependent conditional statements */
-
 
1560
		EXP c = DEREF_exp(exp_hash_if_cond(e));
-
 
1561
		EXP a = DEREF_exp(exp_hash_if_true_code(e));
-
 
1562
		EXP b = DEREF_exp(exp_hash_if_false_code(e));
-
 
1563
		c = copy_exp(c, type_bool, type_bool);
-
 
1564
		a = copy_exp(a, t1, t2);
1441
	    e = copy_compound_stmt ( e, t1, t2 ) ;
1565
		b = copy_exp(b, t1, t2);
-
 
1566
		MAKE_exp_hash_if (t2, c, a, b, e);
-
 
1567
		set_parent_stmt(a, e);
-
 
1568
		set_parent_stmt(b, e);
1442
	    break ;
1569
		break;
1443
	}
1570
	}
1444
	case exp_solve_stmt_tag : {
1571
	case exp_return_stmt_tag: {
1445
	    /* Solve statements */
1572
		/* Return statements */
1446
	    EXP a = DEREF_exp ( exp_solve_stmt_body ( e ) ) ;
1573
		EXP a = DEREF_exp(exp_return_stmt_value(e));
1447
	    a = copy_exp ( a, t1, t2 ) ;
1574
		EXP b = implicit_cast_exp(a);
1448
	    MAKE_exp_solve_stmt ( t2, a, e ) ;
-
 
1449
	    CONS_exp ( e, all_solve_stmts, all_solve_stmts ) ;
-
 
1450
	    set_parent_stmt ( a, e ) ;
-
 
1451
	    break ;
-
 
1452
	}
-
 
1453
	case exp_decl_stmt_tag : {
1575
		if (!IS_NULL_exp(b)) {
1454
	    /* Declaration statements */
-
 
1455
	    IDENTIFIER id = DEREF_id ( exp_decl_stmt_id ( e ) ) ;
-
 
1456
	    IDENTIFIER aid = DEREF_id ( id_alias ( id ) ) ;
-
 
1457
	    IDENTIFIER cid = copy_local ( id ) ;
1576
			IDENTIFIER lab = NULL_id;
1458
	    EXP a = DEREF_exp ( exp_decl_stmt_body ( e ) ) ;
-
 
1459
	    a = copy_exp ( a, t1, t2 ) ;
-
 
1460
	    MAKE_exp_decl_stmt ( t2, cid, a, e ) ;
-
 
1461
	    set_parent_stmt ( a, e ) ;
-
 
1462
	    COPY_id ( id_alias ( id ), aid ) ;
-
 
1463
	    break ;
-
 
1464
	}
-
 
1465
	case exp_if_stmt_tag : {
-
 
1466
	    /* Conditional statements */
-
 
1467
	    EXP c = DEREF_exp ( exp_if_stmt_cond ( e ) ) ;
-
 
1468
	    EXP a = DEREF_exp ( exp_if_stmt_true_code ( e ) ) ;
-
 
1469
	    EXP b = DEREF_exp ( exp_if_stmt_false_code ( e ) ) ;
-
 
1470
	    IDENTIFIER lab = DEREF_id ( exp_if_stmt_label ( e ) ) ;
-
 
1471
	    c = copy_exp ( c, type_bool, type_bool ) ;
-
 
1472
	    lab = copy_label ( lab, 1 ) ;
-
 
1473
	    a = copy_exp ( a, t1, t2 ) ;
-
 
1474
	    b = copy_exp ( b, t1, t2 ) ;
1577
			b = copy_exp(b, t1, t2);
1475
	    MAKE_exp_if_stmt ( t2, c, a, b, lab, e ) ;
1578
			a = find_return_exp(b, &lab, lex_return);
1476
	    set_parent_stmt ( a, e ) ;
-
 
1477
	    set_parent_stmt ( b, e ) ;
-
 
1478
	    break ;
1579
		} else {
1479
	}
-
 
1480
	case exp_while_stmt_tag : {
-
 
1481
	    /* While statements */
-
 
1482
	    LIST ( IDENTIFIER ) pids ;
-
 
1483
	    EXP c = DEREF_exp ( exp_while_stmt_cond ( e ) ) ;
-
 
1484
	    EXP a = DEREF_exp ( exp_while_stmt_body ( e ) ) ;
-
 
1485
	    IDENTIFIER blab = DEREF_id ( exp_while_stmt_break_lab ( e ) ) ;
-
 
1486
	    IDENTIFIER clab = DEREF_id ( exp_while_stmt_cont_lab ( e ) ) ;
-
 
1487
	    IDENTIFIER llab = DEREF_id ( exp_while_stmt_loop_lab ( e ) ) ;
-
 
1488
	    c = copy_exp ( c, type_bool, type_bool ) ;
-
 
1489
	    blab = copy_label ( blab, 1 ) ;
-
 
1490
	    clab = copy_label ( clab, 1 ) ;
-
 
1491
	    llab = copy_label ( llab, 1 ) ;
-
 
1492
	    pids = DEREF_list ( exp_while_stmt_cond_id ( e ) ) ;
-
 
1493
	    a = copy_exp ( a, t1, t2 ) ;
1580
			a = copy_exp(a, t1, t2);
1494
	    MAKE_exp_while_stmt ( t2, c, blab, clab, llab, e ) ;
-
 
1495
	    COPY_exp ( exp_while_stmt_body ( e ), a ) ;
-
 
1496
	    set_jump_joins ( blab, e ) ;
-
 
1497
	    set_jump_joins ( clab, e ) ;
-
 
1498
	    set_parent_stmt ( a, e ) ;
-
 
1499
	    if ( !IS_NULL_list ( pids ) ) {
-
 
1500
		LIST ( IDENTIFIER ) qids = NULL_list ( IDENTIFIER ) ;
-
 
1501
		while ( !IS_NULL_list ( pids ) ) {
-
 
1502
		    IDENTIFIER id = DEREF_id ( HEAD_list ( pids ) ) ;
-
 
1503
		    id = DEREF_id ( id_alias ( id ) ) ;
-
 
1504
		    CONS_id ( id, qids, qids ) ;
-
 
1505
		    pids = TAIL_list ( pids ) ;
-
 
1506
		}
1581
		}
1507
		qids = REVERSE_list ( qids ) ;
-
 
1508
		COPY_list ( exp_while_stmt_cond_id ( e ), qids ) ;
-
 
1509
	    }
-
 
1510
	    break ;
-
 
1511
	}
-
 
1512
	case exp_do_stmt_tag : {
-
 
1513
	    /* Do statements */
-
 
1514
	    EXP c = DEREF_exp ( exp_do_stmt_cond ( e ) ) ;
-
 
1515
	    EXP a = DEREF_exp ( exp_do_stmt_body ( e ) ) ;
-
 
1516
	    IDENTIFIER blab = DEREF_id ( exp_do_stmt_break_lab ( e ) ) ;
-
 
1517
	    IDENTIFIER clab = DEREF_id ( exp_do_stmt_cont_lab ( e ) ) ;
-
 
1518
	    IDENTIFIER llab = DEREF_id ( exp_do_stmt_loop_lab ( e ) ) ;
-
 
1519
	    blab = copy_label ( blab, 1 ) ;
-
 
1520
	    clab = copy_label ( clab, 1 ) ;
-
 
1521
	    llab = copy_label ( llab, 1 ) ;
-
 
1522
	    a = copy_exp ( a, t1, t2 ) ;
-
 
1523
	    c = copy_exp ( c, type_bool, type_bool ) ;
-
 
1524
	    MAKE_exp_do_stmt ( t2, c, blab, clab, llab, e ) ;
-
 
1525
	    COPY_exp ( exp_do_stmt_body ( e ), a ) ;
-
 
1526
	    set_jump_joins ( blab, e ) ;
-
 
1527
	    set_jump_joins ( clab, e ) ;
-
 
1528
	    set_parent_stmt ( a, e ) ;
1582
		MAKE_exp_return_stmt(t2, a, e);
1529
	    break ;
1583
		break;
1530
	}
1584
	}
1531
	case exp_switch_stmt_tag : {
1585
	case exp_goto_stmt_tag: {
1532
	    /* Switch statements */
1586
		/* Goto statements */
-
 
1587
		IDENTIFIER lab = DEREF_id(exp_goto_stmt_label(e));
-
 
1588
		lab = copy_label(lab, 0);
1533
	    e = copy_switch_stmt ( e, t1, t2 ) ;
1589
		e = make_jump_stmt(lab, NULL_exp);
1534
	    break ;
1590
		break;
1535
	}
1591
	}
1536
	case exp_hash_if_tag : {
1592
	case exp_label_stmt_tag: {
1537
	    /* Target dependent conditional statements */
1593
		/* Labelled statements */
1538
	    EXP c = DEREF_exp ( exp_hash_if_cond ( e ) ) ;
-
 
1539
	    EXP a = DEREF_exp ( exp_hash_if_true_code ( e ) ) ;
1594
		IDENTIFIER lab = DEREF_id(exp_label_stmt_label(e));
1540
	    EXP b = DEREF_exp ( exp_hash_if_false_code ( e ) ) ;
-
 
1541
	    c = copy_exp ( c, type_bool, type_bool ) ;
-
 
1542
	    a = copy_exp ( a, t1, t2 ) ;
-
 
1543
	    b = copy_exp ( b, t1, t2 ) ;
1595
		lab = copy_label(lab, 1);
1544
	    MAKE_exp_hash_if ( t2, c, a, b, e ) ;
-
 
1545
	    set_parent_stmt ( a, e ) ;
1596
		e = DEREF_exp(id_label_stmt(lab));
1546
	    set_parent_stmt ( b, e ) ;
-
 
1547
	    break ;
1597
		break;
1548
	}
1598
	}
-
 
1599
#if LANGUAGE_CPP
1549
	case exp_return_stmt_tag : {
1600
	case exp_try_block_tag: {
1550
	    /* Return statements */
1601
		/* Try blocks */
1551
	    EXP a = DEREF_exp ( exp_return_stmt_value ( e ) ) ;
1602
		e = copy_try_stmt(e, t1, t2);
-
 
1603
		break;
-
 
1604
	}
-
 
1605
	case exp_handler_tag: {
1552
	    EXP b = implicit_cast_exp ( a ) ;
1606
		/* Exception handlers */
1553
	    if ( !IS_NULL_exp ( b ) ) {
1607
		IDENTIFIER id = DEREF_id(exp_handler_except(e));
1554
		IDENTIFIER lab = NULL_id ;
1608
		IDENTIFIER aid = DEREF_id(id_alias(id));
1555
		b = copy_exp ( b, t1, t2 ) ;
1609
		IDENTIFIER cid = copy_local(id);
1556
		a = find_return_exp ( b, &lab, lex_return ) ;
1610
		EXP a = DEREF_exp(exp_handler_body(e));
1557
	    } else {
-
 
1558
		a = copy_exp ( a, t1, t2 ) ;
1611
		a = copy_exp(a, t1, t2);
1559
	    }
1612
		MAKE_exp_handler(t2, cid, a, e);
1560
	    MAKE_exp_return_stmt ( t2, a, e ) ;
1613
		set_parent_stmt(a, e);
-
 
1614
		COPY_id(id_alias(id), aid);
1561
	    break ;
1615
		break;
1562
	}
1616
	}
1563
	case exp_goto_stmt_tag : {
1617
	case exp_exception_tag: {
1564
	    /* Goto statements */
1618
		/* Exception expressions */
1565
	    IDENTIFIER lab = DEREF_id ( exp_goto_stmt_label ( e ) ) ;
1619
		EXP a = DEREF_exp(exp_exception_arg(e));
1566
	    lab = copy_label ( lab, 0 ) ;
1620
		EXP b = DEREF_exp(exp_exception_size(e));
1567
	    e = make_jump_stmt ( lab, NULL_exp ) ;
1621
		EXP c = DEREF_exp(exp_exception_destr(e));
1568
	    break ;
-
 
1569
	}
-
 
1570
	case exp_label_stmt_tag : {
-
 
1571
	    /* Labelled statements */
-
 
1572
	    IDENTIFIER lab = DEREF_id ( exp_label_stmt_label ( e ) ) ;
1622
		int expl = DEREF_int(exp_exception_expl(e));
1573
	    lab = copy_label ( lab, 1 ) ;
1623
		a = copy_exp(a, t1, t2);
1574
	    e = DEREF_exp ( id_label_stmt ( lab ) ) ;
1624
		b = copy_exp(b, t1, t2);
1575
	    break ;
-
 
1576
	}
-
 
1577
#if LANGUAGE_CPP
-
 
1578
	case exp_try_block_tag : {
1625
		c = copy_exp(c, t1, t2);
1579
	    /* Try blocks */
-
 
1580
	    e = copy_try_stmt ( e, t1, t2 ) ;
1626
		MAKE_exp_exception(t2, a, b, c, expl, e);
1581
	    break ;
1627
		break;
1582
	}
1628
	}
1583
	case exp_handler_tag : {
-
 
1584
	    /* Exception handlers */
-
 
1585
	    IDENTIFIER id = DEREF_id ( exp_handler_except ( e ) ) ;
-
 
1586
	    IDENTIFIER aid = DEREF_id ( id_alias ( id ) ) ;
-
 
1587
	    IDENTIFIER cid = copy_local ( id ) ;
-
 
1588
	    EXP a = DEREF_exp ( exp_handler_body ( e ) ) ;
-
 
1589
	    a = copy_exp ( a, t1, t2 ) ;
-
 
1590
	    MAKE_exp_handler ( t2, cid, a, e ) ;
-
 
1591
	    set_parent_stmt ( a, e ) ;
-
 
1592
	    COPY_id ( id_alias ( id ), aid ) ;
-
 
1593
	    break ;
-
 
1594
	}
-
 
1595
	case exp_exception_tag : {
-
 
1596
	    /* Exception expressions */
-
 
1597
	    EXP a = DEREF_exp ( exp_exception_arg ( e ) ) ;
-
 
1598
	    EXP b = DEREF_exp ( exp_exception_size ( e ) ) ;
-
 
1599
	    EXP c = DEREF_exp ( exp_exception_destr ( e ) ) ;
-
 
1600
	    int expl = DEREF_int ( exp_exception_expl ( e ) ) ;
-
 
1601
	    a = copy_exp ( a, t1, t2 ) ;
-
 
1602
	    b = copy_exp ( b, t1, t2 ) ;
-
 
1603
	    c = copy_exp ( c, t1, t2 ) ;
-
 
1604
	    MAKE_exp_exception ( t2, a, b, c, expl, e ) ;
-
 
1605
	    break ;
-
 
1606
	}
-
 
1607
	case exp_thrown_tag : {
1629
	case exp_thrown_tag: {
1608
	    /* Thrown expressions */
1630
		/* Thrown expressions */
1609
	    int d = DEREF_int ( exp_thrown_done ( e ) ) ;
1631
		int d = DEREF_int(exp_thrown_done(e));
1610
	    MAKE_exp_thrown ( t2, d, e ) ;
1632
		MAKE_exp_thrown(t2, d, e);
1611
	    break ;
1633
		break;
1612
	}
1634
	}
1613
#endif
1635
#endif
1614
	case exp_op_tag : {
1636
	case exp_op_tag: {
1615
	    /* Undetermined expressions */
1637
		/* Undetermined expressions */
1616
	    int op = DEREF_int ( exp_op_lex ( e ) ) ;
1638
		int op = DEREF_int(exp_op_lex(e));
1617
	    EXP a = DEREF_exp ( exp_op_arg1 ( e ) ) ;
1639
		EXP a = DEREF_exp(exp_op_arg1(e));
1618
	    EXP b = DEREF_exp ( exp_op_arg2 ( e ) ) ;
1640
		EXP b = DEREF_exp(exp_op_arg2(e));
1619
	    if ( IS_NULL_exp ( b ) ) {
1641
		if (IS_NULL_exp(b)) {
1620
		e = apply_unary ( op, a, t1, t2, 1 ) ;
1642
			e = apply_unary(op, a, t1, t2, 1);
1621
	    } else {
1643
		} else {
1622
		e = apply_binary ( op, a, b, t1, t2, 1 ) ;
1644
			e = apply_binary(op, a, b, t1, t2, 1);
1623
	    }
1645
		}
1624
	    break ;
1646
		break;
1625
	}
1647
	}
1626
	case exp_opn_tag : {
1648
	case exp_opn_tag: {
1627
	    /* Undetermined expressions */
1649
		/* Undetermined expressions */
1628
	    int op = DEREF_int ( exp_opn_lex ( e ) ) ;
1650
		int op = DEREF_int(exp_opn_lex(e));
1629
	    LIST ( EXP ) args = DEREF_list ( exp_opn_args ( e ) ) ;
1651
		LIST(EXP)args = DEREF_list(exp_opn_args(e));
1630
	    e = apply_nary ( op, args, t1, t2, 1 ) ;
1652
		e = apply_nary(op, args, t1, t2, 1);
1631
	    break ;
1653
		break;
1632
	}
1654
	}
1633
	case exp_assembler_tag : {
1655
	case exp_assembler_tag: {
1634
	    /* Assembler expressions */
1656
		/* Assembler expressions */
1635
	    STRING op = DEREF_str ( exp_assembler_op ( e ) ) ;
1657
		STRING op = DEREF_str(exp_assembler_op(e));
1636
	    LIST ( EXP ) args = DEREF_list ( exp_assembler_args ( e ) ) ;
1658
		LIST(EXP)args = DEREF_list(exp_assembler_args(e));
1637
	    args = copy_exp_list ( args, t1, t2 ) ;
1659
		args = copy_exp_list(args, t1, t2);
1638
	    MAKE_exp_assembler ( t2, op, args, e ) ;
1660
		MAKE_exp_assembler(t2, op, args, e);
1639
	    break ;
1661
		break;
1640
	}
1662
	}
1641
	case exp_uncompiled_tag : {
1663
	case exp_uncompiled_tag: {
1642
	    /* Uncompiled expressions */
1664
		/* Uncompiled expressions */
1643
	    PPTOKEN *p = DEREF_pptok ( exp_uncompiled_defn ( e ) ) ;
1665
		PPTOKEN *p = DEREF_pptok(exp_uncompiled_defn(e));
1644
	    DEREF_loc ( exp_uncompiled_start ( e ), crt_loc ) ;
1666
		DEREF_loc(exp_uncompiled_start(e), crt_loc);
1645
	    MAKE_exp_uncompiled ( t2, crt_loc, p, e ) ;
1667
		MAKE_exp_uncompiled(t2, crt_loc, p, e);
1646
	    break ;
1668
		break;
1647
	}
1669
	}
1648
	case exp_location_tag : {
1670
	case exp_location_tag: {
1649
	    /* Location expressions */
1671
		/* Location expressions */
1650
	    EXP a = DEREF_exp ( exp_location_arg ( e ) ) ;
1672
		EXP a = DEREF_exp(exp_location_arg(e));
1651
	    a = copy_exp ( a, t1, t2 ) ;
1673
		a = copy_exp(a, t1, t2);
1652
	    DEREF_loc ( exp_location_end ( e ), crt_loc ) ;
1674
		DEREF_loc(exp_location_end(e), crt_loc);
1653
	    MAKE_exp_location ( t2, crt_loc, a, e ) ;
1675
		MAKE_exp_location(t2, crt_loc, a, e);
1654
	    break ;
1676
		break;
1655
	}
1677
	}
1656
	case exp_fail_tag : {
1678
	case exp_fail_tag: {
1657
	    /* Installer error expressions */
1679
		/* Installer error expressions */
1658
	    string msg = DEREF_string ( exp_fail_msg ( e ) ) ;
1680
		string msg = DEREF_string(exp_fail_msg(e));
1659
	    MAKE_exp_fail ( t2, msg, e ) ;
1681
		MAKE_exp_fail(t2, msg, e);
-
 
1682
		break;
-
 
1683
	}
-
 
1684
	case exp_dummy_tag: {
-
 
1685
		/* Dummy expressions */
-
 
1686
		e = copy_dummy_exp(e, t1, t2);
1660
	    break ;
1687
		break;
1661
	}
1688
	}
1662
	case exp_dummy_tag : {
1689
	case exp_token_tag: {
1663
	    /* Dummy expressions */
1690
		/* Expression tokens */
1664
	    e = copy_dummy_exp ( e, t1, t2 ) ;
1691
		e = expand_exp(e, 1, 0);
1665
	    break ;
1692
		break;
1666
	}
1693
	}
1667
	case exp_token_tag : {
-
 
1668
	    /* Expression tokens */
-
 
1669
	    e = expand_exp ( e, 1, 0 ) ;
-
 
1670
	    break ;
-
 
1671
	}
1694
	}
1672
    }
-
 
1673
    return ( e ) ;
1695
	return (e);
1674
}
1696
}
1675
 
1697
 
1676
 
1698
 
1677
/*
1699
/*
1678
    EVALUATE A CONSTANT EXPRESSION
1700
    EVALUATE A CONSTANT EXPRESSION
1679
 
1701
 
1680
    This routine evaluates the integer constant expression e, expanding
1702
    This routine evaluates the integer constant expression e, expanding
1681
    any template parameters and tokens.  If ch is true then any character
1703
    any template parameters and tokens.  If ch is true then any character
1682
    literals are replaced by their ASCII values.
1704
    literals are replaced by their ASCII values.
1860
    COPY AN OBJECT FUNCTION DEFINITION
1892
    COPY AN OBJECT FUNCTION DEFINITION
1861
 
1893
 
1862
    This defines the object id to be a copy of the expression e.  It
1894
    This defines the object id to be a copy of the expression e.  It
1863
    is used in the instantiation of template functions and static data
1895
    is used in the instantiation of template functions and static data
1864
    members of template classes.
1896
    members of template classes.
1865
*/
1897
*/
1866
 
1898
 
1867
void copy_object
1899
void
1868
    PROTO_N ( ( id, e ) )
-
 
1869
    PROTO_T ( IDENTIFIER id X EXP e )
1900
copy_object(IDENTIFIER id, EXP e)
1870
{
1901
{
1871
    if ( !IS_NULL_exp ( e ) ) {
1902
	if (!IS_NULL_exp(e)) {
1872
	int r = record_location ;
1903
		int r = record_location;
1873
	record_location = 0 ;
1904
		record_location = 0;
1874
	begin_declarator ( id, qual_none, NULL_nspace, 0 ) ;
1905
		begin_declarator(id, qual_none, NULL_nspace, 0);
1875
	switch ( TAG_id ( id ) ) {
1906
		switch (TAG_id(id)) {
1876
	    case id_function_tag :
1907
		case id_function_tag:
1877
	    case id_mem_func_tag :
1908
		case id_mem_func_tag:
1878
	    case id_stat_mem_func_tag : {
1909
		case id_stat_mem_func_tag: {
1879
		/* Functions */
1910
			/* Functions */
1880
		TYPE fn = DEREF_type ( id_function_etc_type ( id ) ) ;
1911
			TYPE fn = DEREF_type(id_function_etc_type(id));
1881
		in_function_defn++ ;
1912
			in_function_defn++;
1882
		really_in_function_defn++ ;
1913
			really_in_function_defn++;
1883
		IGNORE begin_templ_scope ( fn ) ;
1914
			IGNORE begin_templ_scope(fn);
1884
		begin_function ( id ) ;
1915
			begin_function(id);
1885
		e = copy_exp ( e, type_bottom, type_bottom ) ;
1916
			e = copy_exp(e, type_bottom, type_bottom);
1886
		IGNORE pop_namespace () ;
1917
			IGNORE pop_namespace();
1887
		unreached_code = 1 ;
1918
			unreached_code = 1;
1888
		IGNORE end_function ( id, e ) ;
1919
			IGNORE end_function(id, e);
1889
		end_templ_scope ( fn ) ;
1920
			end_templ_scope(fn);
1890
		really_in_function_defn-- ;
1921
			really_in_function_defn--;
1891
		in_function_defn-- ;
1922
			in_function_defn--;
1892
		break ;
1923
			break;
1893
	    }
1924
		}
1894
	    case id_stat_member_tag : {
1925
		case id_stat_member_tag: {
1895
		/* Static data members */
1926
			/* Static data members */
1896
		copy_variable ( id, e ) ;
1927
			copy_variable(id, e);
1897
		if ( !in_template_decl ) {
1928
			if (!in_template_decl) {
1898
		    compile_variable ( id, 0 ) ;
1929
				compile_variable(id, 0);
1899
		}
1930
			}
-
 
1931
			if (do_dump) {
1900
		if ( do_dump ) dump_declare ( id, &crt_loc, 1 ) ;
1932
				dump_declare(id, &crt_loc, 1);
1901
		break ;
-
 
1902
	    }
1933
			}
1903
	    case id_class_name_tag : {
-
 
1904
		/* Nested template classes */
-
 
1905
		CLASS_TYPE ct, cs ;
1934
			break;
1906
		TYPE t = DEREF_type ( id_class_name_defn ( id ) ) ;
-
 
1907
		TYPE s = DEREF_type ( exp_type ( e ) ) ;
-
 
1908
		while ( IS_type_templ ( t ) ) {
-
 
1909
		    t = DEREF_type ( type_templ_defn ( t ) ) ;
-
 
1910
		}
1935
		}
-
 
1936
		case id_class_name_tag: {
-
 
1937
			/* Nested template classes */
-
 
1938
			CLASS_TYPE ct, cs;
-
 
1939
			TYPE t = DEREF_type(id_class_name_defn(id));
-
 
1940
			TYPE s = DEREF_type(exp_type(e));
-
 
1941
			while (IS_type_templ(t)) {
-
 
1942
				t = DEREF_type(type_templ_defn(t));
-
 
1943
			}
1911
		ct = DEREF_ctype ( type_compound_defn ( t ) ) ;
1944
			ct = DEREF_ctype(type_compound_defn(t));
1912
		while ( IS_type_templ ( s ) ) {
1945
			while (IS_type_templ(s)) {
1913
		    s = DEREF_type ( type_templ_defn ( s ) ) ;
1946
				s = DEREF_type(type_templ_defn(s));
-
 
1947
			}
-
 
1948
			cs = DEREF_ctype(type_compound_defn(s));
-
 
1949
			copy_members(ct, cs, cinfo_none, 1);
-
 
1950
			break;
1914
		}
1951
		}
1915
		cs = DEREF_ctype ( type_compound_defn ( s ) ) ;
-
 
-
 
1952
		}
1916
		copy_members ( ct, cs, cinfo_none, 1 ) ;
1953
		end_declarator(id, 0);
1917
		break ;
1954
		record_location = r;
1918
	    }
-
 
1919
	}
1955
	}
1920
	end_declarator ( id, 0 ) ;
-
 
1921
	record_location = r ;
-
 
1922
    }
-
 
1923
    return ;
1956
	return;
1924
}
1957
}
1925
 
1958
 
1926
 
1959
 
1927
/*
1960
/*
1928
    CHECK FOR NON-CLASS NAMESPACES
1961
    CHECK FOR NON-CLASS NAMESPACES
1929
 
1962
 
1930
    Qualifiers of the form 'T::' where T is a template parameter can lead
1963
    Qualifiers of the form 'T::' where T is a template parameter can lead
1931
    to repeated errors if T is bound to a non-class type.  This routine
1964
    to repeated errors if T is bound to a non-class type.  This routine
1932
    is used to keep track of those instances which have been reported
1965
    is used to keep track of those instances which have been reported
1933
    to avoid duplication.
1966
    to avoid duplication.
1934
*/
1967
*/
1935
 
1968
 
1936
static int reported_nspace
1969
static int
1937
    PROTO_N ( ( ns, t ) )
-
 
1938
    PROTO_T ( NAMESPACE ns X TYPE t )
1970
reported_nspace(NAMESPACE ns, TYPE t)
1939
{
1971
{
1940
    static LIST ( TYPE ) types = NULL_list ( TYPE ) ;
1972
	static LIST(TYPE)types = NULL_list(TYPE);
1941
    static LIST ( NAMESPACE ) nspaces = NULL_list ( NAMESPACE ) ;
1973
	static LIST(NAMESPACE)nspaces = NULL_list(NAMESPACE);
1942
    LIST ( TYPE ) p = types ;
1974
	LIST(TYPE)p = types;
1943
    LIST ( NAMESPACE ) q = nspaces ;
1975
	LIST(NAMESPACE)q = nspaces;
1944
    while ( !IS_NULL_list ( q ) ) {
1976
	while (!IS_NULL_list(q)) {
1945
	NAMESPACE pns = DEREF_nspace ( HEAD_list ( q ) ) ;
1977
		NAMESPACE pns = DEREF_nspace(HEAD_list(q));
1946
	if ( EQ_nspace ( pns, ns ) ) {
1978
		if (EQ_nspace(pns, ns)) {
1947
	    TYPE pt = DEREF_type ( HEAD_list ( p ) ) ;
1979
			TYPE pt = DEREF_type(HEAD_list(p));
1948
	    if ( eq_type ( pt, t ) ) return ( 1 ) ;
1980
			if (eq_type(pt, t)) {
-
 
1981
				return (1);
-
 
1982
			}
-
 
1983
		}
-
 
1984
		p = TAIL_list(p);
-
 
1985
		q = TAIL_list(q);
1949
	}
1986
	}
1950
	p = TAIL_list ( p ) ;
-
 
1951
	q = TAIL_list ( q ) ;
-
 
1952
    }
-
 
1953
    CONS_type ( t, types, types ) ;
1987
	CONS_type(t, types, types);
1954
    CONS_nspace ( ns, nspaces, nspaces ) ;
1988
	CONS_nspace(ns, nspaces, nspaces);
1955
    return ( 0 ) ;
1989
	return (0);
1956
}
1990
}
1957
 
1991
 
1958
 
1992
 
1959
/*
1993
/*
1960
    EXPAND A NAMESPACE
1994
    EXPAND A NAMESPACE
1961
 
1995
 
1962
    This routine expands the namespace ns by replacing any class namespace
1996
    This routine expands the namespace ns by replacing any class namespace
1963
    by the namespace of the expanded class.
1997
    by the namespace of the expanded class.
1964
*/
1998
*/
1965
 
1999
 
1966
NAMESPACE rescan_nspace
2000
NAMESPACE
1967
    PROTO_N ( ( ns ) )
-
 
1968
    PROTO_T ( NAMESPACE ns )
2001
rescan_nspace(NAMESPACE ns)
1969
{
2002
{
1970
    if ( !IS_NULL_nspace ( ns ) && IS_nspace_ctype ( ns ) ) {
2003
	if (!IS_NULL_nspace(ns) && IS_nspace_ctype(ns)) {
1971
	TYPE s ;
2004
		TYPE s;
1972
	IDENTIFIER tid = DEREF_id ( nspace_name ( ns ) ) ;
2005
		IDENTIFIER tid = DEREF_id(nspace_name(ns));
1973
	TYPE t = DEREF_type ( id_class_name_etc_defn ( tid ) ) ;
2006
		TYPE t = DEREF_type(id_class_name_etc_defn(tid));
1974
	while ( IS_type_templ ( t ) ) {
2007
		while (IS_type_templ(t)) {
1975
	    t = DEREF_type ( type_templ_defn ( t ) ) ;
2008
			t = DEREF_type(type_templ_defn(t));
1976
	}
2009
		}
1977
	s = expand_type ( t, 1 ) ;
2010
		s = expand_type(t, 1);
1978
	if ( !EQ_type ( t, s ) ) {
2011
		if (!EQ_type(t, s)) {
1979
	    unsigned tag = TAG_type ( s ) ;
2012
			unsigned tag = TAG_type(s);
1980
	    while ( tag == type_templ_tag ) {
2013
			while (tag == type_templ_tag) {
1981
		s = DEREF_type ( type_templ_defn ( s ) ) ;
2014
				s = DEREF_type(type_templ_defn(s));
1982
		tag = TAG_type ( s ) ;
2015
				tag = TAG_type(s);
1983
	    }
2016
			}
1984
	    if ( tag == type_compound_tag ) {
2017
			if (tag == type_compound_tag) {
1985
		/* Expands to class type */
2018
				/* Expands to class type */
-
 
2019
				CLASS_TYPE cs =
1986
		CLASS_TYPE cs = DEREF_ctype ( type_compound_defn ( s ) ) ;
2020
				    DEREF_ctype(type_compound_defn(s));
1987
		complete_class ( cs, 1 ) ;
2021
				complete_class(cs, 1);
1988
		ns = DEREF_nspace ( ctype_member ( cs ) ) ;
2022
				ns = DEREF_nspace(ctype_member(cs));
1989
	    } else if ( tag == type_token_tag && is_templ_type ( s ) ) {
2023
			} else if (tag == type_token_tag && is_templ_type(s)) {
1990
		/* Allow template parameters */
2024
				/* Allow template parameters */
1991
		IDENTIFIER id = DEREF_id ( type_token_tok ( s ) ) ;
2025
				IDENTIFIER id = DEREF_id(type_token_tok(s));
1992
		CLASS_TYPE cs = find_class ( id ) ;
2026
				CLASS_TYPE cs = find_class(id);
1993
		if ( !IS_NULL_ctype ( cs ) ) {
2027
				if (!IS_NULL_ctype(cs)) {
1994
		    ns = DEREF_nspace ( ctype_member ( cs ) ) ;
2028
					ns = DEREF_nspace(ctype_member(cs));
1995
		}
2029
				}
1996
	    } else {
2030
			} else {
-
 
2031
				if (tag != type_error_tag &&
1997
		if ( tag != type_error_tag && !reported_nspace ( ns, s ) ) {
2032
				    !reported_nspace(ns, s)) {
1998
		    /* Other types are not allowed */
2033
					/* Other types are not allowed */
-
 
2034
					report(crt_loc,
1999
		    report ( crt_loc, ERR_temp_res_nspace ( ns, s ) ) ;
2035
					       ERR_temp_res_nspace(ns, s));
2000
		}
2036
				}
2001
	    }
2037
			}
2002
	}
2038
		}
2003
    }
2039
	}
2004
    return ( ns ) ;
2040
	return (ns);
2005
}
2041
}
2006
 
2042
 
2007
 
2043
 
2008
/*
2044
/*
2009
    RESCAN AN IDENTIFIER NAME
2045
    RESCAN AN IDENTIFIER NAME
2010
 
2046
 
2011
    This routine looks up the identifier id again in the current context.
2047
    This routine looks up the identifier id again in the current context.
2012
    The name is looked up as a type-name if type is true.  The routine is
2048
    The name is looked up as a type-name if type is true.  The routine is
2013
    used in the resolution of dependent names in template instantiations.
2049
    used in the resolution of dependent names in template instantiations.
2014
*/
2050
*/
2015
 
2051
 
2016
IDENTIFIER rescan_id
2052
IDENTIFIER
2017
    PROTO_N ( ( id, qual, type ) )
-
 
2018
    PROTO_T ( IDENTIFIER id X QUALIFIER qual X int type )
2053
rescan_id(IDENTIFIER id, QUALIFIER qual, int type)
2019
{
2054
{
2020
    DECL_SPEC ds ;
2055
	DECL_SPEC ds;
2021
    int member = 0 ;
2056
	int member = 0;
2022
    IDENTIFIER rid = NULL_id ;
2057
	IDENTIFIER rid = NULL_id;
2023
    HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
2058
	HASHID nm = DEREF_hashid(id_name(id));
2024
    NAMESPACE ns = DEREF_nspace ( id_parent ( id ) ) ;
2059
	NAMESPACE ns = DEREF_nspace(id_parent(id));
2025
 
2060
 
2026
    /* Allow for pseudo-template instances */
2061
	/* Allow for pseudo-template instances */
2027
    if ( IS_id_undef ( id ) ) {
2062
	if (IS_id_undef(id)) {
2028
	TYPE form = DEREF_type ( id_undef_form ( id ) ) ;
2063
		TYPE form = DEREF_type(id_undef_form(id));
2029
	if ( !IS_NULL_type ( form ) && IS_type_token ( form ) ) {
2064
		if (!IS_NULL_type(form) && IS_type_token(form)) {
2030
	    int force = 0 ;
2065
			int force = 0;
2031
	    IDENTIFIER tid = DEREF_id ( type_token_tok ( form ) ) ;
2066
			IDENTIFIER tid = DEREF_id(type_token_tok(form));
2032
	    LIST ( TOKEN ) args = DEREF_list ( type_token_args ( form ) ) ;
2067
			LIST(TOKEN)args = DEREF_list(type_token_args(form));
2033
	    tid = rescan_id ( tid, qual, type ) ;
2068
			tid = rescan_id(tid, qual, type);
2034
	    if ( IS_id_undef ( tid ) ) force = 1 ;
2069
			if (IS_id_undef(tid)) {
-
 
2070
				force = 1;
-
 
2071
			}
2035
	    args = expand_args ( args, 1, 1 ) ;
2072
			args = expand_args(args, 1, 1);
2036
	    rid = apply_template ( tid, args, 0, force ) ;
2073
			rid = apply_template(tid, args, 0, force);
2037
	    return ( rid ) ;
2074
			return (rid);
2038
	}
2075
		}
2039
    }
2076
	}
2040
 
2077
 
2041
    /* Allow for template instances */
2078
	/* Allow for template instances */
2042
    ds = DEREF_dspec ( id_storage ( id ) ) ;
2079
	ds = DEREF_dspec(id_storage(id));
2043
    if ( ds & dspec_instance ) {
2080
	if (ds & dspec_instance) {
2044
	if ( IS_id_function_etc ( id ) ) {
2081
		if (IS_id_function_etc(id)) {
2045
	    /* Template functions */
2082
			/* Template functions */
2046
	    TYPE form = DEREF_type ( id_function_etc_form ( id ) ) ;
2083
			TYPE form = DEREF_type(id_function_etc_form(id));
2047
	    if ( !IS_NULL_type ( form ) && IS_type_token ( form ) ) {
2084
			if (!IS_NULL_type(form) && IS_type_token(form)) {
2048
		IDENTIFIER tid = DEREF_id ( type_token_tok ( form ) ) ;
2085
				IDENTIFIER tid = DEREF_id(type_token_tok(form));
2049
		if ( IS_id_function_etc ( tid ) ) {
2086
				if (IS_id_function_etc(tid)) {
2050
		    LIST ( TOKEN ) args ;
2087
					LIST(TOKEN)args;
2051
		    tid = rescan_id ( tid, qual, type ) ;
2088
					tid = rescan_id(tid, qual, type);
-
 
2089
					args =
2052
		    args = DEREF_list ( type_token_args ( form ) ) ;
2090
					    DEREF_list(type_token_args(form));
2053
		    args = expand_args ( args, 1, 1 ) ;
2091
					args = expand_args(args, 1, 1);
2054
		    rid = apply_template ( tid, args, 0, 0 ) ;
2092
					rid = apply_template(tid, args, 0, 0);
2055
		    return ( rid ) ;
2093
					return (rid);
2056
		}
2094
				}
2057
	    }
-
 
2058
	}
-
 
2059
    }
-
 
2060
 
-
 
2061
    /* Look up identifier */
-
 
2062
    nm = expand_name ( nm, NULL_ctype ) ;
-
 
2063
    if ( !IS_NULL_nspace ( ns ) ) {
-
 
2064
	if ( qual != qual_none ) {
-
 
2065
	    member = 1 ;
-
 
2066
	} else if ( IS_nspace_ctype ( ns ) && !IS_id_undef ( id ) ) {
-
 
2067
	    member = 1 ;
-
 
2068
	}
2095
			}
2069
    }
-
 
2070
    if ( member ) {
-
 
2071
	/* Expand namespace */
-
 
2072
	NAMESPACE cns = rescan_nspace ( ns ) ;
-
 
2073
	if ( IS_nspace_ctype ( cns ) ) {
-
 
2074
	    rid = search_field ( cns, nm, 0, type ) ;
-
 
2075
	} else {
-
 
2076
	    MEMBER mem = search_member ( cns, nm, 0 ) ;
-
 
2077
	    if ( !IS_NULL_member ( mem ) ) {
-
 
2078
		if ( type ) {
-
 
2079
		    rid = type_member ( mem, type ) ;
-
 
2080
		} else {
-
 
2081
		    rid = DEREF_id ( member_id ( mem ) ) ;
-
 
2082
		}
2096
		}
2083
	    }
-
 
2084
	}
-
 
2085
 
-
 
2086
	/* Check for undeclared identifiers */
-
 
2087
	if ( IS_NULL_id ( rid ) ) {
-
 
2088
	    MAKE_id_undef ( nm, dspec_none, cns, crt_loc, rid ) ;
-
 
2089
	}
2097
	}
2090
 
2098
 
-
 
2099
	/* Look up identifier */
-
 
2100
	nm = expand_name(nm, NULL_ctype);
-
 
2101
	if (!IS_NULL_nspace(ns)) {
-
 
2102
		if (qual != qual_none) {
-
 
2103
			member = 1;
-
 
2104
		} else if (IS_nspace_ctype(ns) && !IS_id_undef(id)) {
-
 
2105
			member = 1;
-
 
2106
		}
-
 
2107
	}
-
 
2108
	if (member) {
-
 
2109
		/* Expand namespace */
-
 
2110
		NAMESPACE cns = rescan_nspace(ns);
-
 
2111
		if (IS_nspace_ctype(cns)) {
-
 
2112
			rid = search_field(cns, nm, 0, type);
-
 
2113
		} else {
-
 
2114
			MEMBER mem = search_member(cns, nm, 0);
-
 
2115
			if (!IS_NULL_member(mem)) {
-
 
2116
				if (type) {
-
 
2117
					rid = type_member(mem, type);
2091
    } else {
2118
				} else {
-
 
2119
					rid = DEREF_id(member_id(mem));
-
 
2120
				}
-
 
2121
			}
-
 
2122
		}
-
 
2123
 
-
 
2124
		/* Check for undeclared identifiers */
-
 
2125
		if (IS_NULL_id(rid)) {
-
 
2126
			MAKE_id_undef(nm, dspec_none, cns, crt_loc, rid);
-
 
2127
		}
-
 
2128
 
-
 
2129
	} else {
2092
	/* Simple name look-up */
2130
		/* Simple name look-up */
2093
	rid = find_id ( nm ) ;
2131
		rid = find_id(nm);
2094
    }
2132
	}
2095
    return ( rid ) ;
2133
	return (rid);
2096
}
2134
}
2097
 
2135
 
2098
 
2136
 
2099
/*
2137
/*
2100
    RESCAN A FUNCTION IDENTIFIER NAME
2138
    RESCAN A FUNCTION IDENTIFIER NAME
2101
 
2139
 
2102
    This routine is a special case of rescan_id which is used to look up
2140
    This routine is a special case of rescan_id which is used to look up
2103
    the names of functions in template instantiations.  If the look-ups
2141
    the names of functions in template instantiations.  If the look-ups
Line 2105... Line 2143...
2105
    instantiation are both functions then the result is an ambiguous
2143
    instantiation are both functions then the result is an ambiguous
2106
    identifier consisting of both sets of overloaded functions.
2144
    identifier consisting of both sets of overloaded functions.
2107
    Overload resolution is then used to select within these two sets.
2145
    Overload resolution is then used to select within these two sets.
2108
*/
2146
*/
2109
 
2147
 
2110
IDENTIFIER rescan_func_id
2148
IDENTIFIER
2111
    PROTO_N ( ( id, qual ) )
-
 
2112
    PROTO_T ( IDENTIFIER id X QUALIFIER qual )
2149
rescan_func_id(IDENTIFIER id, QUALIFIER qual)
2113
{
2150
{
2114
    IDENTIFIER pid = rescan_id ( id, qual, 0 ) ;
2151
	IDENTIFIER pid = rescan_id(id, qual, 0);
2115
    IDENTIFIER qid = rescan_member ( id ) ;
2152
	IDENTIFIER qid = rescan_member(id);
2116
    NAMESPACE qns = DEREF_nspace ( id_parent ( qid ) ) ;
2153
	NAMESPACE qns = DEREF_nspace(id_parent(qid));
2117
    if ( !IS_NULL_nspace ( qns ) && IS_nspace_block ( qns ) ) {
2154
	if (!IS_NULL_nspace(qns) && IS_nspace_block(qns)) {
2118
	qid = pid ;
2155
		qid = pid;
2119
    }
2156
	}
2120
    /* QUERY: should qid be rescanned in context? */
2157
	/* QUERY: should qid be rescanned in context? */
2121
    if ( !EQ_id ( pid, qid ) && !IS_id_undef ( qid ) ) {
2158
	if (!EQ_id(pid, qid) && !IS_id_undef(qid)) {
2122
	int eq = 0 ;
2159
		int eq = 0;
2123
	if ( IS_id_function_etc ( pid ) && IS_id_function_etc ( qid ) ) {
2160
		if (IS_id_function_etc(pid) && IS_id_function_etc(qid)) {
2124
	    /* Check for overloaded functions */
2161
			/* Check for overloaded functions */
2125
	    IDENTIFIER rid = pid ;
2162
			IDENTIFIER rid = pid;
2126
	    while ( !IS_NULL_id ( rid ) ) {
2163
			while (!IS_NULL_id(rid)) {
2127
		if ( EQ_id ( rid, qid ) ) {
2164
				if (EQ_id(rid, qid)) {
2128
		    eq = 1 ;
2165
					eq = 1;
2129
		    break ;
2166
					break;
-
 
2167
				}
-
 
2168
				rid = DEREF_id(id_function_etc_over(rid));
-
 
2169
			}
-
 
2170
		}
-
 
2171
		if (!eq) {
-
 
2172
			/* Create ambiguous identifier */
-
 
2173
			DECL_SPEC ds;
-
 
2174
			LOCATION loc;
-
 
2175
			LIST(IDENTIFIER)pids;
-
 
2176
			HASHID nm = DEREF_hashid(id_name(pid));
-
 
2177
			NAMESPACE ns = DEREF_nspace(id_parent(pid));
-
 
2178
			DEREF_loc(id_loc(pid), loc);
-
 
2179
			CONS_id(pid, NULL_list(IDENTIFIER), pids);
-
 
2180
			CONS_id(qid, pids, pids);
-
 
2181
			ds = find_ambig_dspec(pids);
-
 
2182
			MAKE_id_ambig(nm, ds, ns, loc, pids, 1, pid);
2130
		}
2183
		}
2131
		rid = DEREF_id ( id_function_etc_over ( rid ) ) ;
-
 
2132
	    }
-
 
2133
	}
2184
	}
2134
	if ( !eq ) {
-
 
2135
	    /* Create ambiguous identifier */
-
 
2136
	    DECL_SPEC ds ;
-
 
2137
	    LOCATION loc ;
-
 
2138
	    LIST ( IDENTIFIER ) pids ;
-
 
2139
	    HASHID nm = DEREF_hashid ( id_name ( pid ) ) ;
-
 
2140
	    NAMESPACE ns = DEREF_nspace ( id_parent ( pid ) ) ;
-
 
2141
	    DEREF_loc ( id_loc ( pid ), loc ) ;
-
 
2142
	    CONS_id ( pid, NULL_list ( IDENTIFIER ), pids ) ;
-
 
2143
	    CONS_id ( qid, pids, pids ) ;
-
 
2144
	    ds = find_ambig_dspec ( pids ) ;
-
 
2145
	    MAKE_id_ambig ( nm, ds, ns, loc, pids, 1, pid ) ;
-
 
2146
	}
-
 
2147
    }
-
 
2148
    return ( pid ) ;
2185
	return (pid);
2149
}
2186
}
2150
 
2187
 
2151
 
2188
 
2152
/*
2189
/*
2153
    RESCAN A MEMBER NAME
2190
    RESCAN A MEMBER NAME
2154
 
2191
 
2155
    This routine rescans the identifier id.  If id is a member of a template
2192
    This routine rescans the identifier id.  If id is a member of a template
2156
    class then the corresponding member of the expanded class is returned.
2193
    class then the corresponding member of the expanded class is returned.
2157
    id is also marked as having been used and is instantiated if necessary.
2194
    id is also marked as having been used and is instantiated if necessary.
2158
*/
2195
*/
2159
 
2196
 
2160
IDENTIFIER rescan_member
2197
IDENTIFIER
2161
    PROTO_N ( ( id ) )
-
 
2162
    PROTO_T ( IDENTIFIER id )
2198
rescan_member(IDENTIFIER id)
2163
{
2199
{
2164
    IDENTIFIER lid ;
2200
	IDENTIFIER lid;
2165
    NAMESPACE ns = DEREF_nspace ( id_parent ( id ) ) ;
2201
	NAMESPACE ns = DEREF_nspace(id_parent(id));
2166
    DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
2202
	DECL_SPEC ds = DEREF_dspec(id_storage(id));
2167
 
2203
 
2168
    /* Check for template functions */
2204
	/* Check for template functions */
2169
    if ( ds & dspec_instance ) {
2205
	if (ds & dspec_instance) {
2170
	if ( IS_id_function_etc ( id ) ) {
2206
		if (IS_id_function_etc(id)) {
2171
	    /* Template functions */
2207
			/* Template functions */
2172
	    TYPE form = DEREF_type ( id_function_etc_form ( id ) ) ;
2208
			TYPE form = DEREF_type(id_function_etc_form(id));
2173
	    if ( !IS_NULL_type ( form ) && IS_type_token ( form ) ) {
2209
			if (!IS_NULL_type(form) && IS_type_token(form)) {
2174
		IDENTIFIER tid = DEREF_id ( type_token_tok ( form ) ) ;
2210
				IDENTIFIER tid = DEREF_id(type_token_tok(form));
2175
		if ( IS_id_function_etc ( tid ) ) {
2211
				if (IS_id_function_etc(tid)) {
2176
		    LIST ( TOKEN ) args ;
2212
					LIST(TOKEN) args;
2177
		    tid = rescan_member ( tid ) ;
2213
					tid = rescan_member(tid);
2178
		    args = DEREF_list ( type_token_args ( form ) ) ;
2214
					args = DEREF_list(type_token_args(form));
2179
		    args = expand_args ( args, 1, 1 ) ;
2215
					args = expand_args(args, 1, 1);
2180
		    id = apply_template ( tid, args, 0, 0 ) ;
2216
					id = apply_template(tid, args, 0, 0);
2181
		    ns = NULL_nspace ;
2217
					ns = NULL_nspace;
-
 
2218
				}
-
 
2219
			}
-
 
2220
		}
-
 
2221
	}
-
 
2222
 
-
 
2223
	/* Check for template class members */
-
 
2224
	if (!IS_NULL_nspace(ns) && IS_nspace_ctype(ns)) {
-
 
2225
		NAMESPACE pns = rescan_nspace(ns);
-
 
2226
		if (!EQ_nspace(ns, pns)) {
-
 
2227
			IDENTIFIER pid = DEREF_id(nspace_name(pns));
-
 
2228
			lid = find_copied(pid, id, 1);
-
 
2229
			if (!EQ_id(lid, id)) {
-
 
2230
				define_template(lid, 0);
-
 
2231
				id = lid;
-
 
2232
				ds = DEREF_dspec(id_storage(id));
-
 
2233
			}
2182
		}
2234
		}
2183
	    }
-
 
2184
	}
2235
	}
2185
    }
-
 
2186
 
-
 
2187
    /* Check for template class members */
-
 
2188
    if ( !IS_NULL_nspace ( ns ) && IS_nspace_ctype ( ns ) ) {
-
 
2189
	NAMESPACE pns = rescan_nspace ( ns ) ;
-
 
2190
	if ( !EQ_nspace ( ns, pns ) ) {
-
 
2191
	    IDENTIFIER pid = DEREF_id ( nspace_name ( pns ) ) ;
-
 
2192
	    lid = find_copied ( pid, id, 1 ) ;
-
 
2193
	    if ( !EQ_id ( lid, id ) ) {
-
 
2194
		define_template ( lid, 0 ) ;
-
 
2195
		id = lid ;
-
 
2196
		ds = DEREF_dspec ( id_storage ( id ) ) ;
-
 
2197
	    }
-
 
2198
	}
-
 
2199
    }
-
 
2200
 
2236
 
2201
    /* Handle implicitly declared parameters */
2237
	/* Handle implicitly declared parameters */
2202
    if ( ( ds & dspec_implicit ) && ( ds & dspec_auto ) ) {
2238
	if ((ds & dspec_implicit) && (ds & dspec_auto)) {
2203
	HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
2239
		HASHID nm = DEREF_hashid(id_name(id));
2204
	id = find_id ( nm ) ;
2240
		id = find_id(nm);
2205
	ds = DEREF_dspec ( id_storage ( id ) ) ;
2241
		ds = DEREF_dspec(id_storage(id));
2206
    }
2242
	}
2207
 
2243
 
2208
    /* Mark as used */
2244
	/* Mark as used */
2209
    ds |= dspec_used ;
2245
	ds |= dspec_used;
2210
    COPY_dspec ( id_storage ( id ), ds ) ;
2246
	COPY_dspec(id_storage(id), ds);
2211
    lid = DEREF_id ( id_alias ( id ) ) ;
2247
	lid = DEREF_id(id_alias(id));
2212
    if ( !EQ_id ( lid, id ) ) {
2248
	if (!EQ_id(lid, id)) {
2213
	ds = DEREF_dspec ( id_storage ( lid ) ) ;
2249
		ds = DEREF_dspec(id_storage(lid));
2214
	ds |= dspec_used ;
2250
		ds |= dspec_used;
2215
	COPY_dspec ( id_storage ( lid ), ds ) ;
2251
		COPY_dspec(id_storage(lid), ds);
2216
    }
2252
	}
2217
    return ( id ) ;
2253
	return (id);
2218
}
2254
}