Debian Codegraph @

gcc/c/c-tree.h

raw
1 /* Definitions for C parsing and type checking.
2 Copyright (C) 1987-2025 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.cc, but langhooks.cc needs to
27 know how big it is. This is sanity-checked in c-decl.cc. */
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, nonzero if any component is
38 volatile, restrict-qualified or atomic; that is, has a type not
39 permitted for a constexpr object. */
40 #define C_TYPE_FIELDS_NON_CONSTEXPR(TYPE) TREE_LANG_FLAG_4 (TYPE)
41
42 /* In a RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE
43 nonzero if the definition of the type has already started. */
44 #define C_TYPE_BEING_DEFINED(TYPE) TYPE_LANG_FLAG_0 (TYPE)
45
46 /* In an incomplete RECORD_TYPE, UNION_TYPE or ENUMERAL_TYPE, a list of
47 variable declarations whose type would be completed by completing
48 that type. */
49 #define C_TYPE_INCOMPLETE_VARS(TYPE) \
50 TYPE_LANG_SLOT_1 (TREE_CHECK4 (TYPE, RECORD_TYPE, UNION_TYPE, \
51 QUAL_UNION_TYPE, ENUMERAL_TYPE))
52
53 /* In an IDENTIFIER_NODE, nonzero if this identifier is actually a
54 keyword. C_RID_CODE (node) is then the RID_* value of the keyword. */
55 #define C_IS_RESERVED_WORD(ID) TREE_LANG_FLAG_0 (ID)
56
57 /* Record whether a type or decl was written with nonconstant size.
58 Note that TYPE_SIZE may have simplified to a constant. */
59 #define C_TYPE_VARIABLE_SIZE(TYPE) TYPE_LANG_FLAG_1 (TYPE)
60 #define C_DECL_VARIABLE_SIZE(TYPE) DECL_LANG_FLAG_0 (TYPE)
61
62 /* Record whether a type is variably modified. */
63 #define C_TYPE_VARIABLY_MODIFIED(TYPE) TYPE_LANG_FLAG_6 (TYPE)
64
65
66 /* Record whether a type is defined inside a struct or union type.
67 This is used for -Wc++-compat. */
68 #define C_TYPE_DEFINED_IN_STRUCT(TYPE) TYPE_LANG_FLAG_2 (TYPE)
69
70 /* Record whether a typedef for type `int' was actually `signed int'. */
71 #define C_TYPEDEF_EXPLICITLY_SIGNED(EXP) DECL_LANG_FLAG_1 (EXP)
72
73 /* For a FUNCTION_DECL, nonzero if it was defined without an explicit
74 return type. */
75 #define C_FUNCTION_IMPLICIT_INT(EXP) DECL_LANG_FLAG_1 (EXP)
76
77 /* For a FUNCTION_DECL, nonzero if it was an implicit declaration. */
78 #define C_DECL_IMPLICIT(EXP) DECL_LANG_FLAG_2 (EXP)
79
80 /* For a PARM_DECL, nonzero if it was declared as an array. */
81 #define C_ARRAY_PARAMETER(NODE) DECL_LANG_FLAG_0 (NODE)
82
83 /* For FUNCTION_DECLs, evaluates true if the decl is built-in but has
84 been declared. */
85 #define C_DECL_DECLARED_BUILTIN(EXP) \
86 DECL_LANG_FLAG_3 (FUNCTION_DECL_CHECK (EXP))
87
88 /* For FUNCTION_DECLs, evaluates true if the decl is built-in, has a
89 built-in prototype and does not have a non-built-in prototype. */
90 #define C_DECL_BUILTIN_PROTOTYPE(EXP) \
91 DECL_LANG_FLAG_6 (FUNCTION_DECL_CHECK (EXP))
92
93 /* For LABEL_DECLs marks canonical name of a loop. */
94 #define C_DECL_LOOP_NAME(EXP) DECL_LANG_FLAG_3 (LABEL_DECL_CHECK (EXP))
95
96 /* For LABEL_DECLs marks canonical name of a switch. During parsing of
97 ObjC foreach named loop both C_DECL_LOOP_NAME and C_DECL_SWITCH_NAME
98 are temporarily set. */
99 #define C_DECL_SWITCH_NAME(EXP) DECL_LANG_FLAG_5 (LABEL_DECL_CHECK (EXP))
100
101 /* For LABEL_DECLs marks canonical name of a loop or switch being
102 valid for use in break identifier or continue identifier statements. */
103 #define C_DECL_LOOP_SWITCH_NAME_VALID(EXP) \
104 DECL_LANG_FLAG_6 (LABEL_DECL_CHECK (EXP))
105
106 /* For LABEL_DECLs marks canonical loop or switch names which were actually
107 used in one or more break identifier or continue identifier statements. */
108 #define C_DECL_LOOP_SWITCH_NAME_USED(EXP) \
109 DECL_LANG_FLAG_8 (LABEL_DECL_CHECK (EXP))
110
111 /* Record whether a decl was declared register. This is strictly a
112 front-end flag, whereas DECL_REGISTER is used for code generation;
113 they may differ for structures with volatile fields. */
114 #define C_DECL_REGISTER(EXP) DECL_LANG_FLAG_4 (EXP)
115
116 /* Record whether a decl was used in an expression anywhere except an
117 unevaluated operand of sizeof / typeof / alignof. This is only
118 used for functions declared static but not defined, though outside
119 sizeof and typeof it is set for other function decls as well. */
120 #define C_DECL_USED(EXP) DECL_LANG_FLAG_5 (FUNCTION_DECL_CHECK (EXP))
121
122 /* Record whether a variable has been declared threadprivate by
123 #pragma omp threadprivate. */
124 #define C_DECL_THREADPRIVATE_P(DECL) DECL_LANG_FLAG_3 (VAR_DECL_CHECK (DECL))
125
126 /* Set on VAR_DECLs for compound literals. */
127 #define C_DECL_COMPOUND_LITERAL_P(DECL) \
128 DECL_LANG_FLAG_5 (VAR_DECL_CHECK (DECL))
129
130 /* Set on decls used as placeholders for a C23 underspecified object
131 definition. */
132 #define C_DECL_UNDERSPECIFIED(DECL) DECL_LANG_FLAG_7 (DECL)
133
134 /* Set on VAR_DECLs declared as 'constexpr'. */
135 #define C_DECL_DECLARED_CONSTEXPR(DECL) \
136 DECL_LANG_FLAG_8 (VAR_DECL_CHECK (DECL))
137
138 /* Nonzero for a decl which either doesn't exist or isn't a prototype.
139 N.B. Could be simplified if all built-in decls had complete prototypes
140 (but this is presently difficult because some of them need FILE*). */
141 #define C_DECL_ISNT_PROTOTYPE(EXP) \
142 (EXP == 0 \
143 || (!prototype_p (TREE_TYPE (EXP)) \
144 && !fndecl_built_in_p (EXP)))
145
146 /* For FUNCTION_TYPE, a hidden list of types of arguments. The same as
147 TYPE_ARG_TYPES for functions with prototypes, but created for functions
148 without prototypes. */
149 #define TYPE_ACTUAL_ARG_TYPES(NODE) \
150 TYPE_LANG_SLOT_1 (FUNCTION_TYPE_CHECK (NODE))
151
152 /* For a CONSTRUCTOR, whether some initializer contains a
153 subexpression meaning it is not a constant expression. */
154 #define CONSTRUCTOR_NON_CONST(EXPR) TREE_LANG_FLAG_1 (CONSTRUCTOR_CHECK (EXPR))
155
156 /* For a SAVE_EXPR, nonzero if the operand of the SAVE_EXPR has already
157 been folded. */
158 #define SAVE_EXPR_FOLDED_P(EXP) TREE_LANG_FLAG_1 (SAVE_EXPR_CHECK (EXP))
159
160 /* Whether a type has boolean semantics: either a boolean type or an
161 enumeration type with a boolean type as its underlying type. */
162 #define C_BOOLEAN_TYPE_P(TYPE) \
163 (TREE_CODE (TYPE) == BOOLEAN_TYPE \
164 || (TREE_CODE (TYPE) == ENUMERAL_TYPE \
165 && ENUM_UNDERLYING_TYPE (TYPE) != NULL_TREE \
166 && TREE_CODE (ENUM_UNDERLYING_TYPE (TYPE)) == BOOLEAN_TYPE))
167
168 /* Record parser information about an expression that is irrelevant
169 for code generation alongside a tree representing its value. */
170 struct c_expr
171 {
172 /* The value of the expression. */
173 tree value;
174 /* Record the original unary/binary operator of an expression, which may
175 have been changed by fold, STRING_CST for unparenthesized string
176 constants, C_MAYBE_CONST_EXPR for __builtin_constant_p calls
177 (even if parenthesized), for subexpressions, and for non-constant
178 initializers, or ERROR_MARK for other expressions (including
179 parenthesized expressions). */
180 enum tree_code original_code;
181 /* If not NULL, the original type of an expression. This will
182 differ from the type of the value field for an enum constant.
183 The type of an enum constant is a plain integer type, but this
184 field will be the enum type. */
185 tree original_type;
186
187 /* The source range of this expression. This is redundant
188 for node values that have locations, but not all node kinds
189 have locations (e.g. constants, and references to params, locals,
190 etc), so we stash a copy here. */
191 source_range src_range;
192
193 /* True if this was directly from a decimal constant token. */
194 bool m_decimal : 1;
195
196 /* Access to the first and last locations within the source spelling
197 of this expression. */
198 location_t get_start () const { return src_range.m_start; }
199 location_t get_finish () const { return src_range.m_finish; }
200
201 location_t get_location () const
202 {
203 if (EXPR_HAS_LOCATION (value))
204 return EXPR_LOCATION (value);
205 else
206 return make_location (get_start (), get_start (), get_finish ());
207 }
208
209 /* Set the value to error_mark_node whilst ensuring that src_range
210 and m_decimal are initialized. */
211 void set_error ()
212 {
213 value = error_mark_node;
214 src_range.m_start = UNKNOWN_LOCATION;
215 src_range.m_finish = UNKNOWN_LOCATION;
216 m_decimal = 0;
217 }
218 };
219
220 /* Type alias for struct c_expr. This allows to use the structure
221 inside the VEC types. */
222 typedef struct c_expr c_expr_t;
223
224 /* A kind of type specifier. Note that this information is currently
225 only used to distinguish tag definitions, tag references and typeof
226 uses. */
227 enum c_typespec_kind {
228 /* No typespec. This appears only in struct c_declspec. */
229 ctsk_none,
230 /* A reserved keyword type specifier. */
231 ctsk_resword,
232 /* A reference to a tag, previously declared, such as "struct foo".
233 This includes where the previous declaration was as a different
234 kind of tag, in which case this is only valid if shadowing that
235 tag in an inner scope. */
236 ctsk_tagref,
237 /* Likewise, with standard attributes present in the reference. */
238 ctsk_tagref_attrs,
239 /* A reference to a tag, not previously declared in a visible
240 scope. */
241 ctsk_tagfirstref,
242 /* Likewise, with standard attributes present in the reference. */
243 ctsk_tagfirstref_attrs,
244 /* A definition of a tag such as "struct foo { int a; }". */
245 ctsk_tagdef,
246 /* A typedef name. */
247 ctsk_typedef,
248 /* An ObjC-specific kind of type specifier. */
249 ctsk_objc,
250 /* A typeof specifier, or _Atomic ( type-name ). */
251 ctsk_typeof
252 };
253
254 /* A type specifier: this structure is created in the parser and
255 passed to declspecs_add_type only. */
256 struct c_typespec {
257 /* What kind of type specifier this is. */
258 enum c_typespec_kind kind;
259 /* Whether the expression has operands suitable for use in constant
260 expressions. */
261 bool expr_const_operands;
262 /* Whether the type specifier includes an enum type specifier (that
263 is, ": specifier-qualifier-list" in a declaration using
264 "enum"). */
265 bool has_enum_type_specifier;
266 /* The specifier itself. */
267 tree spec;
268 /* An expression to be evaluated before the type specifier, in the
269 case of typeof specifiers, or NULL otherwise or if no such
270 expression is required for a particular typeof specifier. In
271 particular, when typeof is applied to an expression of variably
272 modified type, that expression must be evaluated in order to
273 determine array sizes that form part of the type, but the
274 expression itself (as opposed to the array sizes) forms no part
275 of the type and so needs to be recorded separately. */
276 tree expr;
277 };
278
279 /* A storage class specifier. */
280 enum c_storage_class {
281 csc_none,
282 csc_auto,
283 csc_extern,
284 csc_register,
285 csc_static,
286 csc_typedef
287 };
288
289 /* A type specifier keyword "void", "_Bool", "char", "int", "float",
290 "double", "_Decimal32", "_Decimal64", "_Decimal128", "_Decimal64x",
291 "_Fract", "_Accum", "_BitInt", or none of these. */
292 enum c_typespec_keyword {
293 cts_none,
294 cts_void,
295 cts_bool,
296 cts_char,
297 cts_int,
298 cts_float,
299 cts_int_n,
300 cts_double,
301 cts_dfloat32,
302 cts_dfloat64,
303 cts_dfloat128,
304 cts_dfloat64x,
305 cts_floatn_nx,
306 cts_fract,
307 cts_accum,
308 cts_bitint,
309 cts_auto_type
310 };
311
312 /* This enum lists all the possible declarator specifiers, storage
313 class or attribute that a user can write. There is at least one
314 enumerator per possible declarator specifier in the struct
315 c_declspecs below.
316
317 It is used to index the array of declspec locations in struct
318 c_declspecs. */
319 enum c_declspec_word {
320 cdw_typespec /* A catch-all for a typespec. */,
321 cdw_storage_class /* A catch-all for a storage class */,
322 cdw_attributes,
323 cdw_typedef,
324 cdw_explicit_signed,
325 cdw_deprecated,
326 cdw_default_int,
327 cdw_long,
328 cdw_long_long,
329 cdw_short,
330 cdw_signed,
331 cdw_unsigned,
332 cdw_complex,
333 cdw_inline,
334 cdw_noreturn,
335 cdw_thread,
336 cdw_const,
337 cdw_volatile,
338 cdw_restrict,
339 cdw_atomic,
340 cdw_saturating,
341 cdw_alignas,
342 cdw_address_space,
343 cdw_gimple,
344 cdw_rtl,
345 cdw_number_of_elements /* This one must always be the last
346 enumerator. */
347 };
348
349 enum c_declspec_il {
350 cdil_none,
351 cdil_gimple, /* __GIMPLE */
352 cdil_gimple_cfg, /* __GIMPLE(cfg) */
353 cdil_gimple_ssa, /* __GIMPLE(ssa) */
354 cdil_rtl /* __RTL */
355 };
356
357 /* A sequence of declaration specifiers in C. When a new declaration
358 specifier is added, please update the enum c_declspec_word above
359 accordingly. */
360 struct c_declspecs {
361 location_t locations[cdw_number_of_elements];
362 /* The type specified, if a single type specifier such as a struct,
363 union or enum specifier, typedef name or typeof specifies the
364 whole type, or NULL_TREE if none or a keyword such as "void" or
365 "char" is used. Does not include qualifiers. */
366 tree type;
367 /* Any expression to be evaluated before the type, from a typeof
368 specifier. */
369 tree expr;
370 /* The attributes from a typedef decl. */
371 tree decl_attr;
372 /* When parsing, the GNU attributes and prefix standard attributes.
373 Outside the parser, this will be NULL; attributes (possibly from
374 multiple lists) will be passed separately. */
375 tree attrs;
376 /* When parsing, postfix standard attributes (which appertain to the
377 type specified by the preceding declaration specifiers, unlike
378 prefix standard attributes which appertain to the declaration or
379 declarations as a whole). */
380 tree postfix_attrs;
381 /* The pass to start compiling a __GIMPLE or __RTL function with. */
382 char *gimple_or_rtl_pass;
383 /* ENTRY BB count. */
384 profile_count entry_bb_count;
385 /* The base-2 log of the greatest alignment required by an _Alignas
386 specifier, in bytes, or -1 if no such specifiers with nonzero
387 alignment. */
388 int align_log;
389 union {
390 /* For the __intN declspec, this stores the index into the int_n_*
391 arrays. */
392 int int_n_idx;
393 /* For the _FloatN and _FloatNx declspec, this stores the index into
394 the floatn_nx_types array. */
395 int floatn_nx_idx;
396 /* For _BitInt(N) this stores the N. */
397 int bitint_prec;
398 } u;
399 /* The storage class specifier, or csc_none if none. */
400 enum c_storage_class storage_class;
401 /* Any type specifier keyword used such as "int", not reflecting
402 modifiers such as "short", or cts_none if none. */
403 ENUM_BITFIELD (c_typespec_keyword) typespec_word : 8;
404 /* The kind of type specifier if one has been seen, ctsk_none
405 otherwise. */
406 ENUM_BITFIELD (c_typespec_kind) typespec_kind : 4;
407 ENUM_BITFIELD (c_declspec_il) declspec_il : 3;
408 /* Whether any expressions in typeof specifiers may appear in
409 constant expressions. */
410 BOOL_BITFIELD expr_const_operands : 1;
411 /* Whether any declaration specifiers have been seen at all. */
412 BOOL_BITFIELD declspecs_seen_p : 1;
413 /* Whether any declaration specifiers other than standard attributes
414 have been seen at all. If only standard attributes have been
415 seen, this is an attribute-declaration. */
416 BOOL_BITFIELD non_std_attrs_seen_p : 1;
417 /* Whether something other than a storage class specifier or
418 attribute has been seen. This is used to warn for the
419 obsolescent usage of storage class specifiers other than at the
420 start of the list. (Doing this properly would require function
421 specifiers to be handled separately from storage class
422 specifiers.) */
423 BOOL_BITFIELD non_sc_seen_p : 1;
424 /* Whether the type is specified by a typedef or typeof name. */
425 BOOL_BITFIELD typedef_p : 1;
426 /* Whether the type is explicitly "signed" or specified by a typedef
427 whose type is explicitly "signed". */
428 BOOL_BITFIELD explicit_signed_p : 1;
429 /* Whether the specifiers include a deprecated typedef. */
430 BOOL_BITFIELD deprecated_p : 1;
431 /* Whether the specifiers include an unavailable typedef. */
432 BOOL_BITFIELD unavailable_p : 1;
433 /* Whether the type defaulted to "int" because there were no type
434 specifiers. */
435 BOOL_BITFIELD default_int_p : 1;
436 /* Whether "long" was specified. */
437 BOOL_BITFIELD long_p : 1;
438 /* Whether "long" was specified more than once. */
439 BOOL_BITFIELD long_long_p : 1;
440 /* Whether "short" was specified. */
441 BOOL_BITFIELD short_p : 1;
442 /* Whether "signed" was specified. */
443 BOOL_BITFIELD signed_p : 1;
444 /* Whether "unsigned" was specified. */
445 BOOL_BITFIELD unsigned_p : 1;
446 /* Whether "complex" was specified. */
447 BOOL_BITFIELD complex_p : 1;
448 /* Whether "inline" was specified. */
449 BOOL_BITFIELD inline_p : 1;
450 /* Whether "_Noreturn" was speciied. */
451 BOOL_BITFIELD noreturn_p : 1;
452 /* Whether "__thread" or "_Thread_local" was specified. */
453 BOOL_BITFIELD thread_p : 1;
454 /* Whether "__thread" rather than "_Thread_local" was specified. */
455 BOOL_BITFIELD thread_gnu_p : 1;
456 /* Whether "const" was specified. */
457 BOOL_BITFIELD const_p : 1;
458 /* Whether "volatile" was specified. */
459 BOOL_BITFIELD volatile_p : 1;
460 /* Whether "restrict" was specified. */
461 BOOL_BITFIELD restrict_p : 1;
462 /* Whether "_Atomic" was specified. */
463 BOOL_BITFIELD atomic_p : 1;
464 /* Whether "_Sat" was specified. */
465 BOOL_BITFIELD saturating_p : 1;
466 /* Whether any alignment specifier (even with zero alignment) was
467 specified. */
468 BOOL_BITFIELD alignas_p : 1;
469 /* Whether an enum type specifier (": specifier-qualifier-list") was
470 specified other than in a definition of that enum (if so, this is
471 invalid unless it is an empty declaration "enum identifier
472 enum-type-specifier;", but such an empty declaration is valid in
473 C23 when "enum identifier;" would not be). */
474 BOOL_BITFIELD enum_type_specifier_ref_p : 1;
475 /* Whether "auto" was specified in C23 (or later) mode and means the
476 type is to be deduced from an initializer, or would mean that if
477 no type specifier appears later in these declaration
478 specifiers. */
479 BOOL_BITFIELD c23_auto_p : 1;
480 /* Whether "constexpr" was specified. */
481 BOOL_BITFIELD constexpr_p : 1;
482 /* The address space that the declaration belongs to. */
483 addr_space_t address_space;
484 };
485
486 /* The various kinds of declarators in C. */
487 enum c_declarator_kind {
488 /* An identifier. */
489 cdk_id,
490 /* A function. */
491 cdk_function,
492 /* An array. */
493 cdk_array,
494 /* A pointer. */
495 cdk_pointer,
496 /* Parenthesized declarator with nested attributes. */
497 cdk_attrs
498 };
499
500 struct c_arg_tag {
501 /* The argument name. */
502 tree id;
503 /* The type of the argument. */
504 tree type;
505 };
506
507
508 /* Information about the parameters in a function declarator. */
509 struct c_arg_info {
510 /* A list of parameter decls. */
511 tree parms;
512 /* A list of structure, union and enum tags defined. */
513 vec<c_arg_tag, va_gc> *tags;
514 /* A list of argument types to go in the FUNCTION_TYPE. */
515 tree types;
516 /* A list of non-parameter decls (notably enumeration constants)
517 defined with the parameters. */
518 tree others;
519 /* A compound expression of VLA sizes from the parameters, or NULL.
520 In a function definition, these are used to ensure that
521 side-effects in sizes of arrays converted to pointers (such as a
522 parameter int i[n++]) take place; otherwise, they are
523 ignored. */
524 tree pending_sizes;
525 /* True when these arguments had [*]. */
526 BOOL_BITFIELD had_vla_unspec : 1;
527 /* True when the arguments are a (...) prototype. */
528 BOOL_BITFIELD no_named_args_stdarg_p : 1;
529 /* True when empty parentheses have been interpreted as (void) in C23 or
530 later. This is only for use by -Wtraditional and is no longer needed if
531 -Wtraditional is removed. */
532 BOOL_BITFIELD c23_empty_parens : 1;
533 };
534
535 /* A declarator. */
536 struct c_declarator {
537 /* The kind of declarator. */
538 enum c_declarator_kind kind;
539 location_t id_loc; /* Currently only set for cdk_id, cdk_array. */
540 /* Except for cdk_id, the contained declarator. For cdk_id, NULL. */
541 struct c_declarator *declarator;
542 union {
543 /* For identifiers. */
544 struct {
545 /* An IDENTIFIER_NODE, or NULL_TREE if an abstract
546 declarator. */
547 tree id;
548 /* Any attributes (which apply to the declaration rather than to
549 the type described by the outer declarators). */
550 tree attrs;
551 } id;
552 /* For functions. */
553 struct c_arg_info *arg_info;
554 /* For arrays. */
555 struct {
556 /* The array dimension, or NULL for [] and [*]. */
557 tree dimen;
558 /* The qualifiers inside []. */
559 int quals;
560 /* The attributes (currently ignored) inside []. */
561 tree attrs;
562 /* Whether [static] was used. */
563 BOOL_BITFIELD static_p : 1;
564 /* Whether [*] was used. */
565 BOOL_BITFIELD vla_unspec_p : 1;
566 } array;
567 /* For pointers, the qualifiers on the pointer type. */
568 int pointer_quals;
569 /* For attributes. */
570 tree attrs;
571 } u;
572 };
573
574 /* A type name. */
575 struct c_type_name {
576 /* The declaration specifiers. */
577 struct c_declspecs *specs;
578 /* The declarator. */
579 struct c_declarator *declarator;
580 };
581
582 /* A parameter. */
583 struct c_parm {
584 /* The declaration specifiers, minus any prefix attributes. */
585 struct c_declspecs *specs;
586 /* The attributes. */
587 tree attrs;
588 /* The declarator. */
589 struct c_declarator *declarator;
590 /* The location of the parameter. */
591 location_t loc;
592 };
593
594 /* Used when parsing an enum. Initialized by start_enum. */
595 struct c_enum_contents
596 {
597 /* While defining an enum type, this is 1 plus the last enumerator
598 constant value. */
599 tree enum_next_value;
600
601 /* The enumeration type itself. */
602 tree enum_type;
603
604 /* Nonzero means that there was overflow computing enum_next_value. */
605 int enum_overflow;
606 };
607
608 /* A type of reference to a static identifier in an inline
609 function. */
610 enum c_inline_static_type {
611 /* Identifier with internal linkage used in function that may be an
612 inline definition (i.e., file-scope static). */
613 csi_internal,
614 /* Modifiable object with static storage duration defined in
615 function that may be an inline definition (i.e., local
616 static). */
617 csi_modifiable
618 };
619
620
621 /* in c-parser.cc */
622 struct c_tree_token_vec;
623 extern void c_parse_init (void);
624 extern bool c_keyword_starts_typename (enum rid keyword);
625
626 /* in c-aux-info.cc */
627 extern void gen_aux_info_record (tree, int, int, int);
628
629 /* in c-decl.cc */
630 struct c_spot_bindings;
631 class c_struct_parse_info;
632 extern struct obstack parser_obstack;
633 /* Set to IN_ITERATION_STMT if parsing an iteration-statement,
634 to IN_OMP_BLOCK if parsing OpenMP structured block and
635 IN_OMP_FOR if parsing OpenMP loop. If parsing a switch statement,
636 this is bitwise ORed with IN_SWITCH_STMT, unless parsing an
637 iteration-statement, OpenMP block or loop within that switch.
638 If the innermost iteration/switch statement is named, IN_NAMED_STMT
639 is additionally bitwise ORed into it. */
640 #define IN_SWITCH_STMT 1
641 #define IN_ITERATION_STMT 2
642 #define IN_OMP_BLOCK 4
643 #define IN_OMP_FOR 8
644 #define IN_OBJC_FOREACH 16
645 #define IN_NAMED_STMT 32
646 extern unsigned char in_statement;
647
648 extern bool switch_statement_break_seen_p;
649
650 extern bool global_bindings_p (void);
651 extern tree pushdecl (tree);
652 extern unsigned int start_underspecified_init (location_t, tree);
653 extern void finish_underspecified_init (tree, unsigned int);
654 extern void push_scope (void);
655 extern tree pop_scope (void);
656 extern void c_mark_decl_jump_unsafe_in_current_scope ();
657 extern void c_bindings_start_stmt_expr (struct c_spot_bindings *);
658 extern void c_bindings_end_stmt_expr (struct c_spot_bindings *);
659
660 extern void record_inline_static (location_t, tree, tree,
661 enum c_inline_static_type);
662 extern void c_init_decl_processing (void);
663 extern void c_print_identifier (FILE *, tree, int);
664 extern int quals_from_declspecs (const struct c_declspecs *);
665 extern struct c_declarator *build_array_declarator (location_t, tree,
666 struct c_declspecs *,
667 bool, bool);
668 extern tree build_enumerator (location_t, location_t, struct c_enum_contents *,
669 tree, tree);
670 extern tree check_for_loop_decls (location_t, bool);
671 extern void mark_forward_parm_decls (void);
672 extern void declare_parm_level (void);
673 extern void undeclared_variable (location_t, tree);
674 extern tree lookup_label_for_goto (location_t, tree);
675 extern tree declare_label (tree);
676 extern tree define_label (location_t, tree);
677 extern struct c_spot_bindings *c_get_switch_bindings (void);
678 extern void c_release_switch_bindings (struct c_spot_bindings *);
679 extern bool c_check_switch_jump_warnings (struct c_spot_bindings *,
680 location_t, location_t);
681 extern void finish_decl (tree, location_t, tree, tree, tree);
682 extern tree finish_enum (tree, tree, tree);
683 extern void finish_function (location_t = input_location);
684 extern tree finish_struct (location_t, tree, tree, tree,
685 class c_struct_parse_info *,
686 tree *expr = NULL);
687 extern tree c_simulate_enum_decl (location_t, const char *,
688 vec<string_int_pair> *);
689 extern tree c_simulate_record_decl (location_t, const char *,
690 array_slice<const tree>);
691 extern struct c_arg_info *build_arg_info (void);
692 extern struct c_arg_info *get_parm_info (bool, tree);
693 extern tree grokfield (location_t, struct c_declarator *,
694 struct c_declspecs *, tree, tree *, tree *);
695 extern tree groktypename (struct c_type_name *, tree *, bool *);
696 extern tree grokparm (const struct c_parm *, tree *);
697 extern tree implicitly_declare (location_t, tree);
698 extern void keep_next_level (void);
699 extern void pending_xref_error (void);
700 extern void c_push_function_context (void);
701 extern void c_pop_function_context (void);
702 extern void push_parm_decl (const struct c_parm *, tree *);
703 extern struct c_declarator *set_array_declarator_inner (struct c_declarator *,
704 struct c_declarator *);
705 extern tree c_builtin_function (tree);
706 extern tree c_builtin_function_ext_scope (tree);
707 extern tree c_simulate_builtin_function_decl (tree);
708 extern void c_warn_unused_attributes (tree);
709 extern tree c_warn_type_attributes (tree, tree);
710 extern void shadow_tag (const struct c_declspecs *);
711 extern void shadow_tag_warned (const struct c_declspecs *, int);
712 extern tree start_enum (location_t, struct c_enum_contents *, tree, tree,
713 bool potential_nesting_p);
714 extern bool start_function (struct c_declspecs *, struct c_declarator *, tree);
715 extern tree start_decl (struct c_declarator *, struct c_declspecs *, bool,
716 tree, bool = true, location_t * = NULL);
717 extern tree start_struct (location_t, enum tree_code, tree,
718 class c_struct_parse_info **);
719 extern void store_parm_decls (void);
720 extern void store_parm_decls_from (struct c_arg_info *);
721 extern void temp_store_parm_decls (tree, tree);
722 extern void temp_pop_parm_decls (void);
723 extern tree xref_tag (enum tree_code, tree);
724 extern struct c_typespec parser_xref_tag (location_t, enum tree_code, tree,
725 bool, tree, bool);
726 extern struct c_parm *build_c_parm (struct c_declspecs *, tree,
727 struct c_declarator *, location_t);
728 extern struct c_declarator *build_attrs_declarator (tree,
729 struct c_declarator *);
730 extern struct c_declarator *build_function_declarator (struct c_arg_info *,
731 struct c_declarator *);
732 extern struct c_declarator *build_id_declarator (tree);
733 extern struct c_declarator *make_pointer_declarator (struct c_declspecs *,
734 struct c_declarator *);
735 extern struct c_declspecs *build_null_declspecs (void);
736 extern struct c_declspecs *declspecs_add_qual (location_t,
737 struct c_declspecs *, tree);
738 extern struct c_declspecs *declspecs_add_type (location_t,
739 struct c_declspecs *,
740 struct c_typespec);
741 extern struct c_declspecs *declspecs_add_scspec (location_t,
742 struct c_declspecs *, tree);
743 extern struct c_declspecs *declspecs_add_attrs (location_t,
744 struct c_declspecs *, tree);
745 extern struct c_declspecs *declspecs_add_addrspace (location_t,
746 struct c_declspecs *,
747 addr_space_t);
748 extern struct c_declspecs *declspecs_add_alignas (location_t,
749 struct c_declspecs *, tree);
750 extern struct c_declspecs *finish_declspecs (struct c_declspecs *);
751 extern size_t c_tree_size (enum tree_code);
752 extern int c_get_loop_names (tree, bool, tree *);
753 extern void c_release_loop_names (int);
754 extern tree c_finish_bc_name (location_t, tree, bool);
755
756 /* in c-objc-common.cc */
757 extern bool c_objc_common_init (void);
758 extern bool c_missing_noreturn_ok_p (tree);
759 extern bool c_warn_unused_global_decl (const_tree);
760 extern void c_initialize_diagnostics (diagnostic_context *);
761 extern bool c_var_mod_p (tree x, tree fn);
762 extern alias_set_type c_get_alias_set (tree);
763 extern int c_type_dwarf_attribute (const_tree, int);
764
765 /* in c-typeck.cc */
766 extern int in_alignof;
767 extern int in_sizeof;
768 extern int in_typeof;
769 extern bool c_in_omp_for;
770 extern bool c_omp_array_section_p;
771
772 extern tree c_last_sizeof_arg;
773 extern location_t c_last_sizeof_loc;
774
775 extern struct c_switch *c_switch_stack;
776
777 extern bool null_pointer_constant_p (const_tree);
778
779
780 inline bool
781 c_type_variably_modified_p (tree t)
782 {
783 return error_mark_node != t && C_TYPE_VARIABLY_MODIFIED (t);
784 }
785
786 inline bool
787 c_type_unspecified_p (tree t)
788 {
789 return error_mark_node != t
790 && C_TYPE_VARIABLE_SIZE (t) && TREE_CODE (t) == ARRAY_TYPE
791 && TYPE_DOMAIN (t) && TYPE_MAX_VALUE (TYPE_DOMAIN (t))
792 && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) == COMPOUND_EXPR
793 && integer_zerop (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0))
794 && integer_zerop (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 1));
795 }
796
797 extern bool char_type_p (tree);
798 extern tree c_type_tag (const_tree t);
799 extern tree c_objc_common_truthvalue_conversion (location_t, tree,
800 tree = integer_type_node);
801 extern tree require_complete_type (location_t, tree);
802 extern bool same_translation_unit_p (const_tree, const_tree);
803 extern int comptypes (tree, tree);
804 extern bool comptypes_same_p (tree, tree);
805 extern bool comptypes_equiv_p (tree, tree);
806 extern int comptypes_check_different_types (tree, tree, bool *);
807 extern int comptypes_check_enum_int (tree, tree, bool *);
808 extern bool c_mark_addressable (tree, bool = false);
809 extern void c_incomplete_type_error (location_t, const_tree, const_tree);
810 extern tree c_type_promotes_to (tree);
811 extern struct c_expr default_function_array_conversion (location_t,
812 struct c_expr);
813 extern struct c_expr default_function_array_read_conversion (location_t,
814 struct c_expr);
815 extern struct c_expr convert_lvalue_to_rvalue (location_t, struct c_expr,
816 bool, bool, bool = false);
817 extern tree decl_constant_value_1 (tree, bool);
818 extern void mark_exp_read (tree);
819 extern tree composite_type (tree, tree);
820 extern tree lookup_field (const_tree, tree);
821 extern tree build_component_ref (location_t, tree, tree, location_t,
822 location_t, bool = true);
823 extern tree handle_counted_by_for_component_ref (location_t, tree);
824 extern tree build_array_ref (location_t, tree, tree);
825 extern tree build_omp_array_section (location_t, tree, tree, tree);
826 extern tree build_external_ref (location_t, tree, bool, tree *);
827 extern void pop_maybe_used (bool);
828 extern struct c_expr c_expr_sizeof_expr (location_t, struct c_expr);
829 extern struct c_expr c_expr_sizeof_type (location_t, struct c_type_name *);
830 extern struct c_expr parser_build_unary_op (location_t, enum tree_code,
831 struct c_expr);
832 extern struct c_expr parser_build_binary_op (location_t,
833 enum tree_code, struct c_expr,
834 struct c_expr);
835 extern tree build_conditional_expr (location_t, tree, bool, tree, tree,
836 location_t, tree, tree, location_t);
837 extern tree build_compound_expr (location_t, tree, tree);
838 extern tree c_cast_expr (location_t, struct c_type_name *, tree);
839 extern tree build_c_cast (location_t, tree, tree);
840 extern void store_init_value (location_t, tree, tree, tree);
841 extern void maybe_warn_string_init (location_t, tree, struct c_expr);
842 extern void start_init (tree, tree, bool, bool, rich_location *);
843 extern void finish_init (void);
844 extern void really_start_incremental_init (tree);
845 extern void finish_implicit_inits (location_t, struct obstack *);
846 extern void push_init_level (location_t, int, struct obstack *);
847 extern struct c_expr pop_init_level (location_t, int, struct obstack *,
848 location_t);
849 extern void set_init_index (location_t, tree, tree, struct obstack *);
850 extern void set_init_label (location_t, tree, location_t, struct obstack *);
851 unsigned c_maybe_optimize_large_byte_initializer (void);
852 extern void process_init_element (location_t, struct c_expr, bool,
853 struct obstack *);
854 extern tree build_compound_literal (location_t, tree, tree, bool,
855 unsigned int, struct c_declspecs *);
856 extern void check_compound_literal_type (location_t, struct c_type_name *);
857 extern tree c_start_switch (location_t, location_t, tree, bool, tree);
858 extern void c_finish_switch (tree, tree);
859 extern tree build_asm_expr (location_t, tree, tree, tree, tree, tree, bool,
860 bool);
861 extern tree build_asm_stmt (bool, tree);
862 extern int c_types_compatible_p (tree, tree);
863 extern tree c_begin_compound_stmt (bool);
864 extern tree c_end_compound_stmt (location_t, tree, bool);
865 extern void c_finish_if_stmt (location_t, tree, tree, tree);
866 extern void c_finish_loop (location_t, location_t, tree, location_t, tree,
867 tree, tree, tree, bool);
868 extern tree c_begin_stmt_expr (void);
869 extern tree c_finish_stmt_expr (location_t, tree);
870 extern tree c_process_expr_stmt (location_t, tree);
871 extern tree c_finish_expr_stmt (location_t, tree);
872 extern tree c_finish_return (location_t, tree, tree, bool = false);
873 extern tree c_finish_bc_stmt (location_t, tree, bool, tree);
874 extern tree c_finish_goto_label (location_t, tree);
875 extern tree c_finish_goto_ptr (location_t, c_expr val);
876 extern tree c_expr_to_decl (tree, bool *, bool *);
877 extern tree c_finish_omp_construct (location_t, enum tree_code, tree, tree);
878 extern tree c_finish_oacc_data (location_t, tree, tree);
879 extern tree c_finish_oacc_host_data (location_t, tree, tree);
880 extern tree c_begin_omp_parallel (void);
881 extern tree c_finish_omp_parallel (location_t, tree, tree);
882 extern tree c_begin_omp_task (void);
883 extern tree c_finish_omp_task (location_t, tree, tree);
884 extern void c_finish_omp_cancel (location_t, tree);
885 extern void c_finish_omp_cancellation_point (location_t, tree);
886 extern tree c_finish_omp_clauses (tree, enum c_omp_region_type);
887 extern tree c_build_va_arg (location_t, tree, location_t, tree);
888 extern tree c_finish_transaction (location_t, tree, int);
889 extern bool c_tree_equal (tree, tree);
890 extern tree c_build_function_call_vec (location_t, const vec<location_t>&,
891 tree, vec<tree, va_gc> *,
892 vec<tree, va_gc> *);
893 extern tree c_omp_clause_copy_ctor (tree, tree, tree);
894 extern tree c_reconstruct_complex_type (tree, tree);
895 extern tree c_type_canonical (tree);
896 extern tree c_build_type_attribute_variant (tree ntype, tree attrs);
897 extern tree c_build_pointer_type (tree type);
898 extern tree c_build_array_type (tree type, tree domain);
899 extern tree c_build_array_type_unspecified (tree type);
900 extern tree c_build_function_type (tree type, tree args, bool no = false);
901 extern tree c_build_pointer_type_for_mode (tree type, machine_mode mode, bool m);
902
903 /* Set to 0 at beginning of a function definition, set to 1 if
904 a return statement that specifies a return value is seen. */
905
906 extern int current_function_returns_value;
907
908 /* Set to 0 at beginning of a function definition, set to 1 if
909 a return statement with no argument is seen. */
910
911 extern int current_function_returns_null;
912
913 /* Set to 0 at beginning of a function definition, set to 1 if
914 a call to a noreturn function is seen. */
915
916 extern int current_function_returns_abnormally;
917
918 /* In c-decl.cc */
919
920 /* Tell the binding oracle what kind of binding we are looking for. */
921
922 enum c_oracle_request
923 {
924 C_ORACLE_SYMBOL,
925 C_ORACLE_TAG,
926 C_ORACLE_LABEL
927 };
928
929 /* If this is non-NULL, then it is a "binding oracle" which can lazily
930 create bindings when needed by the C compiler. The oracle is told
931 the name and type of the binding to create. It can call pushdecl
932 or the like to ensure the binding is visible; or do nothing,
933 leaving the binding untouched. c-decl.cc takes note of when the
934 oracle has been called and will not call it again if it fails to
935 create a given binding. */
936
937 typedef void c_binding_oracle_function (enum c_oracle_request, tree identifier);
938
939 extern c_binding_oracle_function *c_binding_oracle;
940
941 extern void c_finish_incomplete_decl (tree);
942 extern tree c_omp_reduction_id (enum tree_code, tree);
943 extern tree c_omp_reduction_decl (tree);
944 extern tree c_omp_reduction_lookup (tree, tree);
945 extern tree c_check_omp_declare_reduction_r (tree *, int *, void *);
946 extern bool c_check_in_current_scope (tree);
947 extern void c_pushtag (location_t, tree, tree);
948 extern void c_bind (location_t, tree, bool);
949 extern bool tag_exists_p (enum tree_code, tree);
950
951 /* In c-errors.cc */
952 extern bool pedwarn_c90 (location_t, diagnostic_option_id, const char *, ...)
953 ATTRIBUTE_GCC_DIAG(3,4);
954 extern bool pedwarn_c99 (location_t, diagnostic_option_id, const char *, ...)
955 ATTRIBUTE_GCC_DIAG(3,4);
956 extern bool pedwarn_c11 (location_t, diagnostic_option_id, const char *, ...)
957 ATTRIBUTE_GCC_DIAG(3,4);
958 extern bool pedwarn_c23 (location_t, diagnostic_option_id, const char *, ...)
959 ATTRIBUTE_GCC_DIAG(3,4);
960 extern void add_note_about_new_keyword (location_t loc,
961 tree keyword_id);
962
963 extern void
964 set_c_expr_source_range (c_expr *expr,
965 location_t start, location_t finish);
966
967 extern void
968 set_c_expr_source_range (c_expr *expr,
969 source_range src_range);
970
971 /* In c-fold.cc */
972 extern vec<tree> incomplete_record_decls;
973
974 extern const char *c_get_sarif_source_language (const char *filename);
975
976 extern const struct scoped_attribute_specs std_attribute_table;
977
978 #if CHECKING_P
979 namespace selftest {
980 extern void run_c_tests (void);
981 } // namespace selftest
982 #endif /* #if CHECKING_P */
983
984
985 #endif /* ! GCC_C_TREE_H */