1 /* Definitions for C parsing and type checking.
2 Copyright (C) 1987 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* Language-dependent contents of an identifier. */
22 struct lang_identifier
24 struct tree_identifier ignore;
25 tree global_value, local_value, label_value, implicit_decl;
29 /* Macros for access to language-specific slots in an identifier. */
31 #define IDENTIFIER_GLOBAL_VALUE(NODE) \
32 (((struct lang_identifier *)(NODE))->global_value)
33 #define IDENTIFIER_LOCAL_VALUE(NODE) \
34 (((struct lang_identifier *)(NODE))->local_value)
35 #define IDENTIFIER_LABEL_VALUE(NODE) \
36 (((struct lang_identifier *)(NODE))->label_value)
37 #define IDENTIFIER_IMPLICIT_DECL(NODE) \
38 (((struct lang_identifier *)(NODE))->implicit_decl)
39 #define IDENTIFIER_ERROR_LOCUS(NODE) \
40 (((struct lang_identifier *)(NODE))->error_locus)
42 /* In identifiers, C uses the following fields in a special way:
43 TREE_PUBLIC to record that there was a previous local extern decl.
44 TREE_USED to record that such a decl was used.
45 TREE_ADDRESSABLE to record that the address of such a decl was used. */
47 /* Nonzero means reject anything that ANSI standard C forbids. */
50 /* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only. */
51 #define C_TYPE_FIELDS_READONLY(type) TREE_LANG_FLAG_1 (type)
53 /* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is volatile. */
54 #define C_TYPE_FIELDS_VOLATILE(type) TREE_LANG_FLAG_2 (type)
56 /* In a RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE
57 nonzero if the definition of the type has already started. */
58 #define C_TYPE_BEING_DEFINED(type) TYPE_LANG_FLAG_0 (type)
60 /* In a RECORD_TYPE, a sorted array of the fields of the type. */
67 /* Mark which labels are explicitly declared.
68 These may be shadowed, and may be referenced from nested functions. */
69 #define C_DECLARED_LABEL_FLAG(label) TREE_LANG_FLAG_1 (label)
71 /* Record whether a type or decl was written with nonconstant size.
72 Note that TYPE_SIZE may have simplified to a constant. */
73 #define C_TYPE_VARIABLE_SIZE(type) TYPE_LANG_FLAG_1 (type)
74 #define C_DECL_VARIABLE_SIZE(type) DECL_LANG_FLAG_0 (type)
76 /* Record in each node resulting from a binary operator
77 what operator was specified for it. */
78 #define C_EXP_ORIGINAL_CODE(exp) ((enum tree_code) TREE_COMPLEXITY (exp))
81 /* Record whether a decl for a function or function pointer has
82 already been mentioned (in a warning) because it was called
83 but didn't have a prototype. */
84 #define C_MISSING_PROTOTYPE_WARNED(decl) DECL_LANG_FLAG_2(decl)
87 /* Store a value in that field. */
88 #define C_SET_EXP_ORIGINAL_CODE(exp, code) \
89 (TREE_COMPLEXITY (exp) = (int)(code))
91 /* Record whether a typedef for type `int' was actually `signed int'. */
92 #define C_TYPEDEF_EXPLICITLY_SIGNED(exp) DECL_LANG_FLAG_1 ((exp))
94 /* Nonzero for a declaration of a built in function if there has been no
95 occasion that would declare the function in ordinary C.
96 Using the function draws a pedantic warning in this case. */
97 #define C_DECL_ANTICIPATED(exp) DECL_LANG_FLAG_3 ((exp))
99 /* For FUNCTION_TYPE, a hidden list of types of arguments. The same as
100 TYPE_ARG_TYPES for functions with prototypes, but created for functions
101 without prototypes. */
102 #define TYPE_ACTUAL_ARG_TYPES(NODE) TYPE_NONCOPIED_PARTS (NODE)
104 /* in c-typecheck.c */
105 extern tree build_component_ref (), build_conditional_expr (), build_compound_expr ();
106 extern tree build_unary_op (), build_binary_op (), build_function_call ();
107 extern tree parser_build_binary_op ();
108 extern tree build_indirect_ref (), build_array_ref (), build_c_cast ();
109 extern tree build_modify_expr ();
110 extern tree c_sizeof (), c_alignof (), c_alignof_expr ();
111 extern void store_init_value ();
112 extern tree digest_init ();
113 extern tree c_expand_start_case ();
114 extern tree default_conversion ();
116 /* Given two integer or real types, return the type for their sum.
117 Given two compatible ANSI C types, returns the merged type. */
119 extern tree common_type ();
122 extern tree build_label ();
124 extern int start_function ();
125 extern void finish_function ();
126 extern void store_parm_decls ();
127 extern tree get_parm_info ();
128 extern tree combine_parm_decls ();
130 extern void pushlevel ();
131 extern tree poplevel ();
133 extern tree groktypename (), lookup_name ();
135 extern tree lookup_label (), define_label (), shadow_label ();
137 extern tree implicitly_declare (), getdecls (), gettags ();
139 extern tree start_decl ();
140 extern void finish_decl ();
142 extern tree start_struct (), finish_struct (), xref_tag ();
143 extern tree grokfield ();
145 extern tree start_enum (), finish_enum ();
146 extern tree build_enumerator ();
148 extern tree make_index_type ();
150 /* Add qualifiers to a type, in the fashion for C. */
151 extern tree c_build_type_variant ();
153 /* Declare a predefined function. Return the declaration. */
154 extern tree builtin_function ();
156 /* Functions in c-common.c: */
158 /* Concatenate a list of STRING_CST nodes into one STRING_CST. */
159 extern tree combine_strings ();
161 /* Validate the expression after `case' and apply default promotions. */
162 extern tree check_case_value ();
164 /* Print an error message for invalid operands to arith operation CODE.
165 NOP_EXPR is used as a special case (see truthvalue_conversion). */
167 extern void binary_op_error ();
169 /* Subroutine of build_binary_op, used for comparison operations.
170 See if the operands have both been converted from subword integer types
171 and, if so, perhaps change them both back to their original type. */
173 extern tree shorten_compare ();
175 /* Read the rest of the current #-directive line. */
176 extern char *get_directive_line ();
178 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
179 or validate its data type for an `if' or `while' statement or ?..: exp. */
180 extern tree truthvalue_conversion ();
182 extern int maybe_objc_comptypes ();
183 extern tree maybe_building_objc_message_expr ();
185 /* Standard named or nameless data types of the C compiler. */
187 extern tree short_integer_type_node, integer_type_node;
188 extern tree long_integer_type_node, long_long_integer_type_node;
189 extern tree short_unsigned_type_node, unsigned_type_node;
190 extern tree long_unsigned_type_node, long_long_unsigned_type_node;
191 extern tree ptrdiff_type_node;
192 extern tree unsigned_char_type_node, signed_char_type_node, char_type_node;
193 extern tree wchar_type_node, signed_wchar_type_node, unsigned_wchar_type_node;
194 extern tree float_type_node, double_type_node, long_double_type_node;
195 extern tree intQI_type_node, unsigned_intQI_type_node;
196 extern tree intHI_type_node, unsigned_intHI_type_node;
197 extern tree intSI_type_node, unsigned_intSI_type_node;
198 extern tree intDI_type_node, unsigned_intDI_type_node;
199 extern tree void_type_node, ptr_type_node, const_ptr_type_node;
200 extern tree string_type_node, const_string_type_node;
201 extern tree char_array_type_node, int_array_type_node, wchar_array_type_node;
202 extern tree default_function_type;
203 extern tree double_ftype_double, double_ftype_double_double;
204 extern tree int_ftype_int, long_ftype_long;
205 extern tree void_ftype_ptr_ptr_int, int_ftype_ptr_ptr_int;
206 extern tree void_ftype_ptr_int_int, string_ftype_ptr_ptr;
207 extern tree int_ftype_string_string, int_ftype_cptr_cptr_sizet;
209 /* Set to 0 at beginning of a function definition, set to 1 if
210 a return statement that specifies a return value is seen. */
212 extern int current_function_returns_value;
214 /* Set to 0 at beginning of a function definition, set to 1 if
215 a return statement with no argument is seen. */
217 extern int current_function_returns_null;
219 /* Nonzero means `$' can be in an identifier. */
221 extern int dollars_in_ident;
223 /* Nonzero means allow type mismatches in conditional expressions;
224 just make their values `void'. */
226 extern int flag_cond_mismatch;
228 /* Nonzero means don't recognize the keyword `asm'. */
230 extern int flag_no_asm;
232 /* Nonzero means ignore `#ident' directives. */
234 extern int flag_no_ident;
236 /* Nonzero means warn about implicit declarations. */
238 extern int warn_implicit;
240 /* Nonzero means give string constants the type `const char *'
241 to get extra warnings from them. These warnings will be too numerous
242 to be useful, except in thoroughly ANSIfied programs. */
244 extern int warn_write_strings;
246 /* Nonzero means warn about sizeof (function) or addition/subtraction
247 of function pointers. */
249 extern int warn_pointer_arith;
251 /* Nonzero means warn for all old-style non-prototype function decls. */
253 extern int warn_strict_prototypes;
255 /* Nonzero means warn about multiple (redundant) decls for the same single
256 variable or function. */
258 extern int warn_redundant_decls;
260 /* Nonzero means warn about extern declarations of objects not at
261 file-scope level and about *all* declarations of functions (whether
262 extern or static) not at file-scope level. Note that we exclude
263 implicit function declarations. To get warnings about those, use
266 extern int warn_nested_externs;
268 /* Nonzero means warn about pointer casts that can drop a type qualifier
269 from the pointer target type. */
271 extern int warn_cast_qual;
273 /* Warn about traditional constructs whose meanings changed in ANSI C. */
275 extern int warn_traditional;
277 /* Warn about *printf or *scanf format/argument anomalies. */
279 extern int warn_format;
281 /* Warn about a subscript that has type char. */
283 extern int warn_char_subscripts;
285 /* Warn if a type conversion is done that might have confusing results. */
287 extern int warn_conversion;
289 /* Nonzero means do some things the same way PCC does. */
291 extern int flag_traditional;
293 /* Nonzero means warn about suggesting putting in ()'s. */
295 extern int warn_parentheses;
297 /* Nonzero means this is a function to call to perform comptypes
298 on two record types. */
300 extern int (*comptypes_record_hook) ();
302 /* Nonzero means we are reading code that came from a system header file. */
304 extern int system_header_p;