|
|
1.1 root 1: /* Definitions for C parsing and type checking.
2: Copyright (C) 1987 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, 675 Mass Ave, Cambridge, MA 02139, USA. */
19:
20: /* Language-dependent contents of an identifier. */
21:
1.1.1.3 ! root 22: /* The limbo_value is used for block level extern declarations, which need
! 23: to be type checked against subsequent extern declarations. They can't
! 24: be referenced after they fall out of scope, so they can't be global. */
! 25:
1.1 root 26: struct lang_identifier
27: {
28: struct tree_identifier ignore;
29: tree global_value, local_value, label_value, implicit_decl;
1.1.1.3 ! root 30: tree error_locus, limbo_value;
1.1 root 31: };
32:
33: /* Macros for access to language-specific slots in an identifier. */
1.1.1.3 ! root 34: /* Each of these slots contains a DECL node or null. */
1.1 root 35:
1.1.1.3 ! root 36: /* This represents the value which the identifier has in the
! 37: file-scope namespace. */
1.1 root 38: #define IDENTIFIER_GLOBAL_VALUE(NODE) \
39: (((struct lang_identifier *)(NODE))->global_value)
1.1.1.3 ! root 40: /* This represents the value which the identifier has in the current
! 41: scope. */
1.1 root 42: #define IDENTIFIER_LOCAL_VALUE(NODE) \
43: (((struct lang_identifier *)(NODE))->local_value)
1.1.1.3 ! root 44: /* This represents the value which the identifier has as a label in
! 45: the current label scope. */
1.1 root 46: #define IDENTIFIER_LABEL_VALUE(NODE) \
47: (((struct lang_identifier *)(NODE))->label_value)
1.1.1.3 ! root 48: /* This records the extern decl of this identifier, if it has had one
! 49: at any point in this compilation. */
! 50: #define IDENTIFIER_LIMBO_VALUE(NODE) \
! 51: (((struct lang_identifier *)(NODE))->limbo_value)
! 52: /* This records the implicit function decl of this identifier, if it
! 53: has had one at any point in this compilation. */
1.1 root 54: #define IDENTIFIER_IMPLICIT_DECL(NODE) \
55: (((struct lang_identifier *)(NODE))->implicit_decl)
1.1.1.3 ! root 56: /* This is the last function in which we printed an "undefined variable"
! 57: message for this identifier. Value is a FUNCTION_DECL or null. */
1.1 root 58: #define IDENTIFIER_ERROR_LOCUS(NODE) \
59: (((struct lang_identifier *)(NODE))->error_locus)
60:
61: /* In identifiers, C uses the following fields in a special way:
62: TREE_PUBLIC to record that there was a previous local extern decl.
63: TREE_USED to record that such a decl was used.
64: TREE_ADDRESSABLE to record that the address of such a decl was used. */
65:
66: /* Nonzero means reject anything that ANSI standard C forbids. */
67: extern int pedantic;
68:
69: /* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only. */
70: #define C_TYPE_FIELDS_READONLY(type) TREE_LANG_FLAG_1 (type)
71:
72: /* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is volatile. */
73: #define C_TYPE_FIELDS_VOLATILE(type) TREE_LANG_FLAG_2 (type)
74:
75: /* In a RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE
76: nonzero if the definition of the type has already started. */
77: #define C_TYPE_BEING_DEFINED(type) TYPE_LANG_FLAG_0 (type)
78:
79: /* In a RECORD_TYPE, a sorted array of the fields of the type. */
80: struct lang_type
81: {
82: int len;
83: tree elts[1];
84: };
85:
86: /* Mark which labels are explicitly declared.
87: These may be shadowed, and may be referenced from nested functions. */
88: #define C_DECLARED_LABEL_FLAG(label) TREE_LANG_FLAG_1 (label)
89:
90: /* Record whether a type or decl was written with nonconstant size.
91: Note that TYPE_SIZE may have simplified to a constant. */
92: #define C_TYPE_VARIABLE_SIZE(type) TYPE_LANG_FLAG_1 (type)
93: #define C_DECL_VARIABLE_SIZE(type) DECL_LANG_FLAG_0 (type)
94:
95: /* Record in each node resulting from a binary operator
96: what operator was specified for it. */
97: #define C_EXP_ORIGINAL_CODE(exp) ((enum tree_code) TREE_COMPLEXITY (exp))
98:
99: #if 0 /* Not used. */
100: /* Record whether a decl for a function or function pointer has
101: already been mentioned (in a warning) because it was called
102: but didn't have a prototype. */
103: #define C_MISSING_PROTOTYPE_WARNED(decl) DECL_LANG_FLAG_2(decl)
104: #endif
105:
106: /* Store a value in that field. */
107: #define C_SET_EXP_ORIGINAL_CODE(exp, code) \
108: (TREE_COMPLEXITY (exp) = (int)(code))
109:
110: /* Record whether a typedef for type `int' was actually `signed int'. */
111: #define C_TYPEDEF_EXPLICITLY_SIGNED(exp) DECL_LANG_FLAG_1 ((exp))
112:
1.1.1.3 ! root 113: /* Nonzero for a declaration of a built in function if there has been no
! 114: occasion that would declare the function in ordinary C.
! 115: Using the function draws a pedantic warning in this case. */
! 116: #define C_DECL_ANTICIPATED(exp) DECL_LANG_FLAG_3 ((exp))
! 117:
1.1 root 118: /* For FUNCTION_TYPE, a hidden list of types of arguments. The same as
119: TYPE_ARG_TYPES for functions with prototypes, but created for functions
120: without prototypes. */
121: #define TYPE_ACTUAL_ARG_TYPES(NODE) TYPE_NONCOPIED_PARTS (NODE)
1.1.1.3 ! root 122:
! 123: /* Nonzero if the type T promotes to itself.
! 124: ANSI C states explicitly the list of types that promote;
! 125: in particular, short promotes to int even if they have the same width. */
! 126: #define C_PROMOTING_INTEGER_TYPE_P(t) \
! 127: (TREE_CODE ((t)) == INTEGER_TYPE \
! 128: && (TYPE_MAIN_VARIANT (t) == char_type_node \
! 129: || TYPE_MAIN_VARIANT (t) == signed_char_type_node \
! 130: || TYPE_MAIN_VARIANT (t) == unsigned_char_type_node \
! 131: || TYPE_MAIN_VARIANT (t) == short_integer_type_node \
! 132: || TYPE_MAIN_VARIANT (t) == short_unsigned_type_node))
1.1 root 133:
134: /* in c-typecheck.c */
135: extern tree build_component_ref (), build_conditional_expr (), build_compound_expr ();
136: extern tree build_unary_op (), build_binary_op (), build_function_call ();
137: extern tree parser_build_binary_op ();
138: extern tree build_indirect_ref (), build_array_ref (), build_c_cast ();
139: extern tree build_modify_expr ();
140: extern tree c_sizeof (), c_alignof (), c_alignof_expr ();
141: extern void store_init_value ();
142: extern tree digest_init ();
143: extern tree c_expand_start_case ();
144: extern tree default_conversion ();
145:
146: /* Given two integer or real types, return the type for their sum.
147: Given two compatible ANSI C types, returns the merged type. */
148:
149: extern tree common_type ();
150:
151: /* in c-decl.c */
152: extern tree build_label ();
153:
154: extern int start_function ();
155: extern void finish_function ();
156: extern void store_parm_decls ();
157: extern tree get_parm_info ();
158: extern tree combine_parm_decls ();
159:
160: extern void pushlevel ();
161: extern tree poplevel ();
162:
163: extern tree groktypename (), lookup_name ();
164:
165: extern tree lookup_label (), define_label (), shadow_label ();
166:
167: extern tree implicitly_declare (), getdecls (), gettags ();
168:
169: extern tree start_decl ();
170: extern void finish_decl ();
171:
172: extern tree start_struct (), finish_struct (), xref_tag ();
173: extern tree grokfield ();
174:
175: extern tree start_enum (), finish_enum ();
176: extern tree build_enumerator ();
177:
178: extern tree make_index_type ();
179:
180: /* Add qualifiers to a type, in the fashion for C. */
181: extern tree c_build_type_variant ();
182:
1.1.1.2 root 183: /* Declare a predefined function. Return the declaration. */
184: extern tree builtin_function ();
185:
1.1 root 186: /* Functions in c-common.c: */
187:
188: /* Concatenate a list of STRING_CST nodes into one STRING_CST. */
189: extern tree combine_strings ();
190:
191: /* Validate the expression after `case' and apply default promotions. */
192: extern tree check_case_value ();
193:
194: /* Print an error message for invalid operands to arith operation CODE.
195: NOP_EXPR is used as a special case (see truthvalue_conversion). */
196:
197: extern void binary_op_error ();
198:
199: /* Subroutine of build_binary_op, used for comparison operations.
200: See if the operands have both been converted from subword integer types
201: and, if so, perhaps change them both back to their original type. */
202:
203: extern tree shorten_compare ();
204:
205: /* Read the rest of the current #-directive line. */
206: extern char *get_directive_line ();
207:
1.1.1.3 ! root 208: /* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
! 209: or validate its data type for an `if' or `while' statement or ?..: exp. */
! 210: extern tree truthvalue_conversion ();
! 211:
1.1 root 212: extern int maybe_objc_comptypes ();
213: extern tree maybe_building_objc_message_expr ();
214:
215: /* Standard named or nameless data types of the C compiler. */
216:
217: extern tree short_integer_type_node, integer_type_node;
218: extern tree long_integer_type_node, long_long_integer_type_node;
219: extern tree short_unsigned_type_node, unsigned_type_node;
220: extern tree long_unsigned_type_node, long_long_unsigned_type_node;
221: extern tree ptrdiff_type_node;
222: extern tree unsigned_char_type_node, signed_char_type_node, char_type_node;
223: extern tree wchar_type_node, signed_wchar_type_node, unsigned_wchar_type_node;
224: extern tree float_type_node, double_type_node, long_double_type_node;
1.1.1.3 ! root 225: extern tree intQI_type_node, unsigned_intQI_type_node;
! 226: extern tree intHI_type_node, unsigned_intHI_type_node;
! 227: extern tree intSI_type_node, unsigned_intSI_type_node;
! 228: extern tree intDI_type_node, unsigned_intDI_type_node;
1.1 root 229: extern tree void_type_node, ptr_type_node, const_ptr_type_node;
230: extern tree string_type_node, const_string_type_node;
231: extern tree char_array_type_node, int_array_type_node, wchar_array_type_node;
232: extern tree default_function_type;
233: extern tree double_ftype_double, double_ftype_double_double;
234: extern tree int_ftype_int, long_ftype_long;
235: extern tree void_ftype_ptr_ptr_int, int_ftype_ptr_ptr_int;
236: extern tree void_ftype_ptr_int_int, string_ftype_ptr_ptr;
237: extern tree int_ftype_string_string, int_ftype_cptr_cptr_sizet;
238:
239: /* Set to 0 at beginning of a function definition, set to 1 if
240: a return statement that specifies a return value is seen. */
241:
242: extern int current_function_returns_value;
243:
244: /* Set to 0 at beginning of a function definition, set to 1 if
245: a return statement with no argument is seen. */
246:
247: extern int current_function_returns_null;
248:
249: /* Nonzero means `$' can be in an identifier. */
250:
251: extern int dollars_in_ident;
252:
253: /* Nonzero means allow type mismatches in conditional expressions;
254: just make their values `void'. */
255:
256: extern int flag_cond_mismatch;
257:
258: /* Nonzero means don't recognize the keyword `asm'. */
259:
260: extern int flag_no_asm;
261:
262: /* Nonzero means ignore `#ident' directives. */
263:
264: extern int flag_no_ident;
265:
266: /* Nonzero means warn about implicit declarations. */
267:
268: extern int warn_implicit;
269:
270: /* Nonzero means give string constants the type `const char *'
271: to get extra warnings from them. These warnings will be too numerous
272: to be useful, except in thoroughly ANSIfied programs. */
273:
274: extern int warn_write_strings;
275:
276: /* Nonzero means warn about sizeof (function) or addition/subtraction
277: of function pointers. */
278:
279: extern int warn_pointer_arith;
280:
281: /* Nonzero means warn for all old-style non-prototype function decls. */
282:
283: extern int warn_strict_prototypes;
284:
285: /* Nonzero means warn about multiple (redundant) decls for the same single
286: variable or function. */
287:
288: extern int warn_redundant_decls;
289:
290: /* Nonzero means warn about extern declarations of objects not at
291: file-scope level and about *all* declarations of functions (whether
292: extern or static) not at file-scope level. Note that we exclude
293: implicit function declarations. To get warnings about those, use
294: -Wimplicit. */
295:
296: extern int warn_nested_externs;
297:
298: /* Nonzero means warn about pointer casts that can drop a type qualifier
299: from the pointer target type. */
300:
301: extern int warn_cast_qual;
302:
303: /* Warn about traditional constructs whose meanings changed in ANSI C. */
304:
305: extern int warn_traditional;
306:
307: /* Warn about *printf or *scanf format/argument anomalies. */
308:
309: extern int warn_format;
310:
311: /* Warn about a subscript that has type char. */
312:
313: extern int warn_char_subscripts;
314:
315: /* Warn if a type conversion is done that might have confusing results. */
316:
317: extern int warn_conversion;
318:
319: /* Nonzero means do some things the same way PCC does. */
320:
321: extern int flag_traditional;
322:
323: /* Nonzero means warn about suggesting putting in ()'s. */
324:
325: extern int warn_parentheses;
326:
327: /* Nonzero means this is a function to call to perform comptypes
328: on two record types. */
329:
330: extern int (*comptypes_record_hook) ();
331:
332: /* Nonzero means we are reading code that came from a system header file. */
333:
334: extern int system_header_p;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.