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, 1998
32
    		 Crown Copyright (c) 1997, 1998
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 73... Line 103...
73
 
103
 
74
    This flag may be set to true to indicate that the parser is in a sizeof
104
    This flag may be set to true to indicate that the parser is in a sizeof
75
    expression or similar so that any usages should not be included.
105
    expression or similar so that any usages should not be included.
76
*/
106
*/
77
 
107
 
78
int suppress_usage = 0 ;
108
int suppress_usage = 0;
79
 
109
 
80
 
110
 
81
/*
111
/*
82
    MARK AN IDENTIFIER AS BEING USED
112
    MARK AN IDENTIFIER AS BEING USED
83
 
113
 
84
    This routine marks the identifier id as having been used and checks
114
    This routine marks the identifier id as having been used and checks
85
    any access controls.
115
    any access controls.
86
*/
116
*/
87
 
117
 
88
void use_id
118
void
89
    PROTO_N ( ( id, suppress ) )
-
 
90
    PROTO_T ( IDENTIFIER id X int suppress )
119
use_id(IDENTIFIER id, int suppress)
91
{
120
{
92
    DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
121
	DECL_SPEC ds = DEREF_dspec(id_storage(id));
93
    DECL_SPEC acc = ( ds & dspec_access ) ;
122
	DECL_SPEC acc = (ds & dspec_access);
94
    if ( acc ) check_access ( id, acc ) ;
123
	if (acc)check_access(id, acc);
-
 
124
 
-
 
125
	/* Check usage */
-
 
126
	if (ds & dspec_main) {
-
 
127
		HASHID nm = DEREF_hashid(id_name(id));
-
 
128
		switch (TAG_hashid(nm)) {
-
 
129
		case hashid_name_tag:
-
 
130
			/* Can't take the address of 'main' */
-
 
131
			report(crt_loc, ERR_basic_start_main_addr(id));
-
 
132
			break;
-
 
133
		case hashid_constr_tag:
-
 
134
			/* Can't take the address of a constructor */
-
 
135
			report(crt_loc, ERR_class_ctor_addr(id));
-
 
136
			break;
-
 
137
		case hashid_destr_tag:
-
 
138
			/* Can't take the address of a destructor */
-
 
139
			report(crt_loc, ERR_class_dtor_addr(id));
-
 
140
			break;
-
 
141
		}
-
 
142
	}
95
 
143
 
96
    /* Check usage */
-
 
97
    if ( ds & dspec_main ) {
-
 
98
	HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
-
 
99
	switch ( TAG_hashid ( nm ) ) {
-
 
100
	    case hashid_name_tag : {
-
 
101
		/* Can't take the address of 'main' */
-
 
102
		report ( crt_loc, ERR_basic_start_main_addr ( id ) ) ;
-
 
103
		break ;
-
 
104
	    }
-
 
105
	    case hashid_constr_tag : {
-
 
106
		/* Can't take the address of a constructor */
-
 
107
		report ( crt_loc, ERR_class_ctor_addr ( id ) ) ;
-
 
108
		break ;
-
 
109
	    }
-
 
110
	    case hashid_destr_tag : {
-
 
111
		/* Can't take the address of a destructor */
-
 
112
		report ( crt_loc, ERR_class_dtor_addr ( id ) ) ;
-
 
113
		break ;
-
 
114
	    }
-
 
115
	}
-
 
116
    }
-
 
117
 
-
 
118
    /* Mark use */
-
 
119
    if ( !( ds & dspec_used ) ) {
-
 
120
	if ( !suppress ) {
-
 
121
	    ds |= dspec_used ;
-
 
122
	    COPY_dspec ( id_storage ( id ), ds ) ;
-
 
123
	}
-
 
124
	if ( ds & ( dspec_inherit | dspec_alias | dspec_extern ) ) {
-
 
125
	    /* Check for inheritance */
-
 
126
	    IDENTIFIER uid = DEREF_id ( id_alias ( id ) ) ;
-
 
127
	    if ( !EQ_id ( uid, id ) ) {
-
 
128
		ds = DEREF_dspec ( id_storage ( uid ) ) ;
-
 
129
		if ( ds & dspec_used ) {
-
 
130
		    if ( do_usage ) dump_use ( id, &crt_loc, 1 ) ;
-
 
131
		    return ;
-
 
132
		}
-
 
133
		if ( !suppress ) {
-
 
134
		    ds |= dspec_used ;
-
 
135
		    COPY_dspec ( id_storage ( uid ), ds ) ;
-
 
136
		}
-
 
137
	    }
-
 
138
	}
-
 
139
	if ( !( ds & dspec_defn ) && ( ds & dspec_instance ) ) {
-
 
140
	    /* Define template instance */
-
 
141
	    if ( !suppress ) define_template ( id, 0 ) ;
-
 
142
	}
-
 
143
    }
-
 
144
    if ( do_usage ) dump_use ( id, &crt_loc, 1 ) ;
-
 
145
    return ;
-
 
146
}
-
 
147
 
-
 
148
 
-
 
149
/*
-
 
150
    MARK A FUNCTION IDENTIFIER AS BEING USED
-
 
151
 
-
 
152
    This routine marks the function identifier id as having been called
-
 
153
    and checks any access controls.  In addition certain checks are applied
-
 
154
    to the first call of an identifier.  expl is true for explicit calls.
-
 
155
*/
-
 
156
 
-
 
157
void use_func_id
-
 
158
    PROTO_N ( ( id, expl, suppress ) )
-
 
159
    PROTO_T ( IDENTIFIER id X int expl X int suppress )
-
 
160
{
-
 
161
    DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
-
 
162
    DECL_SPEC acc = ( ds & dspec_access ) ;
-
 
163
    if ( acc ) check_access ( id, acc ) ;
-
 
164
    if ( !( ds & dspec_called ) ) {
-
 
165
	/* Mark use */
144
	/* Mark use */
166
	if ( !suppress ) {
-
 
167
	    if ( !( ds & dspec_virtual ) ) ds |= dspec_used ;
-
 
168
	    ds |= dspec_called ;
-
 
169
	    COPY_dspec ( id_storage ( id ), ds ) ;
-
 
170
	}
-
 
171
 
-
 
172
	/* Check for inheritance */
-
 
173
	if ( ds & ( dspec_inherit | dspec_alias | dspec_extern ) ) {
-
 
174
	    IDENTIFIER uid = DEREF_id ( id_alias ( id ) ) ;
-
 
175
	    if ( !EQ_id ( uid, id ) ) {
-
 
176
		ds = DEREF_dspec ( id_storage ( uid ) ) ;
-
 
177
		if ( ds & dspec_called ) {
145
	if (!(ds & dspec_used)) {
178
		    if ( do_usage ) dump_call ( id, &crt_loc, expl ) ;
-
 
179
		    return ;
-
 
180
		}
-
 
181
		if ( !suppress ) {
146
		if (!suppress) {
182
		    if ( !( ds & dspec_virtual ) ) ds |= dspec_used ;
-
 
183
		    ds |= dspec_called ;
147
			ds |= dspec_used;
184
		    COPY_dspec ( id_storage ( uid ), ds ) ;
148
			COPY_dspec(id_storage(id), ds);
185
		}
149
		}
186
	    }
150
		if (ds & (dspec_inherit | dspec_alias | dspec_extern)) {
187
	}
-
 
188
 
-
 
189
	/* Check usage */
151
			/* Check for inheritance */
-
 
152
			IDENTIFIER uid = DEREF_id(id_alias(id));
190
	if ( ds & dspec_main ) {
153
			if (!EQ_id(uid, id)) {
191
	    HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
154
				ds = DEREF_dspec(id_storage(uid));
192
	    if ( IS_hashid_name ( nm ) ) {
155
				if (ds & dspec_used) {
193
		/* Can't call 'main' */
156
					if (do_usage) {
194
		report ( crt_loc, ERR_basic_start_main_call ( id ) ) ;
157
						dump_use(id, &crt_loc, 1);
195
	    }
158
					}
-
 
159
					return;
196
	}
160
				}
197
	if ( !( ds & dspec_defn ) && !suppress ) {
161
				if (!suppress) {
198
	    if ( ds & dspec_implicit ) {
162
					ds |= dspec_used;
199
		/* Define implicitly declared function */
-
 
200
		implicit_defn ( id, DEFAULT_USR ) ;
-
 
201
		ds = DEREF_dspec ( id_storage ( id ) ) ;
163
					COPY_dspec(id_storage(uid), ds);
202
	    } else if ( ds & dspec_instance ) {
-
 
203
		/* Define template function */
164
				}
204
		if ( !( ds & dspec_virtual ) ) {
-
 
205
		    define_template ( id, 0 ) ;
165
			}
206
		    ds = DEREF_dspec ( id_storage ( id ) ) ;
-
 
207
		}
166
		}
208
	    }
-
 
209
	    if ( ( ds & dspec_inline ) && !( ds & dspec_defn ) ) {
167
		if (!(ds & dspec_defn) && (ds & dspec_instance)) {
210
		/* An inline function called before it is defined */
168
			/* Define template instance */
-
 
169
			if (!suppress) {
211
		report ( crt_loc, ERR_dcl_fct_spec_inline_call ( id ) ) ;
170
				define_template(id, 0);
212
	    }
171
			}
-
 
172
		}
-
 
173
	}
-
 
174
	if (do_usage) {
-
 
175
		dump_use(id, &crt_loc, 1);
213
	}
176
	}
-
 
177
	return;
-
 
178
}
-
 
179
 
-
 
180
 
-
 
181
/*
-
 
182
    MARK A FUNCTION IDENTIFIER AS BEING USED
-
 
183
 
-
 
184
    This routine marks the function identifier id as having been called
-
 
185
    and checks any access controls.  In addition certain checks are applied
-
 
186
    to the first call of an identifier.  expl is true for explicit calls.
-
 
187
*/
-
 
188
 
-
 
189
void
-
 
190
use_func_id(IDENTIFIER id, int expl, int suppress)
-
 
191
{
-
 
192
	DECL_SPEC ds = DEREF_dspec(id_storage(id));
-
 
193
	DECL_SPEC acc = (ds & dspec_access);
-
 
194
	if (acc) {
-
 
195
		check_access(id, acc);
-
 
196
	}
-
 
197
	if (!(ds & dspec_called)) {
-
 
198
		/* Mark use */
-
 
199
		if (!suppress) {
-
 
200
			if (!(ds & dspec_virtual)) {
-
 
201
				ds |= dspec_used;
-
 
202
			}
-
 
203
			ds |= dspec_called;
-
 
204
			COPY_dspec(id_storage(id), ds);
-
 
205
		}
-
 
206
 
-
 
207
		/* Check for inheritance */
-
 
208
		if (ds & (dspec_inherit | dspec_alias | dspec_extern)) {
-
 
209
			IDENTIFIER uid = DEREF_id(id_alias(id));
-
 
210
			if (!EQ_id(uid, id)) {
-
 
211
				ds = DEREF_dspec(id_storage(uid));
-
 
212
				if (ds & dspec_called) {
-
 
213
					if (do_usage) {
-
 
214
						dump_call(id, &crt_loc, expl);
-
 
215
					}
-
 
216
					return;
-
 
217
				}
-
 
218
				if (!suppress) {
-
 
219
					if (!(ds & dspec_virtual)) {
-
 
220
						ds |= dspec_used;
-
 
221
					}
-
 
222
					ds |= dspec_called;
-
 
223
					COPY_dspec(id_storage(uid), ds);
-
 
224
				}
-
 
225
			}
-
 
226
		}
-
 
227
 
-
 
228
		/* Check usage */
-
 
229
		if (ds & dspec_main) {
-
 
230
			HASHID nm = DEREF_hashid(id_name(id));
-
 
231
			if (IS_hashid_name(nm)) {
-
 
232
				/* Can't call 'main' */
-
 
233
				report(crt_loc, ERR_basic_start_main_call(id));
-
 
234
			}
-
 
235
		}
-
 
236
		if (!(ds & dspec_defn) && !suppress) {
-
 
237
			if (ds & dspec_implicit) {
-
 
238
				/* Define implicitly declared function */
-
 
239
				implicit_defn(id, DEFAULT_USR);
-
 
240
				ds = DEREF_dspec(id_storage(id));
-
 
241
			} else if (ds & dspec_instance) {
-
 
242
				/* Define template function */
-
 
243
				if (!(ds & dspec_virtual)) {
-
 
244
					define_template(id, 0);
-
 
245
					ds = DEREF_dspec(id_storage(id));
214
    }
246
				}
-
 
247
			}
-
 
248
			if ((ds & dspec_inline) && !(ds & dspec_defn)) {
-
 
249
				/* An inline function called before it is
-
 
250
				 * defined */
-
 
251
				report(crt_loc,
-
 
252
				       ERR_dcl_fct_spec_inline_call(id));
-
 
253
			}
-
 
254
		}
-
 
255
	}
-
 
256
	if (do_usage) {
215
    if ( do_usage ) dump_call ( id, &crt_loc, expl ) ;
257
		dump_call(id, &crt_loc, expl);
-
 
258
	}
216
    return ;
259
	return;
217
}
260
}
218
 
261
 
219
 
262
 
220
/*
263
/*
221
    MARK A VIRTUAL FUNCTION AS BEING USED
264
    MARK A VIRTUAL FUNCTION AS BEING USED
Line 224... Line 267...
224
    used because the actual function called can only be determined at
267
    used because the actual function called can only be determined at
225
    run-time.  If subsequently it is found that the function called can
268
    run-time.  If subsequently it is found that the function called can
226
    be determined statically then this routine is called to mark that
269
    be determined statically then this routine is called to mark that
227
    function as having been used.  It is also used in certain similar
270
    function as having been used.  It is also used in certain similar
228
    situations.
271
    situations.
229
*/
272
*/
230
 
273
 
231
void reuse_id
274
void
232
    PROTO_N ( ( id, suppress ) )
-
 
233
    PROTO_T ( IDENTIFIER id X int suppress )
275
reuse_id(IDENTIFIER id, int suppress)
234
{
276
{
235
    DECL_SPEC ds = DEREF_dspec ( id_storage ( id ) ) ;
277
	DECL_SPEC ds = DEREF_dspec(id_storage(id));
236
    if ( !( ds & dspec_used ) && !suppress ) {
278
	if (!(ds & dspec_used) && !suppress) {
237
	ds |= dspec_used ;
279
		ds |= dspec_used;
238
	COPY_dspec ( id_storage ( id ), ds ) ;
280
		COPY_dspec(id_storage(id), ds);
239
	if ( !( ds & dspec_defn ) ) {
281
		if (!(ds & dspec_defn)) {
240
	    if ( ds & dspec_implicit ) {
282
			if (ds & dspec_implicit) {
241
		/* Define implicitly declared function */
283
				/* Define implicitly declared function */
242
		implicit_defn ( id, DEFAULT_USR ) ;
284
				implicit_defn(id, DEFAULT_USR);
243
	    } else if ( ds & dspec_instance ) {
285
			} else if (ds & dspec_instance) {
244
		/* Instantiate template functions */
286
				/* Instantiate template functions */
245
		define_template ( id, 0 ) ;
287
				define_template(id, 0);
246
	    }
288
			}
247
	}
289
		}
248
    }
290
	}
249
    return ;
291
	return;
250
}
292
}
251
 
293
 
252
 
294
 
253
/*
295
/*
254
    DEFINE AN IDENTIFIER ALIAS
296
    DEFINE AN IDENTIFIER ALIAS
255
 
297
 
256
    This routine is called if the function or variable id is defined
298
    This routine is called if the function or variable id is defined
257
    (excluding tentative definitions).  It passes the definition on to
299
    (excluding tentative definitions).  It passes the definition on to
258
    any alias of id.
300
    any alias of id.
259
*/
301
*/
260
 
302
 
261
void define_id
303
void
262
    PROTO_N ( ( id ) )
-
 
263
    PROTO_T ( IDENTIFIER id )
304
define_id(IDENTIFIER id)
264
{
305
{
265
    IDENTIFIER lid = DEREF_id ( id_alias ( id ) ) ;
306
	IDENTIFIER lid = DEREF_id(id_alias(id));
266
    if ( !EQ_id ( lid, id ) ) {
307
	if (!EQ_id(lid, id)) {
267
	/* Check for previous definition */
308
		/* Check for previous definition */
268
	LOCATION loc ;
309
		LOCATION loc;
269
	DECL_SPEC ds ;
310
		DECL_SPEC ds;
270
	DEREF_loc ( id_loc ( id ), loc ) ;
311
		DEREF_loc(id_loc(id), loc);
271
	ds = DEREF_dspec ( id_storage ( lid ) ) ;
312
		ds = DEREF_dspec(id_storage(lid));
272
	if ( ds & dspec_defn ) {
313
		if (ds & dspec_defn) {
273
	    EXP e = DEREF_exp ( id_variable_etc_init ( lid ) ) ;
314
			EXP e = DEREF_exp(id_variable_etc_init(lid));
274
	    if ( IS_NULL_exp ( e ) || !IS_exp_zero ( e ) ) {
315
			if (IS_NULL_exp(e) || !IS_exp_zero(e)) {
275
		/* Exclude previous tentative definitions */
316
				/* Exclude previous tentative definitions */
276
		PTR ( LOCATION ) ploc = id_loc ( lid ) ;
317
				PTR(LOCATION)ploc = id_loc(lid);
277
		ERROR err = ERR_basic_odr_def ( lid, ploc ) ;
318
				ERROR err = ERR_basic_odr_def(lid, ploc);
278
		if ( ds & dspec_c ) {
319
				if (ds & dspec_c) {
279
		    /* Explain C linkage identifications */
320
					/* Explain C linkage identifications */
280
		    HASHID nm = DEREF_hashid ( id_name ( lid ) ) ;
321
					HASHID nm = DEREF_hashid(id_name(lid));
-
 
322
					ERROR err2 =
281
		    ERROR err2 = ERR_dcl_link_redecl ( nm, ploc ) ;
323
					    ERR_dcl_link_redecl(nm, ploc);
282
		    err = concat_error ( err, err2 ) ;
324
					err = concat_error(err, err2);
283
		}
325
				}
284
		report ( loc, err ) ;
326
				report(loc, err);
285
	    }
327
			}
286
	}
328
		}
287
 
329
 
288
	/* Copy definition */
330
		/* Copy definition */
289
	if ( IS_id_function_etc ( id ) ) {
331
		if (IS_id_function_etc(id)) {
290
	    EXP e = DEREF_exp ( id_function_etc_defn ( id ) ) ;
332
			EXP e = DEREF_exp(id_function_etc_defn(id));
291
	    COPY_exp ( id_function_etc_defn ( lid ), e ) ;
333
			COPY_exp(id_function_etc_defn(lid), e);
292
	} else if ( IS_id_variable_etc ( id ) ) {
334
		} else if (IS_id_variable_etc(id)) {
293
	    TYPE t = DEREF_type ( id_variable_etc_type ( id ) ) ;
335
			TYPE t = DEREF_type(id_variable_etc_type(id));
294
	    EXP e = DEREF_exp ( id_variable_etc_init ( id ) ) ;
336
			EXP e = DEREF_exp(id_variable_etc_init(id));
295
	    EXP d = DEREF_exp ( id_variable_etc_term ( id ) ) ;
337
			EXP d = DEREF_exp(id_variable_etc_term(id));
296
	    COPY_exp ( id_variable_etc_init ( lid ), e ) ;
338
			COPY_exp(id_variable_etc_init(lid), e);
297
	    COPY_exp ( id_variable_etc_term ( lid ), d ) ;
339
			COPY_exp(id_variable_etc_term(lid), d);
298
	    COPY_type ( id_variable_etc_type ( lid ), t ) ;
340
			COPY_type(id_variable_etc_type(lid), t);
299
	}
341
		}
300
 
342
 
301
	/* Record definition */
343
		/* Record definition */
302
	ds |= dspec_defn ;
344
		ds |= dspec_defn;
303
	COPY_dspec ( id_storage ( lid ), ds ) ;
345
		COPY_dspec(id_storage(lid), ds);
304
	DEREF_loc ( id_loc ( lid ), loc ) ;
346
		DEREF_loc(id_loc(lid), loc);
305
    }
347
	}
306
    return ;
348
	return;
307
}
349
}
308
 
350
 
309
 
351
 
310
/*
352
/*
311
    FIND THE END OF A LIST OF IDENTIFIER ALIASES
353
    FIND THE END OF A LIST OF IDENTIFIER ALIASES
312
 
354
 
313
    In most cases the alias of an identifier is its underlying meaning,
355
    In most cases the alias of an identifier is its underlying meaning,
314
    however for function parameters it is possible to have vast lists
356
    however for function parameters it is possible to have vast lists
315
    of identifiers arising from redeclarations all linked by their alias
357
    of identifiers arising from redeclarations all linked by their alias
316
    field.  This routine scans down such a list until it finds an identifier
358
    field.  This routine scans down such a list until it finds an identifier
317
    which is its own alias.
359
    which is its own alias.
318
*/
360
*/
319
 
361
 
320
IDENTIFIER chase_alias
362
IDENTIFIER
321
    PROTO_N ( ( id ) )
-
 
322
    PROTO_T ( IDENTIFIER id )
363
chase_alias(IDENTIFIER id)
323
{
364
{
324
    while ( !IS_NULL_id ( id ) ) {
365
	while (!IS_NULL_id(id)) {
325
	IDENTIFIER lid = DEREF_id ( id_alias ( id ) ) ;
366
		IDENTIFIER lid = DEREF_id(id_alias(id));
326
	if ( EQ_id ( lid, id ) ) break ;
367
		if (EQ_id(lid, id)) {
-
 
368
			break;
-
 
369
		}
327
	id = lid ;
370
		id = lid;
328
    }
371
	}
329
    return ( id ) ;
372
	return (id);
330
}
373
}
331
 
374
 
332
 
375
 
333
/*
376
/*
334
    CURRENT IDENTIFIER QUALIFIER
377
    CURRENT IDENTIFIER QUALIFIER
335
 
378
 
336
    This variable is set to describe how the current identifier is
379
    This variable is set to describe how the current identifier is
337
    qualified.
380
    qualified.
338
*/
381
*/
339
 
382
 
340
QUALIFIER crt_id_qualifier = qual_none ;
383
QUALIFIER crt_id_qualifier = qual_none;
341
int crt_templ_qualifier = 0 ;
384
int crt_templ_qualifier = 0;
342
 
385
 
343
 
386
 
344
/*
387
/*
345
    CHECK AN IDENTIFIER NAME
388
    CHECK AN IDENTIFIER NAME
346
 
389
 
347
    This routine checks whether the identifier name id is suitable for use
390
    This routine checks whether the identifier name id is suitable for use
348
    in the context given by loc.  The namespace qualifiers used in describing
391
    in the context given by loc.  The namespace qualifiers used in describing
349
    id will be given by crt_id_qualifier.  The routine returns true for
392
    id will be given by crt_id_qualifier.  The routine returns true for
350
    legal identifiers.
393
    legal identifiers.
351
*/
394
*/
352
 
395
 
353
ERROR check_id_name
396
ERROR
354
    PROTO_N ( ( id, loc ) )
-
 
355
    PROTO_T ( IDENTIFIER id X int loc )
397
check_id_name(IDENTIFIER id, int loc)
356
{
398
{
357
    /* Check on namespace component */
399
	/* Check on namespace component */
358
    ERROR err = NULL_err ;
400
	ERROR err = NULL_err;
359
    QUALIFIER cq = crt_id_qualifier ;
401
	QUALIFIER cq = crt_id_qualifier;
360
    switch ( cq ) {
402
	switch (cq) {
361
	case qual_none : {
403
	case qual_none: {
362
	    /* No namespace specifier */
404
		/* No namespace specifier */
363
	    if ( in_template_decl && is_templ_alias ( id ) ) {
405
		if (in_template_decl && is_templ_alias(id)) {
364
		/* Check for hiding of template parameters */
406
			/* Check for hiding of template parameters */
365
		err = ERR_temp_local_hide ( id ) ;
407
			err = ERR_temp_local_hide(id);
366
		if ( !IS_NULL_err ( err ) ) return ( err ) ;
408
			if (!IS_NULL_err(err)) {
-
 
409
				return (err);
367
	    }
410
			}
-
 
411
		}
368
	    if ( crt_templ_qualifier ) goto qualifier_lab ;
412
		if (crt_templ_qualifier) {
-
 
413
			goto qualifier_lab;
-
 
414
		}
369
	    break ;
415
		break;
370
	}
416
	}
371
	case qual_nested :
417
	case qual_nested:
372
	qualifier_lab : {
418
qualifier_lab:
373
	    /* Nested namespace specifier */
419
		/* Nested namespace specifier */
374
	    if ( loc == CONTEXT_PARAMETER || loc == CONTEXT_TEMPL_PARAM ) {
420
		if (loc == CONTEXT_PARAMETER || loc == CONTEXT_TEMPL_PARAM) {
375
		err = ERR_dcl_meaning_id ( cq, id ) ;
421
			err = ERR_dcl_meaning_id(cq, id);
376
		if ( !IS_NULL_err ( err ) ) return ( err ) ;
422
			if (!IS_NULL_err(err)) {
-
 
423
				return (err);
377
	    }
424
			}
378
	    break ;
-
 
379
	}
425
		}
-
 
426
		break;
380
	case qual_full :
427
	case qual_full:
381
	case qual_top : {
428
	case qual_top:
382
	    /* Namespace specifier beginning with '::' */
429
		/* Namespace specifier beginning with '::' */
383
	    err = ERR_dcl_meaning_full ( cq, id ) ;
430
		err = ERR_dcl_meaning_full(cq, id);
384
	    if ( !IS_NULL_err ( err ) ) return ( err ) ;
431
		if (!IS_NULL_err(err)) {
385
	    goto qualifier_lab ;
432
			return (err);
386
	}
433
		}
-
 
434
		goto qualifier_lab;
387
    }
435
	}
388
 
436
 
389
    /* Check on name component */
437
	/* Check on name component */
390
    if ( loc != CONTEXT_FUNCTION && loc != CONTEXT_FUNC_MEMBER ) {
438
	if (loc != CONTEXT_FUNCTION && loc != CONTEXT_FUNC_MEMBER) {
391
	HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
439
		HASHID nm = DEREF_hashid(id_name(id));
392
	switch ( TAG_hashid ( nm ) ) {
440
		switch (TAG_hashid(nm)) {
393
	    case hashid_constr_tag : {
441
		case hashid_constr_tag:
394
		/* A constructor must be a member function */
442
			/* A constructor must be a member function */
395
		err = ERR_class_mem_ctor ( id ) ;
443
			err = ERR_class_mem_ctor(id);
396
		break ;
444
			break;
397
	    }
-
 
398
	    case hashid_destr_tag : {
445
		case hashid_destr_tag:
399
		/* A destructor must be a member function */
446
			/* A destructor must be a member function */
400
		err = ERR_class_dtor_func ( nm ) ;
447
			err = ERR_class_dtor_func(nm);
401
		break ;
448
			break;
402
	    }
-
 
403
	    case hashid_conv_tag :
449
		case hashid_conv_tag:
404
	    case hashid_op_tag : {
450
		case hashid_op_tag:
405
		/* These must be functions */
451
			/* These must be functions */
406
		err = ERR_dcl_meaning_id ( cq, id ) ;
452
			err = ERR_dcl_meaning_id(cq, id);
407
		break ;
453
			break;
408
	    }
454
		}
409
	}
455
	}
410
    }
-
 
411
    return ( err ) ;
456
	return (err);
412
}
457
}
413
 
458
 
414
 
459
 
415
/*
460
/*
416
    DECLARE AN IMPLICIT FUNCTION
461
    DECLARE AN IMPLICIT FUNCTION
417
 
462
 
418
    This routine declares a function named id in the current scope with
463
    This routine declares a function named id in the current scope with
419
    declaration specifiers ds, return type ret (which may be the null type),
464
    declaration specifiers ds, return type ret (which may be the null type),
420
    parameter types p (terminated by the null type), and function kind ell.
465
    parameter types p (terminated by the null type), and function kind ell.
421
    It is used to declare implicit functions.
466
    It is used to declare implicit functions.
422
*/
467
*/
423
 
468
 
424
IDENTIFIER declare_func
469
IDENTIFIER
425
    PROTO_N ( ( ds, id, ret, p, ell, ex ) )
-
 
426
    PROTO_T ( DECL_SPEC ds X IDENTIFIER id X TYPE ret X TYPE *p X
470
declare_func(DECL_SPEC ds, IDENTIFIER id, TYPE ret, TYPE *p, int ell,
427
	      int ell X LIST ( TYPE ) ex )
471
	     LIST(TYPE) ex)
428
{
472
{
429
    /* Save certain information */
473
	/* Save certain information */
430
    TYPE t ;
474
	TYPE t;
431
    CV_SPEC cv ;
475
	CV_SPEC cv;
432
    DECL_SPEC acc = crt_access ;
476
	DECL_SPEC acc = crt_access;
433
    int td = have_type_declaration ;
477
	int td = have_type_declaration;
434
    QUALIFIER cq = crt_id_qualifier ;
478
	QUALIFIER cq = crt_id_qualifier;
435
    int tq = crt_templ_qualifier ;
479
	int tq = crt_templ_qualifier;
436
    crt_access = dspec_public ;
480
	crt_access = dspec_public;
437
    crt_id_qualifier = qual_none ;
481
	crt_id_qualifier = qual_none;
438
    crt_templ_qualifier = 0 ;
482
	crt_templ_qualifier = 0;
439
    have_type_declaration = TYPE_DECL_NONE ;
483
	have_type_declaration = TYPE_DECL_NONE;
440
 
484
 
441
    /* Declare parameters */
485
	/* Declare parameters */
442
    decl_loc = crt_loc ;
486
	decl_loc = crt_loc;
443
    begin_param ( id ) ;
487
	begin_param(id);
444
    while ( !IS_NULL_type ( *p ) ) {
488
	while (!IS_NULL_type(*p)) {
445
	HASHID nm = lookup_anon () ;
489
		HASHID nm = lookup_anon();
446
        IDENTIFIER pid = DEREF_id ( hashid_id ( nm ) ) ;
490
		IDENTIFIER pid = DEREF_id(hashid_id(nm));
447
        pid = make_param_decl ( dspec_none, *p, pid, CONTEXT_PARAMETER ) ;
491
		pid = make_param_decl(dspec_none, *p, pid, CONTEXT_PARAMETER);
448
        init_param ( pid, NULL_exp ) ;
492
		init_param(pid, NULL_exp);
449
	p++ ;
493
		p++;
450
    }
494
	}
451
    if ( IS_NULL_type ( ret ) ) ret = type_inferred ;
495
	if (IS_NULL_type(ret)) {
-
 
496
		ret = type_inferred;
-
 
497
	}
452
    cv = func_linkage ( cv_none ) ;
498
	cv = func_linkage(cv_none);
453
    t = make_func_type ( ret, ell, cv, ex ) ;
499
	t = make_func_type(ret, ell, cv, ex);
454
    end_param () ;
500
	end_param();
455
 
501
 
456
    /* Declare the function */
502
	/* Declare the function */
457
    if ( in_class_defn ) {
503
	if (in_class_defn) {
458
#if LANGUAGE_CPP
504
#if LANGUAGE_CPP
459
	if ( ds & dspec_friend ) {
505
		if (ds & dspec_friend) {
460
	    id = make_friend_decl ( ds, t, id, 0, 1 ) ;
506
			id = make_friend_decl(ds, t, id, 0, 1);
461
	} else {
507
		} else {
462
	    id = make_func_mem_decl ( ds, t, id, 0 ) ;
508
			id = make_func_mem_decl(ds, t, id, 0);
463
	}
509
		}
464
#else
510
#else
465
	id = make_member_decl ( ds, t, id, 0 ) ;
511
		id = make_member_decl(ds, t, id, 0);
466
#endif
512
#endif
467
    } else {
513
	} else {
468
	id = make_func_decl ( ds, t, id, 0 ) ;
514
		id = make_func_decl(ds, t, id, 0);
469
    }
515
	}
470
    if ( do_dump ) {
516
	if (do_dump) {
471
	dump_implicit = 1 ;
517
		dump_implicit = 1;
472
	dump_declare ( id, &decl_loc, 0 ) ;
518
		dump_declare(id, &decl_loc, 0);
473
    }
519
	}
474
    have_type_declaration = td ;
520
	have_type_declaration = td;
475
    crt_templ_qualifier = tq ;
521
	crt_templ_qualifier = tq;
476
    crt_id_qualifier = cq ;
522
	crt_id_qualifier = cq;
477
    crt_access = acc ;
523
	crt_access = acc;
478
    return ( id ) ;
524
	return (id);
479
}
525
}
480
 
526
 
481
 
527
 
482
/*
528
/*
483
    IMPLICITLY DECLARE AN IDENTIFIER
529
    IMPLICITLY DECLARE AN IDENTIFIER
484
 
530
 
485
    This routine implicitly declares an identifier id, either as a local
531
    This routine implicitly declares an identifier id, either as a local
486
    variable, if fn is false, or as a function.  fn will be 2 in the cases
532
    variable, if fn is false, or as a function.  fn will be 2 in the cases
487
    where C allows an implicit function declaration.  The routine returns
533
    where C allows an implicit function declaration.  The routine returns
488
    the corresponding identifier expression.
534
    the corresponding identifier expression.
489
*/
535
*/
490
 
536
 
491
EXP implicit_id_exp
537
EXP
492
    PROTO_N ( ( id, fn ) )
-
 
493
    PROTO_T ( IDENTIFIER id X int fn )
538
implicit_id_exp(IDENTIFIER id, int fn)
494
{
539
{
495
    EXP e ;
540
	EXP e;
496
    ERROR err ;
541
	ERROR err;
497
    LOCATION loc ;
542
	LOCATION loc;
498
    DECL_SPEC ds ;
543
	DECL_SPEC ds;
499
    IDENTIFIER pid ;
544
	IDENTIFIER pid;
500
    DECL_SPEC cl = crt_linkage ;
545
	DECL_SPEC cl = crt_linkage;
501
    QUALIFIER cq = crt_id_qualifier ;
546
	QUALIFIER cq = crt_id_qualifier;
502
    int tq = crt_templ_qualifier ;
547
	int tq = crt_templ_qualifier;
503
    NAMESPACE cns = crt_namespace ;
548
	NAMESPACE cns = crt_namespace;
504
    HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
549
	HASHID nm = DEREF_hashid(id_name(id));
505
    NAMESPACE ns = DEREF_nspace ( id_parent ( id ) ) ;
550
	NAMESPACE ns = DEREF_nspace(id_parent(id));
506
 
551
 
507
    /* Check for implicit function declarations */
552
	/* Check for implicit function declarations */
508
    if ( fn == 2 && option ( OPT_func_impl ) == OPTION_DISALLOW ) fn = 1 ;
553
	if (fn == 2 && option(OPT_func_impl) == OPTION_DISALLOW) {
-
 
554
		fn = 1;
-
 
555
	}
509
 
556
 
510
    /* Allow for template dependent declarations */
557
	/* Allow for template dependent declarations */
511
    if ( in_template_decl && is_templ_nspace ( cns ) ) {
558
	if (in_template_decl && is_templ_nspace(cns)) {
512
	int opt = OPT_templ_undecl ;
559
		int opt = OPT_templ_undecl;
513
	OPTION sev = option ( opt ) ;
560
		OPTION sev = option(opt);
514
	if ( sev != OPTION_ALLOW ) {
561
		if (sev != OPTION_ALLOW) {
515
	    /* Implicit declarations for dependent identifiers */
562
			/* Implicit declarations for dependent identifiers */
516
	    if ( dependent_id ( id ) ) {
563
			if (dependent_id(id)) {
517
		opt = OPT_none ;
564
				opt = OPT_none;
518
		sev = OPTION_ALLOW ;
565
				sev = OPTION_ALLOW;
519
	    }
566
			}
520
	}
567
		}
521
	if ( sev != OPTION_DISALLOW ) {
568
		if (sev != OPTION_DISALLOW) {
522
	    if ( sev != OPTION_ALLOW && fn != 2 ) {
569
			if (sev != OPTION_ALLOW && fn != 2) {
523
		if ( cq == qual_none ) {
570
				if (cq == qual_none) {
524
		    err = ERR_lookup_unqual_undef ( nm ) ;
571
					err = ERR_lookup_unqual_undef(nm);
525
		} else {
572
				} else {
526
		    err = ERR_lookup_qual_undef ( nm, ns ) ;
573
					err = ERR_lookup_qual_undef(nm, ns);
527
		}
574
				}
528
		err = set_severity ( err, opt, 0 ) ;
575
				err = set_severity(err, opt, 0);
529
		report ( crt_loc, err ) ;
576
				report(crt_loc, err);
530
	    }
577
			}
531
	    MAKE_exp_undeclared ( type_templ_param, id, cq, e ) ;
578
			MAKE_exp_undeclared(type_templ_param, id, cq, e);
532
	    return ( e ) ;
579
			return (e);
533
	}
580
		}
534
	if ( cq == qual_none ) ns = NULL_nspace ;
581
		if (cq == qual_none) {
-
 
582
			ns = NULL_nspace;
535
    }
583
		}
-
 
584
	}
536
 
585
 
537
    /* Check for previous declaration */
586
	/* Check for previous declaration */
538
    if ( IS_NULL_nspace ( ns ) ) {
587
	if (IS_NULL_nspace(ns)) {
539
	OPTION sev = option ( OPT_decl_unify ) ;
588
		OPTION sev = option(OPT_decl_unify);
540
	if ( sev != OPTION_OFF ) {
589
		if (sev != OPTION_OFF) {
541
	    LIST ( IDENTIFIER ) p ;
590
			LIST(IDENTIFIER)p;
542
	    NAMESPACE pns = nonblock_namespace ;
591
			NAMESPACE pns = nonblock_namespace;
543
	    p = DEREF_list ( nspace_named_etc_extra ( pns ) ) ;
592
			p = DEREF_list(nspace_named_etc_extra(pns));
544
	    pid = unify_extern ( id, NULL_type, pns, p ) ;
593
			pid = unify_extern(id, NULL_type, pns, p);
545
	    if ( !IS_NULL_id ( pid ) ) {
594
			if (!IS_NULL_id(pid)) {
546
		if ( sev != OPTION_ON ) {
595
				if (sev != OPTION_ON) {
547
		    err = ERR_lookup_unqual_vis ( pid ) ;
596
					err = ERR_lookup_unqual_vis(pid);
548
		    err = set_severity ( err, OPT_decl_unify, 0 ) ;
597
					err = set_severity(err, OPT_decl_unify,
-
 
598
							   0);
549
		    report ( crt_loc, err ) ;
599
					report(crt_loc, err);
550
		}
600
				}
551
		e = make_id_exp ( pid ) ;
601
				e = make_id_exp(pid);
552
		return ( e ) ;
602
				return (e);
553
	    }
603
			}
554
	}
604
		}
555
	ns = cns ;
605
		ns = cns;
556
    }
606
	}
557
 
607
 
558
    /* Rescan identifier */
608
	/* Rescan identifier */
559
    pid = search_id ( ns, nm, 0, 0 ) ;
609
	pid = search_id(ns, nm, 0, 0);
560
    if ( !IS_NULL_id ( pid ) ) {
610
	if (!IS_NULL_id(pid)) {
561
	switch ( TAG_id ( pid ) ) {
611
		switch (TAG_id(pid)) {
562
	    case id_variable_tag :
612
		case id_variable_tag:
563
	    case id_function_tag : {
613
		case id_function_tag: {
564
		e = make_id_exp ( pid ) ;
614
			e = make_id_exp(pid);
565
		return ( e ) ;
615
			return (e);
566
	    }
616
		}
567
	}
617
		}
568
    }
618
	}
569
 
619
 
570
    /* Find namespace for declaration */
620
	/* Find namespace for declaration */
571
    crt_linkage = dspec_c ;
621
	crt_linkage = dspec_c;
572
    crt_id_qualifier = qual_none ;
622
	crt_id_qualifier = qual_none;
573
    crt_templ_qualifier = 0 ;
623
	crt_templ_qualifier = 0;
574
    push_namespace ( ns ) ;
624
	push_namespace(ns);
575
    bad_crt_loc++ ;
625
	bad_crt_loc++;
576
    loc = crt_loc ;
626
	loc = crt_loc;
577
    if ( crt_state_depth == 0 ) {
627
	if (crt_state_depth == 0) {
578
	/* Find identifier location */
628
		/* Find identifier location */
579
	IDENTIFIER uid = underlying_id ( id ) ;
629
		IDENTIFIER uid = underlying_id(id);
580
	DEREF_loc ( id_loc ( uid ), crt_loc ) ;
630
		DEREF_loc(id_loc(uid), crt_loc);
581
    }
631
	}
582
 
632
 
583
    if ( fn ) {
633
	if (fn) {
584
	/* Implicit functions declarations */
634
		/* Implicit functions declarations */
585
	int ell ;
635
		int ell;
586
	TYPE ret = type_sint ;
636
		TYPE ret = type_sint;
587
	TYPE pars = NULL_type ;
637
		TYPE pars = NULL_type;
588
#if LANGUAGE_CPP
638
#if LANGUAGE_CPP
589
	/* Type is 'int ( ... )' in C++ */
639
		/* Type is 'int ( ... )' in C++ */
590
	ell = FUNC_ELLIPSIS ;
640
		ell = FUNC_ELLIPSIS;
-
 
641
		if (fn == 1) {
591
	if ( fn == 1 ) ret = type_error ;
642
			ret = type_error;
-
 
643
		}
592
#else
644
#else
593
	/* Type is 'int ()' in C */
645
		/* Type is 'int ()' in C */
594
	ell = FUNC_NO_PARAMS ;
646
		ell = FUNC_NO_PARAMS;
595
#endif
647
#endif
596
	ds = ( dspec_extern | dspec_ignore ) ;
648
		ds = (dspec_extern | dspec_ignore);
597
	id = declare_func ( ds, id, ret, &pars, ell, empty_type_set ) ;
649
		id = declare_func(ds, id, ret, &pars, ell, empty_type_set);
598
 
-
 
599
    } else {
650
	} else {
600
	/* Other implicit declarations */
651
		/* Other implicit declarations */
601
	decl_loc = crt_loc ;
652
		decl_loc = crt_loc;
602
	id = make_object_decl ( dspec_none, type_error, id, 0 ) ;
653
		id = make_object_decl(dspec_none, type_error, id, 0);
603
	IGNORE init_object ( id, NULL_exp ) ;
654
		IGNORE init_object(id, NULL_exp);
604
    }
-
 
605
 
-
 
606
    /* Report error */
-
 
607
    crt_linkage = cl ;
-
 
608
    crt_templ_qualifier = tq ;
-
 
609
    crt_id_qualifier = cq ;
-
 
610
    if ( fn == 2 ) {
-
 
611
	pid = DEREF_id ( id_alias ( id ) ) ;
-
 
612
	ds = DEREF_dspec ( id_storage ( pid ) ) ;
-
 
613
	if ( ds & dspec_temp ) {
-
 
614
	    /* Implicit declaration already reported */
-
 
615
	    err = NULL_err ;
-
 
616
	} else {
-
 
617
	    err = ERR_expr_call_undecl ( id ) ;
-
 
618
	    if ( !IS_NULL_err ( err ) ) {
-
 
619
		ds |= dspec_temp ;
-
 
620
		COPY_dspec ( id_storage ( pid ), ds ) ;
-
 
621
	    }
-
 
622
	}
655
	}
-
 
656
 
-
 
657
	/* Report error */
-
 
658
	crt_linkage = cl;
-
 
659
	crt_templ_qualifier = tq;
-
 
660
	crt_id_qualifier = cq;
-
 
661
	if (fn == 2) {
-
 
662
		pid = DEREF_id(id_alias(id));
-
 
663
		ds = DEREF_dspec(id_storage(pid));
-
 
664
		if (ds & dspec_temp) {
-
 
665
			/* Implicit declaration already reported */
-
 
666
			err = NULL_err;
-
 
667
		} else {
-
 
668
			err = ERR_expr_call_undecl(id);
-
 
669
			if (!IS_NULL_err(err)) {
-
 
670
				ds |= dspec_temp;
-
 
671
				COPY_dspec(id_storage(pid), ds);
-
 
672
			}
-
 
673
		}
623
    } else if ( cq == qual_none ) {
674
	} else if (cq == qual_none) {
624
	err = ERR_lookup_unqual_undef ( nm ) ;
675
		err = ERR_lookup_unqual_undef(nm);
625
    } else {
676
	} else {
626
	err = ERR_lookup_qual_undef ( nm, ns ) ;
677
		err = ERR_lookup_qual_undef(nm, ns);
627
    }
678
	}
628
    report ( crt_loc, err ) ;
679
	report(crt_loc, err);
629
 
680
 
630
    /* Construct the result */
681
	/* Construct the result */
631
    crt_loc = loc ;
682
	crt_loc = loc;
632
    bad_crt_loc-- ;
683
	bad_crt_loc--;
633
    IGNORE pop_namespace () ;
684
	IGNORE pop_namespace();
634
    e = make_id_exp ( id ) ;
685
	e = make_id_exp(id);
635
    return ( e ) ;
686
	return (e);
636
}
687
}
637
 
688
 
638
 
689
 
639
/*
690
/*
640
    LIST OF MEANINGS
691
    LIST OF MEANINGS
641
 
692
 
642
    This list is built up by list_ambiguous to give all the meanings of
693
    This list is built up by list_ambiguous to give all the meanings of
643
    its ambiguous identifier which match its type argument.
694
    its ambiguous identifier which match its type argument.
644
*/
695
*/
645
 
696
 
646
static LIST ( IDENTIFIER ) ambig_meanings = NULL_list ( IDENTIFIER ) ;
697
static LIST(IDENTIFIER) ambig_meanings = NULL_list(IDENTIFIER);
647
 
698
 
648
 
699
 
649
/*
700
/*
650
    LIST MEANINGS OF AN AMBIGUOUS IDENTIFIER
701
    LIST MEANINGS OF AN AMBIGUOUS IDENTIFIER
651
 
702
 
652
    This routine adds all meanings of the ambiguous identifier id to the
703
    This routine adds all meanings of the ambiguous identifier id to the
653
    error list err.
704
    error list err.
654
*/
705
*/
655
 
706
 
656
static unsigned list_ambiguous
707
static unsigned
657
    PROTO_N ( ( id, n, err, type, rec ) )
-
 
658
    PROTO_T ( IDENTIFIER id X unsigned n X ERROR *err X int type X int rec )
708
list_ambiguous(IDENTIFIER id, unsigned n, ERROR *err, int type, int rec)
659
{
709
{
660
    if ( !IS_NULL_id ( id ) ) {
710
	if (!IS_NULL_id(id)) {
661
	switch ( TAG_id ( id ) ) {
711
		switch (TAG_id(id)) {
662
	    case id_ambig_tag : {
712
		case id_ambig_tag: {
663
		/* Ambiguous identifiers */
713
			/* Ambiguous identifiers */
664
		LIST ( IDENTIFIER ) p = DEREF_list ( id_ambig_ids ( id ) ) ;
714
			LIST(IDENTIFIER) p = DEREF_list(id_ambig_ids(id));
665
		rec = DEREF_int ( id_ambig_over ( id ) ) ;
715
			rec = DEREF_int(id_ambig_over(id));
666
		while ( !IS_NULL_list ( p ) ) {
716
			while (!IS_NULL_list(p)) {
667
		    id = DEREF_id ( HEAD_list ( p ) ) ;
717
				id = DEREF_id(HEAD_list(p));
668
		    n = list_ambiguous ( id, n, err, type, rec ) ;
718
				n = list_ambiguous(id, n, err, type, rec);
669
		    p = TAIL_list ( p ) ;
719
				p = TAIL_list(p);
-
 
720
			}
-
 
721
			break;
-
 
722
		}
-
 
723
		case id_function_tag:
-
 
724
		case id_mem_func_tag:
-
 
725
		case id_stat_mem_func_tag: {
-
 
726
			/* Functions */
-
 
727
			if (rec) {
-
 
728
				IDENTIFIER over;
-
 
729
				over = DEREF_id(id_function_etc_over(id));
-
 
730
				n = list_ambiguous(over, n, err, type, rec);
-
 
731
			}
-
 
732
			goto default_lab;
-
 
733
		}
-
 
734
		case id_class_name_tag:
-
 
735
		case id_class_alias_tag:
-
 
736
		case id_enum_name_tag:
-
 
737
		case id_enum_alias_tag:
-
 
738
		case id_type_alias_tag: {
-
 
739
			/* Types */
-
 
740
			type = 0;
-
 
741
			goto default_lab;
670
		}
742
		}
671
		break ;
743
		default:
672
	    }
744
default_lab: {
673
	    case id_function_tag :
745
		     /* Other identifiers */
674
	    case id_mem_func_tag :
746
		     PTR(LOCATION) loc = id_loc(id);
-
 
747
		     n++;
675
	    case id_stat_mem_func_tag : {
748
		     add_error(err, ERR_fail_list_item(n, id, loc));
676
		/* Functions */
749
		     break;
677
		if ( rec ) {
750
	     }
-
 
751
		}
678
		    IDENTIFIER over ;
752
		if (type == 0) {
679
		    over = DEREF_id ( id_function_etc_over ( id ) ) ;
753
			/* Add to list of meanings */
680
		    n = list_ambiguous ( over, n, err, type, rec ) ;
754
			CONS_id(id, ambig_meanings, ambig_meanings);
681
		}
755
		}
682
		goto default_lab ;
-
 
683
	    }
-
 
684
	    case id_class_name_tag :
-
 
685
	    case id_class_alias_tag :
-
 
686
	    case id_enum_name_tag :
-
 
687
	    case id_enum_alias_tag :
-
 
688
	    case id_type_alias_tag : {
-
 
689
		/* Types */
-
 
690
		type = 0 ;
-
 
691
		goto default_lab ;
-
 
692
	    }
-
 
693
	    default :
-
 
694
	    default_lab : {
-
 
695
		/* Other identifiers */
-
 
696
		PTR ( LOCATION ) loc = id_loc ( id ) ;
-
 
697
		n++ ;
-
 
698
		add_error ( err, ERR_fail_list_item ( n, id, loc ) ) ;
-
 
699
		break ;
-
 
700
	    }
-
 
701
	}
-
 
702
	if ( type == 0 ) {
-
 
703
	    /* Add to list of meanings */
-
 
704
	    CONS_id ( id, ambig_meanings, ambig_meanings ) ;
-
 
705
	}
756
	}
706
    }
-
 
707
    return ( n ) ;
757
	return (n);
708
}
758
}
709
 
759
 
710
 
760
 
711
/*
761
/*
712
    REPORT AN AMBIGUOUS IDENTIFIER
762
    REPORT AN AMBIGUOUS IDENTIFIER
Line 714... Line 764...
714
    This routine reports the identifier id as being ambiguous.  Overloaded
764
    This routine reports the identifier id as being ambiguous.  Overloaded
715
    functions count as a single identifier unless rec is true.  It returns
765
    functions count as a single identifier unless rec is true.  It returns
716
    one of the possible meanings.  Only types are considered if type is
766
    one of the possible meanings.  Only types are considered if type is
717
    true.  If there is exactly one possible meaning or force is true the
767
    true.  If there is exactly one possible meaning or force is true the
718
    first meaning is returned.  Otherwise the null identifier is returned.
768
    first meaning is returned.  Otherwise the null identifier is returned.
719
*/
769
*/
720
 
770
 
721
IDENTIFIER report_ambiguous
771
IDENTIFIER
722
    PROTO_N ( ( id, type, rec, force ) )
-
 
723
    PROTO_T ( IDENTIFIER id X int type X int rec X int force )
772
report_ambiguous(IDENTIFIER id, int type, int rec, int force)
724
{
773
{
725
    ERROR err, err2 ;
774
	ERROR err, err2;
726
    LIST ( IDENTIFIER ) p ;
775
	LIST(IDENTIFIER) p;
727
    NAMESPACE ns = DEREF_nspace ( id_parent ( id ) ) ;
776
	NAMESPACE ns = DEREF_nspace(id_parent(id));
728
 
777
 
729
    /* List all meanings */
778
	/* List all meanings */
730
    if ( !IS_NULL_nspace ( ns ) && IS_nspace_ctype ( ns ) ) {
779
	if (!IS_NULL_nspace(ns) && IS_nspace_ctype(ns)) {
731
	err = ERR_lookup_ambig_mem ( id ) ;
780
		err = ERR_lookup_ambig_mem(id);
732
    } else {
781
	} else {
733
	err = ERR_lookup_ambig_id ( id ) ;
782
		err = ERR_lookup_ambig_id(id);
734
    }
783
	}
735
    err2 = ERR_lookup_ambig_list () ;
784
	err2 = ERR_lookup_ambig_list();
736
    if ( !IS_NULL_err ( err2 ) ) {
785
	if (!IS_NULL_err(err2)) {
737
	unsigned n = 0 ;
786
		unsigned n = 0;
738
	err = concat_error ( err, err2 ) ;
787
		err = concat_error(err, err2);
739
	n = list_ambiguous ( id, n, &err, type, rec ) ;
788
		n = list_ambiguous(id, n, &err, type, rec);
740
	err = concat_error ( err, ERR_fail_list_end ( n ) ) ;
789
		err = concat_error(err, ERR_fail_list_end(n));
741
    }
790
	}
742
    report ( crt_loc, err ) ;
791
	report(crt_loc, err);
743
 
792
 
744
    /* Check for resolved meaning */
793
	/* Check for resolved meaning */
745
    id = NULL_id ;
794
	id = NULL_id;
746
    p = ambig_meanings ;
795
	p = ambig_meanings;
747
    if ( !IS_NULL_list ( p ) ) {
796
	if (!IS_NULL_list(p)) {
748
	if ( IS_NULL_list ( TAIL_list ( p ) ) || force ) {
797
		if (IS_NULL_list(TAIL_list(p)) || force) {
749
	    id = DEREF_id ( HEAD_list ( p ) ) ;
798
			id = DEREF_id(HEAD_list(p));
750
	}
799
		}
751
	DESTROY_list ( p, SIZE_id ) ;
800
		DESTROY_list(p, SIZE_id);
752
	ambig_meanings = NULL_list ( IDENTIFIER ) ;
801
		ambig_meanings = NULL_list(IDENTIFIER);
753
    }
802
	}
754
    return ( id ) ;
803
	return (id);
755
}
804
}
756
 
805
 
757
 
806
 
758
/*
807
/*
759
    FIND THE DECLARATION SPECIFIER FOR AN AMBIGUOUS IDENTIFIER
808
    FIND THE DECLARATION SPECIFIER FOR AN AMBIGUOUS IDENTIFIER
760
 
809
 
761
    This routine finds the declaration specifier for an ambiguous identifier
810
    This routine finds the declaration specifier for an ambiguous identifier
762
    given by the list of cases pids.  This consists of various properties
811
    given by the list of cases pids.  This consists of various properties
763
    which all the cases share.
812
    which all the cases share.
764
*/
813
*/
765
 
814
 
766
DECL_SPEC find_ambig_dspec
815
DECL_SPEC
767
    PROTO_N ( ( pids ) )
-
 
768
    PROTO_T ( LIST ( IDENTIFIER ) pids )
816
find_ambig_dspec(LIST(IDENTIFIER) pids)
769
{
817
{
770
    DECL_SPEC ds = ( dspec_implicit | dspec_template ) ;
818
	DECL_SPEC ds = (dspec_implicit | dspec_template);
771
    while ( !IS_NULL_list ( pids ) ) {
819
	while (!IS_NULL_list(pids)) {
772
	IDENTIFIER pid = DEREF_id ( HEAD_list ( pids ) ) ;
820
		IDENTIFIER pid = DEREF_id(HEAD_list(pids));
773
	if ( !IS_NULL_id ( pid ) ) {
821
		if (!IS_NULL_id(pid)) {
774
	    DECL_SPEC pds = DEREF_dspec ( id_storage ( pid ) ) ;
822
			DECL_SPEC pds = DEREF_dspec(id_storage(pid));
775
	    ds &= pds ;
823
			ds &= pds;
776
	}
-
 
777
	pids = TAIL_list ( pids ) ;
-
 
778
    }
-
 
779
    return ( ds ) ;
-
 
780
}
-
 
781
 
-
 
782
 
-
 
783
/*
-
 
784
    CREATE AN IDENTIFIER EXPRESSION
-
 
785
 
-
 
786
    This routine creates an expression corresponding to the identifier id.
-
 
787
    Note that static member functions are identifier expressions if they
-
 
788
    are not overloaded, but member expression otherwise.  They are sorted
-
 
789
    out properly during overload resolution (see resolve_cast).
-
 
790
*/
-
 
791
 
-
 
792
EXP make_id_exp
-
 
793
    PROTO_N ( ( id ) )
-
 
794
    PROTO_T ( IDENTIFIER id )
-
 
795
{
-
 
796
    EXP e ;
-
 
797
    unsigned tag = TAG_id ( id ) ;
-
 
798
    QUALIFIER cq = crt_id_qualifier ;
-
 
799
    switch ( tag ) {
-
 
800
 
-
 
801
	case id_variable_tag :
-
 
802
	case id_parameter_tag : {
-
 
803
	    /* Variables and parameters */
-
 
804
	    TYPE t ;
-
 
805
	    DECL_SPEC ds ;
-
 
806
	    use_id ( id, 0 ) ;
-
 
807
	    ds = DEREF_dspec ( id_storage ( id ) ) ;
-
 
808
	    if ( ds & dspec_auto ) {
-
 
809
		/* Check use of automatic variable */
-
 
810
		NAMESPACE ns = crt_namespace ;
-
 
811
		switch ( TAG_nspace ( ns ) ) {
-
 
812
		    case nspace_block_tag :
-
 
813
		    case nspace_dummy_tag : {
-
 
814
			if ( really_in_function_defn > 1 ) {
-
 
815
			    /* Used in nested function */
-
 
816
			    IDENTIFIER fid ;
-
 
817
			    ns = DEREF_nspace ( id_parent ( id ) ) ;
-
 
818
			    fid = DEREF_id ( nspace_name ( ns ) ) ;
-
 
819
			    if ( !EQ_id ( fid, crt_func_id ) ) {
-
 
820
				ERROR err = ERR_class_local_auto ( id ) ;
-
 
821
				report ( crt_loc, err ) ;
-
 
822
			    }
-
 
823
			}
-
 
824
			break ;
-
 
825
		    }
-
 
826
		    case nspace_param_tag :
-
 
827
		    case nspace_templ_tag : {
-
 
828
			/* Used in default argument */
-
 
829
			if ( in_default_arg ) {
-
 
830
			    ERROR err = ERR_dcl_fct_default_param ( id ) ;
-
 
831
			    report ( crt_loc, err ) ;
-
 
832
			}
-
 
833
			break ;
-
 
834
		    }
-
 
835
		    default : {
-
 
836
			/* Used in local class */
-
 
837
			ERROR err = ERR_class_local_auto ( id ) ;
-
 
838
			report ( crt_loc, err ) ;
-
 
839
			break ;
-
 
840
		    }
-
 
841
		}
-
 
842
	    }
-
 
843
	    t = DEREF_type ( id_variable_etc_type ( id ) ) ;
-
 
844
	    if ( ( ds & dspec_extern ) && cv_extern ) {
-
 
845
		CV_SPEC cv = DEREF_cv ( type_qual ( t ) ) ;
-
 
846
		t = qualify_type ( t, ( cv | cv_extern ), 0 ) ;
-
 
847
		used_extern_volatile = 1 ;
-
 
848
	    }
-
 
849
	    MAKE_exp_identifier ( t, id, cq, e ) ;
-
 
850
	    break ;
-
 
851
	}
-
 
852
 
-
 
853
	case id_stat_member_tag : {
-
 
854
	    /* Static data members */
-
 
855
	    TYPE t ;
-
 
856
	    DECL_SPEC ds ;
-
 
857
	    use_id ( id, suppress_usage ) ;
-
 
858
	    ds = DEREF_dspec ( id_storage ( id ) ) ;
-
 
859
	    if ( ds & dspec_inherit ) id = DEREF_id ( id_alias ( id ) ) ;
-
 
860
	    t = DEREF_type ( id_stat_member_type ( id ) ) ;
-
 
861
	    if ( ( ds & dspec_extern ) && cv_extern ) {
-
 
862
		CV_SPEC cv = DEREF_cv ( type_qual ( t ) ) ;
-
 
863
		t = qualify_type ( t, ( cv | cv_extern ), 0 ) ;
-
 
864
		used_extern_volatile = 1 ;
-
 
865
	    }
-
 
866
	    MAKE_exp_identifier ( t, id, cq, e ) ;
-
 
867
	    break ;
-
 
868
	}
-
 
869
 
-
 
870
	case id_function_tag : {
-
 
871
	    /* Normal functions */
-
 
872
	    TYPE t = DEREF_type ( id_function_type ( id ) ) ;
-
 
873
	    MAKE_exp_identifier ( t, id, cq, e ) ;
-
 
874
	    break ;
-
 
875
	}
-
 
876
 
-
 
877
	case id_stat_mem_func_tag : {
-
 
878
	    /* Static member functions */
-
 
879
	    TYPE t = DEREF_type ( id_stat_mem_func_type ( id ) ) ;
-
 
880
	    IDENTIFIER over = DEREF_id ( id_stat_mem_func_over ( id ) ) ;
-
 
881
	    if ( IS_NULL_id ( over ) ) {
-
 
882
		MAKE_exp_identifier ( t, id, cq, e ) ;
-
 
883
	    } else {
-
 
884
		MAKE_exp_member ( t, id, cq, e ) ;
-
 
885
	    }
-
 
886
	    break ;
-
 
887
	}
-
 
888
 
-
 
889
	case id_mem_func_tag : {
-
 
890
	    /* Non-static member functions */
-
 
891
	    TYPE t = DEREF_type ( id_mem_func_type ( id ) ) ;
-
 
892
	    MAKE_exp_member ( t, id, cq, e ) ;
-
 
893
	    break ;
-
 
894
	}
-
 
895
 
-
 
896
	case id_member_tag : {
-
 
897
	    /* Non-static members */
-
 
898
	    TYPE t = DEREF_type ( id_member_type ( id ) ) ;
-
 
899
	    MAKE_exp_member ( t, id, cq, e ) ;
-
 
900
	    break ;
-
 
901
	}
-
 
902
 
-
 
903
	case id_enumerator_tag : {
-
 
904
	    /* Enumerators */
-
 
905
	    NAT n ;
-
 
906
	    TYPE t ;
-
 
907
	    use_id ( id, 0 ) ;
-
 
908
	    e = DEREF_exp ( id_enumerator_value ( id ) ) ;
-
 
909
	    DECONS_exp_int_lit ( t, n, tag, e ) ;
-
 
910
	    MAKE_exp_int_lit ( t, n, tag, e ) ;
-
 
911
	    break ;
-
 
912
	}
-
 
913
 
-
 
914
	case id_token_tag : {
-
 
915
	    /* Tokens */
-
 
916
	    TOKEN tok = DEREF_tok ( id_token_sort ( id ) ) ;
-
 
917
	    switch ( TAG_tok ( tok ) ) {
-
 
918
		case tok_exp_tag :
-
 
919
		case tok_nat_tag :
-
 
920
		case tok_snat_tag :
-
 
921
		case tok_stmt_tag : {
-
 
922
		    /* Expression tokens */
-
 
923
		    use_id ( id, 0 ) ;
-
 
924
		    id = DEREF_id ( id_token_alt ( id ) ) ;
-
 
925
		    e = apply_exp_token ( id, NULL_list ( TOKEN ), 0 ) ;
-
 
926
		    break ;
-
 
927
		}
-
 
928
		default : {
-
 
929
		    /* Other tokens */
-
 
930
		    goto default_lab ;
-
 
931
		}
824
		}
932
	    }
-
 
933
	    break ;
825
		pids = TAIL_list(pids);
934
	}
826
	}
935
 
-
 
936
	case id_class_name_tag :
-
 
937
	case id_enum_name_tag :
-
 
938
	case id_class_alias_tag :
-
 
939
	case id_enum_alias_tag :
-
 
940
	case id_type_alias_tag : {
-
 
941
	    /* Type names */
-
 
942
	    TYPE t = DEREF_type ( id_class_name_etc_defn ( id ) ) ;
-
 
943
	    report ( crt_loc, ERR_expr_prim_type ( id ) ) ;
-
 
944
	    MAKE_exp_value ( t, e ) ;
-
 
945
	    break ;
-
 
946
	}
-
 
947
 
-
 
948
	case id_ambig_tag : {
-
 
949
	    /* Ambiguous identifiers */
-
 
950
	    MAKE_exp_ambiguous ( type_error, id, cq, e ) ;
-
 
951
	    break ;
-
 
952
	}
-
 
953
 
-
 
954
	default :
-
 
955
	default_lab : {
-
 
956
	    /* Undefined identifiers */
-
 
957
	    if ( cq == qual_none && in_template_decl ) {
-
 
958
		/* Create a dummy identifier */
-
 
959
		HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
-
 
960
		NAMESPACE ns = nonblock_namespace ;
-
 
961
		MAKE_id_undef ( nm, dspec_none, ns, crt_loc, id ) ;
-
 
962
	    }
-
 
963
	    MAKE_exp_undeclared ( type_error, id, cq, e ) ;
-
 
964
	    break ;
-
 
965
	}
-
 
966
    }
-
 
967
    return ( e ) ;
827
	return (ds);
968
}
828
}
969
 
829
 
970
 
830
 
971
/*
831
/*
972
    FIND THE THIS PARAMETER OF A FUNCTION
832
    CREATE AN IDENTIFIER EXPRESSION
973
 
833
 
974
    This routine returns the 'this' parameter of the member function fn.
834
    This routine creates an expression corresponding to the identifier id.
-
 
835
    Note that static member functions are identifier expressions if they
-
 
836
    are not overloaded, but member expression otherwise.  They are sorted
975
    If use is true then the parameter is marked as used.
837
    out properly during overload resolution (see resolve_cast).
976
*/
838
*/
977
 
839
 
978
IDENTIFIER this_param
840
EXP
979
    PROTO_N ( ( fn, use ) )
-
 
980
    PROTO_T ( IDENTIFIER fn X int use )
841
make_id_exp(IDENTIFIER id)
981
{
842
{
-
 
843
	EXP e;
-
 
844
	unsigned tag = TAG_id(id);
-
 
845
	QUALIFIER cq = crt_id_qualifier;
-
 
846
	switch (tag) {
-
 
847
	case id_variable_tag:
-
 
848
	case id_parameter_tag: {
-
 
849
		/* Variables and parameters */
-
 
850
		TYPE t;
-
 
851
		DECL_SPEC ds;
-
 
852
		use_id(id, 0);
-
 
853
		ds = DEREF_dspec(id_storage(id));
-
 
854
		if (ds & dspec_auto) {
-
 
855
			/* Check use of automatic variable */
-
 
856
			NAMESPACE ns = crt_namespace;
-
 
857
			switch (TAG_nspace(ns)) {
-
 
858
			case nspace_block_tag:
-
 
859
			case nspace_dummy_tag: {
-
 
860
				if (really_in_function_defn > 1) {
-
 
861
					/* Used in nested function */
-
 
862
					IDENTIFIER fid;
-
 
863
					ns = DEREF_nspace(id_parent(id));
-
 
864
					fid = DEREF_id(nspace_name(ns));
-
 
865
					if (!EQ_id(fid, crt_func_id)) {
-
 
866
						ERROR err =
-
 
867
						    ERR_class_local_auto(id);
-
 
868
						report(crt_loc, err);
-
 
869
					}
-
 
870
				}
-
 
871
				break;
-
 
872
			}
-
 
873
			case nspace_param_tag:
-
 
874
			case nspace_templ_tag: {
-
 
875
				/* Used in default argument */
-
 
876
				if (in_default_arg) {
-
 
877
					ERROR err =
-
 
878
					    ERR_dcl_fct_default_param(id);
-
 
879
					report(crt_loc, err);
-
 
880
				}
-
 
881
				break;
-
 
882
			}
-
 
883
			default: {
-
 
884
				/* Used in local class */
-
 
885
				ERROR err = ERR_class_local_auto(id);
-
 
886
				report(crt_loc, err);
-
 
887
				break;
-
 
888
			}
-
 
889
			}
-
 
890
		}
-
 
891
		t = DEREF_type(id_variable_etc_type(id));
-
 
892
		if ((ds & dspec_extern) && cv_extern) {
-
 
893
			CV_SPEC cv = DEREF_cv(type_qual(t));
-
 
894
			t = qualify_type(t,(cv | cv_extern), 0);
-
 
895
			used_extern_volatile = 1;
-
 
896
		}
-
 
897
		MAKE_exp_identifier(t, id, cq, e);
-
 
898
		break;
-
 
899
	}
-
 
900
	case id_stat_member_tag: {
-
 
901
		/* Static data members */
-
 
902
		TYPE t;
-
 
903
		DECL_SPEC ds;
-
 
904
		use_id(id, suppress_usage);
-
 
905
		ds = DEREF_dspec(id_storage(id));
-
 
906
		if (ds & dspec_inherit) {
-
 
907
			id = DEREF_id(id_alias(id));
-
 
908
		}
-
 
909
		t = DEREF_type(id_stat_member_type(id));
-
 
910
		if ((ds & dspec_extern) && cv_extern) {
-
 
911
			CV_SPEC cv = DEREF_cv(type_qual(t));
-
 
912
			t = qualify_type(t,(cv | cv_extern), 0);
-
 
913
			used_extern_volatile = 1;
-
 
914
		}
-
 
915
		MAKE_exp_identifier(t, id, cq, e);
-
 
916
		break;
-
 
917
	}
-
 
918
	case id_function_tag: {
-
 
919
		/* Normal functions */
-
 
920
		TYPE t = DEREF_type(id_function_type(id));
-
 
921
		MAKE_exp_identifier(t, id, cq, e);
-
 
922
		break;
-
 
923
	}
-
 
924
	case id_stat_mem_func_tag: {
-
 
925
		/* Static member functions */
-
 
926
		TYPE t = DEREF_type(id_stat_mem_func_type(id));
-
 
927
		IDENTIFIER over = DEREF_id(id_stat_mem_func_over(id));
-
 
928
		if (IS_NULL_id(over)) {
-
 
929
			MAKE_exp_identifier(t, id, cq, e);
-
 
930
		} else {
-
 
931
			MAKE_exp_member(t, id, cq, e);
-
 
932
		}
-
 
933
		break;
-
 
934
	}
-
 
935
	case id_mem_func_tag: {
-
 
936
		/* Non-static member functions */
-
 
937
		TYPE t = DEREF_type(id_mem_func_type(id));
-
 
938
		MAKE_exp_member(t, id, cq, e);
-
 
939
		break;
-
 
940
	}
-
 
941
	case id_member_tag: {
-
 
942
		/* Non-static members */
-
 
943
		TYPE t = DEREF_type(id_member_type(id));
-
 
944
		MAKE_exp_member(t, id, cq, e);
-
 
945
		break;
-
 
946
	}
-
 
947
	case id_enumerator_tag: {
-
 
948
		/* Enumerators */
-
 
949
		NAT n;
-
 
950
		TYPE t;
-
 
951
		use_id(id, 0);
-
 
952
		e = DEREF_exp(id_enumerator_value(id));
-
 
953
		DECONS_exp_int_lit(t, n, tag, e);
-
 
954
		MAKE_exp_int_lit(t, n, tag, e);
-
 
955
		break;
-
 
956
	}
-
 
957
	case id_token_tag: {
-
 
958
		/* Tokens */
-
 
959
		TOKEN tok = DEREF_tok(id_token_sort(id));
-
 
960
		switch (TAG_tok(tok)) {
-
 
961
		case tok_exp_tag:
-
 
962
		case tok_nat_tag:
-
 
963
		case tok_snat_tag:
-
 
964
		case tok_stmt_tag:
-
 
965
			/* Expression tokens */
-
 
966
			use_id(id, 0);
-
 
967
			id = DEREF_id(id_token_alt(id));
-
 
968
			e = apply_exp_token(id, NULL_list(TOKEN), 0);
-
 
969
			break;
-
 
970
		default:
-
 
971
			/* Other tokens */
-
 
972
			goto default_lab;
-
 
973
		}
-
 
974
		break;
-
 
975
	}
-
 
976
	case id_class_name_tag:
-
 
977
	case id_enum_name_tag:
-
 
978
	case id_class_alias_tag:
-
 
979
	case id_enum_alias_tag:
-
 
980
	case id_type_alias_tag: {
-
 
981
		/* Type names */
-
 
982
		TYPE t = DEREF_type(id_class_name_etc_defn(id));
-
 
983
		report(crt_loc, ERR_expr_prim_type(id));
-
 
984
		MAKE_exp_value(t, e);
-
 
985
		break;
-
 
986
	}
-
 
987
	case id_ambig_tag: {
-
 
988
		/* Ambiguous identifiers */
-
 
989
		MAKE_exp_ambiguous(type_error, id, cq, e);
-
 
990
		break;
-
 
991
	}
-
 
992
	default:
-
 
993
default_lab:
-
 
994
		/* Undefined identifiers */
-
 
995
		if (cq == qual_none && in_template_decl) {
-
 
996
			/* Create a dummy identifier */
-
 
997
			HASHID nm = DEREF_hashid(id_name(id));
-
 
998
			NAMESPACE ns = nonblock_namespace;
-
 
999
			MAKE_id_undef(nm, dspec_none, ns, crt_loc, id);
-
 
1000
		}
-
 
1001
		MAKE_exp_undeclared(type_error, id, cq, e);
-
 
1002
		break;
-
 
1003
	}
-
 
1004
	return (e);
-
 
1005
}
-
 
1006
 
-
 
1007
 
-
 
1008
/*
-
 
1009
    FIND THE THIS PARAMETER OF A FUNCTION
-
 
1010
 
-
 
1011
    This routine returns the 'this' parameter of the member function fn.
-
 
1012
    If use is true then the parameter is marked as used.
-
 
1013
*/
-
 
1014
 
-
 
1015
IDENTIFIER
-
 
1016
this_param(IDENTIFIER fn, int use)
-
 
1017
{
982
    NAMESPACE ns ;
1018
	NAMESPACE ns;
983
    IDENTIFIER pid ;
1019
	IDENTIFIER pid;
984
    HASHID nm = KEYWORD ( lex_this_Hname ) ;
1020
	HASHID nm = KEYWORD(lex_this_Hname);
985
    TYPE t = DEREF_type ( id_mem_func_type ( fn ) ) ;
1021
	TYPE t = DEREF_type(id_mem_func_type(fn));
986
    while ( IS_type_templ ( t ) ) {
1022
	while (IS_type_templ(t)) {
987
	t = DEREF_type ( type_templ_defn ( t ) ) ;
1023
		t = DEREF_type(type_templ_defn(t));
988
    }
1024
	}
989
    ns = DEREF_nspace ( type_func_pars ( t ) ) ;
1025
	ns = DEREF_nspace(type_func_pars(t));
990
    pid = search_id ( ns, nm, 0, 0 ) ;
1026
	pid = search_id(ns, nm, 0, 0);
991
    if ( !IS_NULL_id ( pid ) && use ) {
1027
	if (!IS_NULL_id(pid) && use) {
992
	/* Mark parameter as used */
1028
		/* Mark parameter as used */
993
	DECL_SPEC ds = DEREF_dspec ( id_storage ( pid ) ) ;
1029
		DECL_SPEC ds = DEREF_dspec(id_storage(pid));
994
	ds |= dspec_used ;
1030
		ds |= dspec_used;
995
	COPY_dspec ( id_storage ( pid ), ds ) ;
1031
		COPY_dspec(id_storage(pid), ds);
996
    }
1032
	}
997
    return ( pid ) ;
1033
	return (pid);
998
}
1034
}
999
 
1035
 
1000
 
1036
 
1001
/*
1037
/*
1002
    CREATE A THIS EXPRESSION
1038
    CREATE A THIS EXPRESSION
1003
 
1039
 
1004
    This routine deals with the 'this' expression.  This is only in scope
1040
    This routine deals with the 'this' expression.  This is only in scope
1005
    in the definition of a non-static member function.   Note that the
1041
    in the definition of a non-static member function.   Note that the
1006
    current value of 'this' is given by the address of the dummy parameter
1042
    current value of 'this' is given by the address of the dummy parameter
1007
    with name given by lex_this_Hname.
1043
    with name given by lex_this_Hname.
1008
*/
1044
*/
1009
 
1045
 
1010
EXP make_this_exp
1046
EXP
1011
    PROTO_Z ()
1047
make_this_exp(void)
1012
{
1048
{
1013
    EXP e ;
1049
	EXP e;
1014
    TYPE t ;
1050
	TYPE t;
1015
    IDENTIFIER fn = crt_func_id ;
1051
	IDENTIFIER fn = crt_func_id;
1016
    if ( in_function_defn && IS_id_mem_func ( fn ) ) {
1052
	if (in_function_defn && IS_id_mem_func(fn)) {
1017
	/* The current value of 'this' is returned */
1053
		/* The current value of 'this' is returned */
1018
        IDENTIFIER pid = this_param ( fn, 1 ) ;
1054
		IDENTIFIER pid = this_param(fn, 1);
1019
	if ( in_default_arg ) {
1055
		if (in_default_arg) {
1020
	    /* Can't use 'this' in default argument */
1056
			/* Can't use 'this' in default argument */
1021
	    ERROR err = ERR_dcl_fct_default_param ( pid ) ;
1057
			ERROR err = ERR_dcl_fct_default_param(pid);
1022
	    report ( crt_loc, err ) ;
1058
			report(crt_loc, err);
-
 
1059
		}
-
 
1060
		e = DEREF_exp(id_parameter_init(pid));
-
 
1061
		t = DEREF_type(exp_type(e));
-
 
1062
		MAKE_exp_copy(t, e, e);
-
 
1063
	} else {
-
 
1064
		/* Must be inside a non-static member function */
-
 
1065
		report(crt_loc, ERR_expr_prim_this());
-
 
1066
		e = make_error_exp(0);
1023
	}
1067
	}
1024
	e = DEREF_exp ( id_parameter_init ( pid ) ) ;
-
 
1025
	t = DEREF_type ( exp_type ( e ) ) ;
-
 
1026
	MAKE_exp_copy ( t, e, e ) ;
-
 
1027
    } else {
-
 
1028
	/* Must be inside a non-static member function */
-
 
1029
	report ( crt_loc, ERR_expr_prim_this () ) ;
-
 
1030
	e = make_error_exp ( 0 ) ;
-
 
1031
    }
-
 
1032
    return ( e ) ;
1068
	return (e);
1033
}
1069
}
1034
 
1070
 
1035
 
1071
 
1036
/*
1072
/*
1037
    CREATE A THIS EXPRESSION
1073
    CREATE A THIS EXPRESSION
1038
 
1074
 
1039
    This routine creates an expression corresponding to the 'this' parameter
1075
    This routine creates an expression corresponding to the 'this' parameter
1040
    of a member function.  The parent class namespace is assigned to pns.
1076
    of a member function.  The parent class namespace is assigned to pns.
1041
    The null expression is returned if we are outside of a member function.
1077
    The null expression is returned if we are outside of a member function.
1042
*/
1078
*/
1043
 
1079
 
1044
EXP make_this_ref
1080
EXP
1045
    PROTO_N ( ( pns ) )
-
 
1046
    PROTO_T ( NAMESPACE *pns )
1081
make_this_ref(NAMESPACE *pns)
1047
{
1082
{
1048
    IDENTIFIER fn = crt_func_id ;
1083
	IDENTIFIER fn = crt_func_id;
1049
    if ( in_function_defn && IS_id_mem_func ( fn ) ) {
1084
	if (in_function_defn && IS_id_mem_func(fn)) {
1050
	EXP e ;
1085
		EXP e;
1051
        IDENTIFIER pid = this_param ( fn, 1 ) ;
1086
		IDENTIFIER pid = this_param(fn, 1);
1052
	TYPE t = DEREF_type ( id_parameter_type ( pid ) ) ;
1087
		TYPE t = DEREF_type(id_parameter_type(pid));
1053
	MAKE_exp_identifier ( t, pid, qual_none, e ) ;
1088
		MAKE_exp_identifier(t, pid, qual_none, e);
1054
	*pns = DEREF_nspace ( id_parent ( fn ) ) ;
1089
		*pns = DEREF_nspace(id_parent(fn));
1055
	return ( e ) ;
1090
		return (e);
1056
    }
1091
	}
1057
    return ( NULL_exp ) ;
1092
	return (NULL_exp);
1058
}
1093
}
1059
 
1094
 
1060
 
1095
 
1061
/*
1096
/*
1062
    DECLARE A THIS PARAMETER
1097
    DECLARE A THIS PARAMETER
1063
 
1098
 
1064
    This routine declares the dummy extra parameter for the non-static
1099
    This routine declares the dummy extra parameter for the non-static
1065
    member function given by the identifier fn.  The type of this parameter
1100
    member function given by the identifier fn.  The type of this parameter
1066
    is the first element of the corresponding mtypes list (see
1101
    is the first element of the corresponding mtypes list (see
1067
    member_func_type).  An expression giving the address of the parameter
1102
    member_func_type).  An expression giving the address of the parameter
1068
    is stored in its default argument position.  This gives the value of
1103
    is stored in its default argument position.  This gives the value of
1069
    the 'this' expression.
1104
    the 'this' expression.
1070
*/
1105
*/
1071
 
1106
 
1072
EXP make_this_decl
1107
EXP
1073
    PROTO_N ( ( fn ) )
-
 
1074
    PROTO_T ( IDENTIFIER fn )
1108
make_this_decl(IDENTIFIER fn)
1075
{
1109
{
1076
    /* Look up identifier */
1110
	/* Look up identifier */
1077
    EXP e ;
1111
	EXP e;
1078
    TYPE t ;
1112
	TYPE t;
1079
    IDENTIFIER pid ;
1113
	IDENTIFIER pid;
1080
    LIST ( TYPE ) mtypes ;
1114
	LIST(TYPE) mtypes;
1081
    NAMESPACE ns = crt_namespace ;
1115
	NAMESPACE ns = crt_namespace;
1082
    HASHID nm = KEYWORD ( lex_this_Hname ) ;
1116
	HASHID nm = KEYWORD(lex_this_Hname);
1083
    MEMBER mem = search_member ( ns, nm, 1 ) ;
1117
	MEMBER mem = search_member(ns, nm, 1);
1084
    IDENTIFIER qid = DEREF_id ( member_id ( mem ) ) ;
1118
	IDENTIFIER qid = DEREF_id(member_id(mem));
1085
    DECL_SPEC ds = ( dspec_auto | dspec_defn | dspec_implicit ) ;
1119
	DECL_SPEC ds = (dspec_auto | dspec_defn | dspec_implicit);
1086
 
1120
 
1087
    /* Construct the type of the parameter */
1121
	/* Construct the type of the parameter */
1088
    TYPE f = DEREF_type ( id_mem_func_type ( fn ) ) ;
1122
	TYPE f = DEREF_type(id_mem_func_type(fn));
1089
    while ( IS_type_templ ( f ) ) {
1123
	while (IS_type_templ(f)) {
1090
	f = DEREF_type ( type_templ_defn ( f ) ) ;
1124
		f = DEREF_type(type_templ_defn(f));
1091
    }
1125
	}
1092
    mtypes = DEREF_list ( type_func_mtypes ( f ) ) ;
1126
	mtypes = DEREF_list(type_func_mtypes(f));
1093
    t = DEREF_type ( HEAD_list ( mtypes ) ) ;
1127
	t = DEREF_type(HEAD_list(mtypes));
1094
 
-
 
1095
    /* Declare parameter */
-
 
1096
    MAKE_id_parameter ( nm, ds, ns, crt_loc, t, pid ) ;
-
 
1097
    if ( !IS_NULL_id ( qid ) ) {
-
 
1098
	qid = DEREF_id ( id_alias ( qid ) ) ;
-
 
1099
	COPY_id ( id_alias ( pid ), qid ) ;
-
 
1100
    }
-
 
1101
    COPY_id ( hashid_cache ( nm ), pid ) ;
-
 
1102
    COPY_id ( member_id ( mem ), pid ) ;
-
 
1103
 
1128
 
-
 
1129
	/* Declare parameter */
-
 
1130
	MAKE_id_parameter(nm, ds, ns, crt_loc, t, pid);
-
 
1131
	if (!IS_NULL_id(qid)) {
-
 
1132
		qid = DEREF_id(id_alias(qid));
-
 
1133
		COPY_id(id_alias(pid), qid);
-
 
1134
	}
-
 
1135
	COPY_id(hashid_cache(nm), pid);
-
 
1136
	COPY_id(member_id(mem), pid);
-
 
1137
 
1104
    /* Construct the 'this' expression */
1138
	/* Construct the 'this' expression */
1105
    t = DEREF_type ( type_ref_sub ( t ) ) ;
1139
	t = DEREF_type(type_ref_sub(t));
1106
    t = rvalue_type ( t ) ;
1140
	t = rvalue_type(t);
1107
    if ( option ( OPT_this_lvalue ) == OPTION_ALLOW ) {
1141
	if (option(OPT_this_lvalue) == OPTION_ALLOW) {
1108
	MAKE_type_ptr ( cv_lvalue, t, t ) ;
1142
		MAKE_type_ptr(cv_lvalue, t, t);
1109
	MAKE_exp_identifier ( t, pid, qual_none, e ) ;
1143
		MAKE_exp_identifier(t, pid, qual_none, e);
1110
    } else {
1144
	} else {
1111
	MAKE_type_ptr ( cv_none, t, t ) ;
1145
		MAKE_type_ptr(cv_none, t, t);
1112
	MAKE_exp_identifier ( t, pid, qual_none, e ) ;
1146
		MAKE_exp_identifier(t, pid, qual_none, e);
1113
	MAKE_exp_contents ( t, e, e ) ;
1147
		MAKE_exp_contents(t, e, e);
1114
    }
1148
	}
1115
    COPY_exp ( id_parameter_init ( pid ), e ) ;
1149
	COPY_exp(id_parameter_init(pid), e);
1116
    return ( e ) ;
1150
	return (e);
1117
}
1151
}
1118
 
1152
 
1119
 
1153
 
1120
/*
1154
/*
1121
    CHECK FOR THIS EXPRESSIONS
1155
    CHECK FOR THIS EXPRESSIONS
1122
 
1156
 
1123
    This routine checks whether the expression e is a 'this' expression.
1157
    This routine checks whether the expression e is a 'this' expression.
1124
*/
1158
*/
1125
 
1159
 
1126
int is_this_exp
1160
int
1127
    PROTO_N ( ( e ) )
-
 
1128
    PROTO_T ( EXP e )
1161
is_this_exp(EXP e)
1129
{
1162
{
1130
    if ( !IS_NULL_exp ( e ) ) {
1163
	if (!IS_NULL_exp(e)) {
1131
	unsigned tag = TAG_exp ( e ) ;
1164
		unsigned tag = TAG_exp(e);
1132
	if ( tag == exp_indir_tag ) {
1165
		if (tag == exp_indir_tag) {
1133
	    e = DEREF_exp ( exp_indir_ptr ( e ) ) ;
1166
			e = DEREF_exp(exp_indir_ptr(e));
1134
	    tag = TAG_exp ( e ) ;
1167
			tag = TAG_exp(e);
1135
	}
1168
		}
1136
	if ( tag == exp_copy_tag ) {
1169
		if (tag == exp_copy_tag) {
1137
	    e = DEREF_exp ( exp_copy_arg ( e ) ) ;
1170
			e = DEREF_exp(exp_copy_arg(e));
1138
	    tag = TAG_exp ( e ) ;
1171
			tag = TAG_exp(e);
1139
	}
1172
		}
1140
	if ( tag == exp_contents_tag ) {
1173
		if (tag == exp_contents_tag) {
1141
	    e = DEREF_exp ( exp_contents_ptr ( e ) ) ;
1174
			e = DEREF_exp(exp_contents_ptr(e));
1142
	    tag = TAG_exp ( e ) ;
1175
			tag = TAG_exp(e);
1143
	}
1176
		}
1144
	if ( tag == exp_copy_tag ) {
1177
		if (tag == exp_copy_tag) {
1145
	    e = DEREF_exp ( exp_copy_arg ( e ) ) ;
1178
			e = DEREF_exp(exp_copy_arg(e));
1146
	    tag = TAG_exp ( e ) ;
1179
			tag = TAG_exp(e);
1147
	}
1180
		}
1148
	if ( tag == exp_identifier_tag ) {
1181
		if (tag == exp_identifier_tag) {
1149
	    IDENTIFIER id = DEREF_id ( exp_identifier_id ( e ) ) ;
1182
			IDENTIFIER id = DEREF_id(exp_identifier_id(e));
1150
	    HASHID nm = DEREF_hashid ( id_name ( id ) ) ;
1183
			HASHID nm = DEREF_hashid(id_name(id));
1151
	    if ( EQ_KEYWORD ( nm, lex_this_Hname ) ) return ( 1 ) ;
1184
			if (EQ_KEYWORD(nm, lex_this_Hname)) {
-
 
1185
				return (1);
-
 
1186
			}
1152
	}
1187
		}
1153
    }
1188
	}
1154
    return ( 0 ) ;
1189
	return (0);
1155
}
1190
}
1156
 
1191
 
1157
 
1192
 
1158
/*
1193
/*
1159
    FIND THE ELLIPSIS PARAMETER OF A FUNCTION
1194
    FIND THE ELLIPSIS PARAMETER OF A FUNCTION
1160
 
1195
 
1161
    This routine returns the ellipsis parameter of the function fn.
1196
    This routine returns the ellipsis parameter of the function fn.
1162
*/
1197
*/
1163
 
1198
 
1164
IDENTIFIER ellipsis_param
1199
IDENTIFIER
1165
    PROTO_N ( ( fn ) )
-
 
1166
    PROTO_T ( IDENTIFIER fn )
1200
ellipsis_param(IDENTIFIER fn)
1167
{
1201
{
1168
    int ell ;
1202
	int ell;
1169
    TYPE t = DEREF_type ( id_function_etc_type ( fn ) ) ;
1203
	TYPE t = DEREF_type(id_function_etc_type(fn));
1170
    while ( IS_type_templ ( t ) ) {
1204
	while (IS_type_templ(t)) {
1171
	t = DEREF_type ( type_templ_defn ( t ) ) ;
1205
		t = DEREF_type(type_templ_defn(t));
1172
    }
1206
	}
1173
    ell = DEREF_int ( type_func_ellipsis ( t ) ) ;
1207
	ell = DEREF_int(type_func_ellipsis(t));
1174
    if ( ell & FUNC_ELLIPSIS ) {
1208
	if (ell & FUNC_ELLIPSIS) {
1175
	HASHID nm = KEYWORD ( lex_ellipsis_Hexp ) ;
1209
		HASHID nm = KEYWORD(lex_ellipsis_Hexp);
1176
	NAMESPACE ns = DEREF_nspace ( type_func_pars ( t ) ) ;
1210
		NAMESPACE ns = DEREF_nspace(type_func_pars(t));
1177
	IDENTIFIER pid = search_id ( ns, nm, 0, 0 ) ;
1211
		IDENTIFIER pid = search_id(ns, nm, 0, 0);
1178
	return ( pid ) ;
1212
		return (pid);
1179
    }
1213
	}
1180
    return ( NULL_id ) ;
1214
	return (NULL_id);
1181
}
1215
}
1182
 
1216
 
1183
 
1217
 
1184
/*
1218
/*
1185
    FIND ELLIPSIS TYPE
1219
    FIND ELLIPSIS TYPE
1186
 
1220
 
1187
    This routine returns the type of the dummy ellipsis parameter.  If
1221
    This routine returns the type of the dummy ellipsis parameter.  If
1188
    force is true then an error is reported if this type has not been
1222
    force is true then an error is reported if this type has not been
1189
    declared.
1223
    declared.
1190
*/
1224
*/
1191
 
1225
 
1192
static TYPE find_ellipsis_type
1226
static TYPE
1193
    PROTO_N ( ( force ) )
-
 
1194
    PROTO_T ( int force )
1227
find_ellipsis_type(int force)
1195
{
1228
{
1196
    TYPE t = type_ellipsis ;
1229
	TYPE t = type_ellipsis;
1197
    if ( IS_NULL_type ( t ) ) {
1230
	if (IS_NULL_type(t)) {
1198
	/* Look up token if not already defined */
1231
		/* Look up token if not already defined */
1199
	IDENTIFIER tid = get_special ( TOK_va_t, 1 ) ;
1232
		IDENTIFIER tid = get_special(TOK_va_t, 1);
1200
	if ( !IS_NULL_id ( tid ) && IS_id_token ( tid ) ) {
1233
		if (!IS_NULL_id(tid) && IS_id_token(tid)) {
1201
	    tid = DEREF_id ( id_token_alt ( tid ) ) ;
1234
			tid = DEREF_id(id_token_alt(tid));
1202
	    if ( IS_id_class_name_etc ( tid ) ) {
1235
			if (IS_id_class_name_etc(tid)) {
1203
		t = DEREF_type ( id_class_name_etc_defn ( tid ) ) ;
1236
				t = DEREF_type(id_class_name_etc_defn(tid));
1204
		type_ellipsis = t ;
1237
				type_ellipsis = t;
1205
	    }
1238
			}
1206
	}
1239
		}
1207
	if ( IS_NULL_type ( t ) ) {
1240
		if (IS_NULL_type(t)) {
1208
	    if ( force ) {
1241
			if (force) {
1209
		/* Report if ellipsis type is undefined */
1242
				/* Report if ellipsis type is undefined */
1210
		HASHID nm = KEYWORD ( lex_ellipsis_Hexp ) ;
1243
				HASHID nm = KEYWORD(lex_ellipsis_Hexp);
-
 
1244
				report(crt_loc,
1211
		report ( crt_loc, ERR_lib_builtin ( NULL_string, nm ) ) ;
1245
				       ERR_lib_builtin(NULL_string, nm));
1212
	    }
1246
			}
1213
	    t = type_error ;
1247
			t = type_error;
-
 
1248
		}
1214
	}
1249
	}
1215
    }
-
 
1216
    return ( t ) ;
1250
	return (t);
1217
}
1251
}
1218
 
1252
 
1219
 
1253
 
1220
/*
1254
/*
1221
    DECLARE AN ELLIPSIS PARAMETER
1255
    DECLARE AN ELLIPSIS PARAMETER
1222
 
1256
 
1223
    This routine declares the dummy extra parameter representing the
1257
    This routine declares the dummy extra parameter representing the
1224
    ellipsis component of the function id.
1258
    ellipsis component of the function id.
1225
*/
1259
*/
1226
 
1260
 
-
 
1261
void
1227
void make_ellipsis_decl
1262
make_ellipsis_decl(void)
1228
    PROTO_Z ()
-
 
1229
{
1263
{
1230
    IDENTIFIER pid ;
1264
	IDENTIFIER pid;
1231
    NAMESPACE ns = crt_namespace ;
1265
	NAMESPACE ns = crt_namespace;
1232
    TYPE t = find_ellipsis_type ( 0 ) ;
1266
	TYPE t = find_ellipsis_type(0);
1233
    HASHID nm = KEYWORD ( lex_ellipsis_Hexp ) ;
1267
	HASHID nm = KEYWORD(lex_ellipsis_Hexp);
1234
    MEMBER mem = search_member ( ns, nm, 1 ) ;
1268
	MEMBER mem = search_member(ns, nm, 1);
1235
    IDENTIFIER qid = DEREF_id ( member_id ( mem ) ) ;
1269
	IDENTIFIER qid = DEREF_id(member_id(mem));
1236
    DECL_SPEC ds = ( dspec_auto | dspec_defn | dspec_implicit ) ;
1270
	DECL_SPEC ds = (dspec_auto | dspec_defn | dspec_implicit);
1237
    MAKE_id_parameter ( nm, ds, ns, crt_loc, t, pid ) ;
1271
	MAKE_id_parameter(nm, ds, ns, crt_loc, t, pid);
1238
    if ( !IS_NULL_id ( qid ) ) {
1272
	if (!IS_NULL_id(qid)) {
1239
	qid = DEREF_id ( id_alias ( qid ) ) ;
1273
		qid = DEREF_id(id_alias(qid));
1240
	COPY_id ( id_alias ( pid ), qid ) ;
1274
		COPY_id(id_alias(pid), qid);
1241
    }
1275
	}
1242
    COPY_id ( hashid_cache ( nm ), pid ) ;
1276
	COPY_id(hashid_cache(nm), pid);
1243
    COPY_id ( member_id ( mem ), pid ) ;
1277
	COPY_id(member_id(mem), pid);
1244
    return ;
1278
	return;
1245
}
1279
}
1246
 
1280
 
1247
 
1281
 
1248
/*
1282
/*
1249
    CREATE AN ELLIPSIS EXPRESSION
1283
    CREATE AN ELLIPSIS EXPRESSION
Line 1252... Line 1286...
1252
    expression '...'.  This can only be used in a function definition
1286
    expression '...'.  This can only be used in a function definition
1253
    which has an ellipsis type, in which case it is an rvalue of type
1287
    which has an ellipsis type, in which case it is an rvalue of type
1254
    type_ellipsis.
1288
    type_ellipsis.
1255
*/
1289
*/
1256
 
1290
 
-
 
1291
EXP
1257
EXP make_ellipsis_exp
1292
make_ellipsis_exp(void)
1258
    PROTO_Z ()
-
 
1259
{
1293
{
1260
    EXP e ;
1294
	EXP e;
1261
    if ( in_function_defn ) {
1295
	if (in_function_defn) {
1262
	IDENTIFIER pid = ellipsis_param ( crt_func_id ) ;
1296
		IDENTIFIER pid = ellipsis_param(crt_func_id);
1263
	if ( !IS_NULL_id ( pid ) ) {
1297
		if (!IS_NULL_id(pid)) {
1264
	    /* Form result */
1298
			/* Form result */
1265
	    TYPE t = find_ellipsis_type ( 1 ) ;
1299
			TYPE t = find_ellipsis_type(1);
1266
	    report ( crt_loc, ERR_expr_call_ell_exp () ) ;
1300
			report(crt_loc, ERR_expr_call_ell_exp());
1267
	    MAKE_exp_identifier ( t, pid, qual_none, e ) ;
1301
			MAKE_exp_identifier(t, pid, qual_none, e);
1268
	    return ( e ) ;
1302
			return (e);
-
 
1303
		}
1269
	}
1304
	}
1270
    }
-
 
1271
    report ( crt_loc, ERR_expr_call_ell_func () ) ;
1305
	report(crt_loc, ERR_expr_call_ell_func());
1272
    e = make_error_exp ( 0 ) ;
1306
	e = make_error_exp(0);
1273
    return ( e ) ;
1307
	return (e);
1274
}
1308
}