Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
#include "config.h"
32
#include "c_types.h"
33
#include "exp_ops.h"
34
#include "ftype_ops.h"
35
#include "id_ops.h"
36
#include "itype_ops.h"
37
#include "nat_ops.h"
38
#include "tok_ops.h"
39
#include "type_ops.h"
40
#include "error.h"
41
#include "catalog.h"
42
#include "option.h"
43
#include "basetype.h"
44
#include "class.h"
45
#include "constant.h"
46
#include "convert.h"
47
#include "chktype.h"
48
#include "function.h"
49
#include "identifier.h"
50
#include "inttype.h"
51
#include "lex.h"
52
#include "predict.h"
53
#include "preproc.h"
54
#include "redeclare.h"
55
#include "syntax.h"
56
#include "template.h"
57
#include "token.h"
58
 
59
 
60
/*
61
    CREATE A QUALIFIED TYPE
62
 
63
    This routine creates a type consisting of t qualified by the const-
64
    volatile qualifiers cv.  Note that the existing qualifiers for t are
65
    not taken into account in the result.  If t already has qualifier cv
66
    and force is false then t itself is returned, otherwise a copy of t
67
    with the appropriate qualifier is constructed.
68
*/
69
 
70
TYPE qualify_type
71
    PROTO_N ( ( t, cv, force ) )
72
    PROTO_T ( TYPE t X CV_SPEC cv X int force )
73
{
74
    TYPE r ;
75
    unsigned tag ;
76
    IDENTIFIER tid ;
77
 
78
    /* Just return t if it is correctly qualified */
79
    CV_SPEC qual = DEREF_cv ( type_qual ( t ) ) ;
80
    if ( qual == cv && !force ) return ( t ) ;
81
 
82
    /* Copy the type otherwise */
83
    tag = TAG_type ( t ) ;
84
    ASSERT ( ORDER_type == 18 ) ;
85
    switch ( tag ) {
86
	case type_pre_tag : {
87
	    BASE_TYPE rep ;
88
	    QUALIFIER idtype ;
89
	    DECONS_type_pre ( qual, tid, rep, idtype, t ) ;
90
	    MAKE_type_pre ( cv, rep, idtype, r ) ;
91
	    break ;
92
	}
93
	case type_integer_tag : {
94
	    INT_TYPE rep ;
95
	    INT_TYPE sem ;
96
	    DECONS_type_integer ( qual, tid, rep, sem, t ) ;
97
	    if ( cv == cv_none && IS_NULL_id ( tid ) && !force ) {
98
		r = make_itype ( rep, sem ) ;
99
		break ;
100
	    }
101
	    MAKE_type_integer ( cv, rep, sem, r ) ;
102
	    break ;
103
	}
104
	case type_floating_tag : {
105
	    FLOAT_TYPE rep ;
106
	    FLOAT_TYPE sem ;
107
	    DECONS_type_floating ( qual, tid, rep, sem, t ) ;
108
	    if ( cv == cv_none && IS_NULL_id ( tid ) && !force ) {
109
		if ( IS_ftype_basic ( rep ) ) {
110
		    BUILTIN_TYPE n = DEREF_ntype ( ftype_basic_no ( rep ) ) ;
111
		    r = type_builtin [n] ;
112
		    break ;
113
		}
114
	    }
115
	    MAKE_type_floating ( cv, rep, sem, r ) ;
116
	    break ;
117
	}
118
	case type_top_tag : {
119
	    tid = DEREF_id ( type_name ( t ) ) ;
120
	    if ( cv == cv_none && IS_NULL_id ( tid ) && !force ) {
121
		r = type_void ;
122
		break ;
123
	    }
124
	    MAKE_type_top ( cv, r ) ;
125
	    break ;
126
	}
127
	case type_bottom_tag : {
128
	    tid = DEREF_id ( type_name ( t ) ) ;
129
	    if ( cv == cv_none && IS_NULL_id ( tid ) && !force ) {
130
		r = type_bottom ;
131
		break ;
132
	    }
133
	    MAKE_type_bottom ( cv, r ) ;
134
	    break ;
135
	}
136
	case type_ptr_tag : {
137
	    TYPE sub ;
138
	    DECONS_type_ptr ( qual, tid, sub, t ) ;
139
	    MAKE_type_ptr ( cv, sub, r ) ;
140
	    break ;
141
	}
142
	case type_ref_tag : {
143
	    TYPE sub ;
144
	    CV_SPEC cv1 = ( cv & cv_qual ) ;
145
	    DECONS_type_ref ( qual, tid, sub, t ) ;
146
	    if ( cv1 ) {
147
		/* Pass cv-qualifiers to base type */
148
		CV_SPEC cv2 = DEREF_cv ( type_qual ( sub ) ) ;
149
		sub = qualify_type ( sub, ( cv1 | cv2 ), force ) ;
150
		cv &= ~cv_qual ;
151
	    }
152
	    MAKE_type_ref ( cv, sub, r ) ;
153
	    break ;
154
	}
155
#if LANGUAGE_CPP
156
	case type_ptr_mem_tag : {
157
	    CLASS_TYPE of ;
158
	    TYPE sub ;
159
	    DECONS_type_ptr_mem ( qual, tid, of, sub, t ) ;
160
	    MAKE_type_ptr_mem ( cv, of, sub, r ) ;
161
	    break ;
162
	}
163
#endif
164
	case type_func_tag : {
165
	    int ell ;
166
	    TYPE ret ;
167
	    CV_SPEC mqual ;
168
	    NAMESPACE pars ;
169
	    LIST ( TYPE ) ptypes ;
170
	    LIST ( TYPE ) mtypes ;
171
	    LIST ( TYPE ) except ;
172
	    LIST ( IDENTIFIER ) pids ;
173
	    DECONS_type_func ( qual, tid, ret, ptypes, ell, mqual,
174
			       mtypes, pars, pids, except, t ) ;
175
	    cv &= ~cv_qual ;
176
	    MAKE_type_func ( cv, ret, ptypes, ell, mqual,
177
			     mtypes, pars, pids, except, r ) ;
178
	    break ;
179
	}
180
	case type_array_tag : {
181
	    TYPE sub ;
182
	    NAT size ;
183
	    CV_SPEC cv1 = ( cv & cv_qual ) ;
184
	    DECONS_type_array ( qual, tid, sub, size, t ) ;
185
	    if ( cv1 ) {
186
		/* Pass cv-qualifiers to base type */
187
		CV_SPEC cv2 = DEREF_cv ( type_qual ( sub ) ) ;
188
		sub = qualify_type ( sub, ( cv1 | cv2 ), force ) ;
189
		cv &= ~cv_qual ;
190
	    }
191
	    MAKE_type_array ( cv, sub, size, r ) ;
192
	    break ;
193
	}
194
	case type_bitfield_tag : {
195
	    INT_TYPE defn ;
196
	    DECONS_type_bitfield ( qual, tid, defn, t ) ;
197
	    MAKE_type_bitfield ( cv, defn, r ) ;
198
	    break ;
199
	}
200
	case type_compound_tag : {
201
	    CLASS_TYPE defn ;
202
	    DECONS_type_compound ( qual, tid, defn, t ) ;
203
	    MAKE_type_compound ( cv, defn, r ) ;
204
	    break ;
205
	}
206
	case type_enumerate_tag : {
207
	    ENUM_TYPE defn ;
208
	    DECONS_type_enumerate ( qual, tid, defn, t ) ;
209
	    MAKE_type_enumerate ( cv, defn, r ) ;
210
	    break ;
211
	}
212
	case type_token_tag : {
213
	    INSTANCE app ;
214
	    IDENTIFIER tok ;
215
	    LIST ( TOKEN ) args ;
216
	    DECONS_type_token ( qual, tid, tok, args, app, t ) ;
217
	    MAKE_type_token ( cv, tok, args, r ) ;
218
	    COPY_inst ( type_token_app ( r ), app ) ;
219
	    break ;
220
	}
221
	case type_templ_tag : {
222
	    int fix ;
223
	    TYPE defn ;
224
	    TOKEN sort ;
225
	    DECONS_type_templ ( qual, tid, sort, defn, fix, t ) ;
226
	    MAKE_type_templ ( cv, sort, defn, fix, r ) ;
227
	    break ;
228
	}
229
	case type_instance_tag : {
230
	    IDENTIFIER id ;
231
	    DECL_SPEC acc ;
232
	    DECONS_type_instance ( qual, tid, id, acc, t ) ;
233
	    MAKE_type_instance ( cv, id, acc, r ) ;
234
	    break ;
235
	}
236
	case type_dummy_tag : {
237
	    int tok ;
238
	    DECONS_type_dummy ( qual, tid, tok, t ) ;
239
	    MAKE_type_dummy ( cv, tok, r ) ;
240
	    break ;
241
	}
242
	case type_error_tag : {
243
	    tid = DEREF_id ( type_name ( t ) ) ;
244
	    cv &= cv_lvalue ;
245
	    MAKE_type_error ( cv, r ) ;
246
	    break ;
247
	}
248
	default : {
249
	    FAIL ( Invalid type ) ;
250
	    tid = NULL_id ;
251
	    r = t ;
252
	    break ;
253
	}
254
    }
255
    COPY_id ( type_name ( r ), tid ) ;
256
    UNUSED ( qual ) ;
257
    return ( r ) ;
258
}
259
 
260
 
261
/*
262
    COPY A TYPEDEF TYPE
263
 
264
    This routine copies the typedef definition type t (corresponding to the
265
    typedef-name id) qualified by the const-volatile qualifiers cv.  Note
266
    that the qualifiers apply to the base type of an array rather than the
267
    array itself.  For example, in:
268
 
269
		typedef int array [3] ;
270
		const array var ;
271
 
272
    the type of var is 'const int [3]'.  Also any qualifiers applied to
273
    reference and function types are ignored.
274
*/
275
 
276
TYPE copy_typedef
277
    PROTO_N ( ( id, t, cv ) )
278
    PROTO_T ( IDENTIFIER id X TYPE t X CV_SPEC cv )
279
{
280
    CV_SPEC qual = DEREF_cv ( type_qual ( t ) ) ;
281
    CV_SPEC qual_new = ( qual | cv ) ;
282
    CV_SPEC qual_join = ( qual & cv ) ;
283
    if ( qual_join && !IS_NULL_id ( id ) ) {
284
	/* Warn about duplicate qualifiers */
285
	report ( crt_loc, ERR_dcl_type_type_cv ( id, qual_join ) ) ;
286
    }
287
 
288
    /* Check types */
289
    switch ( TAG_type ( t ) ) {
290
 
291
	case type_ptr_tag : {
292
	    /* Copy pointer types */
293
	    TYPE s = DEREF_type ( type_ptr_sub ( t ) ) ;
294
	    TYPE r = copy_typedef ( id, s, cv_none ) ;
295
	    if ( !EQ_type ( r, s ) || qual_new != qual ) {
296
		IDENTIFIER tid = DEREF_id ( type_name ( t ) ) ;
297
		MAKE_type_ptr ( qual_new, r, t ) ;
298
		COPY_id ( type_name ( t ), tid ) ;
299
	    }
300
	    break ;
301
	}
302
 
303
	case type_ref_tag : {
304
	    /* Ignore qualifiers for references */
305
	    TYPE s, r ;
306
	    if ( cv && !IS_NULL_id ( id ) ) {
307
		report ( crt_loc, ERR_dcl_ref_cv_type ( cv, id ) ) ;
308
	    }
309
	    s = DEREF_type ( type_ref_sub ( t ) ) ;
310
	    r = copy_typedef ( id, s, cv_none ) ;
311
	    if ( !EQ_type ( r, s ) ) {
312
		IDENTIFIER tid = DEREF_id ( type_name ( t ) ) ;
313
		MAKE_type_ref ( qual, r, t ) ;
314
		COPY_id ( type_name ( t ), tid ) ;
315
	    }
316
	    break ;
317
	}
318
 
319
#if LANGUAGE_CPP
320
	case type_ptr_mem_tag : {
321
	    /* Copy pointer member types */
322
	    TYPE s = DEREF_type ( type_ptr_mem_sub ( t ) ) ;
323
	    TYPE r = copy_typedef ( id, s, cv_none ) ;
324
	    if ( !EQ_type ( r, s ) || qual_new != qual ) {
325
		IDENTIFIER tid = DEREF_id ( type_name ( t ) ) ;
326
		CLASS_TYPE of = DEREF_ctype ( type_ptr_mem_of ( t ) ) ;
327
		MAKE_type_ptr_mem ( qual_new, of, r, t ) ;
328
		COPY_id ( type_name ( t ), tid ) ;
329
	    }
330
	    break ;
331
	}
332
#endif
333
 
334
	case type_func_tag : {
335
	    /* Ignore qualifiers for functions */
336
	    int ell ;
337
	    TYPE ret ;
338
	    CV_SPEC mqual ;
339
	    IDENTIFIER tid ;
340
	    NAMESPACE pars ;
341
	    LIST ( TYPE ) except ;
342
	    LIST ( TYPE ) ptypes ;
343
	    LIST ( TYPE ) mtypes ;
344
	    LIST ( IDENTIFIER ) pids ;
345
	    LIST ( TYPE ) mtypes_new ;
346
	    LIST ( TYPE ) ptypes_new = NULL_list ( TYPE ) ;
347
	    LIST ( IDENTIFIER ) pids_new = NULL_list ( IDENTIFIER ) ;
348
 
349
	    /* Warn about qualifiers */
350
	    if ( cv && !IS_NULL_id ( id ) ) {
351
		report ( crt_loc, ERR_dcl_fct_qual ( cv, id ) ) ;
352
	    }
353
 
354
	    /* Decompose old function type */
355
	    DECONS_type_func ( qual, tid, ret, ptypes, ell, mqual,
356
			       mtypes, pars, pids, except, t ) ;
357
 
358
	    /* Copy appropriate components */
359
	    ret = copy_typedef ( id, ret, cv_none ) ;
360
	    while ( !IS_NULL_list ( pids ) ) {
361
		/* Redeclare each parameter */
362
		TYPE s ;
363
		IDENTIFIER pid = DEREF_id ( HEAD_list ( pids ) ) ;
364
		pid = copy_id ( pid, 1 ) ;
365
		CONS_id ( pid, pids_new, pids_new ) ;
366
		s = DEREF_type ( id_parameter_type ( pid ) ) ;
367
		s = qualify_type ( s, cv_none, 0 ) ;
368
		CONS_type ( s, ptypes_new, ptypes_new ) ;
369
		pids = TAIL_list ( pids ) ;
370
	    }
371
	    pids_new = REVERSE_list ( pids_new ) ;
372
	    ptypes_new = REVERSE_list ( ptypes_new ) ;
373
	    if ( EQ_list ( ptypes, mtypes ) ) {
374
		mtypes_new = ptypes_new ;
375
	    } else {
376
		TYPE r = DEREF_type ( HEAD_list ( mtypes ) ) ;
377
		CONS_type ( r, ptypes_new, mtypes_new ) ;
378
	    }
379
 
380
	    /* Construct new function type */
381
	    MAKE_type_func ( qual, ret, ptypes_new, ell, mqual,
382
			     mtypes_new, pars, pids_new, except, t ) ;
383
	    COPY_id ( type_name ( t ), tid ) ;
384
	    break ;
385
	}
386
 
387
	case type_array_tag : {
388
	    /* Qualify the base type of an array */
389
	    NAT n = DEREF_nat ( type_array_size ( t ) ) ;
390
	    TYPE s = DEREF_type ( type_array_sub ( t ) ) ;
391
	    TYPE r = copy_typedef ( id, s, cv ) ;
392
	    IDENTIFIER tid = DEREF_id ( type_name ( t ) ) ;
393
	    MAKE_type_array ( qual, r, n, t ) ;
394
	    COPY_id ( type_name ( t ), tid ) ;
395
	    break ;
396
	}
397
 
398
	case type_token_tag : {
399
	    /* Tokenised types */
400
	    IDENTIFIER tok = DEREF_id ( type_token_tok ( t ) ) ;
401
	    DECL_SPEC ds = DEREF_dspec ( id_storage ( tok ) ) ;
402
	    if ( !( ds & dspec_defn ) ) goto default_lab ;
403
	    t = expand_type ( t, 0 ) ;
404
	    t = qualify_type ( t, qual_new, 0 ) ;
405
	    break ;
406
	}
407
 
408
	case type_templ_tag : {
409
	    /* Template types */
410
	    TYPE s = DEREF_type ( type_templ_defn ( t ) ) ;
411
	    TOKEN tok = DEREF_tok ( type_templ_sort ( t ) ) ;
412
	    IDENTIFIER tid = DEREF_id ( type_name ( t ) ) ;
413
	    MAKE_type_templ ( qual_new, tok, s, 1, t ) ;
414
	    COPY_id ( type_name ( t ), tid ) ;
415
	    break ;
416
	}
417
 
418
	default :
419
	default_lab : {
420
	    /* Other types */
421
	    if ( qual_new != qual ) {
422
		t = qualify_type ( t, qual_new, 0 ) ;
423
	    }
424
	    break ;
425
	}
426
    }
427
    return ( t ) ;
428
}
429
 
430
 
431
/*
432
    CREATE AN LVALUE TYPE
433
 
434
    This routine creates a type which is an lvalue qualified version of t
435
    (also preserving any other type qualifiers).
436
*/
437
 
438
TYPE lvalue_type
439
    PROTO_N ( ( t ) )
440
    PROTO_T ( TYPE t )
441
{
442
    CV_SPEC qual = DEREF_cv ( type_qual ( t ) ) ;
443
    if ( qual & cv_lvalue ) return ( t ) ;
444
    qual |= cv_lvalue ;
445
    return ( qualify_type ( t, qual, 0 ) ) ;
446
}
447
 
448
 
449
/*
450
    CREATE AN RVALUE TYPE
451
 
452
    This routine creates a type which is identical to t except that it
453
    is an rvalue rather than an lvalue.
454
*/
455
 
456
TYPE rvalue_type
457
    PROTO_N ( ( t ) )
458
    PROTO_T ( TYPE t )
459
{
460
    CV_SPEC qual = DEREF_cv ( type_qual ( t ) ) ;
461
    if ( !( qual & cv_lvalue ) ) return ( t ) ;
462
    qual &= ~cv_lvalue ;
463
    return ( qualify_type ( t, qual, 0 ) ) ;
464
}
465
 
466
 
467
/*
468
    COMBINE TWO PRE-TYPES
469
 
470
    The pre-types are a construction mechanism for allowing built-in types
471
    such as 'unsigned long int' to be built up.  Each pre-type is associated
472
    with a bitmask giving the basic keywords used in defining the type.
473
    This routine is the main constructor function, which combines two
474
    pre-types and returns the result.
475
*/
476
 
477
BASE_TYPE join_pre_types
478
    PROTO_N ( ( b1, b2 ) )
479
    PROTO_T ( BASE_TYPE b1 X BASE_TYPE b2 )
480
{
481
    BASE_TYPE bt = ( b1 | b2 ) ;
482
    BASE_TYPE bs = ( b1 & b2 ) ;
483
    if ( bs ) {
484
	if ( bs == btype_long ) {
485
	    if ( !( bt & btype_long2 ) ) {
486
		/* Allow 'long long' */
487
		bt |= btype_long2 ;
488
		return ( bt ) ;
489
	    }
490
	}
491
	report ( crt_loc, ERR_dcl_type_simple_dup ( bs ) ) ;
492
    }
493
    return ( bt ) ;
494
}
495
 
496
 
497
/*
498
    INJECT A TYPE INTO A PRE-TYPE
499
 
500
    This routine injects the type t into the pre-type p, returning the
501
    result.  p will be built up of pointers, arrays etc. but its base
502
    type will be null.  The routine injects t into the base type position.
503
    It also checks for illegal type constructions.  Note that p itself
504
    is built up using inject_pre_type, so all such illegal constructions
505
    will be detected.  Some of the error recovery for such constructions
506
    is mildly interesting.  Also note that bitfields are handled by a
507
    separate routine, make_bitfield_type.
508
*/
509
 
510
TYPE inject_pre_type
511
    PROTO_N ( ( p, t, chk ) )
512
    PROTO_T ( TYPE p X TYPE t X int chk )
513
{
514
    TYPE q = p ;
515
    unsigned long n = 0 ;
516
    if ( IS_NULL_type ( q ) ) return ( t ) ;
517
    if ( IS_NULL_type ( t ) ) return ( q ) ;
518
 
519
    /* Map 'ptr template' to 'template ptr' etc */
520
    if ( IS_type_templ ( t ) && !IS_type_templ ( q ) ) {
521
	TYPE s ;
522
	int fix ;
523
	TOKEN tok ;
524
	CV_SPEC cv ;
525
	IDENTIFIER tid ;
526
	DECONS_type_templ ( cv, tid, tok, s, fix, t ) ;
527
	if ( !fix ) {
528
	    s = inject_pre_type ( q, s, chk ) ;
529
	    MAKE_type_templ ( cv, tok, s, fix, t ) ;
530
	    COPY_id ( type_name ( t ), tid ) ;
531
	    return ( t ) ;
532
	}
533
    }
534
 
535
    /* Scan down to incomplete component */
536
    do {
537
	switch ( TAG_type ( q ) ) {
538
 
539
	    case type_ptr_tag : {
540
		/* Pointer types, t * */
541
		TYPE s = DEREF_type ( type_ptr_sub ( q ) ) ;
542
		if ( IS_NULL_type ( s ) ) {
543
		    switch ( TAG_type ( t ) ) {
544
			case type_ref_tag : {
545
			    /* Can't have pointer to reference */
546
			    report ( crt_loc, ERR_dcl_ref_ptr () ) ;
547
			    t = DEREF_type ( type_ref_sub ( t ) ) ;
548
			    if ( !IS_NULL_type ( t ) ) t = rvalue_type ( t ) ;
549
			    break ;
550
			}
551
			case type_bitfield_tag : {
552
			    /* Can't have pointer to bitfield */
553
			    report ( crt_loc, ERR_class_bit_ptr () ) ;
554
			    t = find_bitfield_type ( t ) ;
555
			    break ;
556
			}
557
			case type_func_tag : {
558
			    /* Adjust function type */
559
			    member_func_type ( NULL_ctype, null_tag, t ) ;
560
			    check_weak_func ( t, 0 ) ;
561
			    break ;
562
			}
563
		    }
564
		    COPY_type ( type_ptr_sub ( q ), t ) ;
565
		    if ( chk ) s = t ;
566
		}
567
		q = s ;
568
		break ;
569
	    }
570
 
571
	    case type_ref_tag : {
572
		/* Reference types, t & */
573
		TYPE s = DEREF_type ( type_ref_sub ( q ) ) ;
574
		if ( IS_NULL_type ( s ) ) {
575
		    switch ( TAG_type ( t ) ) {
576
			case type_top_tag :
577
			case type_bottom_tag : {
578
			    /* Can't have reference to void */
579
			    report ( crt_loc, ERR_dcl_ref_void ( t ) ) ;
580
			    MODIFY_type_ptr_etc ( type_ptr_tag, q ) ;
581
			    break ;
582
			}
583
			case type_ref_tag : {
584
			    /* Can't have reference to reference */
585
			    report ( crt_loc, ERR_dcl_ref_ref () ) ;
586
			    t = DEREF_type ( type_ref_sub ( t ) ) ;
587
			    break ;
588
			}
589
			case type_bitfield_tag : {
590
			    /* Can't have reference to bitfield */
591
			    report ( crt_loc, ERR_class_bit_ref () ) ;
592
			    t = find_bitfield_type ( t ) ;
593
			    break ;
594
			}
595
			case type_func_tag : {
596
			    /* Adjust function type */
597
			    member_func_type ( NULL_ctype, null_tag, t ) ;
598
			    check_weak_func ( t, 0 ) ;
599
			    break ;
600
			}
601
		    }
602
		    /* All references are 'lvalue t &' */
603
		    if ( !IS_NULL_type ( t ) ) t = lvalue_type ( t ) ;
604
		    COPY_type ( type_ptr_etc_sub ( q ), t ) ;
605
		    if ( chk ) s = t ;
606
		}
607
		q = s ;
608
		break ;
609
	    }
610
 
611
#if LANGUAGE_CPP
612
	    case type_ptr_mem_tag : {
613
		/* Pointer to member types, t c::* */
614
		TYPE s = DEREF_type ( type_ptr_mem_sub ( q ) ) ;
615
		if ( IS_NULL_type ( s ) ) {
616
		    switch ( TAG_type ( t ) ) {
617
			case type_top_tag :
618
			case type_bottom_tag : {
619
			    /* Can't have pointer to void member */
620
			    report ( crt_loc, ERR_dcl_mptr_void ( t ) ) ;
621
			    break ;
622
			}
623
			case type_ref_tag : {
624
			    /* Can't have pointer to reference member */
625
			    report ( crt_loc, ERR_dcl_mptr_ref () ) ;
626
			    t = DEREF_type ( type_ref_sub ( t ) ) ;
627
			    if ( !IS_NULL_type ( t ) ) t = rvalue_type ( t ) ;
628
			    break ;
629
			}
630
			case type_bitfield_tag : {
631
			    /* Can't have pointer to bitfield member */
632
			    report ( crt_loc, ERR_class_bit_mptr () ) ;
633
			    t = find_bitfield_type ( t ) ;
634
			    break ;
635
			}
636
			case type_func_tag : {
637
			    /* Adjust function type */
638
			    CLASS_TYPE ct ;
639
			    ct = DEREF_ctype ( type_ptr_mem_of ( q ) ) ;
640
			    member_func_type ( ct, id_mem_func_tag, t ) ;
641
			    check_weak_func ( t, 0 ) ;
642
			    break ;
643
			}
644
		    }
645
		    COPY_type ( type_ptr_mem_sub ( q ), t ) ;
646
		    if ( chk ) s = t ;
647
		}
648
		q = s ;
649
		break ;
650
	    }
651
#endif
652
 
653
	    case type_func_tag : {
654
		/* Function types, t ( args ) */
655
		TYPE s = DEREF_type ( type_func_ret ( q ) ) ;
656
		if ( IS_NULL_type ( s ) ) {
657
		    ERROR err = NULL_err ;
658
		    switch ( TAG_type ( t ) ) {
659
			case type_array_tag : {
660
			    /* Can't have function returning array */
661
			    report ( crt_loc, ERR_dcl_fct_array () ) ;
662
			    t = DEREF_type ( type_array_sub ( t ) ) ;
663
			    MAKE_type_ptr ( cv_none, t, t ) ;
664
			    break ;
665
			}
666
			case type_bitfield_tag : {
667
			    /* Can't have function returning bitfield */
668
			    report ( crt_loc, ERR_dcl_fct_bitf () ) ;
669
			    t = find_bitfield_type ( t ) ;
670
			    break ;
671
			}
672
			case type_func_tag : {
673
			    /* Can't have function returning function */
674
			    report ( crt_loc, ERR_dcl_fct_func () ) ;
675
			    member_func_type ( NULL_ctype, null_tag, t ) ;
676
			    check_weak_func ( t, 0 ) ;
677
			    MAKE_type_ptr ( cv_none, t, t ) ;
678
			    break ;
679
			}
680
			case type_compound_tag : {
681
			    /* Can't have function returning abstract */
682
			    ERROR err1 = check_abstract ( t ) ;
683
			    if ( !IS_NULL_err ( err1 ) ) {
684
				ERROR err2 = ERR_class_abstract_ret () ;
685
				err1 = concat_error ( err1, err2 ) ;
686
				report ( crt_loc, err1 ) ;
687
			    }
688
			    break ;
689
			}
690
		    }
691
		    t = check_ret_type ( t, &err, 0 ) ;
692
		    if ( !IS_NULL_err ( err ) ) {
693
			err = concat_error ( err, ERR_dcl_fct_ret () ) ;
694
			report ( crt_loc, err ) ;
695
		    }
696
		    object_type ( t, null_tag ) ;
697
		    COPY_type ( type_func_ret ( q ), t ) ;
698
		    if ( chk ) s = t ;
699
		}
700
		q = s ;
701
		break ;
702
	    }
703
 
704
	    case type_array_tag : {
705
		/* Array types, t [n] */
706
		TYPE s = DEREF_type ( type_array_sub ( q ) ) ;
707
		if ( IS_NULL_type ( s ) ) {
708
		    switch ( TAG_type ( t ) ) {
709
			case type_top_tag :
710
			case type_bottom_tag : {
711
			    /* Can't have array of void */
712
			    report ( crt_loc, ERR_dcl_array_void ( t ) ) ;
713
			    break ;
714
			}
715
			case type_ref_tag : {
716
			    /* Can't have array of references */
717
			    report ( crt_loc, ERR_dcl_ref_array () ) ;
718
			    t = DEREF_type ( type_ref_sub ( t ) ) ;
719
			    if ( !IS_NULL_type ( t ) ) t = rvalue_type ( t ) ;
720
			    break ;
721
			}
722
			case type_func_tag : {
723
			    /* Can't have array of functions */
724
			    report ( crt_loc, ERR_dcl_array_func () ) ;
725
			    member_func_type ( NULL_ctype, null_tag, t ) ;
726
			    check_weak_func ( t, 0 ) ;
727
			    MAKE_type_ptr ( cv_none, t, t ) ;
728
			    break ;
729
			}
730
			case type_bitfield_tag : {
731
			    /* Can't have array of bitfields */
732
			    report ( crt_loc, ERR_dcl_array_bitf () ) ;
733
			    t = find_bitfield_type ( t ) ;
734
			    break ;
735
			}
736
			case type_array_tag : {
737
			    /* Check arrays of arrays */
738
			    NAT m = DEREF_nat ( type_array_size ( t ) ) ;
739
			    if ( IS_NULL_nat ( m ) ) {
740
				ERROR err = ERR_dcl_array_array () ;
741
				report ( crt_loc, err ) ;
742
			    }
743
			    break ;
744
			}
745
			case type_compound_tag :
746
			case type_enumerate_tag : {
747
			    ERROR err = check_complete ( t ) ;
748
			    if ( !IS_NULL_err ( err ) ) {
749
				/* Can't have array of incomplete */
750
				ERROR err2 = ERR_dcl_array_incompl () ;
751
				err = concat_error ( err, err2 ) ;
752
				report ( crt_loc, err ) ;
753
			    }
754
			    err = check_abstract ( t ) ;
755
			    if ( !IS_NULL_err ( err ) ) {
756
				/* Can't have array of abstract */
757
				ERROR err2 = ERR_dcl_array_abstract () ;
758
				err = concat_error ( err, err2 ) ;
759
				report ( crt_loc, err ) ;
760
			    }
761
			    break ;
762
			}
763
		    }
764
		    COPY_type ( type_array_sub ( q ), t ) ;
765
		    if ( chk ) s = t ;
766
		}
767
		q = s ;
768
		break ;
769
	    }
770
 
771
	    case type_templ_tag : {
772
		/* Template types, template < ... > t */
773
		TYPE s = DEREF_type ( type_templ_defn ( q ) ) ;
774
		if ( IS_NULL_type ( s ) ) {
775
		    COPY_type ( type_templ_defn ( q ), t ) ;
776
		    if ( chk ) s = t ;
777
		}
778
		q = s ;
779
		n-- ;
780
		break ;
781
	    }
782
 
783
	    default : {
784
		/* Only the types above should appear */
785
		q = NULL_type ;
786
		n-- ;
787
		break ;
788
	    }
789
	}
790
	n++ ;
791
    } while ( !IS_NULL_type ( q ) ) ;
792
    if ( chk ) IGNORE check_value ( OPT_VAL_declarator_max, n ) ;
793
    return ( p ) ;
794
}
795
 
796
 
797
/*
798
    CHECK FOR INFERRED TYPES
799
 
800
    This routine checks whether the type t is formed from the inferred
801
    type type_inferred.  It returns INFERRED_EMPTY if there were no
802
    specifiers or qualifiers in the description of p,  INFERRED_QUAL if
803
    the only type specifiers were const or volatile, INFERRED_SPEC for
804
    other inferred types, and INFERRED_NOT for non-inferred types.
805
*/
806
 
807
int is_type_inferred
808
    PROTO_N ( ( t ) )
809
    PROTO_T ( TYPE t )
810
{
811
    if ( EQ_type ( t, type_inferred ) ) return ( INFERRED_EMPTY ) ;
812
    while ( !IS_NULL_type ( t ) ) {
813
	switch ( TAG_type ( t ) ) {
814
	    case type_integer_tag : {
815
		/* Check integer types */
816
		if ( EQ_type ( t, type_inferred ) ) {
817
		    return ( INFERRED_SPEC ) ;
818
		} else {
819
		    INT_TYPE it = DEREF_itype ( type_integer_rep ( t ) ) ;
820
		    t = DEREF_type ( itype_prom ( it ) ) ;
821
		    if ( EQ_type ( t, type_inferred ) ) {
822
			/* Qualified inferred type */
823
			return ( INFERRED_QUAL ) ;
824
		    }
825
		}
826
		return ( INFERRED_NOT ) ;
827
	    }
828
	    case type_ptr_tag :
829
	    case type_ref_tag : {
830
		/* Check pointer and reference types */
831
		t = DEREF_type ( type_ptr_etc_sub ( t ) ) ;
832
		break ;
833
	    }
834
#if LANGUAGE_CPP
835
	    case type_ptr_mem_tag : {
836
		/* Check pointer to member types */
837
		t = DEREF_type ( type_ptr_mem_sub ( t ) ) ;
838
		break ;
839
	    }
840
#endif
841
	    case type_func_tag : {
842
		/* Check function return types only */
843
		t = DEREF_type ( type_func_ret ( t ) ) ;
844
		break ;
845
	    }
846
	    case type_array_tag : {
847
		/* Check array types */
848
		t = DEREF_type ( type_array_sub ( t ) ) ;
849
		break ;
850
	    }
851
	    case type_bitfield_tag : {
852
		/* Check bitfield types */
853
		t = find_bitfield_type ( t ) ;
854
		break ;
855
	    }
856
	    case type_templ_tag : {
857
		/* Check template types */
858
		t = DEREF_type ( type_templ_defn ( t ) ) ;
859
		break ;
860
	    }
861
	    default : {
862
		/* Other types are not inferred */
863
		return ( INFERRED_NOT ) ;
864
	    }
865
	}
866
    }
867
    return ( INFERRED_QUAL ) ;
868
}
869
 
870
 
871
/*
872
    CLEAN AN INFERRED TYPE
873
 
874
    This routine returns an equivalent type to the inferred type t, but
875
    with any inferred components replaced by 'signed int'.
876
*/
877
 
878
TYPE clean_inferred_type
879
    PROTO_N ( ( t ) )
880
    PROTO_T ( TYPE t )
881
{
882
    TYPE sub ;
883
    CV_SPEC qual ;
884
    IDENTIFIER tid ;
885
    switch ( TAG_type ( t ) ) {
886
	case type_integer_tag : {
887
	    if ( EQ_type ( t, type_inferred ) ) {
888
		/* Simple inferred type */
889
		t = type_sint ;
890
	    } else {
891
		INT_TYPE it = DEREF_itype ( type_integer_rep ( t ) ) ;
892
		TYPE pt = DEREF_type ( itype_prom ( it ) ) ;
893
		if ( EQ_type ( pt, type_inferred ) ) {
894
		    /* Qualified inferred type */
895
		    qual = DEREF_cv ( type_qual ( t ) ) ;
896
		    t = qualify_type ( type_sint, qual, 0 ) ;
897
		}
898
	    }
899
	    break ;
900
	}
901
	case type_ptr_tag : {
902
	    DECONS_type_ptr ( qual, tid, sub, t ) ;
903
	    sub = clean_inferred_type ( sub ) ;
904
	    MAKE_type_ptr ( qual, sub, t ) ;
905
	    COPY_id ( type_name ( t ), tid ) ;
906
	    break ;
907
	}
908
	case type_ref_tag : {
909
	    DECONS_type_ref ( qual, tid, sub, t ) ;
910
	    sub = clean_inferred_type ( sub ) ;
911
	    MAKE_type_ref ( qual, sub, t ) ;
912
	    COPY_id ( type_name ( t ), tid ) ;
913
	    break ;
914
	}
915
#if LANGUAGE_CPP
916
	case type_ptr_mem_tag : {
917
	    CLASS_TYPE of ;
918
	    DECONS_type_ptr_mem ( qual, tid, of, sub, t ) ;
919
	    sub = clean_inferred_type ( sub ) ;
920
	    MAKE_type_ptr_mem ( qual, of, sub, t ) ;
921
	    COPY_id ( type_name ( t ), tid ) ;
922
	    break ;
923
	}
924
#endif
925
	case type_func_tag : {
926
	    int ell ;
927
	    CV_SPEC mqual ;
928
	    NAMESPACE pars ;
929
	    LIST ( TYPE ) ptypes ;
930
	    LIST ( TYPE ) mtypes ;
931
	    LIST ( TYPE ) except ;
932
	    LIST ( IDENTIFIER ) pids ;
933
	    DECONS_type_func ( qual, tid, sub, ptypes, ell, mqual,
934
			       mtypes, pars, pids, except, t ) ;
935
	    sub = clean_inferred_type ( sub ) ;
936
	    MAKE_type_func ( qual, sub, ptypes, ell, mqual,
937
			     mtypes, pars, pids, except, t ) ;
938
	    COPY_id ( type_name ( t ), tid ) ;
939
	    break ;
940
	}
941
	case type_array_tag : {
942
	    NAT size ;
943
	    DECONS_type_array ( qual, tid, sub, size, t ) ;
944
	    sub = clean_inferred_type ( sub ) ;
945
	    MAKE_type_array ( qual, sub, size, t ) ;
946
	    COPY_id ( type_name ( t ), tid ) ;
947
	    break ;
948
	}
949
	case type_bitfield_tag : {
950
	    INT_TYPE bf ;
951
	    DECONS_type_bitfield ( qual, tid, bf, t ) ;
952
	    sub = DEREF_type ( itype_bitfield_sub ( bf ) ) ;
953
	    sub = clean_inferred_type ( sub ) ;
954
	    COPY_type ( itype_bitfield_sub ( bf ), sub ) ;
955
	    MAKE_type_bitfield ( qual, bf, t ) ;
956
	    COPY_id ( type_name ( t ), tid ) ;
957
	    break ;
958
	}
959
	case type_templ_tag : {
960
	    int fix ;
961
	    TOKEN sort ;
962
	    DECONS_type_templ ( qual, tid, sort, sub, fix, t ) ;
963
	    sub = clean_inferred_type ( sub ) ;
964
	    MAKE_type_templ ( qual, sort, sub, fix, t ) ;
965
	    COPY_id ( type_name ( t ), tid ) ;
966
	    break ;
967
	}
968
    }
969
    return ( t ) ;
970
}
971
 
972
 
973
/*
974
    REPORT AN INFERRED TYPE
975
 
976
    This routine returns an error suitable for the inferred type t.
977
    infer gives the value of is_type_inferred on t.
978
*/
979
 
980
ERROR report_inferred_type
981
    PROTO_N ( ( t, infer ) )
982
    PROTO_T ( TYPE t X int infer )
983
{
984
    ERROR err = NULL_err ;
985
    switch ( infer ) {
986
	case INFERRED_EMPTY :
987
	case INFERRED_SPEC : {
988
	    err = ERR_dcl_type_none () ;
989
	    break ;
990
	}
991
	case INFERRED_QUAL : {
992
	    err = ERR_dcl_type_qual () ;
993
	    break ;
994
	}
995
    }
996
    err = concat_error ( err, ERR_dcl_type_infer ( t ) ) ;
997
    return ( err ) ;
998
}
999
 
1000
 
1001
/*
1002
    BASE TYPE SHIFT
1003
 
1004
    This macro is used to shift a base type specifier into a more sensible
1005
    range for use in a switch statement.
1006
*/
1007
 
1008
#define BTYPE( B )		( ( B ) >> 3 )
1009
 
1010
 
1011
/*
1012
    FIND A BASE TYPE
1013
 
1014
    This routine determines the type given by the base type specifiers bt.
1015
*/
1016
 
1017
TYPE make_base_type
1018
    PROTO_N ( ( bt ) )
1019
    PROTO_T ( BASE_TYPE bt )
1020
{
1021
    TYPE t ;
1022
    BASE_TYPE bm = bt ;
1023
    BASE_TYPE bo = btype_none ;
1024
 
1025
    if ( bm & btype_other ) {
1026
	/* Deal with non-integral cases */
1027
	if ( bm & btype_void ) {
1028
	    t = type_void ;
1029
	    bm = btype_void ;
1030
	} else if ( bm & btype_double ) {
1031
	    if ( bm & btype_long ) {
1032
		t = type_ldouble ;
1033
		bm = btype_ldouble ;
1034
	    } else {
1035
		t = type_double ;
1036
		bm = btype_double ;
1037
	    }
1038
	} else if ( bm & btype_float ) {
1039
	    if ( bm & btype_long ) {
1040
		if ( bm & btype_long2 ) {
1041
		    /* Map 'long long float' to 'long double' */
1042
		    bm = ( btype_llong | btype_float ) ;
1043
		    bo = btype_ldouble ;
1044
		    t = type_ldouble ;
1045
		} else {
1046
		    /* Map 'long float' to 'double' */
1047
		    bm = ( btype_long | btype_float ) ;
1048
		    bo = btype_double ;
1049
		    t = type_double ;
1050
		}
1051
	    } else {
1052
		t = type_float ;
1053
		bm = btype_float ;
1054
	    }
1055
	} else if ( bm & btype_bool ) {
1056
	    t = type_bool ;
1057
	    bm = btype_bool ;
1058
	} else if ( bm & btype_wchar_t ) {
1059
	    t = type_wchar_t ;
1060
	    bm = btype_wchar_t ;
1061
	} else if ( bm & btype_bottom ) {
1062
	    t = type_bottom ;
1063
	    bm = btype_bottom ;
1064
	} else if ( bm & btype_size_t ) {
1065
	    t = type_size_t ;
1066
	    bm = btype_size_t ;
1067
	} else if ( bm & btype_ptrdiff_t ) {
1068
	    t = type_ptrdiff_t ;
1069
	    bm = btype_ptrdiff_t ;
1070
	} else {
1071
	    FAIL ( Unknown type specifier ) ;
1072
	    bm = btype_sint ;
1073
	    t = type_sint ;
1074
	}
1075
 
1076
    } else {
1077
	do {
1078
	    /* Deal with obvious integral cases */
1079
	    switch ( BTYPE ( bm ) ) {
1080
		case BTYPE ( btype_char ) : {
1081
		    bm = btype_char ;
1082
		    t = type_char ;
1083
		    break ;
1084
		}
1085
		case BTYPE ( btype_signed | btype_char ) : {
1086
		    bm = btype_schar ;
1087
		    t = type_schar ;
1088
		    break ;
1089
		}
1090
		case BTYPE ( btype_unsigned | btype_char ) : {
1091
		    bm = btype_uchar ;
1092
		    t = type_uchar ;
1093
		    break ;
1094
		}
1095
		case BTYPE ( btype_short ) :
1096
		case BTYPE ( btype_short | btype_int ) :
1097
		case BTYPE ( btype_signed | btype_short ) :
1098
		case BTYPE ( btype_signed | btype_short | btype_int ) : {
1099
		    bm = btype_sshort ;
1100
		    t = type_sshort ;
1101
		    break ;
1102
		}
1103
		case BTYPE ( btype_unsigned | btype_short ) :
1104
		case BTYPE ( btype_unsigned | btype_short | btype_int ) : {
1105
		    bm = btype_ushort ;
1106
		    t = type_ushort ;
1107
		    break ;
1108
		}
1109
		case BTYPE ( btype_int ) :
1110
		case BTYPE ( btype_none ) :
1111
		case BTYPE ( btype_signed ) :
1112
		case BTYPE ( btype_signed | btype_int ) : {
1113
		    bm = btype_sint ;
1114
		    t = type_sint ;
1115
		    break ;
1116
		}
1117
		case BTYPE ( btype_unsigned ) :
1118
		case BTYPE ( btype_unsigned | btype_int ) : {
1119
		    bm = btype_uint ;
1120
		    t = type_uint ;
1121
		    break ;
1122
		}
1123
		case BTYPE ( btype_long ) :
1124
		case BTYPE ( btype_long | btype_int ) :
1125
		case BTYPE ( btype_signed | btype_long ) :
1126
		case BTYPE ( btype_signed | btype_long | btype_int ) : {
1127
		    bm = btype_slong ;
1128
		    t = type_slong ;
1129
		    break ;
1130
		}
1131
		case BTYPE ( btype_unsigned | btype_long ) :
1132
		case BTYPE ( btype_unsigned | btype_long | btype_int ) : {
1133
		    bm = btype_ulong ;
1134
		    t = type_ulong ;
1135
		    break ;
1136
		}
1137
		case BTYPE ( btype_llong ) :
1138
		case BTYPE ( btype_llong | btype_int ) :
1139
		case BTYPE ( btype_signed | btype_llong ) :
1140
		case BTYPE ( btype_signed | btype_llong | btype_int ) : {
1141
		    /* Allow for 'signed long long' */
1142
		    if ( basetype_info [ ntype_sllong ].key ) {
1143
			report ( crt_loc, ERR_dcl_type_simple_llong ( bm ) ) ;
1144
			bm = btype_sllong ;
1145
			t = type_sllong ;
1146
		    } else {
1147
			bm = btype_slong ;
1148
			t = type_slong ;
1149
		    }
1150
		    break ;
1151
		}
1152
		case BTYPE ( btype_unsigned | btype_llong ) :
1153
		case BTYPE ( btype_unsigned | btype_llong | btype_int ) : {
1154
		    /* Allow for 'unsigned long long' */
1155
		    if ( basetype_info [ ntype_sllong ].key ) {
1156
			report ( crt_loc, ERR_dcl_type_simple_llong ( bm ) ) ;
1157
			bm = btype_ullong ;
1158
			t = type_ullong ;
1159
		    } else {
1160
			bm = btype_ulong ;
1161
			t = type_ulong ;
1162
		    }
1163
		    break ;
1164
		}
1165
		case BTYPE ( btype_long | btype_char ) : {
1166
		    /* Map 'long char' to 'wchar_t' */
1167
		    bm = ( btype_long | btype_char ) ;
1168
		    bo = btype_wchar_t ;
1169
		    t = type_wchar_t ;
1170
		    break ;
1171
		}
1172
		default : {
1173
		    /* Invalid type specifier */
1174
		    bm = btype_none ;
1175
		    if ( bt & btype_signed ) {
1176
			bm |= btype_signed ;
1177
		    } else if ( bt & btype_unsigned ) {
1178
			bm |= btype_unsigned ;
1179
		    }
1180
		    if ( bt & btype_char ) {
1181
			bm |= btype_char ;
1182
		    } else if ( bt & btype_short ) {
1183
			bm |= btype_short ;
1184
		    } else if ( bt & btype_long2 ) {
1185
			bm |= btype_llong ;
1186
		    } else if ( bt & btype_long ) {
1187
			bm |= btype_long ;
1188
		    }
1189
		    t = NULL_type ;
1190
		    break ;
1191
		}
1192
	    }
1193
	} while ( IS_NULL_type ( t ) ) ;
1194
    }
1195
 
1196
    /* Check result */
1197
    if ( bt & ~bm ) {
1198
	/* Report excess type specifiers */
1199
	if ( bo == btype_none ) bo = ( bt & bm ) ;
1200
	report ( crt_loc, ERR_dcl_type_simple_bad ( bt, bo ) ) ;
1201
    } else if ( bo ) {
1202
	/* Report non-standard type specifiers */
1203
	report ( crt_loc, ERR_dcl_type_simple_bad ( bt, bo ) ) ;
1204
    }
1205
    return ( t ) ;
1206
}
1207
 
1208
 
1209
/*
1210
    SHOULD A TYPE NAME BE MARKED AS USED?
1211
 
1212
    This flag is used by complete_pre_type to decide whether a type
1213
    name should be marked as having been used.  This is not the case,
1214
    for example, in a class definition.
1215
*/
1216
 
1217
static int use_type_name = 1 ;
1218
 
1219
 
1220
/*
1221
    COMPLETE A PRE-TYPE
1222
 
1223
    This routine turns a pre-type comprising the base type qualifiers bt
1224
    and the type specifier t, used during the type construction routines,
1225
    into a genuine type.  The original type is destroyed.  The routine
1226
    also assigns the const-volatile qualifier cv to the output type.
1227
*/
1228
 
1229
TYPE complete_pre_type
1230
    PROTO_N ( ( bt, t, cv, infer ) )
1231
    PROTO_T ( BASE_TYPE bt X TYPE t X CV_SPEC cv X int infer )
1232
{
1233
    /* Deal with named types */
1234
    if ( !IS_NULL_type ( t ) ) {
1235
	if ( bt ) report ( crt_loc, ERR_dcl_type_simple_undecl ( bt, t ) ) ;
1236
	if ( IS_type_pre ( t ) ) {
1237
	    CV_SPEC qual ;
1238
	    QUALIFIER it ;
1239
	    IDENTIFIER id ;
1240
	    DESTROY_type_pre ( destroy, qual, id, bt, it, t ) ;
1241
	    qual |= cv ;
1242
	    switch ( bt ) {
1243
		case btype_class :
1244
		case btype_struct :
1245
		case btype_union :
1246
		case btype_enum : {
1247
		    /* Deal with elaborated types */
1248
		    DECL_SPEC mode = dspec_used ;
1249
		    if ( it != qual_none ) mode = dspec_alias ;
1250
		    id = find_elaborate_type ( id, bt, NULL_type, mode ) ;
1251
		    break ;
1252
		}
1253
	    }
1254
	    if ( IS_id_class_name_etc ( id ) ) {
1255
		t = DEREF_type ( id_class_name_etc_defn ( id ) ) ;
1256
		if ( IS_type_templ ( t ) ) {
1257
		    t = deduce_type_template ( id, use_type_name ) ;
1258
		}
1259
		t = copy_typedef ( id, t, qual ) ;
1260
		COPY_id ( type_name ( t ), id ) ;
1261
		if ( use_type_name ) use_id ( id, 0 ) ;
1262
	    } else {
1263
		report ( crt_loc, ERR_dcl_type_simple_undef ( id ) ) ;
1264
		t = type_error ;
1265
	    }
1266
	} else {
1267
	    t = copy_typedef ( NULL_id, t, cv ) ;
1268
	}
1269
	return ( t ) ;
1270
    }
1271
 
1272
    /* Deal with type specifiers */
1273
    if ( bt == btype_none ) {
1274
	t = type_inferred ;
1275
    } else {
1276
	t = make_base_type ( bt ) ;
1277
    }
1278
    if ( cv ) t = qualify_type ( t, cv, 0 ) ;
1279
    if ( infer ) {
1280
	/* Check for inferred types */
1281
	int i = is_type_inferred ( t ) ;
1282
	if ( i != INFERRED_NOT ) {
1283
	    ERROR err ;
1284
	    t = clean_inferred_type ( t ) ;
1285
	    err = report_inferred_type ( t, i ) ;
1286
	    report ( crt_loc, err ) ;
1287
	}
1288
    }
1289
    return ( t ) ;
1290
}
1291
 
1292
 
1293
/*
1294
    COMPLETE A NON-ELABORATED PRE-TYPE
1295
 
1296
    This routine is equivalent to complete_pre_type except that it leaves
1297
    elaborated type declarations (such as 'struct s') as pre-types.  It is
1298
    used in declarations without declarators where such declarations
1299
    resolve differently than in the main case.
1300
*/
1301
 
1302
TYPE empty_complete_pre_type
1303
    PROTO_N ( ( bt, t, cv, infer ) )
1304
    PROTO_T ( BASE_TYPE bt X TYPE t X CV_SPEC cv X int infer )
1305
{
1306
    /* Check for elaborated type declarations */
1307
    if ( !IS_NULL_type ( t ) && IS_type_pre ( t ) ) {
1308
	BASE_TYPE key = DEREF_btype ( type_pre_rep ( t ) ) ;
1309
	switch ( key ) {
1310
	    case btype_class :
1311
	    case btype_struct :
1312
	    case btype_union :
1313
	    case btype_enum : {
1314
		if ( bt ) {
1315
		    ERROR err = ERR_dcl_type_simple_undecl ( bt, t ) ;
1316
		    report ( crt_loc, err ) ;
1317
		}
1318
		COPY_cv ( type_qual ( t ), cv ) ;
1319
		COPY_btype ( type_pre_rep ( t ), key ) ;
1320
		return ( t ) ;
1321
	    }
1322
	}
1323
    }
1324
 
1325
    /* Otherwise obtain the completed type */
1326
    use_type_name = 0 ;
1327
    t = complete_pre_type ( bt, t, cv, infer ) ;
1328
    use_type_name = 1 ;
1329
    return ( t ) ;
1330
}
1331
 
1332
 
1333
/*
1334
    FIND UNDERLYING BITFIELD TYPE
1335
 
1336
    This routine returns the type underlying the bitfield type t.
1337
*/
1338
 
1339
TYPE find_bitfield_type
1340
    PROTO_N ( ( t ) )
1341
    PROTO_T ( TYPE t )
1342
{
1343
    INT_TYPE it = DEREF_itype ( type_bitfield_defn ( t ) ) ;
1344
    t = DEREF_type ( itype_bitfield_sub ( it ) ) ;
1345
    return ( t ) ;
1346
}
1347
 
1348
 
1349
/*
1350
    FIND A BITFIELD REPRESENTATION
1351
 
1352
    This routine finds the bitfield representation for a bitfield originally
1353
    declared with representation bt which expands to the type t.
1354
*/
1355
 
1356
BASE_TYPE get_bitfield_rep
1357
    PROTO_N ( ( t, bt ) )
1358
    PROTO_T ( TYPE t X BASE_TYPE bt )
1359
{
1360
    int depth = 0 ;
1361
    IDENTIFIER id = DEREF_id ( type_name ( t ) ) ;
1362
    while ( !IS_NULL_id ( id ) && depth < 100 ) {
1363
	/* Scan down to original typedef definition */
1364
	bt = DEREF_btype ( id_class_name_etc_rep ( id ) ) ;
1365
	t = DEREF_type ( id_class_name_etc_defn ( id ) ) ;
1366
	id = DEREF_id ( type_name ( t ) ) ;
1367
	depth++ ;
1368
    }
1369
    if ( IS_type_integer ( t ) ) {
1370
	INT_TYPE it = DEREF_itype ( type_integer_rep ( t ) ) ;
1371
	if ( IS_itype_basic ( it ) ) {
1372
	    BASE_TYPE br = DEREF_btype ( itype_basic_rep ( it ) ) ;
1373
	    if ( bt & br ) {
1374
		if ( !( br & btype_char ) ) br &= ~btype_signed ;
1375
		if ( bt & btype_signed ) br |= btype_signed ;
1376
	    }
1377
	    bt = br ;
1378
	}
1379
    }
1380
    return ( bt ) ;
1381
}
1382
 
1383
 
1384
/*
1385
    CHECK A BITFIELD TYPE
1386
 
1387
    This routine creates a bitfield type with base type t and width n.
1388
    Note that in 'int : 3', t will be 'signed int' whereas the sign of
1389
    the bitfield itself is implementation dependent.  For this reason
1390
    the pre-type which gave rise to t, bt (in this case 'int'), is also
1391
    given.  The zero argument is true if zero sized bitfields are
1392
    allowed.
1393
*/
1394
 
1395
TYPE check_bitfield_type
1396
    PROTO_N ( ( cv, t, bt, n, zero ) )
1397
    PROTO_T ( CV_SPEC cv X TYPE t X BASE_TYPE bt X NAT n X int zero )
1398
{
1399
    INT_TYPE bf ;
1400
    TYPE p = NULL_type ;
1401
    DECL_SPEC info = dspec_none ;
1402
    CV_SPEC qual = DEREF_cv ( type_qual ( t ) ) ;
1403
    if ( qual ) {
1404
	/* Move any cv-qualifiers to top level */
1405
	t = qualify_type ( t, cv_none, 0 ) ;
1406
	cv |= qual ;
1407
    }
1408
    switch ( TAG_type ( t ) ) {
1409
	case type_integer_tag :
1410
	case type_enumerate_tag : {
1411
	    /* Integral types are allowed */
1412
	    int ok = 1 ;
1413
	    bt = get_bitfield_rep ( t, bt ) ;
1414
	    if ( bt & btype_int ) {
1415
		if ( bt & ( btype_short | btype_long ) ) ok = 0 ;
1416
	    } else {
1417
		ok = 0 ;
1418
	    }
1419
	    if ( !ok ) {
1420
		/* Only 'int' types allowed in C */
1421
		report ( crt_loc, ERR_class_bit_base_int ( t ) ) ;
1422
	    }
1423
	    if ( !( bt & ( btype_signed | btype_unsigned ) ) ) {
1424
		/* No sign given in type specifier */
1425
		report ( crt_loc, ERR_class_bit_sign ( bt ) ) ;
1426
	    }
1427
	    break ;
1428
	}
1429
	case type_token_tag : {
1430
	    /* Allow template parameter types */
1431
	    if ( is_templ_type ( t ) ) {
1432
		IDENTIFIER id = DEREF_id ( type_token_tok ( t ) ) ;
1433
		LIST ( TOKEN ) args = DEREF_list ( type_token_args ( t ) ) ;
1434
		t = apply_itype_token ( id, args ) ;
1435
		bt = ( btype_named | btype_template ) ;
1436
		break ;
1437
	    }
1438
	    report ( crt_loc, ERR_class_bit_base ( t ) ) ;
1439
	    return ( t ) ;
1440
	}
1441
	case type_error_tag : {
1442
	    /* Ignore error types */
1443
	    return ( t ) ;
1444
	}
1445
	default : {
1446
	    /* Other types are not allowed */
1447
	    report ( crt_loc, ERR_class_bit_base ( t ) ) ;
1448
	    return ( t ) ;
1449
	}
1450
    }
1451
 
1452
    /* Check the range of n */
1453
    if ( IS_NULL_nat ( n ) || is_zero_nat ( n ) ) {
1454
	/* Only anonymous bitfields can have size zero */
1455
	if ( !zero ) report ( crt_loc, ERR_class_bit_dim_zero () ) ;
1456
	info |= dspec_pure ;
1457
	n = small_nat [0] ;
1458
	p = type_sint ;
1459
    } else {
1460
	if ( is_negative_nat ( n ) ) {
1461
	    /* Bitfield size cannot be negative */
1462
	    report ( crt_loc, ERR_class_bit_dim_neg ( n ) ) ;
1463
	    n = negate_nat ( n ) ;
1464
	}
1465
	if ( check_type_size ( t, n ) > 0 ) {
1466
	    report ( crt_loc, ERR_class_bit_dim_big ( n, t ) ) ;
1467
	}
1468
	if ( IS_nat_small ( n ) ) {
1469
	    unsigned sz = DEREF_unsigned ( nat_small_value ( n ) ) ;
1470
	    unsigned si = basetype_info [ ntype_sint ].min_bits ;
1471
	    if ( sz < si ) {
1472
		/* Fits into 'signed int' */
1473
		p = type_sint ;
1474
	    } else if ( sz == si && ( bt & btype_unsigned ) ) {
1475
		/* Fits into 'unsigned int' */
1476
		p = type_uint ;
1477
	    }
1478
	}
1479
    }
1480
    if ( IS_NULL_type ( p ) ) {
1481
	/* NOT YET IMPLEMENTED */
1482
	p = promote_type ( t ) ;
1483
    }
1484
 
1485
    /* Construct bitfield type */
1486
    if ( zero ) info |= dspec_ignore ;
1487
    MAKE_itype_bitfield ( p, NULL_list ( TYPE ), t, bt, n, info, bf ) ;
1488
    MAKE_type_bitfield ( cv, bf, t ) ;
1489
    return ( t ) ;
1490
}
1491
 
1492
 
1493
/*
1494
    CREATE A BITFIELD TYPE
1495
 
1496
    This routine is identical to check_bitfield_type except that it
1497
    takes a constant-expression e rather than the integer constant n.
1498
*/
1499
 
1500
TYPE make_bitfield_type
1501
    PROTO_N ( ( t, bt, e, zero ) )
1502
    PROTO_T ( TYPE t X BASE_TYPE bt X EXP e X int zero )
1503
{
1504
    ERROR err = NULL_err ;
1505
    NAT n = make_nat_exp ( e, &err ) ;
1506
    if ( !IS_NULL_err ( err ) ) {
1507
	err = concat_error ( err, ERR_class_bit_dim_const () ) ;
1508
	report ( crt_loc, err ) ;
1509
    }
1510
    t = check_bitfield_type ( cv_none, t, bt, n, zero ) ;
1511
    return ( t ) ;
1512
}
1513
 
1514
 
1515
/*
1516
    CHECK AN ARRAY BOUND
1517
 
1518
    This routine checks the array bound n.  n can be null, indicating an
1519
    unbounded array, or a positive constant.
1520
*/
1521
 
1522
NAT check_array_dim
1523
    PROTO_N ( ( n ) )
1524
    PROTO_T ( NAT n )
1525
{
1526
    if ( !IS_NULL_nat ( n ) ) {
1527
	if ( is_zero_nat ( n ) ) {
1528
	    report ( crt_loc, ERR_dcl_array_dim_zero () ) ;
1529
	} else if ( is_negative_nat ( n ) ) {
1530
	    report ( crt_loc, ERR_dcl_array_dim_neg ( n ) ) ;
1531
	    n = negate_nat ( n ) ;
1532
	}
1533
    }
1534
    return ( n ) ;
1535
}
1536
 
1537
 
1538
/*
1539
    CREATE AN ARRAY BOUND
1540
 
1541
    This routine turns the integer constant expression e into an array
1542
    bound.  e may also be the null expression, indicating an unbounded
1543
    array.
1544
*/
1545
 
1546
NAT make_array_dim
1547
    PROTO_N ( ( e ) )
1548
    PROTO_T ( EXP e )
1549
{
1550
    if ( !IS_NULL_exp ( e ) ) {
1551
	ERROR err = NULL_err ;
1552
	NAT n = make_nat_exp ( e, &err ) ;
1553
	if ( !IS_NULL_err ( err ) ) {
1554
	    err = concat_error ( err, ERR_dcl_array_dim_const () ) ;
1555
	    report ( crt_loc, err ) ;
1556
	}
1557
	n = check_array_dim ( n ) ;
1558
	return ( n ) ;
1559
    }
1560
    return ( NULL_nat ) ;
1561
}
1562
 
1563
 
1564
/*
1565
    CHECK AN INTEGER TYPE
1566
 
1567
    This routine checks whether t is an integral type containing the base
1568
    type specifiers m.  It is used to spot signed types, unsigned types,
1569
    character types and so on.
1570
*/
1571
 
1572
int check_int_type
1573
    PROTO_N ( ( t, m ) )
1574
    PROTO_T ( TYPE t X BASE_TYPE m )
1575
{
1576
    if ( IS_type_integer ( t ) ) {
1577
	INT_TYPE it = DEREF_itype ( type_integer_rep ( t ) ) ;
1578
	switch ( TAG_itype ( it ) ) {
1579
	    case itype_basic_tag : {
1580
		BASE_TYPE bt = DEREF_btype ( itype_basic_rep ( it ) ) ;
1581
		if ( ( bt & m ) == m ) return ( 1 ) ;
1582
		break ;
1583
	    }
1584
	    case itype_token_tag : {
1585
		/* Tokenised types */
1586
		IDENTIFIER tid = DEREF_id ( itype_token_tok ( it ) ) ;
1587
		TOKEN tok = DEREF_tok ( id_token_sort ( tid ) ) ;
1588
		if ( IS_tok_proc ( tok ) ) {
1589
		    tok = DEREF_tok ( tok_proc_res ( tok ) ) ;
1590
		}
1591
		if ( IS_tok_type ( tok ) ) {
1592
		    BASE_TYPE bt = DEREF_btype ( tok_type_kind ( tok ) ) ;
1593
		    if ( ( bt & m ) == m ) return ( 1 ) ;
1594
		}
1595
		break ;
1596
	    }
1597
	}
1598
    }
1599
    return ( 0 ) ;
1600
}
1601
 
1602
 
1603
/*
1604
    LISTS OF COMPATIBLE TYPES
1605
 
1606
    These lists are used to record the compatible types set by the
1607
    routines below.
1608
*/
1609
 
1610
static LIST ( TYPE ) arg1_types = NULL_list ( TYPE ) ;
1611
static LIST ( TYPE ) arg2_types = NULL_list ( TYPE ) ;
1612
static LIST ( TYPE ) ell_types = NULL_list ( TYPE ) ;
1613
 
1614
 
1615
/*
1616
    SET TWO TYPES TO BE COMPATIBLE
1617
 
1618
    This routine sets the types t and s to be compatible with option
1619
    level opt.
1620
*/
1621
 
1622
void set_compatible_type
1623
    PROTO_N ( ( t, s, opt ) )
1624
    PROTO_T ( TYPE t X TYPE s X unsigned opt )
1625
{
1626
    TYPE pt = type_char_star ;
1627
    TYPE ps = type_void_star ;
1628
    if ( eq_type ( t, pt ) && eq_type ( s, ps ) ) {
1629
	set_option ( OPT_gen_ptr_char, opt ) ;
1630
    } else {
1631
	report ( preproc_loc, ERR_pragma_compat_type () ) ;
1632
    }
1633
    return ;
1634
}
1635
 
1636
 
1637
/*
1638
    FIND CANONICAL ARGUMENT TYPE
1639
 
1640
    This routine finds the canonical argument type for the type t by
1641
    chasing down the lists of compatible argument types.  It returns
1642
    the null type if t is not compatible with a type from this list.
1643
*/
1644
 
1645
static TYPE find_arg_type
1646
    PROTO_N ( ( t ) )
1647
    PROTO_T ( TYPE t )
1648
{
1649
    LIST ( TYPE ) p = arg1_types ;
1650
    LIST ( TYPE ) q = arg2_types ;
1651
    while ( !IS_NULL_list ( p ) ) {
1652
	TYPE r = DEREF_type ( HEAD_list ( p ) ) ;
1653
	r = type_composite ( t, r, 0, 1, KILL_err, 0 ) ;
1654
	if ( !IS_NULL_type ( r ) ) {
1655
	    r = DEREF_type ( HEAD_list ( q ) ) ;
1656
	    return ( r ) ;
1657
	}
1658
	q = TAIL_list ( q ) ;
1659
	p = TAIL_list ( p ) ;
1660
    }
1661
    return ( NULL_type ) ;
1662
}
1663
 
1664
 
1665
/*
1666
    SET TWO TYPES TO BE ARGUMENT COMPATIBLE
1667
 
1668
    This routine sets the types t and s to be compatible as function
1669
    parameters.
1670
*/
1671
 
1672
void accept_argument
1673
    PROTO_N ( ( t, s ) )
1674
    PROTO_T ( TYPE t X TYPE s )
1675
{
1676
    TYPE pt, ps ;
1677
    LIST ( TYPE ) p ;
1678
    t = qualify_type ( t, cv_none, 0 ) ;
1679
    t = make_param_type ( t, CONTEXT_PARAMETER ) ;
1680
    s = qualify_type ( s, cv_none, 0 ) ;
1681
    s = make_param_type ( s, CONTEXT_PARAMETER ) ;
1682
    pt = find_arg_type ( t ) ;
1683
    ps = find_arg_type ( s ) ;
1684
    if ( IS_NULL_type ( ps ) ) ps = s ;
1685
    if ( !IS_NULL_type ( pt ) ) {
1686
	/* Already have entry for t */
1687
	if ( !eq_type ( ps, pt ) ) {
1688
	    report ( preproc_loc, ERR_pragma_arg_dup ( t ) ) ;
1689
	}
1690
	return ;
1691
    }
1692
    pt = type_composite ( ps, t, 0, 1, KILL_err, 0 ) ;
1693
    if ( !IS_NULL_type ( pt ) ) {
1694
	report ( preproc_loc, ERR_pragma_arg_cycle () ) ;
1695
	return ;
1696
    }
1697
    p = arg2_types ;
1698
    CONS_type ( t, arg1_types, arg1_types ) ;
1699
    CONS_type ( ps, p, arg2_types ) ;
1700
    while ( !IS_NULL_list ( p ) ) {
1701
	pt = DEREF_type ( HEAD_list ( p ) ) ;
1702
	pt = type_composite ( pt, t, 0, 1, KILL_err, 0 ) ;
1703
	if ( !IS_NULL_type ( pt ) ) COPY_type ( HEAD_list ( p ), ps ) ;
1704
	p = TAIL_list ( p ) ;
1705
    }
1706
    return ;
1707
}
1708
 
1709
 
1710
/*
1711
    SET A TYPE TO BE ELLIPSIS COMPATIBLE
1712
 
1713
    This routine sets the type t to be compatible with an ellipsis in
1714
    function parameters.
1715
*/
1716
 
1717
void accept_ellipsis
1718
    PROTO_N ( ( t ) )
1719
    PROTO_T ( TYPE t )
1720
{
1721
    TYPE r ;
1722
    t = qualify_type ( t, cv_none, 0 ) ;
1723
    t = make_param_type ( t, CONTEXT_PARAMETER ) ;
1724
    r = eq_ellipsis ( t ) ;
1725
    if ( IS_NULL_type ( r ) ) {
1726
	CONS_type ( t, ell_types, ell_types ) ;
1727
    }
1728
    return ;
1729
}
1730
 
1731
 
1732
/*
1733
    ARE TWO TYPES ARGUMENT COMPATIBLE?
1734
 
1735
    This routine checks whether the types t and s are compatible as
1736
    function parameters.  If eq is true then compatibility is only
1737
    checked if one of the types appears in the list of types.  The
1738
    routine returns the composite type.
1739
*/
1740
 
1741
TYPE eq_argument
1742
    PROTO_N ( ( t, s, eq ) )
1743
    PROTO_T ( TYPE t X TYPE s X int eq )
1744
{
1745
    TYPE pt = find_arg_type ( t ) ;
1746
    TYPE ps = find_arg_type ( s ) ;
1747
    if ( EQ_type ( pt, ps ) ) {
1748
	if ( !IS_NULL_type ( pt ) ) return ( pt ) ;
1749
	if ( eq ) return ( NULL_type ) ;
1750
    }
1751
    if ( IS_NULL_type ( pt ) ) pt = t ;
1752
    if ( IS_NULL_type ( ps ) ) ps = s ;
1753
    pt = type_composite ( pt, ps, 0, 1, KILL_err, 1 ) ;
1754
    return ( pt ) ;
1755
}
1756
 
1757
 
1758
/*
1759
    IS A TYPE ELLIPSIS COMPATIBLE?
1760
 
1761
    This routine checks whether the type t is compatible with an ellipsis
1762
    in function parameters.
1763
*/
1764
 
1765
TYPE eq_ellipsis
1766
    PROTO_N ( ( t ) )
1767
    PROTO_T ( TYPE t )
1768
{
1769
    LIST ( TYPE ) p = ell_types ;
1770
    while ( !IS_NULL_list ( p ) ) {
1771
	TYPE r = DEREF_type ( HEAD_list ( p ) ) ;
1772
	TYPE s = eq_argument ( t, r, 0 ) ;
1773
	if ( !IS_NULL_type ( s ) ) return ( s ) ;
1774
	p = TAIL_list ( p ) ;
1775
    }
1776
    return ( NULL_type ) ;
1777
}
1778
 
1779
 
1780
/*
1781
    BASIC TYPES
1782
 
1783
    These variables stand for the basic types which arise naturally in
1784
    C and C++.  This includes the basic integer and floating-point types,
1785
    bool, size_t and related construct types, void and bottom (the type
1786
    of an expression which does not return), plus a few useful composite
1787
    types.
1788
*/
1789
 
1790
TYPE type_builtin [ ORDER_ntype ] ;
1791
TYPE ptr_type_builtin [ ORDER_ntype ] ;
1792
TYPE type_func_void ;
1793
TYPE type_temp_func ;
1794
TYPE type_ellipsis ;
1795
TYPE type_error ;
1796
 
1797
 
1798
/*
1799
    INITIALISE BASIC TYPES
1800
 
1801
    This routine initialises the basic types above.
1802
*/
1803
 
1804
void init_types
1805
    PROTO_Z ()
1806
{
1807
    unsigned long n ;
1808
    init_itypes ( 1 ) ;
1809
    for ( n = 0 ; n < ORDER_ntype ; n++ ) {
1810
	MAKE_type_ptr ( cv_none, type_builtin [n], ptr_type_builtin [n] ) ;
1811
    }
1812
    MAKE_type_func ( cv_lvalue, type_void, NULL_list ( TYPE ), 0, cv_lang,
1813
		     NULL_list ( TYPE ), NULL_nspace, NULL_list ( IDENTIFIER ),
1814
		     NULL_list ( TYPE ), type_func_void ) ;
1815
    MAKE_type_func ( cv_none, type_void, NULL_list ( TYPE ), 0, cv_lang,
1816
		     NULL_list ( TYPE ), NULL_nspace, NULL_list ( IDENTIFIER ),
1817
		     NULL_list ( TYPE ), type_temp_func ) ;
1818
    MAKE_type_error ( cv_none, type_error ) ;
1819
    type_ellipsis = NULL_type ;
1820
    return ;
1821
}