Please let stdio.h define sys_errlist and sys_nerr,
[unix-history] / gnu / usr.bin / cc / common / c-tree.h
CommitLineData
9bf86ebb
PR
1/* Definitions for C parsing and type checking.
2 Copyright (C) 1987, 1993 Free Software Foundation, Inc.
3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20#ifndef _C_TREE_H
21#define _C_TREE_H
22
23#ifndef STDIO_PROTO
24#ifdef BUFSIZ
25#define STDIO_PROTO(ARGS) PROTO(ARGS)
26#else
27#define STDIO_PROTO(ARGS) ()
28#endif
29#endif
30
31/* Language-dependent contents of an identifier. */
32
33/* The limbo_value is used for block level extern declarations, which need
34 to be type checked against subsequent extern declarations. They can't
35 be referenced after they fall out of scope, so they can't be global. */
36
37struct lang_identifier
38{
39 struct tree_identifier ignore;
40 tree global_value, local_value, label_value, implicit_decl;
41 tree error_locus, limbo_value;
42};
43
44/* Macros for access to language-specific slots in an identifier. */
45/* Each of these slots contains a DECL node or null. */
46
47/* This represents the value which the identifier has in the
48 file-scope namespace. */
49#define IDENTIFIER_GLOBAL_VALUE(NODE) \
50 (((struct lang_identifier *)(NODE))->global_value)
51/* This represents the value which the identifier has in the current
52 scope. */
53#define IDENTIFIER_LOCAL_VALUE(NODE) \
54 (((struct lang_identifier *)(NODE))->local_value)
55/* This represents the value which the identifier has as a label in
56 the current label scope. */
57#define IDENTIFIER_LABEL_VALUE(NODE) \
58 (((struct lang_identifier *)(NODE))->label_value)
59/* This records the extern decl of this identifier, if it has had one
60 at any point in this compilation. */
61#define IDENTIFIER_LIMBO_VALUE(NODE) \
62 (((struct lang_identifier *)(NODE))->limbo_value)
63/* This records the implicit function decl of this identifier, if it
64 has had one at any point in this compilation. */
65#define IDENTIFIER_IMPLICIT_DECL(NODE) \
66 (((struct lang_identifier *)(NODE))->implicit_decl)
67/* This is the last function in which we printed an "undefined variable"
68 message for this identifier. Value is a FUNCTION_DECL or null. */
69#define IDENTIFIER_ERROR_LOCUS(NODE) \
70 (((struct lang_identifier *)(NODE))->error_locus)
71
72/* In identifiers, C uses the following fields in a special way:
73 TREE_PUBLIC to record that there was a previous local extern decl.
74 TREE_USED to record that such a decl was used.
75 TREE_ADDRESSABLE to record that the address of such a decl was used. */
76
77/* Nonzero means reject anything that ANSI standard C forbids. */
78extern int pedantic;
79
80/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only. */
81#define C_TYPE_FIELDS_READONLY(type) TREE_LANG_FLAG_1 (type)
82
83/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is volatile. */
84#define C_TYPE_FIELDS_VOLATILE(type) TREE_LANG_FLAG_2 (type)
85
86/* In a RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE
87 nonzero if the definition of the type has already started. */
88#define C_TYPE_BEING_DEFINED(type) TYPE_LANG_FLAG_0 (type)
89
90/* In a RECORD_TYPE, a sorted array of the fields of the type. */
91struct lang_type
92{
93 int len;
94 tree elts[1];
95};
96
97/* Mark which labels are explicitly declared.
98 These may be shadowed, and may be referenced from nested functions. */
99#define C_DECLARED_LABEL_FLAG(label) TREE_LANG_FLAG_1 (label)
100
101/* Record whether a type or decl was written with nonconstant size.
102 Note that TYPE_SIZE may have simplified to a constant. */
103#define C_TYPE_VARIABLE_SIZE(type) TYPE_LANG_FLAG_1 (type)
104#define C_DECL_VARIABLE_SIZE(type) DECL_LANG_FLAG_0 (type)
105
106/* Record in each node resulting from a binary operator
107 what operator was specified for it. */
108#define C_EXP_ORIGINAL_CODE(exp) ((enum tree_code) TREE_COMPLEXITY (exp))
109
110#if 0 /* Not used. */
111/* Record whether a decl for a function or function pointer has
112 already been mentioned (in a warning) because it was called
113 but didn't have a prototype. */
114#define C_MISSING_PROTOTYPE_WARNED(decl) DECL_LANG_FLAG_2(decl)
115#endif
116
117/* Store a value in that field. */
118#define C_SET_EXP_ORIGINAL_CODE(exp, code) \
119 (TREE_COMPLEXITY (exp) = (int)(code))
120
121/* Record whether a typedef for type `int' was actually `signed int'. */
122#define C_TYPEDEF_EXPLICITLY_SIGNED(exp) DECL_LANG_FLAG_1 ((exp))
123
124/* Nonzero for a declaration of a built in function if there has been no
125 occasion that would declare the function in ordinary C.
126 Using the function draws a pedantic warning in this case. */
127#define C_DECL_ANTICIPATED(exp) DECL_LANG_FLAG_3 ((exp))
128
129/* For FUNCTION_TYPE, a hidden list of types of arguments. The same as
130 TYPE_ARG_TYPES for functions with prototypes, but created for functions
131 without prototypes. */
132#define TYPE_ACTUAL_ARG_TYPES(NODE) TYPE_NONCOPIED_PARTS (NODE)
133
134/* Nonzero if the type T promotes to itself.
135 ANSI C states explicitly the list of types that promote;
136 in particular, short promotes to int even if they have the same width. */
137#define C_PROMOTING_INTEGER_TYPE_P(t) \
138 (TREE_CODE ((t)) == INTEGER_TYPE \
139 && (TYPE_MAIN_VARIANT (t) == char_type_node \
140 || TYPE_MAIN_VARIANT (t) == signed_char_type_node \
141 || TYPE_MAIN_VARIANT (t) == unsigned_char_type_node \
142 || TYPE_MAIN_VARIANT (t) == short_integer_type_node \
143 || TYPE_MAIN_VARIANT (t) == short_unsigned_type_node))
144
145/* In a VAR_DECL, means the variable is really an iterator. */
146#define ITERATOR_P(D) (DECL_LANG_FLAG_4(D))
147
148/* In a VAR_DECL for an iterator, means we are within
149 an explicit loop over that iterator. */
150#define ITERATOR_BOUND_P(NODE) ((NODE)->common.readonly_flag)
151\f
152/* in c-lang.c and objc-act.c */
153extern tree lookup_interface PROTO((tree));
154extern tree is_class_name PROTO((tree));
155extern void maybe_objc_check_decl PROTO((tree));
156extern int maybe_objc_comptypes PROTO((tree, tree, int));
157extern tree maybe_building_objc_message_expr PROTO((void));
158extern tree maybe_objc_method_name PROTO((tree));
159extern int recognize_objc_keyword PROTO((void));
160extern tree build_objc_string PROTO((int, char *));
161\f
162/* in c-aux-info.c */
163extern void gen_aux_info_record PROTO((tree, int, int, int));
164
165/* in c-common.c */
166/* Print an error message for invalid operands to arith operation CODE.
167 NOP_EXPR is used as a special case (see truthvalue_conversion). */
168extern void binary_op_error PROTO((enum tree_code));
169extern void c_expand_expr_stmt PROTO((tree));
170/* Validate the expression after `case' and apply default promotions. */
171extern tree check_case_value PROTO((tree));
172/* Concatenate a list of STRING_CST nodes into one STRING_CST. */
173extern tree combine_strings PROTO((tree));
174extern void constant_expression_warning PROTO((tree));
175extern void decl_attributes PROTO((tree, tree));
176extern void declare_function_name PROTO((void));
177extern tree convert_and_check PROTO((tree, tree));
178extern void overflow_warning PROTO((tree));
179extern void unsigned_conversion_warning PROTO((tree, tree));
180/* Read the rest of the current #-directive line. */
181extern char *get_directive_line STDIO_PROTO((FILE *));
182/* Subroutine of build_binary_op, used for comparison operations.
183 See if the operands have both been converted from subword integer types
184 and, if so, perhaps change them both back to their original type. */
185extern tree shorten_compare PROTO((tree *, tree *, tree *, enum tree_code *));
186/* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
187 or validate its data type for an `if' or `while' statement or ?..: exp. */
188extern tree truthvalue_conversion PROTO((tree));
189extern tree type_for_mode PROTO((enum machine_mode, int));
190extern tree type_for_size PROTO((unsigned, int));
191
192/* in c-convert.c */
193extern tree convert PROTO((tree, tree));
194
195/* in c-decl.c */
196/* Standard named or nameless data types of the C compiler. */
197extern tree char_array_type_node;
198extern tree char_type_node;
199extern tree const_ptr_type_node;
200extern tree const_string_type_node;
201extern tree default_function_type;
202extern tree double_ftype_double;
203extern tree double_ftype_double_double;
204extern tree double_type_node;
205extern tree float_type_node;
206extern tree intDI_type_node;
207extern tree intHI_type_node;
208extern tree intQI_type_node;
209extern tree intSI_type_node;
210extern tree int_array_type_node;
211extern tree int_ftype_cptr_cptr_sizet;
212extern tree int_ftype_int;
213extern tree int_ftype_ptr_ptr_int;
214extern tree int_ftype_string_string;
215extern tree integer_type_node;
216extern tree long_double_type_node;
217extern tree long_ftype_long;
218extern tree long_integer_type_node;
219extern tree long_long_integer_type_node;
220extern tree long_long_unsigned_type_node;
221extern tree long_unsigned_type_node;
222extern tree complex_integer_type_node;
223extern tree complex_float_type_node;
224extern tree complex_double_type_node;
225extern tree complex_long_double_type_node;
226extern tree ptr_type_node;
227extern tree ptrdiff_type_node;
228extern tree short_integer_type_node;
229extern tree short_unsigned_type_node;
230extern tree signed_char_type_node;
231extern tree signed_wchar_type_node;
232extern tree string_ftype_ptr_ptr;
233extern tree string_type_node;
234extern tree unsigned_char_type_node;
235extern tree unsigned_intDI_type_node;
236extern tree unsigned_intHI_type_node;
237extern tree unsigned_intQI_type_node;
238extern tree unsigned_intSI_type_node;
239extern tree unsigned_type_node;
240extern tree unsigned_wchar_type_node;
241extern tree void_ftype_ptr_int_int;
242extern tree void_ftype_ptr_ptr_int;
243extern tree void_type_node;
244extern tree wchar_array_type_node;
245extern tree wchar_type_node;
246
247extern tree build_enumerator PROTO((tree, tree));
248/* Declare a predefined function. Return the declaration. */
249extern tree builtin_function PROTO((char *, tree, enum built_in_function function_, char *));
250/* Add qualifiers to a type, in the fashion for C. */
251extern tree c_build_type_variant PROTO((tree, int, int));
252extern int c_decode_option PROTO((char *));
253extern void c_mark_varargs PROTO((void));
254extern tree check_identifier PROTO((tree, tree));
255extern void clear_parm_order PROTO((void));
256extern tree combine_parm_decls PROTO((tree, tree, int));
257extern int complete_array_type PROTO((tree, tree, int));
258extern void declare_parm_level PROTO((int));
259extern tree define_label PROTO((char *, int, tree));
260extern void delete_block PROTO((tree));
261extern void finish_decl PROTO((tree, tree, tree));
262extern tree finish_enum PROTO((tree, tree));
263extern void finish_function PROTO((int));
264extern tree finish_struct PROTO((tree, tree));
265extern tree get_parm_info PROTO((int));
266extern tree getdecls PROTO((void));
267extern tree gettags PROTO((void));
268extern int global_bindings_p PROTO((void));
269extern tree grokfield PROTO((char *, int, tree, tree, tree));
270extern tree groktypename PROTO((tree));
271extern tree groktypename_in_parm_context PROTO((tree));
272extern tree implicitly_declare PROTO((tree));
273extern int in_parm_level_p PROTO((void));
274extern void init_decl_processing PROTO((void));
275extern void insert_block PROTO((tree));
276extern void keep_next_level PROTO((void));
277extern int kept_level_p PROTO((void));
278extern tree lookup_label PROTO((tree));
279extern tree lookup_name PROTO((tree));
280extern tree lookup_name_current_level PROTO((tree));
281extern tree maybe_build_cleanup PROTO((tree));
282extern void parmlist_tags_warning PROTO((void));
283extern void pending_xref_error PROTO((void));
284extern void pop_c_function_context PROTO((void));
285extern void pop_label_level PROTO((void));
286extern tree poplevel PROTO((int, int, int));
287extern void print_lang_decl PROTO((void));
288extern void print_lang_identifier STDIO_PROTO((FILE *, tree,
289 int));
290extern void print_lang_type PROTO((void));
291extern void push_c_function_context PROTO((void));
292extern void push_label_level PROTO((void));
293extern void push_parm_decl PROTO((tree));
294extern tree pushdecl PROTO((tree));
295extern tree pushdecl_top_level PROTO((tree));
296extern void pushlevel PROTO((int));
297extern void pushtag PROTO((tree, tree));
298extern void set_block PROTO((tree));
299extern tree shadow_label PROTO((tree));
300extern void shadow_record_fields PROTO((tree));
301extern void shadow_tag PROTO((tree));
302extern void shadow_tag_warned PROTO((tree, int));
303extern tree start_enum PROTO((tree));
304extern int start_function PROTO((tree, tree, int));
305extern tree start_decl PROTO((tree, tree, int));
306extern tree start_struct PROTO((enum tree_code, tree));
307extern void store_parm_decls PROTO((void));
308extern tree xref_tag PROTO((enum tree_code, tree));
309
310/* in c-typeck.c */
311extern tree build_array_ref PROTO((tree, tree));
312extern tree build_binary_op PROTO((enum tree_code, tree, tree, int));
313extern tree build_c_cast PROTO((tree, tree));
314extern tree build_component_ref PROTO((tree, tree));
315extern tree build_compound_expr PROTO((tree));
316extern tree build_conditional_expr PROTO((tree, tree, tree));
317extern tree build_function_call PROTO((tree, tree));
318extern tree build_indirect_ref PROTO((tree, char *));
319extern tree build_modify_expr PROTO((tree, enum tree_code, tree));
320extern tree build_unary_op PROTO((enum tree_code, tree, int));
321extern tree c_alignof PROTO((tree));
322extern tree c_alignof_expr PROTO((tree));
323extern tree c_sizeof PROTO((tree));
324extern tree c_expand_start_case PROTO((tree));
325/* Given two integer or real types, return the type for their sum.
326 Given two compatible ANSI C types, returns the merged type. */
327extern tree common_type PROTO((tree, tree));
328extern tree default_conversion PROTO((tree));
329extern tree digest_init PROTO((tree, tree, tree *, int, int, char *));
330extern tree parser_build_binary_op PROTO((enum tree_code, tree, tree));
331extern tree require_complete_type PROTO((tree));
332extern void store_init_value PROTO((tree, tree));
333
334/* in c-iterate.c */
335extern void iterator_expand PROTO((tree));
336extern void iterator_for_loop_start PROTO((tree));
337extern void iterator_for_loop_end PROTO((tree));
338extern void iterator_for_loop_record PROTO((tree));
339extern void push_iterator_stack PROTO((void));
340extern void pop_iterator_stack PROTO((void));
341
342/* Set to 0 at beginning of a function definition, set to 1 if
343 a return statement that specifies a return value is seen. */
344
345extern int current_function_returns_value;
346
347/* Set to 0 at beginning of a function definition, set to 1 if
348 a return statement with no argument is seen. */
349
350extern int current_function_returns_null;
351
352/* Nonzero means `$' can be in an identifier. */
353
354extern int dollars_in_ident;
355
356/* Nonzero means allow type mismatches in conditional expressions;
357 just make their values `void'. */
358
359extern int flag_cond_mismatch;
360
361/* Nonzero means don't recognize the keyword `asm'. */
362
363extern int flag_no_asm;
364
365/* Nonzero means ignore `#ident' directives. */
366
367extern int flag_no_ident;
368
369/* Nonzero means warn about implicit declarations. */
370
371extern int warn_implicit;
372
373/* Nonzero means give string constants the type `const char *'
374 to get extra warnings from them. These warnings will be too numerous
375 to be useful, except in thoroughly ANSIfied programs. */
376
377extern int warn_write_strings;
378
379/* Nonzero means warn about sizeof (function) or addition/subtraction
380 of function pointers. */
381
382extern int warn_pointer_arith;
383
384/* Nonzero means warn for all old-style non-prototype function decls. */
385
386extern int warn_strict_prototypes;
387
388/* Nonzero means warn about multiple (redundant) decls for the same single
389 variable or function. */
390
391extern int warn_redundant_decls;
392
393/* Nonzero means warn about extern declarations of objects not at
394 file-scope level and about *all* declarations of functions (whether
395 extern or static) not at file-scope level. Note that we exclude
396 implicit function declarations. To get warnings about those, use
397 -Wimplicit. */
398
399extern int warn_nested_externs;
400
401/* Nonzero means warn about pointer casts that can drop a type qualifier
402 from the pointer target type. */
403
404extern int warn_cast_qual;
405
406/* Warn about traditional constructs whose meanings changed in ANSI C. */
407
408extern int warn_traditional;
409
410/* Warn about *printf or *scanf format/argument anomalies. */
411
412extern int warn_format;
413
414/* Warn about a subscript that has type char. */
415
416extern int warn_char_subscripts;
417
418/* Warn if a type conversion is done that might have confusing results. */
419
420extern int warn_conversion;
421
422/* Nonzero means do some things the same way PCC does. */
423
424extern int flag_traditional;
425
426/* Nonzero means warn about suggesting putting in ()'s. */
427
428extern int warn_parentheses;
429
430/* Warn if initializer is not completely bracketed. */
431
432extern int warn_missing_braces;
433
434/* Nonzero means this is a function to call to perform comptypes
435 on two record types. */
436
437extern int (*comptypes_record_hook) ();
438
439/* Nonzero means we are reading code that came from a system header file. */
440
441extern int system_header_p;
442
443/* Nonzero enables objc features. */
444
445extern int doing_objc_thang;
446
447#endif /* not _C_TREE_H */