]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/c/c-tree.h
Merge remote-tracking branch 'origin/master' into devel/c++-contracts
[thirdparty/gcc.git] / gcc / c / c-tree.h
CommitLineData
40754343 1/* Definitions for C parsing and type checking.
7adcbafe 2 Copyright (C) 1987-2022 Free Software Foundation, Inc.
40754343 3
1322177d 4This file is part of GCC.
40754343 5
1322177d
LB
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
9dcd6f09 8Software Foundation; either version 3, or (at your option) any later
1322177d 9version.
40754343 10
1322177d
LB
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
40754343
RS
15
16You should have received a copy of the GNU General Public License
9dcd6f09
NC
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
40754343 19
88657302
RH
20#ifndef GCC_C_TREE_H
21#define GCC_C_TREE_H
cf1c49cb 22
39dabefd 23#include "c-family/c-common.h"
ede1a387 24#include "diagnostic.h"
7f4edbcb 25
e53b6e56
ML
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. */
18d5f982
ZW
28#define C_SIZEOF_STRUCT_LANG_IDENTIFIER \
29 (sizeof (struct c_common_identifier) + 3 * sizeof (void *))
40754343 30
40754343 31/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only. */
a8086abf 32#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1 (TYPE)
40754343
RS
33
34/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is volatile. */
a8086abf 35#define C_TYPE_FIELDS_VOLATILE(TYPE) TREE_LANG_FLAG_2 (TYPE)
40754343
RS
36
37/* In a RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE
38 nonzero if the definition of the type has already started. */
a8086abf 39#define C_TYPE_BEING_DEFINED(TYPE) TYPE_LANG_FLAG_0 (TYPE)
bf7a697f 40
046c5890
JJ
41/* In an incomplete RECORD_TYPE, UNION_TYPE or ENUMERAL_TYPE, a list of
42 variable declarations whose type would be completed by completing
43 that type. */
44#define C_TYPE_INCOMPLETE_VARS(TYPE) \
45 TYPE_LANG_SLOT_1 (TREE_CHECK4 (TYPE, RECORD_TYPE, UNION_TYPE, \
46 QUAL_UNION_TYPE, ENUMERAL_TYPE))
40754343 47
0e5921e8 48/* In an IDENTIFIER_NODE, nonzero if this identifier is actually a
ee3ff394 49 keyword. C_RID_CODE (node) is then the RID_* value of the keyword. */
a8086abf 50#define C_IS_RESERVED_WORD(ID) TREE_LANG_FLAG_0 (ID)
0e5921e8 51
40754343
RS
52/* Record whether a type or decl was written with nonconstant size.
53 Note that TYPE_SIZE may have simplified to a constant. */
a8086abf
GS
54#define C_TYPE_VARIABLE_SIZE(TYPE) TYPE_LANG_FLAG_1 (TYPE)
55#define C_DECL_VARIABLE_SIZE(TYPE) DECL_LANG_FLAG_0 (TYPE)
40754343 56
24b97832
ILT
57/* Record whether a type is defined inside a struct or union type.
58 This is used for -Wc++-compat. */
59#define C_TYPE_DEFINED_IN_STRUCT(TYPE) TYPE_LANG_FLAG_2 (TYPE)
60
40754343 61/* Record whether a typedef for type `int' was actually `signed int'. */
a8086abf 62#define C_TYPEDEF_EXPLICITLY_SIGNED(EXP) DECL_LANG_FLAG_1 (EXP)
40754343 63
5ce89b2e
JM
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
339a28b9
ZW
68/* For a FUNCTION_DECL, nonzero if it was an implicit declaration. */
69#define C_DECL_IMPLICIT(EXP) DECL_LANG_FLAG_2 (EXP)
70
773ec47f
MP
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
f75fbaf7
ZW
74/* For FUNCTION_DECLs, evaluates true if the decl is built-in but has
75 been declared. */
187230a7
JM
76#define C_DECL_DECLARED_BUILTIN(EXP) \
77 DECL_LANG_FLAG_3 (FUNCTION_DECL_CHECK (EXP))
339a28b9 78
6fb58bba
JM
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
5baeaac0
JM
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. */
9aaabf8a 87#define C_DECL_REGISTER(EXP) DECL_LANG_FLAG_4 (EXP)
5baeaac0 88
bc4b653b
JM
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. */
187230a7 93#define C_DECL_USED(EXP) DECL_LANG_FLAG_5 (FUNCTION_DECL_CHECK (EXP))
bc4b653b 94
953ff289
DN
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
fe509359
JJ
99/* Set on VAR_DECLs for compound literals. */
100#define C_DECL_COMPOUND_LITERAL_P(DECL) \
101 DECL_LANG_FLAG_5 (VAR_DECL_CHECK (DECL))
102
339a28b9
ZW
103/* Nonzero for a decl which either doesn't exist or isn't a prototype.
104 N.B. Could be simplified if all built-in decls had complete prototypes
105 (but this is presently difficult because some of them need FILE*). */
106#define C_DECL_ISNT_PROTOTYPE(EXP) \
107 (EXP == 0 \
f4da8dce 108 || (!prototype_p (TREE_TYPE (EXP)) \
3d78e008 109 && !fndecl_built_in_p (EXP)))
96735c06 110
40754343
RS
111/* For FUNCTION_TYPE, a hidden list of types of arguments. The same as
112 TYPE_ARG_TYPES for functions with prototypes, but created for functions
113 without prototypes. */
046c5890
JJ
114#define TYPE_ACTUAL_ARG_TYPES(NODE) \
115 TYPE_LANG_SLOT_1 (FUNCTION_TYPE_CHECK (NODE))
4e28fa00 116
928c19bb
JM
117/* For a CONSTRUCTOR, whether some initializer contains a
118 subexpression meaning it is not a constant expression. */
119#define CONSTRUCTOR_NON_CONST(EXPR) TREE_LANG_FLAG_1 (CONSTRUCTOR_CHECK (EXPR))
120
b2fa0a8b
MP
121/* For a SAVE_EXPR, nonzero if the operand of the SAVE_EXPR has already
122 been folded. */
123#define SAVE_EXPR_FOLDED_P(EXP) TREE_LANG_FLAG_1 (SAVE_EXPR_CHECK (EXP))
124
e0997c14
JM
125/* Whether a type has boolean semantics: either a boolean type or an
126 enumeration type with a boolean type as its underlying type. */
127#define C_BOOLEAN_TYPE_P(TYPE) \
128 (TREE_CODE (TYPE) == BOOLEAN_TYPE \
129 || (TREE_CODE (TYPE) == ENUMERAL_TYPE \
130 && ENUM_UNDERLYING_TYPE (TYPE) != NULL_TREE \
131 && TREE_CODE (ENUM_UNDERLYING_TYPE (TYPE)) == BOOLEAN_TYPE))
132
487a92fe
JM
133/* Record parser information about an expression that is irrelevant
134 for code generation alongside a tree representing its value. */
135struct c_expr
136{
137 /* The value of the expression. */
138 tree value;
100d537d 139 /* Record the original unary/binary operator of an expression, which may
647eea9d 140 have been changed by fold, STRING_CST for unparenthesized string
928c19bb
JM
141 constants, C_MAYBE_CONST_EXPR for __builtin_constant_p calls
142 (even if parenthesized), for subexpressions, and for non-constant
143 initializers, or ERROR_MARK for other expressions (including
916c5919 144 parenthesized expressions). */
487a92fe 145 enum tree_code original_code;
6866c6e8
ILT
146 /* If not NULL, the original type of an expression. This will
147 differ from the type of the value field for an enum constant.
148 The type of an enum constant is a plain integer type, but this
149 field will be the enum type. */
150 tree original_type;
ebedc9a3
DM
151
152 /* The source range of this expression. This is redundant
153 for node values that have locations, but not all node kinds
154 have locations (e.g. constants, and references to params, locals,
155 etc), so we stash a copy here. */
156 source_range src_range;
157
bedfca64
DM
158 /* True if this was directly from a decimal constant token. */
159 bool m_decimal : 1;
160
ebedc9a3
DM
161 /* Access to the first and last locations within the source spelling
162 of this expression. */
163 location_t get_start () const { return src_range.m_start; }
164 location_t get_finish () const { return src_range.m_finish; }
8a40fef3 165
7f204c0f
DM
166 location_t get_location () const
167 {
14e18d71 168 if (EXPR_HAS_LOCATION (value))
7f204c0f
DM
169 return EXPR_LOCATION (value);
170 else
171 return make_location (get_start (), get_start (), get_finish ());
172 }
173
8a40fef3 174 /* Set the value to error_mark_node whilst ensuring that src_range
86254629 175 and m_decimal are initialized. */
8a40fef3
DM
176 void set_error ()
177 {
178 value = error_mark_node;
179 src_range.m_start = UNKNOWN_LOCATION;
180 src_range.m_finish = UNKNOWN_LOCATION;
86254629 181 m_decimal = 0;
8a40fef3 182 }
487a92fe
JM
183};
184
86785830
AS
185/* Type alias for struct c_expr. This allows to use the structure
186 inside the VEC types. */
187typedef struct c_expr c_expr_t;
188
81da229b
JM
189/* A kind of type specifier. Note that this information is currently
190 only used to distinguish tag definitions, tag references and typeof
191 uses. */
192enum c_typespec_kind {
9e5b2115
PB
193 /* No typespec. This appears only in struct c_declspec. */
194 ctsk_none,
81da229b
JM
195 /* A reserved keyword type specifier. */
196 ctsk_resword,
197 /* A reference to a tag, previously declared, such as "struct foo".
198 This includes where the previous declaration was as a different
199 kind of tag, in which case this is only valid if shadowing that
200 tag in an inner scope. */
201 ctsk_tagref,
4e03c3a7
JM
202 /* Likewise, with standard attributes present in the reference. */
203 ctsk_tagref_attrs,
81da229b
JM
204 /* A reference to a tag, not previously declared in a visible
205 scope. */
206 ctsk_tagfirstref,
4e03c3a7
JM
207 /* Likewise, with standard attributes present in the reference. */
208 ctsk_tagfirstref_attrs,
81da229b
JM
209 /* A definition of a tag such as "struct foo { int a; }". */
210 ctsk_tagdef,
211 /* A typedef name. */
212 ctsk_typedef,
213 /* An ObjC-specific kind of type specifier. */
214 ctsk_objc,
267bac10 215 /* A typeof specifier, or _Atomic ( type-name ). */
81da229b
JM
216 ctsk_typeof
217};
218
219/* A type specifier: this structure is created in the parser and
220 passed to declspecs_add_type only. */
221struct c_typespec {
222 /* What kind of type specifier this is. */
223 enum c_typespec_kind kind;
8415f317
NF
224 /* Whether the expression has operands suitable for use in constant
225 expressions. */
226 bool expr_const_operands;
e0997c14
JM
227 /* Whether the type specifier includes an enum type specifier (that
228 is, ": specifier-qualifier-list" in a declaration using
229 "enum"). */
230 bool has_enum_type_specifier;
81da229b
JM
231 /* The specifier itself. */
232 tree spec;
928c19bb
JM
233 /* An expression to be evaluated before the type specifier, in the
234 case of typeof specifiers, or NULL otherwise or if no such
235 expression is required for a particular typeof specifier. In
236 particular, when typeof is applied to an expression of variably
237 modified type, that expression must be evaluated in order to
238 determine array sizes that form part of the type, but the
239 expression itself (as opposed to the array sizes) forms no part
240 of the type and so needs to be recorded separately. */
241 tree expr;
81da229b
JM
242};
243
d6a1dfd9
JM
244/* A storage class specifier. */
245enum c_storage_class {
246 csc_none,
247 csc_auto,
248 csc_extern,
249 csc_register,
250 csc_static,
251 csc_typedef
252};
253
98c3a782 254/* A type specifier keyword "void", "_Bool", "char", "int", "float",
ab22c1fa
CF
255 "double", "_Decimal32", "_Decimal64", "_Decimal128", "_Fract", "_Accum",
256 or none of these. */
98c3a782
JM
257enum c_typespec_keyword {
258 cts_none,
259 cts_void,
260 cts_bool,
261 cts_char,
262 cts_int,
263 cts_float,
78a7c317 264 cts_int_n,
9a8ce21f
JG
265 cts_double,
266 cts_dfloat32,
267 cts_dfloat64,
ab22c1fa 268 cts_dfloat128,
c65699ef 269 cts_floatn_nx,
ab22c1fa 270 cts_fract,
38b7bc7f
JM
271 cts_accum,
272 cts_auto_type
98c3a782
JM
273};
274
0b2c4be5
DS
275/* This enum lists all the possible declarator specifiers, storage
276 class or attribute that a user can write. There is at least one
277 enumerator per possible declarator specifier in the struct
278 c_declspecs below.
279
280 It is used to index the array of declspec locations in struct
281 c_declspecs. */
282enum c_declspec_word {
283 cdw_typespec /* A catch-all for a typespec. */,
284 cdw_storage_class /* A catch-all for a storage class */,
285 cdw_attributes,
286 cdw_typedef,
287 cdw_explicit_signed,
288 cdw_deprecated,
289 cdw_default_int,
290 cdw_long,
291 cdw_long_long,
292 cdw_short,
293 cdw_signed,
294 cdw_unsigned,
295 cdw_complex,
296 cdw_inline,
297 cdw_noreturn,
298 cdw_thread,
299 cdw_const,
300 cdw_volatile,
301 cdw_restrict,
d6e83a8d 302 cdw_atomic,
0b2c4be5
DS
303 cdw_saturating,
304 cdw_alignas,
305 cdw_address_space,
1ee62b92 306 cdw_gimple,
c2e84327 307 cdw_rtl,
0b2c4be5
DS
308 cdw_number_of_elements /* This one must always be the last
309 enumerator. */
310};
311
baa09dc5
RB
312enum c_declspec_il {
313 cdil_none,
314 cdil_gimple, /* __GIMPLE */
315 cdil_gimple_cfg, /* __GIMPLE(cfg) */
316 cdil_gimple_ssa, /* __GIMPLE(ssa) */
317 cdil_rtl /* __RTL */
318};
319
0b2c4be5
DS
320/* A sequence of declaration specifiers in C. When a new declaration
321 specifier is added, please update the enum c_declspec_word above
322 accordingly. */
deb176fa 323struct c_declspecs {
620e594b 324 location_t locations[cdw_number_of_elements];
98c3a782
JM
325 /* The type specified, if a single type specifier such as a struct,
326 union or enum specifier, typedef name or typeof specifies the
327 whole type, or NULL_TREE if none or a keyword such as "void" or
328 "char" is used. Does not include qualifiers. */
deb176fa 329 tree type;
928c19bb
JM
330 /* Any expression to be evaluated before the type, from a typeof
331 specifier. */
332 tree expr;
deb176fa
JM
333 /* The attributes from a typedef decl. */
334 tree decl_attr;
4e03c3a7
JM
335 /* When parsing, the GNU attributes and prefix standard attributes.
336 Outside the parser, this will be NULL; attributes (possibly from
337 multiple lists) will be passed separately. */
deb176fa 338 tree attrs;
4e03c3a7
JM
339 /* When parsing, postfix standard attributes (which appertain to the
340 type specified by the preceding declaration specifiers, unlike
341 prefix standard attributes which appertain to the declaration or
342 declarations as a whole). */
343 tree postfix_attrs;
c2e84327
DM
344 /* The pass to start compiling a __GIMPLE or __RTL function with. */
345 char *gimple_or_rtl_pass;
d276406a
ML
346 /* ENTRY BB count. */
347 profile_count entry_bb_count;
d19fa6b5
JM
348 /* The base-2 log of the greatest alignment required by an _Alignas
349 specifier, in bytes, or -1 if no such specifiers with nonzero
350 alignment. */
351 int align_log;
78a7c317
DD
352 /* For the __intN declspec, this stores the index into the int_n_* arrays. */
353 int int_n_idx;
c65699ef
JM
354 /* For the _FloatN and _FloatNx declspec, this stores the index into
355 the floatn_nx_types array. */
356 int floatn_nx_idx;
d6a1dfd9
JM
357 /* The storage class specifier, or csc_none if none. */
358 enum c_storage_class storage_class;
8415f317
NF
359 /* Any type specifier keyword used such as "int", not reflecting
360 modifiers such as "short", or cts_none if none. */
361 ENUM_BITFIELD (c_typespec_keyword) typespec_word : 8;
9e5b2115
PB
362 /* The kind of type specifier if one has been seen, ctsk_none
363 otherwise. */
4e03c3a7 364 ENUM_BITFIELD (c_typespec_kind) typespec_kind : 4;
baa09dc5 365 ENUM_BITFIELD (c_declspec_il) declspec_il : 3;
928c19bb
JM
366 /* Whether any expressions in typeof specifiers may appear in
367 constant expressions. */
368 BOOL_BITFIELD expr_const_operands : 1;
27bf414c
JM
369 /* Whether any declaration specifiers have been seen at all. */
370 BOOL_BITFIELD declspecs_seen_p : 1;
4e03c3a7
JM
371 /* Whether any declaration specifiers other than standard attributes
372 have been seen at all. If only standard attributes have been
373 seen, this is an attribute-declaration. */
374 BOOL_BITFIELD non_std_attrs_seen_p : 1;
deb176fa
JM
375 /* Whether something other than a storage class specifier or
376 attribute has been seen. This is used to warn for the
377 obsolescent usage of storage class specifiers other than at the
378 start of the list. (Doing this properly would require function
379 specifiers to be handled separately from storage class
380 specifiers.) */
381 BOOL_BITFIELD non_sc_seen_p : 1;
81da229b 382 /* Whether the type is specified by a typedef or typeof name. */
616aeba2 383 BOOL_BITFIELD typedef_p : 1;
98c3a782
JM
384 /* Whether the type is explicitly "signed" or specified by a typedef
385 whose type is explicitly "signed". */
386 BOOL_BITFIELD explicit_signed_p : 1;
deb176fa
JM
387 /* Whether the specifiers include a deprecated typedef. */
388 BOOL_BITFIELD deprecated_p : 1;
8433baad
IS
389 /* Whether the specifiers include an unavailable typedef. */
390 BOOL_BITFIELD unavailable_p : 1;
98c3a782
JM
391 /* Whether the type defaulted to "int" because there were no type
392 specifiers. */
8415f317 393 BOOL_BITFIELD default_int_p : 1;
98c3a782
JM
394 /* Whether "long" was specified. */
395 BOOL_BITFIELD long_p : 1;
deb176fa
JM
396 /* Whether "long" was specified more than once. */
397 BOOL_BITFIELD long_long_p : 1;
98c3a782
JM
398 /* Whether "short" was specified. */
399 BOOL_BITFIELD short_p : 1;
400 /* Whether "signed" was specified. */
401 BOOL_BITFIELD signed_p : 1;
402 /* Whether "unsigned" was specified. */
403 BOOL_BITFIELD unsigned_p : 1;
404 /* Whether "complex" was specified. */
405 BOOL_BITFIELD complex_p : 1;
d6a1dfd9
JM
406 /* Whether "inline" was specified. */
407 BOOL_BITFIELD inline_p : 1;
bbceee64
JM
408 /* Whether "_Noreturn" was speciied. */
409 BOOL_BITFIELD noreturn_p : 1;
582d9b50 410 /* Whether "__thread" or "_Thread_local" was specified. */
d6a1dfd9 411 BOOL_BITFIELD thread_p : 1;
582d9b50
JM
412 /* Whether "__thread" rather than "_Thread_local" was specified. */
413 BOOL_BITFIELD thread_gnu_p : 1;
3b53cddc
JM
414 /* Whether "const" was specified. */
415 BOOL_BITFIELD const_p : 1;
416 /* Whether "volatile" was specified. */
417 BOOL_BITFIELD volatile_p : 1;
418 /* Whether "restrict" was specified. */
419 BOOL_BITFIELD restrict_p : 1;
267bac10
JM
420 /* Whether "_Atomic" was specified. */
421 BOOL_BITFIELD atomic_p : 1;
ab22c1fa
CF
422 /* Whether "_Sat" was specified. */
423 BOOL_BITFIELD saturating_p : 1;
d19fa6b5
JM
424 /* Whether any alignment specifier (even with zero alignment) was
425 specified. */
426 BOOL_BITFIELD alignas_p : 1;
e0997c14
JM
427 /* Whether an enum type specifier (": specifier-qualifier-list") was
428 specified other than in a definition of that enum (if so, this is
429 invalid unless it is an empty declaration "enum identifier
430 enum-type-specifier;", but such an empty declaration is valid in
431 C2x when "enum identifier;" would not be). */
432 BOOL_BITFIELD enum_type_specifier_ref_p : 1;
36c5e70a
BE
433 /* The address space that the declaration belongs to. */
434 addr_space_t address_space;
deb176fa
JM
435};
436
f8893e47
JM
437/* The various kinds of declarators in C. */
438enum c_declarator_kind {
439 /* An identifier. */
440 cdk_id,
441 /* A function. */
442 cdk_function,
443 /* An array. */
444 cdk_array,
445 /* A pointer. */
446 cdk_pointer,
447 /* Parenthesized declarator with nested attributes. */
448 cdk_attrs
449};
450
a79683d5 451struct c_arg_tag {
e60bf9d4
NF
452 /* The argument name. */
453 tree id;
454 /* The type of the argument. */
455 tree type;
a79683d5 456};
e60bf9d4 457
e60bf9d4 458
f8893e47
JM
459/* Information about the parameters in a function declarator. */
460struct c_arg_info {
461 /* A list of parameter decls. */
462 tree parms;
463 /* A list of structure, union and enum tags defined. */
9771b263 464 vec<c_arg_tag, va_gc> *tags;
f8893e47
JM
465 /* A list of argument types to go in the FUNCTION_TYPE. */
466 tree types;
467 /* A list of non-parameter decls (notably enumeration constants)
468 defined with the parameters. */
469 tree others;
a04a722b
JM
470 /* A compound expression of VLA sizes from the parameters, or NULL.
471 In a function definition, these are used to ensure that
472 side-effects in sizes of arrays converted to pointers (such as a
473 parameter int i[n++]) take place; otherwise, they are
474 ignored. */
475 tree pending_sizes;
52ffd86e
MS
476 /* True when these arguments had [*]. */
477 BOOL_BITFIELD had_vla_unspec : 1;
4fe34cdc
JM
478 /* True when the arguments are a (...) prototype. */
479 BOOL_BITFIELD no_named_args_stdarg_p : 1;
f8893e47
JM
480};
481
482/* A declarator. */
483struct c_declarator {
484 /* The kind of declarator. */
485 enum c_declarator_kind kind;
8415f317 486 location_t id_loc; /* Currently only set for cdk_id, cdk_array. */
f8893e47
JM
487 /* Except for cdk_id, the contained declarator. For cdk_id, NULL. */
488 struct c_declarator *declarator;
489 union {
1723e1be
JM
490 /* For identifiers. */
491 struct {
492 /* An IDENTIFIER_NODE, or NULL_TREE if an abstract
493 declarator. */
494 tree id;
495 /* Any attributes (which apply to the declaration rather than to
496 the type described by the outer declarators). */
497 tree attrs;
498 } id;
f8893e47
JM
499 /* For functions. */
500 struct c_arg_info *arg_info;
501 /* For arrays. */
502 struct {
503 /* The array dimension, or NULL for [] and [*]. */
504 tree dimen;
3b53cddc
JM
505 /* The qualifiers inside []. */
506 int quals;
507 /* The attributes (currently ignored) inside []. */
508 tree attrs;
f8893e47
JM
509 /* Whether [static] was used. */
510 BOOL_BITFIELD static_p : 1;
511 /* Whether [*] was used. */
512 BOOL_BITFIELD vla_unspec_p : 1;
513 } array;
514 /* For pointers, the qualifiers on the pointer type. */
3b53cddc 515 int pointer_quals;
f8893e47
JM
516 /* For attributes. */
517 tree attrs;
518 } u;
519};
520
521/* A type name. */
522struct c_type_name {
523 /* The declaration specifiers. */
deb176fa 524 struct c_declspecs *specs;
f8893e47
JM
525 /* The declarator. */
526 struct c_declarator *declarator;
527};
528
529/* A parameter. */
530struct c_parm {
531 /* The declaration specifiers, minus any prefix attributes. */
deb176fa 532 struct c_declspecs *specs;
f8893e47
JM
533 /* The attributes. */
534 tree attrs;
535 /* The declarator. */
536 struct c_declarator *declarator;
8139a48e
DM
537 /* The location of the parameter. */
538 location_t loc;
f8893e47
JM
539};
540
7114359f
TT
541/* Used when parsing an enum. Initialized by start_enum. */
542struct c_enum_contents
543{
544 /* While defining an enum type, this is 1 plus the last enumerator
545 constant value. */
546 tree enum_next_value;
547
e0997c14
JM
548 /* The enumeration type itself. */
549 tree enum_type;
550
7114359f
TT
551 /* Nonzero means that there was overflow computing enum_next_value. */
552 int enum_overflow;
553};
554
991d6621
JM
555/* A type of reference to a static identifier in an inline
556 function. */
557enum c_inline_static_type {
558 /* Identifier with internal linkage used in function that may be an
559 inline definition (i.e., file-scope static). */
560 csi_internal,
561 /* Modifiable object with static storage duration defined in
562 function that may be an inline definition (i.e., local
563 static). */
564 csi_modifiable
565};
566
7c57c798 567\f
e53b6e56 568/* in c-parser.cc */
2f6e4e97 569extern void c_parse_init (void);
1a4f11c8 570extern bool c_keyword_starts_typename (enum rid keyword);
1526a060 571
e53b6e56 572/* in c-aux-info.cc */
2f6e4e97 573extern void gen_aux_info_record (tree, int, int, int);
40754343 574
e53b6e56 575/* in c-decl.cc */
e1b7793c 576struct c_spot_bindings;
99b1c316 577class c_struct_parse_info;
bc4b653b 578extern struct obstack parser_obstack;
3696a50b
SL
579/* Set to IN_ITERATION_STMT if parsing an iteration-statement,
580 to IN_OMP_BLOCK if parsing OpenMP structured block and
581 IN_OMP_FOR if parsing OpenMP loop. If parsing a switch statement,
582 this is bitwise ORed with IN_SWITCH_STMT, unless parsing an
583 iteration-statement, OpenMP block or loop within that switch. */
584#define IN_SWITCH_STMT 1
585#define IN_ITERATION_STMT 2
586#define IN_OMP_BLOCK 4
587#define IN_OMP_FOR 8
588#define IN_OBJC_FOREACH 16
589extern unsigned char in_statement;
590
591extern bool switch_statement_break_seen_p;
cfe79ecf 592
c99c0026 593extern bool global_bindings_p (void);
641da50a 594extern tree pushdecl (tree);
f75fbaf7
ZW
595extern void push_scope (void);
596extern tree pop_scope (void);
e1b7793c
ILT
597extern void c_bindings_start_stmt_expr (struct c_spot_bindings *);
598extern void c_bindings_end_stmt_expr (struct c_spot_bindings *);
2f6e4e97 599
991d6621
JM
600extern void record_inline_static (location_t, tree, tree,
601 enum c_inline_static_type);
2f6e4e97 602extern void c_init_decl_processing (void);
2f6e4e97 603extern void c_print_identifier (FILE *, tree, int);
3b53cddc 604extern int quals_from_declspecs (const struct c_declspecs *);
c2255bc4
AH
605extern struct c_declarator *build_array_declarator (location_t, tree,
606 struct c_declspecs *,
deb176fa 607 bool, bool);
7370e0da
AC
608extern tree build_enumerator (location_t, location_t, struct c_enum_contents *,
609 tree, tree);
f05b9d93 610extern tree check_for_loop_decls (location_t, bool);
55d54003 611extern void mark_forward_parm_decls (void);
eb1dfbb2 612extern void declare_parm_level (void);
c2255bc4 613extern void undeclared_variable (location_t, tree);
e1b7793c 614extern tree lookup_label_for_goto (location_t, tree);
14e33ee8 615extern tree declare_label (tree);
5b030314 616extern tree define_label (location_t, tree);
e1b7793c
ILT
617extern struct c_spot_bindings *c_get_switch_bindings (void);
618extern void c_release_switch_bindings (struct c_spot_bindings *);
619extern bool c_check_switch_jump_warnings (struct c_spot_bindings *,
620 location_t, location_t);
c2255bc4 621extern void finish_decl (tree, location_t, tree, tree, tree);
2f6e4e97 622extern tree finish_enum (tree, tree, tree);
9def91e9 623extern void finish_function (location_t = input_location);
dc491a25 624extern tree finish_struct (location_t, tree, tree, tree,
99b1c316 625 class c_struct_parse_info *);
ac2cfa6c 626extern tree c_simulate_enum_decl (location_t, const char *,
6b0bde7e 627 vec<string_int_pair> *);
d5c6604f
RS
628extern tree c_simulate_record_decl (location_t, const char *,
629 array_slice<const tree>);
b3399d18 630extern struct c_arg_info *build_arg_info (void);
a04a722b 631extern struct c_arg_info *get_parm_info (bool, tree);
3d10ed6c
AH
632extern tree grokfield (location_t, struct c_declarator *,
633 struct c_declspecs *, tree, tree *);
928c19bb 634extern tree groktypename (struct c_type_name *, tree *, bool *);
a04a722b 635extern tree grokparm (const struct c_parm *, tree *);
c2255bc4 636extern tree implicitly_declare (location_t, tree);
2f6e4e97 637extern void keep_next_level (void);
2f6e4e97 638extern void pending_xref_error (void);
d2784db4
PB
639extern void c_push_function_context (void);
640extern void c_pop_function_context (void);
a04a722b 641extern void push_parm_decl (const struct c_parm *, tree *);
f8893e47 642extern struct c_declarator *set_array_declarator_inner (struct c_declarator *,
6ac0194d 643 struct c_declarator *);
c79efc4d 644extern tree c_builtin_function (tree);
5779e713 645extern tree c_builtin_function_ext_scope (tree);
74078538 646extern tree c_simulate_builtin_function_decl (tree);
4e03c3a7 647extern void c_warn_unused_attributes (tree);
8c5b727a 648extern tree c_warn_type_attributes (tree);
deb176fa
JM
649extern void shadow_tag (const struct c_declspecs *);
650extern void shadow_tag_warned (const struct c_declspecs *, int);
e0997c14 651extern tree start_enum (location_t, struct c_enum_contents *, tree, tree);
e3455240 652extern bool start_function (struct c_declspecs *, struct c_declarator *, tree);
deb176fa 653extern tree start_decl (struct c_declarator *, struct c_declspecs *, bool,
6450f073 654 tree, location_t * = NULL);
dc491a25 655extern tree start_struct (location_t, enum tree_code, tree,
99b1c316 656 class c_struct_parse_info **);
2f6e4e97 657extern void store_parm_decls (void);
f8893e47 658extern void store_parm_decls_from (struct c_arg_info *);
acf0174b
JJ
659extern void temp_store_parm_decls (tree, tree);
660extern void temp_pop_parm_decls (void);
2f6e4e97 661extern tree xref_tag (enum tree_code, tree);
4e03c3a7 662extern struct c_typespec parser_xref_tag (location_t, enum tree_code, tree,
e0997c14 663 bool, tree, bool);
deb176fa 664extern struct c_parm *build_c_parm (struct c_declspecs *, tree,
8139a48e 665 struct c_declarator *, location_t);
f8893e47
JM
666extern struct c_declarator *build_attrs_declarator (tree,
667 struct c_declarator *);
668extern struct c_declarator *build_function_declarator (struct c_arg_info *,
669 struct c_declarator *);
670extern struct c_declarator *build_id_declarator (tree);
deb176fa 671extern struct c_declarator *make_pointer_declarator (struct c_declspecs *,
f8893e47 672 struct c_declarator *);
deb176fa 673extern struct c_declspecs *build_null_declspecs (void);
620e594b 674extern struct c_declspecs *declspecs_add_qual (location_t,
0b2c4be5 675 struct c_declspecs *, tree);
dc491a25
ILT
676extern struct c_declspecs *declspecs_add_type (location_t,
677 struct c_declspecs *,
81da229b 678 struct c_typespec);
620e594b 679extern struct c_declspecs *declspecs_add_scspec (location_t,
0b2c4be5 680 struct c_declspecs *, tree);
620e594b 681extern struct c_declspecs *declspecs_add_attrs (location_t,
0b2c4be5 682 struct c_declspecs *, tree);
620e594b 683extern struct c_declspecs *declspecs_add_addrspace (location_t,
0b2c4be5 684 struct c_declspecs *,
36c5e70a 685 addr_space_t);
620e594b 686extern struct c_declspecs *declspecs_add_alignas (location_t,
0b2c4be5 687 struct c_declspecs *, tree);
98c3a782 688extern struct c_declspecs *finish_declspecs (struct c_declspecs *);
f797f486 689
e53b6e56 690/* in c-objc-common.cc */
2f6e4e97 691extern bool c_objc_common_init (void);
6de9cd9a 692extern bool c_missing_noreturn_ok_p (tree);
ac7d7749 693extern bool c_warn_unused_global_decl (const_tree);
ede1a387 694extern void c_initialize_diagnostics (diagnostic_context *);
52ffd86e 695extern bool c_vla_unspec_p (tree x, tree fn);
2a82beaa 696extern alias_set_type c_get_alias_set (tree);
f797f486 697
e53b6e56 698/* in c-typeck.cc */
bc4b653b
JM
699extern int in_alignof;
700extern int in_sizeof;
701extern int in_typeof;
1160ec9a 702extern bool c_in_omp_for;
bc4b653b 703
1a4049e7 704extern tree c_last_sizeof_arg;
40ffd95f 705extern location_t c_last_sizeof_loc;
1a4049e7 706
506e2710 707extern struct c_switch *c_switch_stack;
d1bd0ded 708
83f83ddf 709extern bool char_type_p (tree);
ba47d38d 710extern tree c_objc_common_truthvalue_conversion (location_t, tree);
4f2e1536 711extern tree require_complete_type (location_t, tree);
e3455240 712extern bool same_translation_unit_p (const_tree, const_tree);
132da1a5 713extern int comptypes (tree, tree);
dc5027f4 714extern int comptypes_check_different_types (tree, tree, bool *);
7da9a089 715extern int comptypes_check_enum_int (tree, tree, bool *);
ac7d7749 716extern bool c_vla_type_p (const_tree);
a9e4a1a5 717extern bool c_mark_addressable (tree, bool = false);
4f2e1536 718extern void c_incomplete_type_error (location_t, const_tree, const_tree);
2f6e4e97 719extern tree c_type_promotes_to (tree);
c2255bc4 720extern struct c_expr default_function_array_conversion (location_t,
ebfbbdc5
JJ
721 struct c_expr);
722extern struct c_expr default_function_array_read_conversion (location_t,
723 struct c_expr);
267bac10
JM
724extern struct c_expr convert_lvalue_to_rvalue (location_t, struct c_expr,
725 bool, bool);
b4923738 726extern tree decl_constant_value_1 (tree, bool);
ebfbbdc5 727extern void mark_exp_read (tree);
10bc1b1b 728extern tree composite_type (tree, tree);
7a3ee77a
JJ
729extern tree build_component_ref (location_t, tree, tree, location_t,
730 location_t);
c2255bc4 731extern tree build_array_ref (location_t, tree, tree);
30af3a2b 732extern tree build_external_ref (location_t, tree, bool, tree *);
bc4b653b 733extern void pop_maybe_used (bool);
c2255bc4
AH
734extern struct c_expr c_expr_sizeof_expr (location_t, struct c_expr);
735extern struct c_expr c_expr_sizeof_type (location_t, struct c_type_name *);
736extern struct c_expr parser_build_unary_op (location_t, enum tree_code,
737 struct c_expr);
b8698a0f 738extern struct c_expr parser_build_binary_op (location_t,
ba47d38d 739 enum tree_code, struct c_expr,
487a92fe 740 struct c_expr);
d130ae11 741extern tree build_conditional_expr (location_t, tree, bool, tree, tree,
a32c8316 742 location_t, tree, tree, location_t);
c2255bc4
AH
743extern tree build_compound_expr (location_t, tree, tree);
744extern tree c_cast_expr (location_t, struct c_type_name *, tree);
745extern tree build_c_cast (location_t, tree, tree);
746extern void store_init_value (location_t, tree, tree, tree);
d033409e 747extern void maybe_warn_string_init (location_t, tree, struct c_expr);
5dd9a9d0 748extern void start_init (tree, tree, int, rich_location *);
2f6e4e97
AJ
749extern void finish_init (void);
750extern void really_start_incremental_init (tree);
16595a1f 751extern void finish_implicit_inits (location_t, struct obstack *);
ea58ef42 752extern void push_init_level (location_t, int, struct obstack *);
5dd9a9d0
DM
753extern struct c_expr pop_init_level (location_t, int, struct obstack *,
754 location_t);
ea58ef42 755extern void set_init_index (location_t, tree, tree, struct obstack *);
f7e4f2e3 756extern void set_init_label (location_t, tree, location_t, struct obstack *);
34cf811f
MP
757extern void process_init_element (location_t, struct c_expr, bool,
758 struct obstack *);
4b2b493f 759extern tree build_compound_literal (location_t, tree, tree, bool,
18981635 760 unsigned int, struct c_declspecs *);
c2255bc4 761extern void check_compound_literal_type (location_t, struct c_type_name *);
3696a50b
SL
762extern tree c_start_switch (location_t, location_t, tree, bool);
763extern void c_finish_switch (tree, tree);
5b76e75f
SB
764extern tree build_asm_expr (location_t, tree, tree, tree, tree, tree, bool,
765 bool);
db4fd626 766extern tree build_asm_stmt (bool, tree);
6de9cd9a 767extern int c_types_compatible_p (tree, tree);
325c3691 768extern tree c_begin_compound_stmt (bool);
c2255bc4 769extern tree c_end_compound_stmt (location_t, tree, bool);
99cd9857 770extern void c_finish_if_stmt (location_t, tree, tree, tree);
f179b64e
JJ
771extern void c_finish_loop (location_t, location_t, tree, location_t, tree,
772 tree, tree, tree, bool);
325c3691 773extern tree c_begin_stmt_expr (void);
c2255bc4
AH
774extern tree c_finish_stmt_expr (location_t, tree);
775extern tree c_process_expr_stmt (location_t, tree);
776extern tree c_finish_expr_stmt (location_t, tree);
777extern tree c_finish_return (location_t, tree, tree);
3696a50b 778extern tree c_finish_bc_stmt (location_t, tree, bool);
c2255bc4 779extern tree c_finish_goto_label (location_t, tree);
e12f66d9 780extern tree c_finish_goto_ptr (location_t, c_expr val);
51eed280 781extern tree c_expr_to_decl (tree, bool *, bool *);
88bae6f4 782extern tree c_finish_omp_construct (location_t, enum tree_code, tree, tree);
41dbbb37 783extern tree c_finish_oacc_data (location_t, tree, tree);
37d5ad46 784extern tree c_finish_oacc_host_data (location_t, tree, tree);
953ff289 785extern tree c_begin_omp_parallel (void);
c2255bc4 786extern tree c_finish_omp_parallel (location_t, tree, tree);
a68ab351 787extern tree c_begin_omp_task (void);
c2255bc4 788extern tree c_finish_omp_task (location_t, tree, tree);
acf0174b
JJ
789extern void c_finish_omp_cancel (location_t, tree);
790extern void c_finish_omp_cancellation_point (location_t, tree);
77886428 791extern tree c_finish_omp_clauses (tree, enum c_omp_region_type);
f187980b 792extern tree c_build_va_arg (location_t, tree, location_t, tree);
0a35513e 793extern tree c_finish_transaction (location_t, tree, int);
acf0174b 794extern bool c_tree_equal (tree, tree);
00dcc88a
MS
795extern tree c_build_function_call_vec (location_t, const vec<location_t>&,
796 tree, vec<tree, va_gc> *,
797 vec<tree, va_gc> *);
9dc5773f 798extern tree c_omp_clause_copy_ctor (tree, tree, tree);
40754343
RS
799
800/* Set to 0 at beginning of a function definition, set to 1 if
801 a return statement that specifies a return value is seen. */
802
803extern int current_function_returns_value;
804
805/* Set to 0 at beginning of a function definition, set to 1 if
806 a return statement with no argument is seen. */
807
808extern int current_function_returns_null;
809
5ce89b2e
JM
810/* Set to 0 at beginning of a function definition, set to 1 if
811 a call to a noreturn function is seen. */
812
813extern int current_function_returns_abnormally;
814
e53b6e56 815/* In c-decl.cc */
ddc8de03
PM
816
817/* Tell the binding oracle what kind of binding we are looking for. */
818
819enum c_oracle_request
820{
821 C_ORACLE_SYMBOL,
822 C_ORACLE_TAG,
823 C_ORACLE_LABEL
824};
825
826/* If this is non-NULL, then it is a "binding oracle" which can lazily
827 create bindings when needed by the C compiler. The oracle is told
828 the name and type of the binding to create. It can call pushdecl
829 or the like to ensure the binding is visible; or do nothing,
e53b6e56 830 leaving the binding untouched. c-decl.cc takes note of when the
ddc8de03
PM
831 oracle has been called and will not call it again if it fails to
832 create a given binding. */
833
834typedef void c_binding_oracle_function (enum c_oracle_request, tree identifier);
835
836extern c_binding_oracle_function *c_binding_oracle;
837
2f6e4e97 838extern void c_finish_incomplete_decl (tree);
acf0174b
JJ
839extern tree c_omp_reduction_id (enum tree_code, tree);
840extern tree c_omp_reduction_decl (tree);
841extern tree c_omp_reduction_lookup (tree, tree);
842extern tree c_check_omp_declare_reduction_r (tree *, int *, void *);
13e41d8b 843extern bool c_check_in_current_scope (tree);
ddc8de03
PM
844extern void c_pushtag (location_t, tree, tree);
845extern void c_bind (location_t, tree, bool);
0e36f5c7 846extern bool tag_exists_p (enum tree_code, tree);
0bb0a00b 847
e53b6e56 848/* In c-errors.cc */
d6e83a8d 849extern bool pedwarn_c90 (location_t, int opt, const char *, ...)
f3bede71 850 ATTRIBUTE_GCC_DIAG(3,4);
35aff4fb 851extern bool pedwarn_c99 (location_t, int opt, const char *, ...)
f3bede71 852 ATTRIBUTE_GCC_DIAG(3,4);
9f936c86
JM
853extern bool pedwarn_c11 (location_t, int opt, const char *, ...)
854 ATTRIBUTE_GCC_DIAG(3,4);
148e4216 855
ebedc9a3
DM
856extern void
857set_c_expr_source_range (c_expr *expr,
858 location_t start, location_t finish);
859
860extern void
861set_c_expr_source_range (c_expr *expr,
862 source_range src_range);
863
e53b6e56 864/* In c-fold.cc */
d25c7690
PK
865extern vec<tree> incomplete_record_decls;
866
6cf276dd
DM
867extern const char *c_get_sarif_source_language (const char *filename);
868
b6f43128
DM
869#if CHECKING_P
870namespace selftest {
871 extern void run_c_tests (void);
872} // namespace selftest
873#endif /* #if CHECKING_P */
874
875
88657302 876#endif /* ! GCC_C_TREE_H */