c-tree.h revision 90083
1/* Definitions for C parsing and type checking.
2   Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998,
3   1999, 2000, 2001, 2002 Free Software Foundation, Inc.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 2, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING.  If not, write to the Free
19Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2002111-1307, USA.  */
21
22/* $FreeBSD: head/contrib/gcc/c-tree.h 90083 2002-02-01 18:54:38Z obrien $ */
23
24#ifndef GCC_C_TREE_H
25#define GCC_C_TREE_H
26
27#include "c-common.h"
28
29/* Language-dependent contents of an identifier.  */
30
31/* The limbo_value is used for block level extern declarations, which need
32   to be type checked against subsequent extern declarations.  They can't
33   be referenced after they fall out of scope, so they can't be global.
34
35   The rid_code field is used for keywords.  It is in all
36   lang_identifier nodes, because some keywords are only special in a
37   particular context.  */
38
39struct lang_identifier
40{
41  struct c_common_identifier ignore;
42  tree global_value, local_value, label_value, implicit_decl;
43  tree error_locus, limbo_value;
44};
45
46/* Language-specific declaration information.  */
47
48struct lang_decl
49{
50  struct c_lang_decl base;
51  /* The return types and parameter types may have variable size.
52     This is a list of any SAVE_EXPRs that need to be evaluated to
53     compute those sizes.  */
54  tree pending_sizes;
55};
56
57/* Macros for access to language-specific slots in an identifier.  */
58/* Each of these slots contains a DECL node or null.  */
59
60/* This represents the value which the identifier has in the
61   file-scope namespace.  */
62#define IDENTIFIER_GLOBAL_VALUE(NODE)	\
63  (((struct lang_identifier *) (NODE))->global_value)
64/* This represents the value which the identifier has in the current
65   scope.  */
66#define IDENTIFIER_LOCAL_VALUE(NODE)	\
67  (((struct lang_identifier *) (NODE))->local_value)
68/* This represents the value which the identifier has as a label in
69   the current label scope.  */
70#define IDENTIFIER_LABEL_VALUE(NODE)	\
71  (((struct lang_identifier *) (NODE))->label_value)
72/* This records the extern decl of this identifier, if it has had one
73   at any point in this compilation.  */
74#define IDENTIFIER_LIMBO_VALUE(NODE)	\
75  (((struct lang_identifier *) (NODE))->limbo_value)
76/* This records the implicit function decl of this identifier, if it
77   has had one at any point in this compilation.  */
78#define IDENTIFIER_IMPLICIT_DECL(NODE)	\
79  (((struct lang_identifier *) (NODE))->implicit_decl)
80/* This is the last function in which we printed an "undefined variable"
81   message for this identifier.  Value is a FUNCTION_DECL or null.  */
82#define IDENTIFIER_ERROR_LOCUS(NODE)	\
83  (((struct lang_identifier *) (NODE))->error_locus)
84
85/* In identifiers, C uses the following fields in a special way:
86   TREE_PUBLIC        to record that there was a previous local extern decl.
87   TREE_USED          to record that such a decl was used.
88   TREE_ADDRESSABLE   to record that the address of such a decl was used.  */
89
90/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only.  */
91#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1 (TYPE)
92
93/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is volatile.  */
94#define C_TYPE_FIELDS_VOLATILE(TYPE) TREE_LANG_FLAG_2 (TYPE)
95
96/* In a RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE
97   nonzero if the definition of the type has already started.  */
98#define C_TYPE_BEING_DEFINED(TYPE) TYPE_LANG_FLAG_0 (TYPE)
99
100/* In an IDENTIFIER_NODE, nonzero if this identifier is actually a
101   keyword.  C_RID_CODE (node) is then the RID_* value of the keyword,
102   and C_RID_YYCODE is the token number wanted by Yacc.  */
103#define C_IS_RESERVED_WORD(ID) TREE_LANG_FLAG_0 (ID)
104
105/* This function was declared inline.  This flag controls the linkage
106   semantics of 'inline'; whether or not the function is inlined is
107   controlled by DECL_INLINE.  */
108#define DECL_DECLARED_INLINE_P(NODE) \
109  (DECL_LANG_SPECIFIC (NODE)->base.declared_inline)
110
111/* In a RECORD_TYPE, a sorted array of the fields of the type.  */
112struct lang_type
113{
114  int len;
115  tree elts[1];
116};
117
118/* Record whether a type or decl was written with nonconstant size.
119   Note that TYPE_SIZE may have simplified to a constant.  */
120#define C_TYPE_VARIABLE_SIZE(TYPE) TYPE_LANG_FLAG_1 (TYPE)
121#define C_DECL_VARIABLE_SIZE(TYPE) DECL_LANG_FLAG_0 (TYPE)
122
123#if 0 /* Not used.  */
124/* Record whether a decl for a function or function pointer has
125   already been mentioned (in a warning) because it was called
126   but didn't have a prototype.  */
127#define C_MISSING_PROTOTYPE_WARNED(DECL) DECL_LANG_FLAG_2 (DECL)
128#endif
129
130/* Store a value in that field.  */
131#define C_SET_EXP_ORIGINAL_CODE(EXP, CODE) \
132  (TREE_COMPLEXITY (EXP) = (int) (CODE))
133
134/* Record whether a typedef for type `int' was actually `signed int'.  */
135#define C_TYPEDEF_EXPLICITLY_SIGNED(EXP) DECL_LANG_FLAG_1 (EXP)
136
137/* Nonzero for a declaration of a built in function if there has been no
138   occasion that would declare the function in ordinary C.
139   Using the function draws a pedantic warning in this case.  */
140#define C_DECL_ANTICIPATED(EXP) DECL_LANG_FLAG_3 (EXP)
141
142/* For FUNCTION_TYPE, a hidden list of types of arguments.  The same as
143   TYPE_ARG_TYPES for functions with prototypes, but created for functions
144   without prototypes.  */
145#define TYPE_ACTUAL_ARG_TYPES(NODE) TYPE_BINFO (NODE)
146
147
148/* in c-lang.c and objc-act.c */
149extern tree lookup_interface			PARAMS ((tree));
150extern tree is_class_name			PARAMS ((tree));
151extern void maybe_objc_check_decl		PARAMS ((tree));
152extern void finish_file				PARAMS ((void));
153extern int maybe_objc_comptypes                 PARAMS ((tree, tree, int));
154extern tree maybe_building_objc_message_expr    PARAMS ((void));
155extern int recognize_objc_keyword		PARAMS ((void));
156extern tree lookup_objc_ivar			PARAMS ((tree));
157
158
159/* in c-parse.in */
160extern void c_parse_init			PARAMS ((void));
161extern void c_set_yydebug			PARAMS ((int));
162extern int yyparse_1				PARAMS ((void));
163
164/* in c-aux-info.c */
165extern void gen_aux_info_record                 PARAMS ((tree, int, int, int));
166
167/* in c-decl.c */
168extern void c_init_decl_processing		PARAMS ((void));
169extern void c_print_identifier			PARAMS ((FILE *, tree, int));
170extern tree build_array_declarator              PARAMS ((tree, tree, int, int));
171extern tree build_enumerator                    PARAMS ((tree, tree));
172extern int  c_decode_option                     PARAMS ((int, char **));
173extern void c_mark_varargs                      PARAMS ((void));
174extern void check_for_loop_decls                PARAMS ((void));
175extern void clear_parm_order                    PARAMS ((void));
176extern int  complete_array_type                 PARAMS ((tree, tree, int));
177extern void declare_parm_level                  PARAMS ((int));
178extern tree define_label                        PARAMS ((const char *, int,
179							 tree));
180extern void finish_decl                         PARAMS ((tree, tree, tree));
181extern tree finish_enum                         PARAMS ((tree, tree, tree));
182extern void finish_function                     PARAMS ((int));
183extern tree finish_struct                       PARAMS ((tree, tree, tree));
184extern tree get_parm_info                       PARAMS ((int));
185extern tree grokfield                           PARAMS ((const char *, int, tree, tree, tree));
186extern tree groktypename                        PARAMS ((tree));
187extern tree groktypename_in_parm_context        PARAMS ((tree));
188extern tree implicitly_declare                  PARAMS ((tree));
189extern void implicit_decl_warning               PARAMS ((tree));
190extern int  in_parm_level_p                     PARAMS ((void));
191extern void keep_next_level                     PARAMS ((void));
192extern int  kept_level_p                        PARAMS ((void));
193extern tree lookup_name                         PARAMS ((tree));
194extern tree lookup_name_current_level		PARAMS ((tree));
195extern void parmlist_tags_warning               PARAMS ((void));
196extern void pending_xref_error                  PARAMS ((void));
197extern void mark_c_function_context             PARAMS ((struct function *));
198extern void push_c_function_context             PARAMS ((struct function *));
199extern void pop_c_function_context              PARAMS ((struct function *));
200extern void pop_label_level                     PARAMS ((void));
201extern void push_label_level                    PARAMS ((void));
202extern void push_parm_decl                      PARAMS ((tree));
203extern tree pushdecl_top_level                  PARAMS ((tree));
204extern void pushtag                             PARAMS ((tree, tree));
205extern tree set_array_declarator_type           PARAMS ((tree, tree, int));
206extern tree shadow_label                        PARAMS ((tree));
207extern void shadow_tag                          PARAMS ((tree));
208extern void shadow_tag_warned                   PARAMS ((tree, int));
209extern tree start_enum                          PARAMS ((tree));
210extern int  start_function                      PARAMS ((tree, tree, tree));
211extern tree start_decl                          PARAMS ((tree, tree, int,
212							 tree));
213extern tree start_struct                        PARAMS ((enum tree_code, tree));
214extern void store_parm_decls                    PARAMS ((void));
215extern tree xref_tag                            PARAMS ((enum tree_code, tree));
216extern tree c_begin_compound_stmt               PARAMS ((void));
217extern void c_expand_deferred_function          PARAMS ((tree));
218extern void c_expand_decl_stmt                  PARAMS ((tree));
219
220
221/* in c-objc-common.c */
222extern int c_disregard_inline_limits		PARAMS ((tree));
223extern int c_cannot_inline_tree_fn		PARAMS ((tree *));
224extern const char *c_objc_common_init		PARAMS ((const char *));
225extern int c_missing_noreturn_ok_p		PARAMS ((tree));
226extern void c_objc_common_finish_file		PARAMS ((void));
227extern int defer_fn				PARAMS ((tree));
228
229#define c_build_type_variant(TYPE, CONST_P, VOLATILE_P)		  \
230  c_build_qualified_type ((TYPE),				  \
231			  ((CONST_P) ? TYPE_QUAL_CONST : 0) |	  \
232			  ((VOLATILE_P) ? TYPE_QUAL_VOLATILE : 0))
233
234/* in c-typeck.c */
235extern tree require_complete_type		PARAMS ((tree));
236extern int comptypes				PARAMS ((tree, tree));
237extern tree c_sizeof_nowarn			PARAMS ((tree));
238extern tree c_size_in_bytes                     PARAMS ((tree));
239extern tree build_component_ref                 PARAMS ((tree, tree));
240extern tree build_indirect_ref                  PARAMS ((tree, const char *));
241extern tree build_array_ref                     PARAMS ((tree, tree));
242extern tree build_external_ref			PARAMS ((tree, int));
243extern tree parser_build_binary_op              PARAMS ((enum tree_code,
244							 tree, tree));
245extern void readonly_warning			PARAMS ((tree, const char *));
246extern tree build_conditional_expr              PARAMS ((tree, tree, tree));
247extern tree build_compound_expr                 PARAMS ((tree));
248extern tree c_cast_expr				PARAMS ((tree, tree));
249extern tree build_c_cast	                PARAMS ((tree, tree));
250extern tree build_modify_expr                   PARAMS ((tree, enum tree_code,
251							 tree));
252extern void store_init_value                    PARAMS ((tree, tree));
253extern void error_init				PARAMS ((const char *));
254extern void pedwarn_init			PARAMS ((const char *));
255extern void start_init				PARAMS ((tree, tree, int));
256extern void finish_init				PARAMS ((void));
257extern void really_start_incremental_init	PARAMS ((tree));
258extern void push_init_level			PARAMS ((int));
259extern tree pop_init_level			PARAMS ((int));
260extern void set_init_index			PARAMS ((tree, tree));
261extern void set_init_label			PARAMS ((tree));
262extern void process_init_element		PARAMS ((tree));
263extern tree build_compound_literal		PARAMS ((tree, tree));
264extern void pedwarn_c99				PARAMS ((const char *, ...))
265							ATTRIBUTE_PRINTF_1;
266extern tree c_start_case                        PARAMS ((tree));
267extern void c_finish_case                       PARAMS ((void));
268extern tree simple_asm_stmt			PARAMS ((tree));
269extern tree build_asm_stmt			PARAMS ((tree, tree, tree,
270							 tree, tree));
271
272/* Set to 0 at beginning of a function definition, set to 1 if
273   a return statement that specifies a return value is seen.  */
274
275extern int current_function_returns_value;
276
277/* Set to 0 at beginning of a function definition, set to 1 if
278   a return statement with no argument is seen.  */
279
280extern int current_function_returns_null;
281
282/* Nonzero means the expression being parsed will never be evaluated.
283   This is a count, since unevaluated expressions can nest.  */
284
285extern int skip_evaluation;
286
287/* Nonzero means `$' can be in an identifier.  */
288
289extern int dollars_in_ident;
290
291/* Nonzero means allow type mismatches in conditional expressions;
292   just make their values `void'.  */
293
294extern int flag_cond_mismatch;
295
296/* Nonzero means don't recognize the keyword `asm'.  */
297
298extern int flag_no_asm;
299
300/* Nonzero means warn about implicit declarations.  */
301
302extern int warn_implicit;
303
304/* Nonzero means warn for all old-style non-prototype function decls.  */
305
306extern int warn_strict_prototypes;
307
308/* Nonzero means warn about multiple (redundant) decls for the same single
309   variable or function.  */
310
311extern int warn_redundant_decls;
312
313/* Nonzero means warn about extern declarations of objects not at
314   file-scope level and about *all* declarations of functions (whether
315   extern or static) not at file-scope level.  Note that we exclude
316   implicit function declarations.  To get warnings about those, use
317   -Wimplicit.  */
318
319extern int warn_nested_externs;
320
321/* Nonzero means warn about pointer casts that can drop a type qualifier
322   from the pointer target type.  */
323
324extern int warn_cast_qual;
325
326/* Nonzero means warn when casting a function call to a type that does
327   not match the return type (e.g. (float)sqrt() or (anything*)malloc()
328   when there is no previous declaration of sqrt or malloc.  */
329
330extern int warn_bad_function_cast;
331
332/* Warn about traditional constructs whose meanings changed in ANSI C.  */
333
334extern int warn_traditional;
335
336/* Warn about a subscript that has type char.  */
337
338extern int warn_char_subscripts;
339
340/* Warn if main is suspicious.  */
341
342extern int warn_main;
343
344/* Nonzero means to allow single precision math even if we're generally
345   being traditional.  */
346extern int flag_allow_single_precision;
347
348/* Warn if initializer is not completely bracketed.  */
349
350extern int warn_missing_braces;
351
352/* Warn about comparison of signed and unsigned values.  */
353
354extern int warn_sign_compare;
355
356/* Warn about testing equality of floating point numbers.  */
357
358extern int warn_float_equal;
359
360/* Warn about multicharacter constants.  */
361
362extern int warn_multichar;
363
364/* Nonzero means we are reading code that came from a system header file.  */
365
366extern int system_header_p;
367
368/* Warn about implicit declarations.  1 = warning, 2 = error.  */
369extern int mesg_implicit_function_declaration;
370
371/* In c-decl.c */
372extern void finish_incomplete_decl PARAMS ((tree));
373
374extern tree static_ctors;
375extern tree static_dtors;
376
377#endif /* ! GCC_C_TREE_H */
378