1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
|
/* $NetBSD: externs1.h,v 1.189 2023/07/07 06:03:31 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Jochen Pohl for
* The NetBSD Project.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <signal.h>
/*
* main1.c
*/
extern int aflag;
extern bool bflag;
extern bool cflag;
extern bool eflag;
extern bool Fflag;
extern bool hflag;
extern bool pflag;
extern bool rflag;
extern bool uflag;
extern bool vflag;
extern bool yflag;
extern bool wflag;
extern bool zflag;
extern bool Tflag;
extern bool Pflag;
extern bool allow_trad;
extern bool allow_c90;
extern bool allow_c99;
extern bool allow_c11;
extern bool allow_c23;
extern bool allow_gcc;
extern sig_atomic_t fpe;
void norecover(void);
/*
* cgram.y
*/
extern int block_level;
extern size_t mem_block_level;
extern int yydebug;
int yyerror(const char *);
int yyparse(void);
/*
* scan.l
*/
extern bool in_gcc_attribute;
extern pos_t curr_pos;
extern pos_t csrc_pos;
extern bool in_system_header;
extern symt_t symtyp;
extern FILE *yyin;
void initscan(void);
int64_t convert_integer(int64_t, tspec_t, unsigned int);
void clear_warn_flags(void);
sym_t *getsym(sbuf_t *);
void clean_up_after_error(void);
sym_t *pushdown(const sym_t *);
sym_t *mktempsym(type_t *);
void rmsym(sym_t *);
void symtab_remove_level(sym_t *);
void inssym(int, sym_t *);
void freeyyv(void *, int);
int yylex(void);
/*
* mem1.c
*/
const char *record_filename(const char *, size_t);
int get_filename_id(const char *);
void add_directory_replacement(char *);
const char *transform_filename(const char *, size_t);
void *block_zero_alloc(size_t);
void *level_zero_alloc(size_t, size_t);
void level_free_all(size_t);
void *expr_zero_alloc(size_t);
tnode_t *expr_alloc_tnode(void);
void expr_free_all(void);
memory_pool expr_save_memory(void);
void expr_restore_memory(memory_pool);
/*
* debug.c
*/
#ifdef DEBUG
const char *decl_level_kind_name(decl_level_kind);
const char *scl_name(scl_t);
const char *symt_name(symt_t);
const char *tqual_name(tqual_t);
void debug_dcs(bool);
void debug_node(const tnode_t *);
void debug_type(const type_t *);
void debug_sym(const char *, const sym_t *, const char *);
void debug_symtab(void);
void debug_printf(const char *fmt, ...) __printflike(1, 2);
void debug_print_indent(void);
void debug_indent_inc(void);
void debug_indent_dec(void);
void debug_enter_func(const char *);
void debug_step(const char *fmt, ...) __printflike(1, 2);
void debug_leave_func(const char *);
#define debug_enter() debug_enter_func(__func__)
#define debug_leave() debug_leave_func(__func__)
#else
#define debug_noop() do { } while (false)
#define debug_dcs(all) debug_noop()
#define debug_sym(p, sym, s) debug_noop()
#define debug_symtab() debug_noop()
#define debug_node(tn) debug_noop()
#define debug_type(tp) debug_noop()
#define debug_printf(...) debug_noop()
#define debug_print_indent() debug_noop()
#define debug_indent_inc() debug_noop()
#define debug_indent_dec() debug_noop()
#define debug_enter() debug_noop()
#define debug_step(...) debug_noop()
#define debug_leave() debug_noop()
#endif
/*
* err.c
*/
extern bool seen_error;
extern bool seen_warning;
extern int sytxerr;
extern bool any_query_enabled;
void msglist(void);
void error_at(int, const pos_t *, ...);
void warning_at(int, const pos_t *, ...);
void message_at(int, const pos_t *, ...);
void error(int, ...);
void warning(int, ...);
bool gnuism(int, ...);
void c99ism(int, ...);
void c11ism(int, ...);
void c23ism(int, ...);
void assert_failed(const char *, int, const char *, const char *)
__attribute__((__noreturn__));
void update_location(const char *, int, bool, bool);
void suppress_messages(const char *);
void query_message(int, ...);
void enable_queries(const char *);
/*
* decl.c
*/
extern decl_level *dcs;
extern const char unnamed[];
extern int enumval;
void initdecl(void);
type_t *gettyp(tspec_t);
type_t *block_dup_type(const type_t *);
type_t *expr_dup_type(const type_t *);
type_t *expr_unqualified_type(const type_t *);
bool is_incomplete(const type_t *);
void dcs_add_storage_class(scl_t);
void dcs_add_type(type_t *);
void dcs_add_qualifier(tqual_t);
void dcs_add_packed(void);
void dcs_set_used(void);
void begin_declaration_level(decl_level_kind);
void end_declaration_level(void);
void dcs_set_asm(void);
void dcs_begin_type(void);
void dcs_end_type(void);
int length_in_bits(const type_t *, const char *);
unsigned int alignment_in_bits(const type_t *);
sym_t *concat_symbols(sym_t *, sym_t *);
void check_type(sym_t *);
sym_t *declare_unnamed_member(void);
sym_t *declare_member(sym_t *);
sym_t *set_bit_field_width(sym_t *, int);
qual_ptr *merge_qualified_pointer(qual_ptr *, qual_ptr *);
sym_t *add_pointer(sym_t *, qual_ptr *);
sym_t *add_array(sym_t *, bool, int);
sym_t *add_function(sym_t *, sym_t *);
void check_function_definition(sym_t *, bool);
sym_t *declarator_name(sym_t *);
sym_t *old_style_function_parameter_name(sym_t *);
type_t *make_tag_type(sym_t *, tspec_t, bool, bool);
const char *storage_class_name(scl_t);
type_t *complete_struct_or_union(sym_t *);
type_t *complete_enum(sym_t *);
sym_t *enumeration_constant(sym_t *, int, bool);
void declare(sym_t *, bool, sbuf_t *);
void copy_usage_info(sym_t *, sym_t *);
bool check_redeclaration(sym_t *, bool *);
bool pointer_types_are_compatible(const type_t *, const type_t *, bool);
bool types_compatible(const type_t *, const type_t *, bool, bool, bool *);
void complete_type(sym_t *, sym_t *);
sym_t *declare_argument(sym_t *, bool);
void check_func_lint_directives(void);
void check_func_old_style_arguments(void);
void declare_local(sym_t *, bool);
sym_t *abstract_name(void);
void global_clean_up(void);
sym_t *declare_abstract_type(sym_t *);
void check_size(sym_t *);
void mark_as_set(sym_t *);
void mark_as_used(sym_t *, bool, bool);
void check_usage(decl_level *);
void check_usage_sym(bool, sym_t *);
void check_global_symbols(void);
void print_previous_declaration(const sym_t *);
int to_int_constant(tnode_t *, bool);
/*
* tree.c
*/
const tnode_t *before_conversion(const tnode_t *);
type_t *block_derive_type(type_t *, tspec_t);
type_t *expr_derive_type(type_t *, tspec_t);
bool is_compiler_builtin(const char *);
tnode_t *build_constant(type_t *, val_t *);
tnode_t *build_name(sym_t *, bool);
tnode_t *build_string(strg_t *);
tnode_t *build_generic_selection(const tnode_t *,
struct generic_association *);
tnode_t *build_binary(tnode_t *, op_t, bool, tnode_t *);
tnode_t *build_unary(op_t, bool, tnode_t *);
tnode_t *build_member_access(tnode_t *, op_t, bool, sbuf_t *);
tnode_t *cconv(tnode_t *);
bool is_typeok_bool_compares_with_zero(const tnode_t *);
bool typeok(op_t, int, const tnode_t *, const tnode_t *);
tnode_t *promote(op_t, bool, tnode_t *);
tnode_t *convert(op_t, int, type_t *, tnode_t *);
void convert_constant(op_t, int, const type_t *, val_t *, val_t *);
tnode_t *build_sizeof(const type_t *);
tnode_t *build_offsetof(const type_t *, const sym_t *);
tnode_t *build_alignof(const type_t *);
tnode_t *cast(tnode_t *, type_t *);
tnode_t *build_function_argument(tnode_t *, tnode_t *);
tnode_t *build_function_call(tnode_t *, bool, tnode_t *);
val_t *integer_constant(tnode_t *, bool);
void expr(tnode_t *, bool, bool, bool, bool);
void check_expr_misc(const tnode_t *, bool, bool, bool, bool, bool, bool);
bool constant_addr(const tnode_t *, const sym_t **, ptrdiff_t *);
strg_t *cat_strings(strg_t *, strg_t *);
unsigned int type_size_in_bits(const type_t *);
sym_t *find_member(const type_t *, const char *);
void begin_statement_expr(void);
void do_statement_expr(tnode_t *);
tnode_t *end_statement_expr(void);
/*
* func.c
*/
extern sym_t *funcsym;
extern bool reached;
extern bool warn_about_unreachable;
extern bool seen_fallthrough;
extern int nargusg;
extern pos_t argsused_pos;
extern int nvararg;
extern pos_t vapos;
extern int printflike_argnum;
extern pos_t printflike_pos;
extern int scanflike_argnum;
extern pos_t scanflike_pos;
extern bool constcond_flag;
extern bool llibflg;
extern int lwarn;
extern bool bitfieldtype_ok;
extern bool plibflg;
extern bool long_long_flag;
void begin_control_statement(control_statement_kind);
void end_control_statement(control_statement_kind);
void check_statement_reachable(void);
void begin_function(sym_t *);
void end_function(void);
void named_label(sym_t *);
void case_label(tnode_t *);
void default_label(void);
void stmt_if_expr(tnode_t *);
void stmt_if_then_stmt(void);
void stmt_if_else_stmt(bool);
void stmt_switch_expr(tnode_t *);
void stmt_switch_expr_stmt(void);
void stmt_while_expr(tnode_t *);
void stmt_while_expr_stmt(void);
void stmt_do(void);
void stmt_do_while_expr(tnode_t *);
void stmt_for_exprs(tnode_t *, tnode_t *, tnode_t *);
void stmt_for_exprs_stmt(void);
void stmt_goto(sym_t *);
void stmt_continue(void);
void stmt_break(void);
void stmt_return(bool, tnode_t *);
void global_clean_up_decl(bool);
void argsused(int);
void constcond(int);
void fallthru(int);
void not_reached(int);
void lintlib(int);
void linted(int);
void varargs(int);
void printflike(int);
void scanflike(int);
void protolib(int);
void longlong(int);
void bitfieldtype(int);
/*
* init.c
*/
void begin_initialization(sym_t *);
void end_initialization(void);
sym_t *current_initsym(void);
void init_rbrace(void);
void init_lbrace(void);
void init_expr(tnode_t *);
void begin_designation(void);
void add_designator_member(sbuf_t *);
void add_designator_subscript(range_t);
/*
* emit.c
*/
void outtype(const type_t *);
void outsym(const sym_t *, scl_t, def_t);
void outfdef(const sym_t *, const pos_t *, bool, bool, const sym_t *);
void outcall(const tnode_t *, bool, bool);
void outusg(const sym_t *);
/*
* lex.c
*/
int lex_name(const char *, size_t);
int lex_integer_constant(const char *, size_t, int);
int lex_floating_constant(const char *, size_t);
int lex_operator(int, op_t);
int lex_string(void);
int lex_wide_string(void);
int lex_character_constant(void);
int lex_wide_character_constant(void);
void lex_directive(const char *);
void lex_next_line(void);
void lex_comment(void);
void lex_slash_slash_comment(void);
void lex_unknown_character(int);
int lex_input(void);
/*
* ckbool.c
*/
bool typeok_scalar_strict_bool(op_t, const mod_t *, int,
const tnode_t *, const tnode_t *);
bool fallback_symbol_strict_bool(sym_t *);
/*
* ckctype.c
*/
void check_ctype_function_call(const tnode_t *, const tnode_t *);
void check_ctype_macro_invocation(const tnode_t *, const tnode_t *);
/*
* ckgetopt.c
*/
void check_getopt_begin_while(const tnode_t *);
void check_getopt_begin_switch(void);
void check_getopt_case_label(int64_t);
void check_getopt_end_switch(void);
void check_getopt_end_while(void);
|