1 /* Definitions for C parsing and type checking.
2 Copyright (C) 1987, 93, 94, 95, 97, 98, 1999 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)
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, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* $FreeBSD: src/contrib/gcc/c-tree.h,v 1.4.2.1 2001/08/01 18:03:24 obrien Exp $ */
22 /* $DragonFly: src/contrib/gcc/Attic/c-tree.h,v 1.2 2003/06/17 04:23:59 dillon Exp $ */
27 /* Language-dependent contents of an identifier. */
29 /* The limbo_value is used for block level extern declarations, which need
30 to be type checked against subsequent extern declarations. They can't
31 be referenced after they fall out of scope, so they can't be global. */
33 struct lang_identifier
35 struct tree_identifier ignore;
36 tree global_value, local_value, label_value, implicit_decl;
37 tree error_locus, limbo_value;
40 /* Macros for access to language-specific slots in an identifier. */
41 /* Each of these slots contains a DECL node or null. */
43 /* This represents the value which the identifier has in the
44 file-scope namespace. */
45 #define IDENTIFIER_GLOBAL_VALUE(NODE) \
46 (((struct lang_identifier *) (NODE))->global_value)
47 /* This represents the value which the identifier has in the current
49 #define IDENTIFIER_LOCAL_VALUE(NODE) \
50 (((struct lang_identifier *) (NODE))->local_value)
51 /* This represents the value which the identifier has as a label in
52 the current label scope. */
53 #define IDENTIFIER_LABEL_VALUE(NODE) \
54 (((struct lang_identifier *) (NODE))->label_value)
55 /* This records the extern decl of this identifier, if it has had one
56 at any point in this compilation. */
57 #define IDENTIFIER_LIMBO_VALUE(NODE) \
58 (((struct lang_identifier *) (NODE))->limbo_value)
59 /* This records the implicit function decl of this identifier, if it
60 has had one at any point in this compilation. */
61 #define IDENTIFIER_IMPLICIT_DECL(NODE) \
62 (((struct lang_identifier *) (NODE))->implicit_decl)
63 /* This is the last function in which we printed an "undefined variable"
64 message for this identifier. Value is a FUNCTION_DECL or null. */
65 #define IDENTIFIER_ERROR_LOCUS(NODE) \
66 (((struct lang_identifier *) (NODE))->error_locus)
68 /* In identifiers, C uses the following fields in a special way:
69 TREE_PUBLIC to record that there was a previous local extern decl.
70 TREE_USED to record that such a decl was used.
71 TREE_ADDRESSABLE to record that the address of such a decl was used. */
73 /* Nonzero means reject anything that ANSI standard C forbids. */
76 /* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only. */
77 #define C_TYPE_FIELDS_READONLY(type) TREE_LANG_FLAG_1 (type)
79 /* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is volatile. */
80 #define C_TYPE_FIELDS_VOLATILE(type) TREE_LANG_FLAG_2 (type)
82 /* In a RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE
83 nonzero if the definition of the type has already started. */
84 #define C_TYPE_BEING_DEFINED(type) TYPE_LANG_FLAG_0 (type)
86 /* C types are partitioned into three subsets: object, function, and
88 #define C_TYPE_OBJECT_P(type) \
89 (TREE_CODE (type) != FUNCTION_TYPE && TYPE_SIZE (type))
91 #define C_TYPE_FUNCTION_P(type) \
92 (TREE_CODE (type) == FUNCTION_TYPE)
94 #define C_TYPE_INCOMPLETE_P(type) \
95 (TREE_CODE (type) != FUNCTION_TYPE && TYPE_SIZE (type) == 0)
97 /* For convenience we define a single macro to identify the class of
98 object or incomplete types. */
99 #define C_TYPE_OBJECT_OR_INCOMPLETE_P(type) \
100 (!C_TYPE_FUNCTION_P (type))
102 /* In a RECORD_TYPE, a sorted array of the fields of the type. */
109 /* Mark which labels are explicitly declared.
110 These may be shadowed, and may be referenced from nested functions. */
111 #define C_DECLARED_LABEL_FLAG(label) TREE_LANG_FLAG_1 (label)
113 /* Record whether a type or decl was written with nonconstant size.
114 Note that TYPE_SIZE may have simplified to a constant. */
115 #define C_TYPE_VARIABLE_SIZE(type) TYPE_LANG_FLAG_1 (type)
116 #define C_DECL_VARIABLE_SIZE(type) DECL_LANG_FLAG_0 (type)
118 /* Record in each node resulting from a binary operator
119 what operator was specified for it. */
120 #define C_EXP_ORIGINAL_CODE(exp) ((enum tree_code) TREE_COMPLEXITY (exp))
122 #if 0 /* Not used. */
123 /* Record whether a decl for a function or function pointer has
124 already been mentioned (in a warning) because it was called
125 but didn't have a prototype. */
126 #define C_MISSING_PROTOTYPE_WARNED(decl) DECL_LANG_FLAG_2(decl)
129 /* Store a value in that field. */
130 #define C_SET_EXP_ORIGINAL_CODE(exp, code) \
131 (TREE_COMPLEXITY (exp) = (int) (code))
133 /* Record whether a typedef for type `int' was actually `signed int'. */
134 #define C_TYPEDEF_EXPLICITLY_SIGNED(exp) DECL_LANG_FLAG_1 ((exp))
136 /* Nonzero for a declaration of a built in function if there has been no
137 occasion that would declare the function in ordinary C.
138 Using the function draws a pedantic warning in this case. */
139 #define C_DECL_ANTICIPATED(exp) DECL_LANG_FLAG_3 ((exp))
141 /* For FUNCTION_TYPE, a hidden list of types of arguments. The same as
142 TYPE_ARG_TYPES for functions with prototypes, but created for functions
143 without prototypes. */
144 #define TYPE_ACTUAL_ARG_TYPES(NODE) TYPE_NONCOPIED_PARTS (NODE)
146 /* In a FIELD_DECL, nonzero if the decl was originally a bitfield. */
147 #define DECL_C_BIT_FIELD(NODE) DECL_LANG_FLAG_4 (NODE)
149 /* Nonzero if the type T promotes to itself.
150 ANSI C states explicitly the list of types that promote;
151 in particular, short promotes to int even if they have the same width. */
152 #define C_PROMOTING_INTEGER_TYPE_P(t) \
153 (TREE_CODE ((t)) == INTEGER_TYPE \
154 && (TYPE_MAIN_VARIANT (t) == char_type_node \
155 || TYPE_MAIN_VARIANT (t) == signed_char_type_node \
156 || TYPE_MAIN_VARIANT (t) == unsigned_char_type_node \
157 || TYPE_MAIN_VARIANT (t) == short_integer_type_node \
158 || TYPE_MAIN_VARIANT (t) == short_unsigned_type_node))
160 /* In a VAR_DECL, means the variable is really an iterator. */
161 #define ITERATOR_P(D) (DECL_LANG_FLAG_4(D))
163 /* In a VAR_DECL for an iterator, means we are within
164 an explicit loop over that iterator. */
165 #define ITERATOR_BOUND_P(NODE) ((NODE)->common.readonly_flag)
167 /* in c-lang.c and objc-act.c */
168 extern tree lookup_interface PROTO((tree));
169 extern tree is_class_name PROTO((tree));
170 extern void maybe_objc_check_decl PROTO((tree));
171 extern void finish_file PROTO((void));
172 extern int maybe_objc_comptypes PROTO((tree, tree, int));
173 extern tree maybe_building_objc_message_expr PROTO((void));
174 extern tree maybe_objc_method_name PROTO((tree));
175 extern int recognize_objc_keyword PROTO((void));
176 extern tree build_objc_string PROTO((int, const char *));
178 /* in c-aux-info.c */
179 extern void gen_aux_info_record PROTO((tree, int, int, int));
182 extern void declare_function_name PROTO((void));
183 extern void decl_attributes PROTO((tree, tree, tree));
184 extern void init_function_format_info PROTO((void));
185 extern void check_function_format PROTO((tree, tree, tree));
186 extern int c_get_alias_set PROTO((tree));
187 extern void c_apply_type_quals_to_decl PROTO((int, tree));
188 /* Print an error message for invalid operands to arith operation CODE.
189 NOP_EXPR is used as a special case (see truthvalue_conversion). */
190 extern void binary_op_error PROTO((enum tree_code));
191 extern void c_expand_expr_stmt PROTO((tree));
192 extern void c_expand_start_cond PROTO((tree, int, int));
193 extern void c_expand_start_else PROTO((void));
194 extern void c_expand_end_cond PROTO((void));
195 /* Validate the expression after `case' and apply default promotions. */
196 extern tree check_case_value PROTO((tree));
197 /* Concatenate a list of STRING_CST nodes into one STRING_CST. */
198 extern tree combine_strings PROTO((tree));
199 extern void constant_expression_warning PROTO((tree));
200 extern tree convert_and_check PROTO((tree, tree));
201 extern void overflow_warning PROTO((tree));
202 extern void unsigned_conversion_warning PROTO((tree, tree));
203 /* Read the rest of the current #-directive line. */
205 extern char *get_directive_line PROTO((void));
206 #define GET_DIRECTIVE_LINE() get_directive_line ()
208 extern char *get_directive_line PROTO((FILE *));
209 #define GET_DIRECTIVE_LINE() get_directive_line (finput)
212 /* Subroutine of build_binary_op, used for comparison operations.
213 See if the operands have both been converted from subword integer types
214 and, if so, perhaps change them both back to their original type. */
215 extern tree shorten_compare PROTO((tree *, tree *, tree *, enum tree_code *));
216 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
217 or validate its data type for an `if' or `while' statement or ?..: exp. */
218 extern tree truthvalue_conversion PROTO((tree));
219 extern tree type_for_mode PROTO((enum machine_mode, int));
220 extern tree type_for_size PROTO((unsigned, int));
223 extern tree convert PROTO((tree, tree));
226 /* Standard named or nameless data types of the C compiler. */
227 extern tree char_array_type_node;
228 extern tree char_type_node;
229 extern tree const_ptr_type_node;
230 extern tree const_string_type_node;
231 extern tree default_function_type;
232 extern tree double_ftype_double;
233 extern tree double_ftype_double_double;
234 extern tree double_type_node;
235 extern tree float_type_node;
236 #if HOST_BITS_PER_WIDE_INT >= 64
237 extern tree intTI_type_node;
239 extern tree intDI_type_node;
240 extern tree intHI_type_node;
241 extern tree intQI_type_node;
242 extern tree intSI_type_node;
243 extern tree int_array_type_node;
244 extern tree int_ftype_cptr_cptr_sizet;
245 extern tree int_ftype_int;
246 extern tree int_ftype_ptr_ptr_int;
247 extern tree int_ftype_string_string;
248 extern tree integer_type_node;
249 extern tree long_double_type_node;
250 extern tree long_ftype_long;
251 extern tree long_integer_type_node;
252 extern tree long_long_integer_type_node;
253 extern tree long_long_unsigned_type_node;
254 extern tree long_unsigned_type_node;
255 extern tree complex_integer_type_node;
256 extern tree complex_float_type_node;
257 extern tree complex_double_type_node;
258 extern tree complex_long_double_type_node;
259 extern tree ptr_type_node;
260 extern tree ptrdiff_type_node;
261 extern tree short_integer_type_node;
262 extern tree short_unsigned_type_node;
263 extern tree signed_char_type_node;
264 extern tree signed_wchar_type_node;
265 extern tree string_ftype_ptr_ptr;
266 extern tree string_type_node;
267 extern tree unsigned_char_type_node;
268 #if HOST_BITS_PER_WIDE_INT >= 64
269 extern tree unsigned_intTI_type_node;
271 extern tree unsigned_intDI_type_node;
272 extern tree unsigned_intHI_type_node;
273 extern tree unsigned_intQI_type_node;
274 extern tree unsigned_intSI_type_node;
275 extern tree unsigned_type_node;
276 extern tree unsigned_wchar_type_node;
277 extern tree void_ftype_ptr_int_int;
278 extern tree void_ftype_ptr_ptr_int;
279 extern tree void_type_node;
280 extern tree wchar_array_type_node;
281 extern tree wchar_type_node;
282 extern tree boolean_type_node;
283 extern tree boolean_true_node;
284 extern tree boolean_false_node;
286 extern tree build_enumerator PROTO((tree, tree));
287 /* Declare a predefined function. Return the declaration. */
288 extern tree builtin_function PROTO((const char *, tree, enum built_in_function function_, const char *));
289 /* Add qualifiers to a type, in the fashion for C. */
290 extern tree c_build_qualified_type PROTO((tree, int));
291 #define c_build_type_variant(TYPE, CONST_P, VOLATILE_P) \
292 c_build_qualified_type (TYPE, \
293 ((CONST_P) ? TYPE_QUAL_CONST : 0) | \
294 ((VOLATILE_P) ? TYPE_QUAL_VOLATILE : 0))
295 extern int c_decode_option PROTO((int, char **));
296 extern void c_mark_varargs PROTO((void));
297 extern tree check_identifier PROTO((tree, tree));
298 extern void clear_parm_order PROTO((void));
299 extern tree combine_parm_decls PROTO((tree, tree, int));
300 extern int complete_array_type PROTO((tree, tree, int));
301 extern void declare_parm_level PROTO((int));
302 extern tree define_label PROTO((char *, int, tree));
303 extern void delete_block PROTO((tree));
304 extern void finish_decl PROTO((tree, tree, tree));
305 extern void finish_decl_top_level PROTO((tree, tree, tree));
306 extern tree finish_enum PROTO((tree, tree, tree));
307 extern void finish_function PROTO((int));
308 extern tree finish_struct PROTO((tree, tree, tree));
309 extern tree get_parm_info PROTO((int));
310 extern tree getdecls PROTO((void));
311 extern tree gettags PROTO((void));
312 extern int global_bindings_p PROTO((void));
313 extern tree grokfield PROTO((const char *, int, tree, tree, tree));
314 extern tree groktypename PROTO((tree));
315 extern tree groktypename_in_parm_context PROTO((tree));
316 extern tree implicitly_declare PROTO((tree));
317 extern int in_parm_level_p PROTO((void));
318 extern void init_decl_processing PROTO((void));
319 extern void insert_block PROTO((tree));
320 extern void keep_next_level PROTO((void));
321 extern int kept_level_p PROTO((void));
322 extern tree lookup_label PROTO((tree));
323 extern tree lookup_name PROTO((tree));
324 extern tree lookup_name_current_level PROTO((tree));
325 extern tree lookup_name_current_level_global PROTO((tree));
326 extern tree maybe_build_cleanup PROTO((tree));
327 extern void parmlist_tags_warning PROTO((void));
328 extern void pending_xref_error PROTO((void));
329 extern void pop_c_function_context PROTO((void));
330 extern void pop_label_level PROTO((void));
331 extern tree poplevel PROTO((int, int, int));
332 extern void print_lang_decl PROTO((FILE *, tree, int));
333 extern void print_lang_identifier PROTO((FILE *, tree, int));
334 extern void print_lang_type PROTO((FILE *, tree, int));
335 extern void push_c_function_context PROTO((void));
336 extern void push_label_level PROTO((void));
337 extern void push_parm_decl PROTO((tree));
338 extern tree pushdecl PROTO((tree));
339 extern tree pushdecl_top_level PROTO((tree));
340 extern void pushlevel PROTO((int));
341 extern void pushtag PROTO((tree, tree));
342 extern void set_block PROTO((tree));
343 extern tree shadow_label PROTO((tree));
344 extern void shadow_record_fields PROTO((tree));
345 extern void shadow_tag PROTO((tree));
346 extern void shadow_tag_warned PROTO((tree, int));
347 extern tree start_enum PROTO((tree));
348 extern int start_function PROTO((tree, tree, tree,
350 extern tree start_decl PROTO((tree, tree, int,
352 extern tree start_struct PROTO((enum tree_code, tree));
353 extern void store_parm_decls PROTO((void));
354 extern tree xref_tag PROTO((enum tree_code, tree));
357 extern tree require_complete_type PROTO((tree));
358 extern void incomplete_type_error PROTO((tree, tree));
359 /* Given two integer or real types, return the type for their sum.
360 Given two compatible ANSI C types, returns the merged type. */
361 extern tree common_type PROTO((tree, tree));
362 extern int comptypes PROTO((tree, tree));
363 extern int self_promoting_args_p PROTO((tree));
364 extern tree c_sizeof PROTO((tree));
365 extern tree c_sizeof_nowarn PROTO((tree));
366 extern tree c_size_in_bytes PROTO((tree));
367 extern tree c_alignof PROTO((tree));
368 extern tree c_alignof_expr PROTO((tree));
369 extern tree default_conversion PROTO((tree));
370 extern tree build_component_ref PROTO((tree, tree));
371 extern tree build_indirect_ref PROTO((tree, const char *));
372 extern tree build_array_ref PROTO((tree, tree));
373 extern tree build_function_call PROTO((tree, tree));
374 extern tree parser_build_binary_op PROTO((enum tree_code,
376 extern tree build_binary_op PROTO((enum tree_code,
378 extern tree build_unary_op PROTO((enum tree_code,
380 extern int lvalue_p PROTO((tree));
381 extern int lvalue_or_else PROTO((tree, const char *));
382 extern void readonly_warning PROTO((tree, const char *));
383 extern int mark_addressable PROTO((tree));
384 extern tree build_conditional_expr PROTO((tree, tree, tree));
385 extern tree build_compound_expr PROTO((tree));
386 extern tree build_c_cast PROTO((tree, tree));
387 extern tree build_modify_expr PROTO((tree, enum tree_code,
389 extern tree initializer_constant_valid_p PROTO((tree, tree));
390 extern void store_init_value PROTO((tree, tree));
391 extern void error_init PROTO((const char *));
392 extern void pedwarn_init PROTO((const char *));
393 extern void start_init PROTO((tree, tree, int));
394 extern void finish_init PROTO((void));
395 extern void really_start_incremental_init PROTO((tree));
396 extern void push_init_level PROTO((int));
397 extern tree pop_init_level PROTO((int));
398 extern void set_init_index PROTO((tree, tree));
399 extern void set_init_label PROTO((tree));
400 extern void process_init_element PROTO((tree));
401 extern void c_expand_asm_operands PROTO((tree, tree, tree, tree,
403 extern void c_expand_return PROTO((tree));
404 extern tree c_expand_start_case PROTO((tree));
407 extern void init_iterators PROTO((void));
408 extern void iterator_expand PROTO((tree));
409 extern void iterator_for_loop_start PROTO((tree));
410 extern void iterator_for_loop_end PROTO((tree));
411 extern void iterator_for_loop_record PROTO((tree));
412 extern void push_iterator_stack PROTO((void));
413 extern void pop_iterator_stack PROTO((void));
415 /* Set to 0 at beginning of a function definition, set to 1 if
416 a return statement that specifies a return value is seen. */
418 extern int current_function_returns_value;
420 /* Set to 0 at beginning of a function definition, set to 1 if
421 a return statement with no argument is seen. */
423 extern int current_function_returns_null;
425 /* Nonzero means the expression being parsed will never be evaluated.
426 This is a count, since unevaluated expressions can nest. */
428 extern int skip_evaluation;
430 /* Nonzero means `$' can be in an identifier. */
432 extern int dollars_in_ident;
434 /* Nonzero means allow type mismatches in conditional expressions;
435 just make their values `void'. */
437 extern int flag_cond_mismatch;
439 /* Nonzero means don't recognize the keyword `asm'. */
441 extern int flag_no_asm;
443 /* Nonzero means environment is hosted (i.e., not freestanding) */
445 extern int flag_hosted;
447 /* Nonzero means warn about implicit declarations. */
449 extern int warn_implicit;
451 /* Nonzero means give string constants the type `const char *'
452 to get extra warnings from them. These warnings will be too numerous
453 to be useful, except in thoroughly ANSIfied programs. */
455 extern int flag_const_strings;
457 /* Nonzero means warn about sizeof (function) or addition/subtraction
458 of function pointers. */
460 extern int warn_pointer_arith;
462 /* Nonzero means warn for all old-style non-prototype function decls. */
464 extern int warn_strict_prototypes;
466 /* Nonzero means warn about multiple (redundant) decls for the same single
467 variable or function. */
469 extern int warn_redundant_decls;
471 /* Nonzero means warn about extern declarations of objects not at
472 file-scope level and about *all* declarations of functions (whether
473 extern or static) not at file-scope level. Note that we exclude
474 implicit function declarations. To get warnings about those, use
477 extern int warn_nested_externs;
479 /* Nonzero means warn about pointer casts that can drop a type qualifier
480 from the pointer target type. */
482 extern int warn_cast_qual;
484 /* Nonzero means warn when casting a function call to a type that does
485 not match the return type (e.g. (float)sqrt() or (anything*)malloc()
486 when there is no previous declaration of sqrt or malloc. */
488 extern int warn_bad_function_cast;
490 /* Warn about functions which might be candidates for attribute noreturn. */
492 extern int warn_missing_noreturn;
494 /* Warn about traditional constructs whose meanings changed in ANSI C. */
496 extern int warn_traditional;
498 /* Warn about *printf or *scanf format/argument anomalies. */
500 extern int warn_format;
501 extern int warn_format_extra_args;
503 /* Warn about a subscript that has type char. */
505 extern int warn_char_subscripts;
507 /* Warn if a type conversion is done that might have confusing results. */
509 extern int warn_conversion;
511 /* Warn if main is suspicious. */
513 extern int warn_main;
515 /* Nonzero means do some things the same way PCC does. */
517 extern int flag_traditional;
519 /* Nonzero means use the ISO C9x dialect of C. */
521 extern int flag_isoc9x;
523 /* Nonzero means to allow single precision math even if we're generally
524 being traditional. */
525 extern int flag_allow_single_precision;
527 /* Nonzero means warn about suggesting putting in ()'s. */
529 extern int warn_parentheses;
531 /* Warn if initializer is not completely bracketed. */
533 extern int warn_missing_braces;
535 /* Warn about comparison of signed and unsigned values. */
537 extern int warn_sign_compare;
539 /* Warn about multicharacter constants. */
541 extern int warn_multichar;
543 /* Warn about long long. */
545 extern int warn_long_long;
547 /* Nonzero means we are reading code that came from a system header file. */
549 extern int system_header_p;
551 /* Nonzero enables objc features. */
553 extern int doing_objc_thang;
556 extern void finish_incomplete_decl PROTO((tree));
558 #endif /* not _C_TREE_H */