111
|
1 /* Definitions for C parsing and type checking.
|
|
2 Copyright (C) 1987-2017 Free Software Foundation, Inc.
|
|
3
|
|
4 This file is part of GCC.
|
|
5
|
|
6 GCC is free software; you can redistribute it and/or modify it under
|
|
7 the terms of the GNU General Public License as published by the Free
|
|
8 Software Foundation; either version 3, or (at your option) any later
|
|
9 version.
|
|
10
|
|
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with GCC; see the file COPYING3. If not see
|
|
18 <http://www.gnu.org/licenses/>. */
|
|
19
|
|
20 #ifndef GCC_C_TREE_H
|
|
21 #define GCC_C_TREE_H
|
|
22
|
|
23 #include "c-family/c-common.h"
|
|
24 #include "diagnostic.h"
|
|
25
|
|
26 /* struct lang_identifier is private to c-decl.c, but langhooks.c needs to
|
|
27 know how big it is. This is sanity-checked in c-decl.c. */
|
|
28 #define C_SIZEOF_STRUCT_LANG_IDENTIFIER \
|
|
29 (sizeof (struct c_common_identifier) + 3 * sizeof (void *))
|
|
30
|
|
31 /* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only. */
|
|
32 #define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1 (TYPE)
|
|
33
|
|
34 /* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is volatile. */
|
|
35 #define C_TYPE_FIELDS_VOLATILE(TYPE) TREE_LANG_FLAG_2 (TYPE)
|
|
36
|
|
37 /* In a RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE
|
|
38 nonzero if the definition of the type has already started. */
|
|
39 #define C_TYPE_BEING_DEFINED(TYPE) TYPE_LANG_FLAG_0 (TYPE)
|
|
40
|
|
41 /* In an incomplete RECORD_TYPE or UNION_TYPE, a list of variable
|
|
42 declarations whose type would be completed by completing that type. */
|
|
43 #define C_TYPE_INCOMPLETE_VARS(TYPE) TYPE_VFIELD (TYPE)
|
|
44
|
|
45 /* In an IDENTIFIER_NODE, nonzero if this identifier is actually a
|
|
46 keyword. C_RID_CODE (node) is then the RID_* value of the keyword. */
|
|
47 #define C_IS_RESERVED_WORD(ID) TREE_LANG_FLAG_0 (ID)
|
|
48
|
|
49 /* Record whether a type or decl was written with nonconstant size.
|
|
50 Note that TYPE_SIZE may have simplified to a constant. */
|
|
51 #define C_TYPE_VARIABLE_SIZE(TYPE) TYPE_LANG_FLAG_1 (TYPE)
|
|
52 #define C_DECL_VARIABLE_SIZE(TYPE) DECL_LANG_FLAG_0 (TYPE)
|
|
53
|
|
54 /* Record whether a type is defined inside a struct or union type.
|
|
55 This is used for -Wc++-compat. */
|
|
56 #define C_TYPE_DEFINED_IN_STRUCT(TYPE) TYPE_LANG_FLAG_2 (TYPE)
|
|
57
|
|
58 /* Record whether an "incomplete type" error was given for the type. */
|
|
59 #define C_TYPE_ERROR_REPORTED(TYPE) TYPE_LANG_FLAG_3 (TYPE)
|
|
60
|
|
61 /* Record whether a typedef for type `int' was actually `signed int'. */
|
|
62 #define C_TYPEDEF_EXPLICITLY_SIGNED(EXP) DECL_LANG_FLAG_1 (EXP)
|
|
63
|
|
64 /* For a FUNCTION_DECL, nonzero if it was defined without an explicit
|
|
65 return type. */
|
|
66 #define C_FUNCTION_IMPLICIT_INT(EXP) DECL_LANG_FLAG_1 (EXP)
|
|
67
|
|
68 /* For a FUNCTION_DECL, nonzero if it was an implicit declaration. */
|
|
69 #define C_DECL_IMPLICIT(EXP) DECL_LANG_FLAG_2 (EXP)
|
|
70
|
|
71 /* For a PARM_DECL, nonzero if it was declared as an array. */
|
|
72 #define C_ARRAY_PARAMETER(NODE) DECL_LANG_FLAG_0 (NODE)
|
|
73
|
|
74 /* For FUNCTION_DECLs, evaluates true if the decl is built-in but has
|
|
75 been declared. */
|
|
76 #define C_DECL_DECLARED_BUILTIN(EXP) \
|
|
77 DECL_LANG_FLAG_3 (FUNCTION_DECL_CHECK (EXP))
|
|
78
|
|
79 /* For FUNCTION_DECLs, evaluates true if the decl is built-in, has a
|
|
80 built-in prototype and does not have a non-built-in prototype. */
|
|
81 #define C_DECL_BUILTIN_PROTOTYPE(EXP) \
|
|
82 DECL_LANG_FLAG_6 (FUNCTION_DECL_CHECK (EXP))
|
|
83
|
|
84 /* Record whether a decl was declared register. This is strictly a
|
|
85 front-end flag, whereas DECL_REGISTER is used for code generation;
|
|
86 they may differ for structures with volatile fields. */
|
|
87 #define C_DECL_REGISTER(EXP) DECL_LANG_FLAG_4 (EXP)
|
|
88
|
|
89 /* Record whether a decl was used in an expression anywhere except an
|
|
90 unevaluated operand of sizeof / typeof / alignof. This is only
|
|
91 used for functions declared static but not defined, though outside
|
|
92 sizeof and typeof it is set for other function decls as well. */
|
|
93 #define C_DECL_USED(EXP) DECL_LANG_FLAG_5 (FUNCTION_DECL_CHECK (EXP))
|
|
94
|
|
95 /* Record whether a variable has been declared threadprivate by
|
|
96 #pragma omp threadprivate. */
|
|
97 #define C_DECL_THREADPRIVATE_P(DECL) DECL_LANG_FLAG_3 (VAR_DECL_CHECK (DECL))
|
|
98
|
|
99 /* Nonzero for a decl which either doesn't exist or isn't a prototype.
|
|
100 N.B. Could be simplified if all built-in decls had complete prototypes
|
|
101 (but this is presently difficult because some of them need FILE*). */
|
|
102 #define C_DECL_ISNT_PROTOTYPE(EXP) \
|
|
103 (EXP == 0 \
|
|
104 || (!prototype_p (TREE_TYPE (EXP)) \
|
|
105 && !DECL_BUILT_IN (EXP)))
|
|
106
|
|
107 /* For FUNCTION_TYPE, a hidden list of types of arguments. The same as
|
|
108 TYPE_ARG_TYPES for functions with prototypes, but created for functions
|
|
109 without prototypes. */
|
|
110 #define TYPE_ACTUAL_ARG_TYPES(NODE) TYPE_LANG_SLOT_1 (NODE)
|
|
111
|
|
112 /* For a CONSTRUCTOR, whether some initializer contains a
|
|
113 subexpression meaning it is not a constant expression. */
|
|
114 #define CONSTRUCTOR_NON_CONST(EXPR) TREE_LANG_FLAG_1 (CONSTRUCTOR_CHECK (EXPR))
|
|
115
|
|
116 /* For a SAVE_EXPR, nonzero if the operand of the SAVE_EXPR has already
|
|
117 been folded. */
|
|
118 #define SAVE_EXPR_FOLDED_P(EXP) TREE_LANG_FLAG_1 (SAVE_EXPR_CHECK (EXP))
|
|
119
|
|
120 /* Record parser information about an expression that is irrelevant
|
|
121 for code generation alongside a tree representing its value. */
|
|
122 struct c_expr
|
|
123 {
|
|
124 /* The value of the expression. */
|
|
125 tree value;
|
|
126 /* Record the original unary/binary operator of an expression, which may
|
|
127 have been changed by fold, STRING_CST for unparenthesized string
|
|
128 constants, C_MAYBE_CONST_EXPR for __builtin_constant_p calls
|
|
129 (even if parenthesized), for subexpressions, and for non-constant
|
|
130 initializers, or ERROR_MARK for other expressions (including
|
|
131 parenthesized expressions). */
|
|
132 enum tree_code original_code;
|
|
133 /* If not NULL, the original type of an expression. This will
|
|
134 differ from the type of the value field for an enum constant.
|
|
135 The type of an enum constant is a plain integer type, but this
|
|
136 field will be the enum type. */
|
|
137 tree original_type;
|
|
138
|
|
139 /* The source range of this expression. This is redundant
|
|
140 for node values that have locations, but not all node kinds
|
|
141 have locations (e.g. constants, and references to params, locals,
|
|
142 etc), so we stash a copy here. */
|
|
143 source_range src_range;
|
|
144
|
|
145 /* Access to the first and last locations within the source spelling
|
|
146 of this expression. */
|
|
147 location_t get_start () const { return src_range.m_start; }
|
|
148 location_t get_finish () const { return src_range.m_finish; }
|
|
149
|
|
150 location_t get_location () const
|
|
151 {
|
|
152 if (EXPR_HAS_LOCATION (value))
|
|
153 return EXPR_LOCATION (value);
|
|
154 else
|
|
155 return make_location (get_start (), get_start (), get_finish ());
|
|
156 }
|
|
157
|
|
158 /* Set the value to error_mark_node whilst ensuring that src_range
|
|
159 is initialized. */
|
|
160 void set_error ()
|
|
161 {
|
|
162 value = error_mark_node;
|
|
163 src_range.m_start = UNKNOWN_LOCATION;
|
|
164 src_range.m_finish = UNKNOWN_LOCATION;
|
|
165 }
|
|
166 };
|
|
167
|
|
168 /* Type alias for struct c_expr. This allows to use the structure
|
|
169 inside the VEC types. */
|
|
170 typedef struct c_expr c_expr_t;
|
|
171
|
|
172 /* A kind of type specifier. Note that this information is currently
|
|
173 only used to distinguish tag definitions, tag references and typeof
|
|
174 uses. */
|
|
175 enum c_typespec_kind {
|
|
176 /* No typespec. This appears only in struct c_declspec. */
|
|
177 ctsk_none,
|
|
178 /* A reserved keyword type specifier. */
|
|
179 ctsk_resword,
|
|
180 /* A reference to a tag, previously declared, such as "struct foo".
|
|
181 This includes where the previous declaration was as a different
|
|
182 kind of tag, in which case this is only valid if shadowing that
|
|
183 tag in an inner scope. */
|
|
184 ctsk_tagref,
|
|
185 /* A reference to a tag, not previously declared in a visible
|
|
186 scope. */
|
|
187 ctsk_tagfirstref,
|
|
188 /* A definition of a tag such as "struct foo { int a; }". */
|
|
189 ctsk_tagdef,
|
|
190 /* A typedef name. */
|
|
191 ctsk_typedef,
|
|
192 /* An ObjC-specific kind of type specifier. */
|
|
193 ctsk_objc,
|
|
194 /* A typeof specifier, or _Atomic ( type-name ). */
|
|
195 ctsk_typeof
|
|
196 };
|
|
197
|
|
198 /* A type specifier: this structure is created in the parser and
|
|
199 passed to declspecs_add_type only. */
|
|
200 struct c_typespec {
|
|
201 /* What kind of type specifier this is. */
|
|
202 enum c_typespec_kind kind;
|
|
203 /* Whether the expression has operands suitable for use in constant
|
|
204 expressions. */
|
|
205 bool expr_const_operands;
|
|
206 /* The specifier itself. */
|
|
207 tree spec;
|
|
208 /* An expression to be evaluated before the type specifier, in the
|
|
209 case of typeof specifiers, or NULL otherwise or if no such
|
|
210 expression is required for a particular typeof specifier. In
|
|
211 particular, when typeof is applied to an expression of variably
|
|
212 modified type, that expression must be evaluated in order to
|
|
213 determine array sizes that form part of the type, but the
|
|
214 expression itself (as opposed to the array sizes) forms no part
|
|
215 of the type and so needs to be recorded separately. */
|
|
216 tree expr;
|
|
217 };
|
|
218
|
|
219 /* A storage class specifier. */
|
|
220 enum c_storage_class {
|
|
221 csc_none,
|
|
222 csc_auto,
|
|
223 csc_extern,
|
|
224 csc_register,
|
|
225 csc_static,
|
|
226 csc_typedef
|
|
227 };
|
|
228
|
|
229 /* A type specifier keyword "void", "_Bool", "char", "int", "float",
|
|
230 "double", "_Decimal32", "_Decimal64", "_Decimal128", "_Fract", "_Accum",
|
|
231 or none of these. */
|
|
232 enum c_typespec_keyword {
|
|
233 cts_none,
|
|
234 cts_void,
|
|
235 cts_bool,
|
|
236 cts_char,
|
|
237 cts_int,
|
|
238 cts_float,
|
|
239 cts_int_n,
|
|
240 cts_double,
|
112
|
241 #ifndef noCbC
|
|
242 cts_CbC_code,
|
|
243 #endif
|
111
|
244 cts_dfloat32,
|
|
245 cts_dfloat64,
|
|
246 cts_dfloat128,
|
|
247 cts_floatn_nx,
|
|
248 cts_fract,
|
|
249 cts_accum,
|
|
250 cts_auto_type
|
|
251 };
|
|
252
|
|
253 /* This enum lists all the possible declarator specifiers, storage
|
|
254 class or attribute that a user can write. There is at least one
|
|
255 enumerator per possible declarator specifier in the struct
|
|
256 c_declspecs below.
|
|
257
|
|
258 It is used to index the array of declspec locations in struct
|
|
259 c_declspecs. */
|
|
260 enum c_declspec_word {
|
|
261 cdw_typespec /* A catch-all for a typespec. */,
|
|
262 cdw_storage_class /* A catch-all for a storage class */,
|
|
263 cdw_attributes,
|
|
264 cdw_typedef,
|
|
265 cdw_explicit_signed,
|
|
266 cdw_deprecated,
|
|
267 cdw_default_int,
|
|
268 cdw_long,
|
|
269 cdw_long_long,
|
|
270 cdw_short,
|
|
271 cdw_signed,
|
|
272 cdw_unsigned,
|
|
273 cdw_complex,
|
|
274 cdw_inline,
|
|
275 cdw_noreturn,
|
|
276 cdw_thread,
|
|
277 cdw_const,
|
|
278 cdw_volatile,
|
|
279 cdw_restrict,
|
|
280 cdw_atomic,
|
|
281 cdw_saturating,
|
|
282 cdw_alignas,
|
|
283 cdw_address_space,
|
|
284 cdw_gimple,
|
|
285 cdw_rtl,
|
|
286 cdw_number_of_elements /* This one must always be the last
|
|
287 enumerator. */
|
|
288 };
|
|
289
|
|
290 /* A sequence of declaration specifiers in C. When a new declaration
|
|
291 specifier is added, please update the enum c_declspec_word above
|
|
292 accordingly. */
|
|
293 struct c_declspecs {
|
|
294 source_location locations[cdw_number_of_elements];
|
|
295 /* The type specified, if a single type specifier such as a struct,
|
|
296 union or enum specifier, typedef name or typeof specifies the
|
|
297 whole type, or NULL_TREE if none or a keyword such as "void" or
|
|
298 "char" is used. Does not include qualifiers. */
|
|
299 tree type;
|
|
300 /* Any expression to be evaluated before the type, from a typeof
|
|
301 specifier. */
|
|
302 tree expr;
|
|
303 /* The attributes from a typedef decl. */
|
|
304 tree decl_attr;
|
|
305 /* When parsing, the attributes. Outside the parser, this will be
|
|
306 NULL; attributes (possibly from multiple lists) will be passed
|
|
307 separately. */
|
|
308 tree attrs;
|
|
309 /* The pass to start compiling a __GIMPLE or __RTL function with. */
|
|
310 char *gimple_or_rtl_pass;
|
|
311 /* The base-2 log of the greatest alignment required by an _Alignas
|
|
312 specifier, in bytes, or -1 if no such specifiers with nonzero
|
|
313 alignment. */
|
|
314 int align_log;
|
|
315 /* For the __intN declspec, this stores the index into the int_n_* arrays. */
|
|
316 int int_n_idx;
|
|
317 /* For the _FloatN and _FloatNx declspec, this stores the index into
|
|
318 the floatn_nx_types array. */
|
|
319 int floatn_nx_idx;
|
|
320 /* The storage class specifier, or csc_none if none. */
|
|
321 enum c_storage_class storage_class;
|
|
322 /* Any type specifier keyword used such as "int", not reflecting
|
|
323 modifiers such as "short", or cts_none if none. */
|
|
324 ENUM_BITFIELD (c_typespec_keyword) typespec_word : 8;
|
|
325 /* The kind of type specifier if one has been seen, ctsk_none
|
|
326 otherwise. */
|
|
327 ENUM_BITFIELD (c_typespec_kind) typespec_kind : 3;
|
|
328 /* Whether any expressions in typeof specifiers may appear in
|
|
329 constant expressions. */
|
|
330 BOOL_BITFIELD expr_const_operands : 1;
|
|
331 /* Whether any declaration specifiers have been seen at all. */
|
|
332 BOOL_BITFIELD declspecs_seen_p : 1;
|
|
333 /* Whether something other than a storage class specifier or
|
|
334 attribute has been seen. This is used to warn for the
|
|
335 obsolescent usage of storage class specifiers other than at the
|
|
336 start of the list. (Doing this properly would require function
|
|
337 specifiers to be handled separately from storage class
|
|
338 specifiers.) */
|
|
339 BOOL_BITFIELD non_sc_seen_p : 1;
|
|
340 /* Whether the type is specified by a typedef or typeof name. */
|
|
341 BOOL_BITFIELD typedef_p : 1;
|
|
342 /* Whether the type is explicitly "signed" or specified by a typedef
|
|
343 whose type is explicitly "signed". */
|
|
344 BOOL_BITFIELD explicit_signed_p : 1;
|
|
345 /* Whether the specifiers include a deprecated typedef. */
|
|
346 BOOL_BITFIELD deprecated_p : 1;
|
|
347 /* Whether the type defaulted to "int" because there were no type
|
|
348 specifiers. */
|
|
349 BOOL_BITFIELD default_int_p : 1;
|
|
350 /* Whether "long" was specified. */
|
|
351 BOOL_BITFIELD long_p : 1;
|
|
352 /* Whether "long" was specified more than once. */
|
|
353 BOOL_BITFIELD long_long_p : 1;
|
|
354 /* Whether "short" was specified. */
|
|
355 BOOL_BITFIELD short_p : 1;
|
|
356 /* Whether "signed" was specified. */
|
|
357 BOOL_BITFIELD signed_p : 1;
|
|
358 /* Whether "unsigned" was specified. */
|
|
359 BOOL_BITFIELD unsigned_p : 1;
|
|
360 /* Whether "complex" was specified. */
|
|
361 BOOL_BITFIELD complex_p : 1;
|
|
362 /* Whether "inline" was specified. */
|
|
363 BOOL_BITFIELD inline_p : 1;
|
|
364 /* Whether "_Noreturn" was speciied. */
|
|
365 BOOL_BITFIELD noreturn_p : 1;
|
|
366 /* Whether "__thread" or "_Thread_local" was specified. */
|
|
367 BOOL_BITFIELD thread_p : 1;
|
|
368 /* Whether "__thread" rather than "_Thread_local" was specified. */
|
|
369 BOOL_BITFIELD thread_gnu_p : 1;
|
|
370 /* Whether "const" was specified. */
|
|
371 BOOL_BITFIELD const_p : 1;
|
|
372 /* Whether "volatile" was specified. */
|
|
373 BOOL_BITFIELD volatile_p : 1;
|
|
374 /* Whether "restrict" was specified. */
|
|
375 BOOL_BITFIELD restrict_p : 1;
|
|
376 /* Whether "_Atomic" was specified. */
|
|
377 BOOL_BITFIELD atomic_p : 1;
|
|
378 /* Whether "_Sat" was specified. */
|
|
379 BOOL_BITFIELD saturating_p : 1;
|
|
380 /* Whether any alignment specifier (even with zero alignment) was
|
|
381 specified. */
|
|
382 BOOL_BITFIELD alignas_p : 1;
|
|
383 /* Whether any __GIMPLE specifier was specified. */
|
|
384 BOOL_BITFIELD gimple_p : 1;
|
|
385 /* Whether any __RTL specifier was specified. */
|
|
386 BOOL_BITFIELD rtl_p : 1;
|
|
387 /* The address space that the declaration belongs to. */
|
|
388 addr_space_t address_space;
|
|
389 };
|
|
390
|
|
391 /* The various kinds of declarators in C. */
|
|
392 enum c_declarator_kind {
|
|
393 /* An identifier. */
|
|
394 cdk_id,
|
|
395 /* A function. */
|
|
396 cdk_function,
|
|
397 /* An array. */
|
|
398 cdk_array,
|
|
399 /* A pointer. */
|
|
400 cdk_pointer,
|
|
401 /* Parenthesized declarator with nested attributes. */
|
|
402 cdk_attrs
|
|
403 };
|
|
404
|
|
405 struct c_arg_tag {
|
|
406 /* The argument name. */
|
|
407 tree id;
|
|
408 /* The type of the argument. */
|
|
409 tree type;
|
|
410 };
|
|
411
|
|
412
|
|
413 /* Information about the parameters in a function declarator. */
|
|
414 struct c_arg_info {
|
|
415 /* A list of parameter decls. */
|
|
416 tree parms;
|
|
417 /* A list of structure, union and enum tags defined. */
|
|
418 vec<c_arg_tag, va_gc> *tags;
|
|
419 /* A list of argument types to go in the FUNCTION_TYPE. */
|
|
420 tree types;
|
|
421 /* A list of non-parameter decls (notably enumeration constants)
|
|
422 defined with the parameters. */
|
|
423 tree others;
|
|
424 /* A compound expression of VLA sizes from the parameters, or NULL.
|
|
425 In a function definition, these are used to ensure that
|
|
426 side-effects in sizes of arrays converted to pointers (such as a
|
|
427 parameter int i[n++]) take place; otherwise, they are
|
|
428 ignored. */
|
|
429 tree pending_sizes;
|
|
430 /* True when these arguments had [*]. */
|
|
431 BOOL_BITFIELD had_vla_unspec : 1;
|
|
432 };
|
|
433
|
|
434 /* A declarator. */
|
|
435 struct c_declarator {
|
|
436 /* The kind of declarator. */
|
|
437 enum c_declarator_kind kind;
|
|
438 location_t id_loc; /* Currently only set for cdk_id, cdk_array. */
|
|
439 /* Except for cdk_id, the contained declarator. For cdk_id, NULL. */
|
|
440 struct c_declarator *declarator;
|
|
441 union {
|
|
442 /* For identifiers, an IDENTIFIER_NODE or NULL_TREE if an abstract
|
|
443 declarator. */
|
|
444 tree id;
|
|
445 /* For functions. */
|
|
446 struct c_arg_info *arg_info;
|
|
447 /* For arrays. */
|
|
448 struct {
|
|
449 /* The array dimension, or NULL for [] and [*]. */
|
|
450 tree dimen;
|
|
451 /* The qualifiers inside []. */
|
|
452 int quals;
|
|
453 /* The attributes (currently ignored) inside []. */
|
|
454 tree attrs;
|
|
455 /* Whether [static] was used. */
|
|
456 BOOL_BITFIELD static_p : 1;
|
|
457 /* Whether [*] was used. */
|
|
458 BOOL_BITFIELD vla_unspec_p : 1;
|
|
459 } array;
|
|
460 /* For pointers, the qualifiers on the pointer type. */
|
|
461 int pointer_quals;
|
|
462 /* For attributes. */
|
|
463 tree attrs;
|
|
464 } u;
|
|
465 };
|
|
466
|
|
467 /* A type name. */
|
|
468 struct c_type_name {
|
|
469 /* The declaration specifiers. */
|
|
470 struct c_declspecs *specs;
|
|
471 /* The declarator. */
|
|
472 struct c_declarator *declarator;
|
|
473 };
|
|
474
|
|
475 /* A parameter. */
|
|
476 struct c_parm {
|
|
477 /* The declaration specifiers, minus any prefix attributes. */
|
|
478 struct c_declspecs *specs;
|
|
479 /* The attributes. */
|
|
480 tree attrs;
|
|
481 /* The declarator. */
|
|
482 struct c_declarator *declarator;
|
|
483 /* The location of the parameter. */
|
|
484 location_t loc;
|
|
485 };
|
|
486
|
|
487 /* Used when parsing an enum. Initialized by start_enum. */
|
|
488 struct c_enum_contents
|
|
489 {
|
|
490 /* While defining an enum type, this is 1 plus the last enumerator
|
|
491 constant value. */
|
|
492 tree enum_next_value;
|
|
493
|
|
494 /* Nonzero means that there was overflow computing enum_next_value. */
|
|
495 int enum_overflow;
|
|
496 };
|
|
497
|
|
498 /* A type of reference to a static identifier in an inline
|
|
499 function. */
|
|
500 enum c_inline_static_type {
|
|
501 /* Identifier with internal linkage used in function that may be an
|
|
502 inline definition (i.e., file-scope static). */
|
|
503 csi_internal,
|
|
504 /* Modifiable object with static storage duration defined in
|
|
505 function that may be an inline definition (i.e., local
|
|
506 static). */
|
|
507 csi_modifiable
|
|
508 };
|
|
509
|
|
510
|
|
511 /* in c-parser.c */
|
|
512 extern void c_parse_init (void);
|
|
513 extern bool c_keyword_starts_typename (enum rid keyword);
|
|
514
|
|
515 /* in c-aux-info.c */
|
|
516 extern void gen_aux_info_record (tree, int, int, int);
|
|
517
|
|
518 /* in c-decl.c */
|
|
519 struct c_spot_bindings;
|
|
520 struct c_struct_parse_info;
|
|
521 extern struct obstack parser_obstack;
|
|
522 extern tree c_break_label;
|
|
523 extern tree c_cont_label;
|
|
524
|
|
525 extern bool global_bindings_p (void);
|
|
526 extern tree pushdecl (tree);
|
|
527 extern void push_scope (void);
|
|
528 extern tree pop_scope (void);
|
|
529 extern void c_bindings_start_stmt_expr (struct c_spot_bindings *);
|
|
530 extern void c_bindings_end_stmt_expr (struct c_spot_bindings *);
|
|
531
|
|
532 extern void record_inline_static (location_t, tree, tree,
|
|
533 enum c_inline_static_type);
|
|
534 extern void c_init_decl_processing (void);
|
|
535 extern void c_print_identifier (FILE *, tree, int);
|
|
536 extern int quals_from_declspecs (const struct c_declspecs *);
|
|
537 extern struct c_declarator *build_array_declarator (location_t, tree,
|
|
538 struct c_declspecs *,
|
|
539 bool, bool);
|
|
540 extern tree build_enumerator (location_t, location_t, struct c_enum_contents *,
|
|
541 tree, tree);
|
|
542 extern tree check_for_loop_decls (location_t, bool);
|
|
543 extern void mark_forward_parm_decls (void);
|
|
544 extern void declare_parm_level (void);
|
|
545 extern void undeclared_variable (location_t, tree);
|
|
546 extern tree lookup_label_for_goto (location_t, tree);
|
|
547 extern tree declare_label (tree);
|
|
548 extern tree define_label (location_t, tree);
|
|
549 extern struct c_spot_bindings *c_get_switch_bindings (void);
|
|
550 extern void c_release_switch_bindings (struct c_spot_bindings *);
|
|
551 extern bool c_check_switch_jump_warnings (struct c_spot_bindings *,
|
|
552 location_t, location_t);
|
|
553 extern void finish_decl (tree, location_t, tree, tree, tree);
|
|
554 extern tree finish_enum (tree, tree, tree);
|
|
555 extern void finish_function (void);
|
|
556 extern tree finish_struct (location_t, tree, tree, tree,
|
|
557 struct c_struct_parse_info *);
|
|
558 extern struct c_arg_info *build_arg_info (void);
|
|
559 extern struct c_arg_info *get_parm_info (bool, tree);
|
|
560 extern tree grokfield (location_t, struct c_declarator *,
|
|
561 struct c_declspecs *, tree, tree *);
|
|
562 extern tree groktypename (struct c_type_name *, tree *, bool *);
|
|
563 extern tree grokparm (const struct c_parm *, tree *);
|
112
|
564 #ifndef noCbC
|
|
565 extern tree implicitly_declare (location_t, tree, int);
|
|
566 #else
|
111
|
567 extern tree implicitly_declare (location_t, tree);
|
112
|
568 #endif
|
111
|
569 extern void keep_next_level (void);
|
|
570 extern void pending_xref_error (void);
|
|
571 extern void c_push_function_context (void);
|
|
572 extern void c_pop_function_context (void);
|
|
573 extern void push_parm_decl (const struct c_parm *, tree *);
|
|
574 extern struct c_declarator *set_array_declarator_inner (struct c_declarator *,
|
|
575 struct c_declarator *);
|
|
576 extern tree c_builtin_function (tree);
|
|
577 extern tree c_builtin_function_ext_scope (tree);
|
|
578 extern void shadow_tag (const struct c_declspecs *);
|
|
579 extern void shadow_tag_warned (const struct c_declspecs *, int);
|
|
580 extern tree start_enum (location_t, struct c_enum_contents *, tree);
|
|
581 extern bool start_function (struct c_declspecs *, struct c_declarator *, tree);
|
|
582 extern tree start_decl (struct c_declarator *, struct c_declspecs *, bool,
|
|
583 tree);
|
|
584 extern tree start_struct (location_t, enum tree_code, tree,
|
|
585 struct c_struct_parse_info **);
|
|
586 extern void store_parm_decls (void);
|
|
587 extern void store_parm_decls_from (struct c_arg_info *);
|
|
588 extern void temp_store_parm_decls (tree, tree);
|
|
589 extern void temp_pop_parm_decls (void);
|
|
590 extern tree xref_tag (enum tree_code, tree);
|
|
591 extern struct c_typespec parser_xref_tag (location_t, enum tree_code, tree);
|
|
592 extern struct c_parm *build_c_parm (struct c_declspecs *, tree,
|
|
593 struct c_declarator *, location_t);
|
|
594 extern struct c_declarator *build_attrs_declarator (tree,
|
|
595 struct c_declarator *);
|
|
596 extern struct c_declarator *build_function_declarator (struct c_arg_info *,
|
|
597 struct c_declarator *);
|
|
598 extern struct c_declarator *build_id_declarator (tree);
|
|
599 extern struct c_declarator *make_pointer_declarator (struct c_declspecs *,
|
|
600 struct c_declarator *);
|
|
601 extern struct c_declspecs *build_null_declspecs (void);
|
|
602 extern struct c_declspecs *declspecs_add_qual (source_location,
|
|
603 struct c_declspecs *, tree);
|
|
604 extern struct c_declspecs *declspecs_add_type (location_t,
|
|
605 struct c_declspecs *,
|
|
606 struct c_typespec);
|
|
607 extern struct c_declspecs *declspecs_add_scspec (source_location,
|
|
608 struct c_declspecs *, tree);
|
|
609 extern struct c_declspecs *declspecs_add_attrs (source_location,
|
|
610 struct c_declspecs *, tree);
|
|
611 extern struct c_declspecs *declspecs_add_addrspace (source_location,
|
|
612 struct c_declspecs *,
|
|
613 addr_space_t);
|
|
614 extern struct c_declspecs *declspecs_add_alignas (source_location,
|
|
615 struct c_declspecs *, tree);
|
|
616 extern struct c_declspecs *finish_declspecs (struct c_declspecs *);
|
|
617
|
|
618 /* in c-objc-common.c */
|
|
619 extern bool c_objc_common_init (void);
|
|
620 extern bool c_missing_noreturn_ok_p (tree);
|
|
621 extern bool c_warn_unused_global_decl (const_tree);
|
|
622 extern void c_initialize_diagnostics (diagnostic_context *);
|
|
623 extern bool c_vla_unspec_p (tree x, tree fn);
|
|
624
|
|
625 /* in c-typeck.c */
|
|
626 extern int in_alignof;
|
|
627 extern int in_sizeof;
|
|
628 extern int in_typeof;
|
|
629
|
|
630 extern tree c_last_sizeof_arg;
|
|
631 extern location_t c_last_sizeof_loc;
|
|
632
|
|
633 extern struct c_switch *c_switch_stack;
|
|
634
|
|
635 extern tree c_objc_common_truthvalue_conversion (location_t, tree);
|
|
636 extern tree require_complete_type (location_t, tree);
|
|
637 extern bool same_translation_unit_p (const_tree, const_tree);
|
|
638 extern int comptypes (tree, tree);
|
|
639 extern int comptypes_check_different_types (tree, tree, bool *);
|
|
640 extern bool c_vla_type_p (const_tree);
|
|
641 extern bool c_mark_addressable (tree, bool = false);
|
|
642 extern void c_incomplete_type_error (location_t, const_tree, const_tree);
|
|
643 extern tree c_type_promotes_to (tree);
|
|
644 extern struct c_expr default_function_array_conversion (location_t,
|
|
645 struct c_expr);
|
|
646 extern struct c_expr default_function_array_read_conversion (location_t,
|
|
647 struct c_expr);
|
|
648 extern struct c_expr convert_lvalue_to_rvalue (location_t, struct c_expr,
|
|
649 bool, bool);
|
|
650 extern void mark_exp_read (tree);
|
|
651 extern tree composite_type (tree, tree);
|
|
652 extern tree build_component_ref (location_t, tree, tree, location_t);
|
|
653 extern tree build_array_ref (location_t, tree, tree);
|
|
654 extern tree build_external_ref (location_t, tree, bool, tree *);
|
|
655 extern void pop_maybe_used (bool);
|
|
656 extern struct c_expr c_expr_sizeof_expr (location_t, struct c_expr);
|
|
657 extern struct c_expr c_expr_sizeof_type (location_t, struct c_type_name *);
|
|
658 extern struct c_expr parser_build_unary_op (location_t, enum tree_code,
|
|
659 struct c_expr);
|
|
660 extern struct c_expr parser_build_binary_op (location_t,
|
|
661 enum tree_code, struct c_expr,
|
|
662 struct c_expr);
|
|
663 extern tree build_conditional_expr (location_t, tree, bool, tree, tree,
|
|
664 location_t, tree, tree, location_t);
|
|
665 extern tree build_compound_expr (location_t, tree, tree);
|
|
666 extern tree c_cast_expr (location_t, struct c_type_name *, tree);
|
|
667 extern tree build_c_cast (location_t, tree, tree);
|
|
668 extern void store_init_value (location_t, tree, tree, tree);
|
|
669 extern void maybe_warn_string_init (location_t, tree, struct c_expr);
|
|
670 extern void start_init (tree, tree, int, rich_location *);
|
|
671 extern void finish_init (void);
|
|
672 extern void really_start_incremental_init (tree);
|
|
673 extern void finish_implicit_inits (location_t, struct obstack *);
|
|
674 extern void push_init_level (location_t, int, struct obstack *);
|
|
675 extern struct c_expr pop_init_level (location_t, int, struct obstack *,
|
|
676 location_t);
|
|
677 extern void set_init_index (location_t, tree, tree, struct obstack *);
|
|
678 extern void set_init_label (location_t, tree, location_t, struct obstack *);
|
|
679 extern void process_init_element (location_t, struct c_expr, bool,
|
|
680 struct obstack *);
|
|
681 extern tree build_compound_literal (location_t, tree, tree, bool);
|
|
682 extern void check_compound_literal_type (location_t, struct c_type_name *);
|
|
683 extern tree c_start_case (location_t, location_t, tree, bool);
|
|
684 extern void c_finish_case (tree, tree);
|
|
685 extern tree build_asm_expr (location_t, tree, tree, tree, tree, tree, bool);
|
|
686 extern tree build_asm_stmt (tree, tree);
|
|
687 extern int c_types_compatible_p (tree, tree);
|
|
688 extern tree c_begin_compound_stmt (bool);
|
|
689 extern tree c_end_compound_stmt (location_t, tree, bool);
|
|
690 extern void c_finish_if_stmt (location_t, tree, tree, tree);
|
|
691 extern void c_finish_loop (location_t, tree, tree, tree, tree, tree, bool);
|
|
692 extern tree c_begin_stmt_expr (void);
|
|
693 extern tree c_finish_stmt_expr (location_t, tree);
|
|
694 extern tree c_process_expr_stmt (location_t, tree);
|
|
695 extern tree c_finish_expr_stmt (location_t, tree);
|
|
696 extern tree c_finish_return (location_t, tree, tree);
|
|
697 extern tree c_finish_bc_stmt (location_t, tree *, bool);
|
|
698 extern tree c_finish_goto_label (location_t, tree);
|
|
699 extern tree c_finish_goto_ptr (location_t, tree);
|
|
700 extern tree c_expr_to_decl (tree, bool *, bool *);
|
|
701 extern tree c_finish_omp_construct (location_t, enum tree_code, tree, tree);
|
|
702 extern tree c_finish_oacc_data (location_t, tree, tree);
|
|
703 extern tree c_finish_oacc_host_data (location_t, tree, tree);
|
|
704 extern tree c_begin_omp_parallel (void);
|
|
705 extern tree c_finish_omp_parallel (location_t, tree, tree);
|
|
706 extern tree c_begin_omp_task (void);
|
|
707 extern tree c_finish_omp_task (location_t, tree, tree);
|
|
708 extern void c_finish_omp_cancel (location_t, tree);
|
|
709 extern void c_finish_omp_cancellation_point (location_t, tree);
|
|
710 extern tree c_finish_omp_clauses (tree, enum c_omp_region_type);
|
|
711 extern tree c_build_va_arg (location_t, tree, location_t, tree);
|
|
712 extern tree c_finish_transaction (location_t, tree, int);
|
|
713 extern bool c_tree_equal (tree, tree);
|
|
714 extern tree c_build_function_call_vec (location_t, vec<location_t>, tree,
|
|
715 vec<tree, va_gc> *, vec<tree, va_gc> *);
|
|
716 extern tree c_omp_clause_copy_ctor (tree, tree, tree);
|
|
717
|
|
718 /* Set to 0 at beginning of a function definition, set to 1 if
|
|
719 a return statement that specifies a return value is seen. */
|
|
720
|
|
721 extern int current_function_returns_value;
|
|
722
|
|
723 /* Set to 0 at beginning of a function definition, set to 1 if
|
|
724 a return statement with no argument is seen. */
|
|
725
|
|
726 extern int current_function_returns_null;
|
|
727
|
|
728 /* Set to 0 at beginning of a function definition, set to 1 if
|
|
729 a call to a noreturn function is seen. */
|
|
730
|
|
731 extern int current_function_returns_abnormally;
|
|
732
|
|
733 /* In c-decl.c */
|
|
734
|
|
735 /* Tell the binding oracle what kind of binding we are looking for. */
|
|
736
|
|
737 enum c_oracle_request
|
|
738 {
|
|
739 C_ORACLE_SYMBOL,
|
|
740 C_ORACLE_TAG,
|
|
741 C_ORACLE_LABEL
|
|
742 };
|
|
743
|
|
744 /* If this is non-NULL, then it is a "binding oracle" which can lazily
|
|
745 create bindings when needed by the C compiler. The oracle is told
|
|
746 the name and type of the binding to create. It can call pushdecl
|
|
747 or the like to ensure the binding is visible; or do nothing,
|
|
748 leaving the binding untouched. c-decl.c takes note of when the
|
|
749 oracle has been called and will not call it again if it fails to
|
|
750 create a given binding. */
|
|
751
|
|
752 typedef void c_binding_oracle_function (enum c_oracle_request, tree identifier);
|
|
753
|
|
754 extern c_binding_oracle_function *c_binding_oracle;
|
|
755
|
|
756 extern void c_finish_incomplete_decl (tree);
|
|
757 extern tree c_omp_reduction_id (enum tree_code, tree);
|
|
758 extern tree c_omp_reduction_decl (tree);
|
|
759 extern tree c_omp_reduction_lookup (tree, tree);
|
|
760 extern tree c_check_omp_declare_reduction_r (tree *, int *, void *);
|
|
761 extern void c_pushtag (location_t, tree, tree);
|
|
762 extern void c_bind (location_t, tree, bool);
|
|
763 extern bool tag_exists_p (enum tree_code, tree);
|
|
764
|
|
765 /* In c-errors.c */
|
|
766 extern bool pedwarn_c90 (location_t, int opt, const char *, ...)
|
|
767 ATTRIBUTE_GCC_DIAG(3,4);
|
|
768 extern bool pedwarn_c99 (location_t, int opt, const char *, ...)
|
|
769 ATTRIBUTE_GCC_DIAG(3,4);
|
|
770
|
|
771 extern void
|
|
772 set_c_expr_source_range (c_expr *expr,
|
|
773 location_t start, location_t finish);
|
|
774
|
|
775 extern void
|
|
776 set_c_expr_source_range (c_expr *expr,
|
|
777 source_range src_range);
|
|
778
|
|
779 /* In c-fold.c */
|
|
780 extern tree decl_constant_value_for_optimization (tree);
|
|
781
|
|
782 extern vec<tree> incomplete_record_decls;
|
|
783
|
|
784 #if CHECKING_P
|
|
785 namespace selftest {
|
|
786 extern void run_c_tests (void);
|
|
787 } // namespace selftest
|
|
788 #endif /* #if CHECKING_P */
|
|
789
|
|
790
|
|
791 #endif /* ! GCC_C_TREE_H */
|