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