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