OSDN Git Service

* Makefile.in (C_AND_OBJC_OBJS): Remove ggc-callbacks.o.
[pf3gnuchains/gcc-fork.git] / gcc / c-tree.h
1 /* Definitions for C parsing and type checking.
2    Copyright (C) 1987, 93, 94, 95, 97, 98, 1999 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
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.
10
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.
15
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.  */
20
21 #ifndef _C_TREE_H
22 #define _C_TREE_H
23
24 #include "c-common.h"
25
26 /* Language-dependent contents of an identifier.  */
27
28 /* The limbo_value is used for block level extern declarations, which need
29    to be type checked against subsequent extern declarations.  They can't
30    be referenced after they fall out of scope, so they can't be global.  */
31
32 struct lang_identifier
33 {
34   struct tree_identifier ignore;
35   tree global_value, local_value, label_value, implicit_decl;
36   tree error_locus, limbo_value;
37 };
38
39 /* Macros for access to language-specific slots in an identifier.  */
40 /* Each of these slots contains a DECL node or null.  */
41
42 /* This represents the value which the identifier has in the
43    file-scope namespace.  */
44 #define IDENTIFIER_GLOBAL_VALUE(NODE)   \
45   (((struct lang_identifier *) (NODE))->global_value)
46 /* This represents the value which the identifier has in the current
47    scope.  */
48 #define IDENTIFIER_LOCAL_VALUE(NODE)    \
49   (((struct lang_identifier *) (NODE))->local_value)
50 /* This represents the value which the identifier has as a label in
51    the current label scope.  */
52 #define IDENTIFIER_LABEL_VALUE(NODE)    \
53   (((struct lang_identifier *) (NODE))->label_value)
54 /* This records the extern decl of this identifier, if it has had one
55    at any point in this compilation.  */
56 #define IDENTIFIER_LIMBO_VALUE(NODE)    \
57   (((struct lang_identifier *) (NODE))->limbo_value)
58 /* This records the implicit function decl of this identifier, if it
59    has had one at any point in this compilation.  */
60 #define IDENTIFIER_IMPLICIT_DECL(NODE)  \
61   (((struct lang_identifier *) (NODE))->implicit_decl)
62 /* This is the last function in which we printed an "undefined variable"
63    message for this identifier.  Value is a FUNCTION_DECL or null.  */
64 #define IDENTIFIER_ERROR_LOCUS(NODE)    \
65   (((struct lang_identifier *) (NODE))->error_locus)
66
67 /* In identifiers, C uses the following fields in a special way:
68    TREE_PUBLIC        to record that there was a previous local extern decl.
69    TREE_USED          to record that such a decl was used.
70    TREE_ADDRESSABLE   to record that the address of such a decl was used.  */
71
72 /* Nonzero means reject anything that ANSI standard C forbids.  */
73 extern int pedantic;
74
75 /* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only.  */
76 #define C_TYPE_FIELDS_READONLY(type) TREE_LANG_FLAG_1 (type)
77
78 /* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is volatile.  */
79 #define C_TYPE_FIELDS_VOLATILE(type) TREE_LANG_FLAG_2 (type)
80
81 /* In a RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE
82    nonzero if the definition of the type has already started.  */
83 #define C_TYPE_BEING_DEFINED(type) TYPE_LANG_FLAG_0 (type)
84
85 /* C types are partitioned into three subsets: object, function, and
86    incomplete types.  */
87 #define C_TYPE_OBJECT_P(type) \
88   (TREE_CODE (type) != FUNCTION_TYPE && TYPE_SIZE (type))
89
90 #define C_TYPE_FUNCTION_P(type) \
91   (TREE_CODE (type) == FUNCTION_TYPE)
92
93 #define C_TYPE_INCOMPLETE_P(type) \
94   (TREE_CODE (type) != FUNCTION_TYPE && TYPE_SIZE (type) == 0)
95
96 /* For convenience we define a single macro to identify the class of
97    object or incomplete types.  */
98 #define C_TYPE_OBJECT_OR_INCOMPLETE_P(type) \
99   (!C_TYPE_FUNCTION_P (type))
100
101 /* In a RECORD_TYPE, a sorted array of the fields of the type.  */
102 struct lang_type
103 {
104   int len;
105   tree elts[1];
106 };
107
108 /* Mark which labels are explicitly declared.
109    These may be shadowed, and may be referenced from nested functions.  */
110 #define C_DECLARED_LABEL_FLAG(label) TREE_LANG_FLAG_1 (label)
111
112 /* Record whether a type or decl was written with nonconstant size.
113    Note that TYPE_SIZE may have simplified to a constant.  */
114 #define C_TYPE_VARIABLE_SIZE(type) TYPE_LANG_FLAG_1 (type)
115 #define C_DECL_VARIABLE_SIZE(type) DECL_LANG_FLAG_0 (type)
116
117 /* Record in each node resulting from a binary operator
118    what operator was specified for it.  */
119 #define C_EXP_ORIGINAL_CODE(exp) ((enum tree_code) TREE_COMPLEXITY (exp))
120
121 #if 0 /* Not used.  */
122 /* Record whether a decl for a function or function pointer has
123    already been mentioned (in a warning) because it was called
124    but didn't have a prototype.  */
125 #define C_MISSING_PROTOTYPE_WARNED(decl) DECL_LANG_FLAG_2(decl)
126 #endif
127
128 /* Store a value in that field.  */
129 #define C_SET_EXP_ORIGINAL_CODE(exp, code) \
130   (TREE_COMPLEXITY (exp) = (int) (code))
131
132 /* Record whether a typedef for type `int' was actually `signed int'.  */
133 #define C_TYPEDEF_EXPLICITLY_SIGNED(exp) DECL_LANG_FLAG_1 ((exp))
134
135 /* Nonzero for a declaration of a built in function if there has been no
136    occasion that would declare the function in ordinary C.
137    Using the function draws a pedantic warning in this case.  */
138 #define C_DECL_ANTICIPATED(exp) DECL_LANG_FLAG_3 ((exp))
139
140 /* For FUNCTION_TYPE, a hidden list of types of arguments.  The same as
141    TYPE_ARG_TYPES for functions with prototypes, but created for functions
142    without prototypes.  */
143 #define TYPE_ACTUAL_ARG_TYPES(NODE) TYPE_NONCOPIED_PARTS (NODE)
144
145 /* In a FIELD_DECL, nonzero if the decl was originally a bitfield.  */
146 #define DECL_C_BIT_FIELD(NODE) DECL_LANG_FLAG_4 (NODE)
147
148 /* Nonzero if the type T promotes to itself.
149    ANSI C states explicitly the list of types that promote;
150    in particular, short promotes to int even if they have the same width.  */
151 #define C_PROMOTING_INTEGER_TYPE_P(t)                           \
152   (TREE_CODE ((t)) == INTEGER_TYPE                              \
153    && (TYPE_MAIN_VARIANT (t) == char_type_node                  \
154        || TYPE_MAIN_VARIANT (t) == signed_char_type_node        \
155        || TYPE_MAIN_VARIANT (t) == unsigned_char_type_node      \
156        || TYPE_MAIN_VARIANT (t) == short_integer_type_node      \
157        || TYPE_MAIN_VARIANT (t) == short_unsigned_type_node))
158
159 /* In a VAR_DECL, means the variable is really an iterator.  */
160 #define ITERATOR_P(D) (DECL_LANG_FLAG_4(D))
161
162 /* In a VAR_DECL for an iterator, means we are within
163    an explicit loop over that iterator.  */
164 #define ITERATOR_BOUND_P(NODE) ((NODE)->common.readonly_flag)
165 \f
166 /* in c-lang.c and objc-act.c */
167 extern tree lookup_interface                    PROTO((tree));
168 extern tree is_class_name                       PROTO((tree));
169 extern void maybe_objc_check_decl               PROTO((tree));
170 extern void finish_file                         PROTO((void));
171 extern int maybe_objc_comptypes                 PROTO((tree, tree, int));
172 extern tree maybe_building_objc_message_expr    PROTO((void));
173 extern tree maybe_objc_method_name              PROTO((tree));
174 extern int recognize_objc_keyword               PROTO((void));
175 extern tree build_objc_string                   PROTO((int, const char *));
176 \f
177 /* in c-parse.in */
178 extern void c_parse_init                        PROTO((void));
179
180 /* in c-aux-info.c */
181 extern void gen_aux_info_record                 PROTO((tree, int, int, int));
182
183 /* in c-convert.c */
184 extern tree convert                             PROTO((tree, tree));
185
186 /* in c-decl.c */
187 extern tree build_enumerator                    PROTO((tree, tree));
188 /* Add qualifiers to a type, in the fashion for C.  */
189 extern tree c_build_qualified_type              PROTO((tree, int));
190 #define c_build_type_variant(TYPE, CONST_P, VOLATILE_P)           \
191   c_build_qualified_type (TYPE,                                   \
192                           ((CONST_P) ? TYPE_QUAL_CONST : 0) |     \
193                           ((VOLATILE_P) ? TYPE_QUAL_VOLATILE : 0))
194 extern int  c_decode_option                     PROTO((int, char **));
195 extern void c_mark_varargs                      PROTO((void));
196 extern tree check_identifier                    PROTO((tree, tree));
197 extern void clear_parm_order                    PROTO((void));
198 extern tree combine_parm_decls                  PROTO((tree, tree, int));
199 extern int  complete_array_type                 PROTO((tree, tree, int));
200 extern void declare_parm_level                  PROTO((int));
201 extern tree define_label                        PROTO((char *, int, tree));
202 extern void delete_block                        PROTO((tree));
203 extern void finish_decl                         PROTO((tree, tree, tree));
204 extern void finish_decl_top_level               PROTO((tree, tree, tree));
205 extern tree finish_enum                         PROTO((tree, tree, tree));
206 extern void finish_function                     PROTO((int));
207 extern tree finish_struct                       PROTO((tree, tree, tree));
208 extern tree get_parm_info                       PROTO((int));
209 extern tree getdecls                            PROTO((void));
210 extern tree gettags                             PROTO((void));
211 extern int  global_bindings_p                   PROTO((void));
212 extern tree grokfield                           PROTO((const char *, int, tree, tree, tree));
213 extern tree groktypename                        PROTO((tree));
214 extern tree groktypename_in_parm_context        PROTO((tree));
215 extern tree implicitly_declare                  PROTO((tree));
216 extern int  in_parm_level_p                     PROTO((void));
217 extern void init_decl_processing                PROTO((void));
218 extern void insert_block                        PROTO((tree));
219 extern void keep_next_level                     PROTO((void));
220 extern int  kept_level_p                        PROTO((void));
221 extern tree lookup_label                        PROTO((tree));
222 extern tree lookup_name                         PROTO((tree));
223 extern tree lookup_name_current_level           PROTO((tree));
224 extern tree lookup_name_current_level_global    PROTO((tree));
225 extern tree maybe_build_cleanup                 PROTO((tree));
226 extern void parmlist_tags_warning               PROTO((void));
227 extern void pending_xref_error                  PROTO((void));
228 extern void mark_c_function_context             PROTO((struct function *));
229 extern void push_c_function_context             PROTO((struct function *));
230 extern void pop_c_function_context              PROTO((struct function *));
231 extern void pop_label_level                     PROTO((void));
232 extern tree poplevel                            PROTO((int, int, int));
233 extern void print_lang_decl                     PROTO((FILE *, tree, int));
234 extern void print_lang_identifier               PROTO((FILE *, tree, int));
235 extern void print_lang_type                     PROTO((FILE *, tree, int));
236 extern void push_label_level                    PROTO((void));
237 extern void push_parm_decl                      PROTO((tree));
238 extern tree pushdecl                            PROTO((tree));
239 extern tree pushdecl_top_level                  PROTO((tree));
240 extern void pushlevel                           PROTO((int));
241 extern void pushtag                             PROTO((tree, tree));
242 extern void set_block                           PROTO((tree));
243 extern tree shadow_label                        PROTO((tree));
244 extern void shadow_record_fields                PROTO((tree));
245 extern void shadow_tag                          PROTO((tree));
246 extern void shadow_tag_warned                   PROTO((tree, int));
247 extern tree start_enum                          PROTO((tree));
248 extern int  start_function                      PROTO((tree, tree, tree,
249                                                        tree, int));
250 extern tree start_decl                          PROTO((tree, tree, int,
251                                                        tree, tree));
252 extern tree start_struct                        PROTO((enum tree_code, tree));
253 extern void store_parm_decls                    PROTO((void));
254 extern tree xref_tag                            PROTO((enum tree_code, tree));
255
256 /* in c-typeck.c */
257 extern tree require_complete_type               PROTO((tree));
258 extern void incomplete_type_error               PROTO((tree, tree));
259 /* Given two integer or real types, return the type for their sum.
260    Given two compatible ANSI C types, returns the merged type.  */
261 extern tree common_type                         PROTO((tree, tree));
262 extern int comptypes                            PROTO((tree, tree));
263 extern int self_promoting_args_p                PROTO((tree));
264 extern tree c_sizeof                            PROTO((tree));
265 extern tree c_sizeof_nowarn                     PROTO((tree));
266 extern tree c_size_in_bytes                     PROTO((tree));
267 extern tree c_alignof                           PROTO((tree));
268 extern tree c_alignof_expr                      PROTO((tree));
269 extern tree default_conversion                  PROTO((tree));
270 extern tree build_component_ref                 PROTO((tree, tree));
271 extern tree build_indirect_ref                  PROTO((tree, const char *));
272 extern tree build_array_ref                     PROTO((tree, tree));
273 extern tree build_function_call                 PROTO((tree, tree));
274 extern tree parser_build_binary_op              PROTO((enum tree_code,
275                                                        tree, tree));
276 extern tree build_binary_op                     PROTO((enum tree_code,
277                                                        tree, tree, int));
278 extern tree build_unary_op                      PROTO((enum tree_code,
279                                                        tree, int));
280 extern int lvalue_p                             PROTO((tree));
281 extern int lvalue_or_else                       PROTO((tree, const char *));
282 extern void readonly_warning                    PROTO((tree, const char *));
283 extern int mark_addressable                     PROTO((tree));
284 extern tree build_conditional_expr              PROTO((tree, tree, tree));
285 extern tree build_compound_expr                 PROTO((tree));
286 extern tree build_c_cast                        PROTO((tree, tree));
287 extern tree build_modify_expr                   PROTO((tree, enum tree_code,
288                                                        tree));
289 extern void store_init_value                    PROTO((tree, tree));
290 extern void error_init                          PROTO((const char *));
291 extern void pedwarn_init                        PROTO((const char *));
292 extern void start_init                          PROTO((tree, tree, int));
293 extern void finish_init                         PROTO((void));
294 extern void really_start_incremental_init       PROTO((tree));
295 extern void push_init_level                     PROTO((int));
296 extern tree pop_init_level                      PROTO((int));
297 extern void set_init_index                      PROTO((tree, tree));
298 extern void set_init_label                      PROTO((tree));
299 extern void process_init_element                PROTO((tree));
300 extern void c_expand_asm_operands               PROTO((tree, tree, tree, tree,
301                                                        int, char *, int));
302 extern void c_expand_return                     PROTO((tree));
303 extern tree c_expand_start_case                 PROTO((tree));
304
305 /* in c-iterate.c */
306 extern void init_iterators                      PROTO((void));
307 extern void iterator_expand                     PROTO((tree));
308 extern void iterator_for_loop_start             PROTO((tree));
309 extern void iterator_for_loop_end               PROTO((tree));
310 extern void iterator_for_loop_record            PROTO((tree));
311 extern void push_iterator_stack                 PROTO((void));
312 extern void pop_iterator_stack                  PROTO((void));
313
314 /* Set to 0 at beginning of a function definition, set to 1 if
315    a return statement that specifies a return value is seen.  */
316
317 extern int current_function_returns_value;
318
319 /* Set to 0 at beginning of a function definition, set to 1 if
320    a return statement with no argument is seen.  */
321
322 extern int current_function_returns_null;
323
324 /* Nonzero means the expression being parsed will never be evaluated.
325    This is a count, since unevaluated expressions can nest.  */
326
327 extern int skip_evaluation;
328
329 /* Nonzero means `$' can be in an identifier.  */
330
331 extern int dollars_in_ident;
332
333 /* Nonzero means allow type mismatches in conditional expressions;
334    just make their values `void'.   */
335
336 extern int flag_cond_mismatch;
337
338 /* Nonzero means don't recognize the keyword `asm'.  */
339
340 extern int flag_no_asm;
341
342 /* Nonzero means environment is hosted (i.e., not freestanding) */
343
344 extern int flag_hosted;
345
346 /* Nonzero means warn about implicit declarations.  */
347
348 extern int warn_implicit;
349
350 /* Nonzero means give string constants the type `const char *'
351    to get extra warnings from them.  These warnings will be too numerous
352    to be useful, except in thoroughly ANSIfied programs.  */
353
354 extern int flag_const_strings;
355
356 /* Nonzero means warn about sizeof (function) or addition/subtraction
357    of function pointers.  */
358
359 extern int warn_pointer_arith;
360
361 /* Nonzero means warn for all old-style non-prototype function decls.  */
362
363 extern int warn_strict_prototypes;
364
365 /* Nonzero means warn about multiple (redundant) decls for the same single
366    variable or function.  */
367
368 extern int warn_redundant_decls;
369
370 /* Nonzero means warn about extern declarations of objects not at
371    file-scope level and about *all* declarations of functions (whether
372    extern or static) not at file-scope level.  Note that we exclude
373    implicit function declarations.  To get warnings about those, use
374    -Wimplicit.  */
375
376 extern int warn_nested_externs;
377
378 /* Nonzero means warn about pointer casts that can drop a type qualifier
379    from the pointer target type.  */
380
381 extern int warn_cast_qual;
382
383 /* Nonzero means warn when casting a function call to a type that does
384    not match the return type (e.g. (float)sqrt() or (anything*)malloc()
385    when there is no previous declaration of sqrt or malloc.  */
386
387 extern int warn_bad_function_cast;
388
389 /* Warn about functions which might be candidates for attribute noreturn. */
390
391 extern int warn_missing_noreturn;
392
393 /* Warn about traditional constructs whose meanings changed in ANSI C.  */
394
395 extern int warn_traditional;
396
397 /* Warn about *printf or *scanf format/argument anomalies. */
398
399 extern int warn_format;
400
401 /* Warn about a subscript that has type char.  */
402
403 extern int warn_char_subscripts;
404
405 /* Warn if a type conversion is done that might have confusing results.  */
406
407 extern int warn_conversion;
408
409 /* Warn if main is suspicious. */
410
411 extern int warn_main;
412
413 /* Nonzero means do some things the same way PCC does.  */
414
415 extern int flag_traditional;
416
417 /* Nonzero means use the ISO C9x dialect of C.  */
418
419 extern int flag_isoc9x;
420
421 /* Nonzero means to allow single precision math even if we're generally
422    being traditional. */
423 extern int flag_allow_single_precision;
424
425 /* Nonzero means warn about suggesting putting in ()'s.  */
426
427 extern int warn_parentheses;
428
429 /* Warn if initializer is not completely bracketed.  */
430
431 extern int warn_missing_braces;
432
433 /* Warn about comparison of signed and unsigned values.  */
434
435 extern int warn_sign_compare;
436
437 /* Warn about multicharacter constants.  */
438
439 extern int warn_multichar;
440
441 /* Warn about long long.  */
442
443 extern int warn_long_long;
444
445 /* Nonzero means we are reading code that came from a system header file.  */
446
447 extern int system_header_p;
448
449 /* Nonzero enables objc features.  */
450
451 extern int doing_objc_thang;
452
453 /* In c-decl.c */
454 extern void finish_incomplete_decl PROTO((tree));
455
456 #endif /* not _C_TREE_H */