1 /* Definitions for C parsing and type checking.
2 Copyright (C) 1987-2024 Free Software Foundation, Inc.
4 This file is part of GCC.
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
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
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/>. */
23 #include "c-family/c-common.h"
24 #include "diagnostic.h"
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 *))
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)
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)
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)
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)
46 /* In an incomplete RECORD_TYPE, UNION_TYPE or ENUMERAL_TYPE, a list of
47 variable declarations whose type would be completed by completing
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))
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)
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)
62 /* Record whether a type is variably modified. */
63 #define C_TYPE_VARIABLY_MODIFIED(TYPE) TYPE_LANG_FLAG_6 (TYPE)
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)
70 /* Record whether a typedef for type `int' was actually `signed int'. */
71 #define C_TYPEDEF_EXPLICITLY_SIGNED(EXP) DECL_LANG_FLAG_1 (EXP)
73 /* For a FUNCTION_DECL, nonzero if it was defined without an explicit
75 #define C_FUNCTION_IMPLICIT_INT(EXP) DECL_LANG_FLAG_1 (EXP)
77 /* For a FUNCTION_DECL, nonzero if it was an implicit declaration. */
78 #define C_DECL_IMPLICIT(EXP) DECL_LANG_FLAG_2 (EXP)
80 /* For a PARM_DECL, nonzero if it was declared as an array. */
81 #define C_ARRAY_PARAMETER(NODE) DECL_LANG_FLAG_0 (NODE)
83 /* For FUNCTION_DECLs, evaluates true if the decl is built-in but has
85 #define C_DECL_DECLARED_BUILTIN(EXP) \
86 DECL_LANG_FLAG_3 (FUNCTION_DECL_CHECK (EXP))
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))
93 /* Record whether a decl was declared register. This is strictly a
94 front-end flag, whereas DECL_REGISTER is used for code generation;
95 they may differ for structures with volatile fields. */
96 #define C_DECL_REGISTER(EXP) DECL_LANG_FLAG_4 (EXP)
98 /* Record whether a decl was used in an expression anywhere except an
99 unevaluated operand of sizeof / typeof / alignof. This is only
100 used for functions declared static but not defined, though outside
101 sizeof and typeof it is set for other function decls as well. */
102 #define C_DECL_USED(EXP) DECL_LANG_FLAG_5 (FUNCTION_DECL_CHECK (EXP))
104 /* Record whether a variable has been declared threadprivate by
105 #pragma omp threadprivate. */
106 #define C_DECL_THREADPRIVATE_P(DECL) DECL_LANG_FLAG_3 (VAR_DECL_CHECK (DECL))
108 /* Set on VAR_DECLs for compound literals. */
109 #define C_DECL_COMPOUND_LITERAL_P(DECL) \
110 DECL_LANG_FLAG_5 (VAR_DECL_CHECK (DECL))
112 /* Set on decls used as placeholders for a C23 underspecified object
114 #define C_DECL_UNDERSPECIFIED(DECL) DECL_LANG_FLAG_7 (DECL)
116 /* Set on VAR_DECLs declared as 'constexpr'. */
117 #define C_DECL_DECLARED_CONSTEXPR(DECL) \
118 DECL_LANG_FLAG_8 (VAR_DECL_CHECK (DECL))
120 /* Nonzero for a decl which either doesn't exist or isn't a prototype.
121 N.B. Could be simplified if all built-in decls had complete prototypes
122 (but this is presently difficult because some of them need FILE*). */
123 #define C_DECL_ISNT_PROTOTYPE(EXP) \
125 || (!prototype_p (TREE_TYPE (EXP)) \
126 && !fndecl_built_in_p (EXP)))
128 /* For FUNCTION_TYPE, a hidden list of types of arguments. The same as
129 TYPE_ARG_TYPES for functions with prototypes, but created for functions
130 without prototypes. */
131 #define TYPE_ACTUAL_ARG_TYPES(NODE) \
132 TYPE_LANG_SLOT_1 (FUNCTION_TYPE_CHECK (NODE))
134 /* For a CONSTRUCTOR, whether some initializer contains a
135 subexpression meaning it is not a constant expression. */
136 #define CONSTRUCTOR_NON_CONST(EXPR) TREE_LANG_FLAG_1 (CONSTRUCTOR_CHECK (EXPR))
138 /* For a SAVE_EXPR, nonzero if the operand of the SAVE_EXPR has already
140 #define SAVE_EXPR_FOLDED_P(EXP) TREE_LANG_FLAG_1 (SAVE_EXPR_CHECK (EXP))
142 /* Whether a type has boolean semantics: either a boolean type or an
143 enumeration type with a boolean type as its underlying type. */
144 #define C_BOOLEAN_TYPE_P(TYPE) \
145 (TREE_CODE (TYPE) == BOOLEAN_TYPE \
146 || (TREE_CODE (TYPE) == ENUMERAL_TYPE \
147 && ENUM_UNDERLYING_TYPE (TYPE) != NULL_TREE \
148 && TREE_CODE (ENUM_UNDERLYING_TYPE (TYPE)) == BOOLEAN_TYPE))
150 /* Record parser information about an expression that is irrelevant
151 for code generation alongside a tree representing its value. */
154 /* The value of the expression. */
156 /* Record the original unary/binary operator of an expression, which may
157 have been changed by fold, STRING_CST for unparenthesized string
158 constants, C_MAYBE_CONST_EXPR for __builtin_constant_p calls
159 (even if parenthesized), for subexpressions, and for non-constant
160 initializers, or ERROR_MARK for other expressions (including
161 parenthesized expressions). */
162 enum tree_code original_code
;
163 /* If not NULL, the original type of an expression. This will
164 differ from the type of the value field for an enum constant.
165 The type of an enum constant is a plain integer type, but this
166 field will be the enum type. */
169 /* The source range of this expression. This is redundant
170 for node values that have locations, but not all node kinds
171 have locations (e.g. constants, and references to params, locals,
172 etc), so we stash a copy here. */
173 source_range src_range
;
175 /* True if this was directly from a decimal constant token. */
178 /* Access to the first and last locations within the source spelling
179 of this expression. */
180 location_t
get_start () const { return src_range
.m_start
; }
181 location_t
get_finish () const { return src_range
.m_finish
; }
183 location_t
get_location () const
185 if (EXPR_HAS_LOCATION (value
))
186 return EXPR_LOCATION (value
);
188 return make_location (get_start (), get_start (), get_finish ());
191 /* Set the value to error_mark_node whilst ensuring that src_range
192 and m_decimal are initialized. */
195 value
= error_mark_node
;
196 src_range
.m_start
= UNKNOWN_LOCATION
;
197 src_range
.m_finish
= UNKNOWN_LOCATION
;
202 /* Type alias for struct c_expr. This allows to use the structure
203 inside the VEC types. */
204 typedef struct c_expr c_expr_t
;
206 /* A kind of type specifier. Note that this information is currently
207 only used to distinguish tag definitions, tag references and typeof
209 enum c_typespec_kind
{
210 /* No typespec. This appears only in struct c_declspec. */
212 /* A reserved keyword type specifier. */
214 /* A reference to a tag, previously declared, such as "struct foo".
215 This includes where the previous declaration was as a different
216 kind of tag, in which case this is only valid if shadowing that
217 tag in an inner scope. */
219 /* Likewise, with standard attributes present in the reference. */
221 /* A reference to a tag, not previously declared in a visible
224 /* Likewise, with standard attributes present in the reference. */
225 ctsk_tagfirstref_attrs
,
226 /* A definition of a tag such as "struct foo { int a; }". */
228 /* A typedef name. */
230 /* An ObjC-specific kind of type specifier. */
232 /* A typeof specifier, or _Atomic ( type-name ). */
236 /* A type specifier: this structure is created in the parser and
237 passed to declspecs_add_type only. */
239 /* What kind of type specifier this is. */
240 enum c_typespec_kind kind
;
241 /* Whether the expression has operands suitable for use in constant
243 bool expr_const_operands
;
244 /* Whether the type specifier includes an enum type specifier (that
245 is, ": specifier-qualifier-list" in a declaration using
247 bool has_enum_type_specifier
;
248 /* The specifier itself. */
250 /* An expression to be evaluated before the type specifier, in the
251 case of typeof specifiers, or NULL otherwise or if no such
252 expression is required for a particular typeof specifier. In
253 particular, when typeof is applied to an expression of variably
254 modified type, that expression must be evaluated in order to
255 determine array sizes that form part of the type, but the
256 expression itself (as opposed to the array sizes) forms no part
257 of the type and so needs to be recorded separately. */
261 /* A storage class specifier. */
262 enum c_storage_class
{
271 /* A type specifier keyword "void", "_Bool", "char", "int", "float",
272 "double", "_Decimal32", "_Decimal64", "_Decimal128", "_Fract", "_Accum",
273 "_BitInt", or none of these. */
274 enum c_typespec_keyword
{
293 /* This enum lists all the possible declarator specifiers, storage
294 class or attribute that a user can write. There is at least one
295 enumerator per possible declarator specifier in the struct
298 It is used to index the array of declspec locations in struct
300 enum c_declspec_word
{
301 cdw_typespec
/* A catch-all for a typespec. */,
302 cdw_storage_class
/* A catch-all for a storage class */,
326 cdw_number_of_elements
/* This one must always be the last
332 cdil_gimple
, /* __GIMPLE */
333 cdil_gimple_cfg
, /* __GIMPLE(cfg) */
334 cdil_gimple_ssa
, /* __GIMPLE(ssa) */
338 /* A sequence of declaration specifiers in C. When a new declaration
339 specifier is added, please update the enum c_declspec_word above
342 location_t locations
[cdw_number_of_elements
];
343 /* The type specified, if a single type specifier such as a struct,
344 union or enum specifier, typedef name or typeof specifies the
345 whole type, or NULL_TREE if none or a keyword such as "void" or
346 "char" is used. Does not include qualifiers. */
348 /* Any expression to be evaluated before the type, from a typeof
351 /* The attributes from a typedef decl. */
353 /* When parsing, the GNU attributes and prefix standard attributes.
354 Outside the parser, this will be NULL; attributes (possibly from
355 multiple lists) will be passed separately. */
357 /* When parsing, postfix standard attributes (which appertain to the
358 type specified by the preceding declaration specifiers, unlike
359 prefix standard attributes which appertain to the declaration or
360 declarations as a whole). */
362 /* The pass to start compiling a __GIMPLE or __RTL function with. */
363 char *gimple_or_rtl_pass
;
364 /* ENTRY BB count. */
365 profile_count entry_bb_count
;
366 /* The base-2 log of the greatest alignment required by an _Alignas
367 specifier, in bytes, or -1 if no such specifiers with nonzero
371 /* For the __intN declspec, this stores the index into the int_n_*
374 /* For the _FloatN and _FloatNx declspec, this stores the index into
375 the floatn_nx_types array. */
377 /* For _BitInt(N) this stores the N. */
380 /* The storage class specifier, or csc_none if none. */
381 enum c_storage_class storage_class
;
382 /* Any type specifier keyword used such as "int", not reflecting
383 modifiers such as "short", or cts_none if none. */
384 ENUM_BITFIELD (c_typespec_keyword
) typespec_word
: 8;
385 /* The kind of type specifier if one has been seen, ctsk_none
387 ENUM_BITFIELD (c_typespec_kind
) typespec_kind
: 4;
388 ENUM_BITFIELD (c_declspec_il
) declspec_il
: 3;
389 /* Whether any expressions in typeof specifiers may appear in
390 constant expressions. */
391 BOOL_BITFIELD expr_const_operands
: 1;
392 /* Whether any declaration specifiers have been seen at all. */
393 BOOL_BITFIELD declspecs_seen_p
: 1;
394 /* Whether any declaration specifiers other than standard attributes
395 have been seen at all. If only standard attributes have been
396 seen, this is an attribute-declaration. */
397 BOOL_BITFIELD non_std_attrs_seen_p
: 1;
398 /* Whether something other than a storage class specifier or
399 attribute has been seen. This is used to warn for the
400 obsolescent usage of storage class specifiers other than at the
401 start of the list. (Doing this properly would require function
402 specifiers to be handled separately from storage class
404 BOOL_BITFIELD non_sc_seen_p
: 1;
405 /* Whether the type is specified by a typedef or typeof name. */
406 BOOL_BITFIELD typedef_p
: 1;
407 /* Whether the type is explicitly "signed" or specified by a typedef
408 whose type is explicitly "signed". */
409 BOOL_BITFIELD explicit_signed_p
: 1;
410 /* Whether the specifiers include a deprecated typedef. */
411 BOOL_BITFIELD deprecated_p
: 1;
412 /* Whether the specifiers include an unavailable typedef. */
413 BOOL_BITFIELD unavailable_p
: 1;
414 /* Whether the type defaulted to "int" because there were no type
416 BOOL_BITFIELD default_int_p
: 1;
417 /* Whether "long" was specified. */
418 BOOL_BITFIELD long_p
: 1;
419 /* Whether "long" was specified more than once. */
420 BOOL_BITFIELD long_long_p
: 1;
421 /* Whether "short" was specified. */
422 BOOL_BITFIELD short_p
: 1;
423 /* Whether "signed" was specified. */
424 BOOL_BITFIELD signed_p
: 1;
425 /* Whether "unsigned" was specified. */
426 BOOL_BITFIELD unsigned_p
: 1;
427 /* Whether "complex" was specified. */
428 BOOL_BITFIELD complex_p
: 1;
429 /* Whether "inline" was specified. */
430 BOOL_BITFIELD inline_p
: 1;
431 /* Whether "_Noreturn" was speciied. */
432 BOOL_BITFIELD noreturn_p
: 1;
433 /* Whether "__thread" or "_Thread_local" was specified. */
434 BOOL_BITFIELD thread_p
: 1;
435 /* Whether "__thread" rather than "_Thread_local" was specified. */
436 BOOL_BITFIELD thread_gnu_p
: 1;
437 /* Whether "const" was specified. */
438 BOOL_BITFIELD const_p
: 1;
439 /* Whether "volatile" was specified. */
440 BOOL_BITFIELD volatile_p
: 1;
441 /* Whether "restrict" was specified. */
442 BOOL_BITFIELD restrict_p
: 1;
443 /* Whether "_Atomic" was specified. */
444 BOOL_BITFIELD atomic_p
: 1;
445 /* Whether "_Sat" was specified. */
446 BOOL_BITFIELD saturating_p
: 1;
447 /* Whether any alignment specifier (even with zero alignment) was
449 BOOL_BITFIELD alignas_p
: 1;
450 /* Whether an enum type specifier (": specifier-qualifier-list") was
451 specified other than in a definition of that enum (if so, this is
452 invalid unless it is an empty declaration "enum identifier
453 enum-type-specifier;", but such an empty declaration is valid in
454 C23 when "enum identifier;" would not be). */
455 BOOL_BITFIELD enum_type_specifier_ref_p
: 1;
456 /* Whether "auto" was specified in C23 (or later) mode and means the
457 type is to be deduced from an initializer, or would mean that if
458 no type specifier appears later in these declaration
460 BOOL_BITFIELD c23_auto_p
: 1;
461 /* Whether "constexpr" was specified. */
462 BOOL_BITFIELD constexpr_p
: 1;
463 /* The address space that the declaration belongs to. */
464 addr_space_t address_space
;
467 /* The various kinds of declarators in C. */
468 enum c_declarator_kind
{
477 /* Parenthesized declarator with nested attributes. */
482 /* The argument name. */
484 /* The type of the argument. */
489 /* Information about the parameters in a function declarator. */
491 /* A list of parameter decls. */
493 /* A list of structure, union and enum tags defined. */
494 vec
<c_arg_tag
, va_gc
> *tags
;
495 /* A list of argument types to go in the FUNCTION_TYPE. */
497 /* A list of non-parameter decls (notably enumeration constants)
498 defined with the parameters. */
500 /* A compound expression of VLA sizes from the parameters, or NULL.
501 In a function definition, these are used to ensure that
502 side-effects in sizes of arrays converted to pointers (such as a
503 parameter int i[n++]) take place; otherwise, they are
506 /* True when these arguments had [*]. */
507 BOOL_BITFIELD had_vla_unspec
: 1;
508 /* True when the arguments are a (...) prototype. */
509 BOOL_BITFIELD no_named_args_stdarg_p
: 1;
513 struct c_declarator
{
514 /* The kind of declarator. */
515 enum c_declarator_kind kind
;
516 location_t id_loc
; /* Currently only set for cdk_id, cdk_array. */
517 /* Except for cdk_id, the contained declarator. For cdk_id, NULL. */
518 struct c_declarator
*declarator
;
520 /* For identifiers. */
522 /* An IDENTIFIER_NODE, or NULL_TREE if an abstract
525 /* Any attributes (which apply to the declaration rather than to
526 the type described by the outer declarators). */
530 struct c_arg_info
*arg_info
;
533 /* The array dimension, or NULL for [] and [*]. */
535 /* The qualifiers inside []. */
537 /* The attributes (currently ignored) inside []. */
539 /* Whether [static] was used. */
540 BOOL_BITFIELD static_p
: 1;
541 /* Whether [*] was used. */
542 BOOL_BITFIELD vla_unspec_p
: 1;
544 /* For pointers, the qualifiers on the pointer type. */
546 /* For attributes. */
553 /* The declaration specifiers. */
554 struct c_declspecs
*specs
;
555 /* The declarator. */
556 struct c_declarator
*declarator
;
561 /* The declaration specifiers, minus any prefix attributes. */
562 struct c_declspecs
*specs
;
563 /* The attributes. */
565 /* The declarator. */
566 struct c_declarator
*declarator
;
567 /* The location of the parameter. */
571 /* Used when parsing an enum. Initialized by start_enum. */
572 struct c_enum_contents
574 /* While defining an enum type, this is 1 plus the last enumerator
576 tree enum_next_value
;
578 /* The enumeration type itself. */
581 /* Nonzero means that there was overflow computing enum_next_value. */
585 /* A type of reference to a static identifier in an inline
587 enum c_inline_static_type
{
588 /* Identifier with internal linkage used in function that may be an
589 inline definition (i.e., file-scope static). */
591 /* Modifiable object with static storage duration defined in
592 function that may be an inline definition (i.e., local
599 struct c_tree_token_vec
;
600 extern void c_parse_init (void);
601 extern bool c_keyword_starts_typename (enum rid keyword
);
603 /* in c-aux-info.cc */
604 extern void gen_aux_info_record (tree
, int, int, int);
607 struct c_spot_bindings
;
608 class c_struct_parse_info
;
609 extern struct obstack parser_obstack
;
610 /* Set to IN_ITERATION_STMT if parsing an iteration-statement,
611 to IN_OMP_BLOCK if parsing OpenMP structured block and
612 IN_OMP_FOR if parsing OpenMP loop. If parsing a switch statement,
613 this is bitwise ORed with IN_SWITCH_STMT, unless parsing an
614 iteration-statement, OpenMP block or loop within that switch. */
615 #define IN_SWITCH_STMT 1
616 #define IN_ITERATION_STMT 2
617 #define IN_OMP_BLOCK 4
619 #define IN_OBJC_FOREACH 16
620 extern unsigned char in_statement
;
622 extern bool switch_statement_break_seen_p
;
624 extern bool global_bindings_p (void);
625 extern tree
pushdecl (tree
);
626 extern unsigned int start_underspecified_init (location_t
, tree
);
627 extern void finish_underspecified_init (tree
, unsigned int);
628 extern void push_scope (void);
629 extern tree
pop_scope (void);
630 extern void c_mark_decl_jump_unsafe_in_current_scope ();
631 extern void c_bindings_start_stmt_expr (struct c_spot_bindings
*);
632 extern void c_bindings_end_stmt_expr (struct c_spot_bindings
*);
634 extern void record_inline_static (location_t
, tree
, tree
,
635 enum c_inline_static_type
);
636 extern void c_init_decl_processing (void);
637 extern void c_print_identifier (FILE *, tree
, int);
638 extern int quals_from_declspecs (const struct c_declspecs
*);
639 extern struct c_declarator
*build_array_declarator (location_t
, tree
,
640 struct c_declspecs
*,
642 extern tree
build_enumerator (location_t
, location_t
, struct c_enum_contents
*,
644 extern tree
check_for_loop_decls (location_t
, bool);
645 extern void mark_forward_parm_decls (void);
646 extern void declare_parm_level (void);
647 extern void undeclared_variable (location_t
, tree
);
648 extern tree
lookup_label_for_goto (location_t
, tree
);
649 extern tree
declare_label (tree
);
650 extern tree
define_label (location_t
, tree
);
651 extern struct c_spot_bindings
*c_get_switch_bindings (void);
652 extern void c_release_switch_bindings (struct c_spot_bindings
*);
653 extern bool c_check_switch_jump_warnings (struct c_spot_bindings
*,
654 location_t
, location_t
);
655 extern void finish_decl (tree
, location_t
, tree
, tree
, tree
);
656 extern tree
finish_enum (tree
, tree
, tree
);
657 extern void finish_function (location_t
= input_location
);
658 extern tree
finish_struct (location_t
, tree
, tree
, tree
,
659 class c_struct_parse_info
*,
661 extern tree
c_simulate_enum_decl (location_t
, const char *,
662 vec
<string_int_pair
> *);
663 extern tree
c_simulate_record_decl (location_t
, const char *,
664 array_slice
<const tree
>);
665 extern struct c_arg_info
*build_arg_info (void);
666 extern struct c_arg_info
*get_parm_info (bool, tree
);
667 extern tree
grokfield (location_t
, struct c_declarator
*,
668 struct c_declspecs
*, tree
, tree
*, tree
*);
669 extern tree
groktypename (struct c_type_name
*, tree
*, bool *);
670 extern tree
grokparm (const struct c_parm
*, tree
*);
671 extern tree
implicitly_declare (location_t
, tree
);
672 extern void keep_next_level (void);
673 extern void pending_xref_error (void);
674 extern void c_push_function_context (void);
675 extern void c_pop_function_context (void);
676 extern void push_parm_decl (const struct c_parm
*, tree
*);
677 extern struct c_declarator
*set_array_declarator_inner (struct c_declarator
*,
678 struct c_declarator
*);
679 extern tree
c_builtin_function (tree
);
680 extern tree
c_builtin_function_ext_scope (tree
);
681 extern tree
c_simulate_builtin_function_decl (tree
);
682 extern void c_warn_unused_attributes (tree
);
683 extern tree
c_warn_type_attributes (tree
);
684 extern void shadow_tag (const struct c_declspecs
*);
685 extern void shadow_tag_warned (const struct c_declspecs
*, int);
686 extern tree
start_enum (location_t
, struct c_enum_contents
*, tree
, tree
,
687 bool potential_nesting_p
);
688 extern bool start_function (struct c_declspecs
*, struct c_declarator
*, tree
);
689 extern tree
start_decl (struct c_declarator
*, struct c_declspecs
*, bool,
690 tree
, bool = true, location_t
* = NULL
);
691 extern tree
start_struct (location_t
, enum tree_code
, tree
,
692 class c_struct_parse_info
**);
693 extern void store_parm_decls (void);
694 extern void store_parm_decls_from (struct c_arg_info
*);
695 extern void temp_store_parm_decls (tree
, tree
);
696 extern void temp_pop_parm_decls (void);
697 extern tree
xref_tag (enum tree_code
, tree
);
698 extern struct c_typespec
parser_xref_tag (location_t
, enum tree_code
, tree
,
700 extern struct c_parm
*build_c_parm (struct c_declspecs
*, tree
,
701 struct c_declarator
*, location_t
);
702 extern struct c_declarator
*build_attrs_declarator (tree
,
703 struct c_declarator
*);
704 extern struct c_declarator
*build_function_declarator (struct c_arg_info
*,
705 struct c_declarator
*);
706 extern struct c_declarator
*build_id_declarator (tree
);
707 extern struct c_declarator
*make_pointer_declarator (struct c_declspecs
*,
708 struct c_declarator
*);
709 extern struct c_declspecs
*build_null_declspecs (void);
710 extern struct c_declspecs
*declspecs_add_qual (location_t
,
711 struct c_declspecs
*, tree
);
712 extern struct c_declspecs
*declspecs_add_type (location_t
,
713 struct c_declspecs
*,
715 extern struct c_declspecs
*declspecs_add_scspec (location_t
,
716 struct c_declspecs
*, tree
);
717 extern struct c_declspecs
*declspecs_add_attrs (location_t
,
718 struct c_declspecs
*, tree
);
719 extern struct c_declspecs
*declspecs_add_addrspace (location_t
,
720 struct c_declspecs
*,
722 extern struct c_declspecs
*declspecs_add_alignas (location_t
,
723 struct c_declspecs
*, tree
);
724 extern struct c_declspecs
*finish_declspecs (struct c_declspecs
*);
725 extern size_t c_tree_size (enum tree_code
);
727 /* in c-objc-common.cc */
728 extern bool c_objc_common_init (void);
729 extern bool c_missing_noreturn_ok_p (tree
);
730 extern bool c_warn_unused_global_decl (const_tree
);
731 extern void c_initialize_diagnostics (diagnostic_context
*);
732 extern bool c_var_mod_p (tree x
, tree fn
);
733 extern alias_set_type
c_get_alias_set (tree
);
734 extern int c_type_dwarf_attribute (const_tree
, int);
737 extern int in_alignof
;
738 extern int in_sizeof
;
739 extern int in_typeof
;
740 extern bool c_in_omp_for
;
741 extern bool c_omp_array_section_p
;
743 extern tree c_last_sizeof_arg
;
744 extern location_t c_last_sizeof_loc
;
746 extern struct c_switch
*c_switch_stack
;
748 extern bool null_pointer_constant_p (const_tree
);
752 bool c_type_variably_modified_p (tree t
)
754 return error_mark_node
!= t
&& C_TYPE_VARIABLY_MODIFIED (t
);
758 extern bool char_type_p (tree
);
759 extern tree
c_objc_common_truthvalue_conversion (location_t
, tree
,
760 tree
= integer_type_node
);
761 extern tree
require_complete_type (location_t
, tree
);
762 extern bool same_translation_unit_p (const_tree
, const_tree
);
763 extern int comptypes (tree
, tree
);
764 extern bool comptypes_same_p (tree
, tree
);
765 extern bool comptypes_equiv_p (tree
, tree
);
766 extern int comptypes_check_different_types (tree
, tree
, bool *);
767 extern int comptypes_check_enum_int (tree
, tree
, bool *);
768 extern bool c_mark_addressable (tree
, bool = false);
769 extern void c_incomplete_type_error (location_t
, const_tree
, const_tree
);
770 extern tree
c_type_promotes_to (tree
);
771 extern struct c_expr
default_function_array_conversion (location_t
,
773 extern struct c_expr
default_function_array_read_conversion (location_t
,
775 extern struct c_expr
convert_lvalue_to_rvalue (location_t
, struct c_expr
,
776 bool, bool, bool = false);
777 extern tree
decl_constant_value_1 (tree
, bool);
778 extern void mark_exp_read (tree
);
779 extern tree
composite_type (tree
, tree
);
780 extern tree
lookup_field (const_tree
, tree
);
781 extern tree
build_component_ref (location_t
, tree
, tree
, location_t
,
782 location_t
, bool = true);
783 extern tree
build_array_ref (location_t
, tree
, tree
);
784 extern tree
build_omp_array_section (location_t
, tree
, tree
, tree
);
785 extern tree
build_external_ref (location_t
, tree
, bool, tree
*);
786 extern void pop_maybe_used (bool);
787 extern struct c_expr
c_expr_sizeof_expr (location_t
, struct c_expr
);
788 extern struct c_expr
c_expr_sizeof_type (location_t
, struct c_type_name
*);
789 extern struct c_expr
parser_build_unary_op (location_t
, enum tree_code
,
791 extern struct c_expr
parser_build_binary_op (location_t
,
792 enum tree_code
, struct c_expr
,
794 extern tree
build_conditional_expr (location_t
, tree
, bool, tree
, tree
,
795 location_t
, tree
, tree
, location_t
);
796 extern tree
build_compound_expr (location_t
, tree
, tree
);
797 extern tree
c_cast_expr (location_t
, struct c_type_name
*, tree
);
798 extern tree
build_c_cast (location_t
, tree
, tree
);
799 extern void store_init_value (location_t
, tree
, tree
, tree
);
800 extern void maybe_warn_string_init (location_t
, tree
, struct c_expr
);
801 extern void start_init (tree
, tree
, bool, bool, rich_location
*);
802 extern void finish_init (void);
803 extern void really_start_incremental_init (tree
);
804 extern void finish_implicit_inits (location_t
, struct obstack
*);
805 extern void push_init_level (location_t
, int, struct obstack
*);
806 extern struct c_expr
pop_init_level (location_t
, int, struct obstack
*,
808 extern void set_init_index (location_t
, tree
, tree
, struct obstack
*);
809 extern void set_init_label (location_t
, tree
, location_t
, struct obstack
*);
810 extern void process_init_element (location_t
, struct c_expr
, bool,
812 extern tree
build_compound_literal (location_t
, tree
, tree
, bool,
813 unsigned int, struct c_declspecs
*);
814 extern void check_compound_literal_type (location_t
, struct c_type_name
*);
815 extern tree
c_start_switch (location_t
, location_t
, tree
, bool);
816 extern void c_finish_switch (tree
, tree
);
817 extern tree
build_asm_expr (location_t
, tree
, tree
, tree
, tree
, tree
, bool,
819 extern tree
build_asm_stmt (bool, tree
);
820 extern int c_types_compatible_p (tree
, tree
);
821 extern tree
c_begin_compound_stmt (bool);
822 extern tree
c_end_compound_stmt (location_t
, tree
, bool);
823 extern void c_finish_if_stmt (location_t
, tree
, tree
, tree
);
824 extern void c_finish_loop (location_t
, location_t
, tree
, location_t
, tree
,
825 tree
, tree
, tree
, bool);
826 extern tree
c_begin_stmt_expr (void);
827 extern tree
c_finish_stmt_expr (location_t
, tree
);
828 extern tree
c_process_expr_stmt (location_t
, tree
);
829 extern tree
c_finish_expr_stmt (location_t
, tree
);
830 extern tree
c_finish_return (location_t
, tree
, tree
, bool = false);
831 extern tree
c_finish_bc_stmt (location_t
, tree
, bool);
832 extern tree
c_finish_goto_label (location_t
, tree
);
833 extern tree
c_finish_goto_ptr (location_t
, c_expr val
);
834 extern tree
c_expr_to_decl (tree
, bool *, bool *);
835 extern tree
c_finish_omp_construct (location_t
, enum tree_code
, tree
, tree
);
836 extern tree
c_finish_oacc_data (location_t
, tree
, tree
);
837 extern tree
c_finish_oacc_host_data (location_t
, tree
, tree
);
838 extern tree
c_begin_omp_parallel (void);
839 extern tree
c_finish_omp_parallel (location_t
, tree
, tree
);
840 extern tree
c_begin_omp_task (void);
841 extern tree
c_finish_omp_task (location_t
, tree
, tree
);
842 extern void c_finish_omp_cancel (location_t
, tree
);
843 extern void c_finish_omp_cancellation_point (location_t
, tree
);
844 extern tree
c_finish_omp_clauses (tree
, enum c_omp_region_type
);
845 extern tree
c_build_va_arg (location_t
, tree
, location_t
, tree
);
846 extern tree
c_finish_transaction (location_t
, tree
, int);
847 extern bool c_tree_equal (tree
, tree
);
848 extern tree
c_build_function_call_vec (location_t
, const vec
<location_t
>&,
849 tree
, vec
<tree
, va_gc
> *,
851 extern tree
c_omp_clause_copy_ctor (tree
, tree
, tree
);
853 /* Set to 0 at beginning of a function definition, set to 1 if
854 a return statement that specifies a return value is seen. */
856 extern int current_function_returns_value
;
858 /* Set to 0 at beginning of a function definition, set to 1 if
859 a return statement with no argument is seen. */
861 extern int current_function_returns_null
;
863 /* Set to 0 at beginning of a function definition, set to 1 if
864 a call to a noreturn function is seen. */
866 extern int current_function_returns_abnormally
;
870 /* Tell the binding oracle what kind of binding we are looking for. */
872 enum c_oracle_request
879 /* If this is non-NULL, then it is a "binding oracle" which can lazily
880 create bindings when needed by the C compiler. The oracle is told
881 the name and type of the binding to create. It can call pushdecl
882 or the like to ensure the binding is visible; or do nothing,
883 leaving the binding untouched. c-decl.cc takes note of when the
884 oracle has been called and will not call it again if it fails to
885 create a given binding. */
887 typedef void c_binding_oracle_function (enum c_oracle_request
, tree identifier
);
889 extern c_binding_oracle_function
*c_binding_oracle
;
891 extern void c_finish_incomplete_decl (tree
);
892 extern tree
c_omp_reduction_id (enum tree_code
, tree
);
893 extern tree
c_omp_reduction_decl (tree
);
894 extern tree
c_omp_reduction_lookup (tree
, tree
);
895 extern tree
c_check_omp_declare_reduction_r (tree
*, int *, void *);
896 extern bool c_check_in_current_scope (tree
);
897 extern void c_pushtag (location_t
, tree
, tree
);
898 extern void c_bind (location_t
, tree
, bool);
899 extern bool tag_exists_p (enum tree_code
, tree
);
902 extern bool pedwarn_c90 (location_t
, int opt
, const char *, ...)
903 ATTRIBUTE_GCC_DIAG(3,4);
904 extern bool pedwarn_c99 (location_t
, int opt
, const char *, ...)
905 ATTRIBUTE_GCC_DIAG(3,4);
906 extern bool pedwarn_c11 (location_t
, int opt
, const char *, ...)
907 ATTRIBUTE_GCC_DIAG(3,4);
908 extern bool pedwarn_c23 (location_t
, int opt
, const char *, ...)
909 ATTRIBUTE_GCC_DIAG(3,4);
912 set_c_expr_source_range (c_expr
*expr
,
913 location_t start
, location_t finish
);
916 set_c_expr_source_range (c_expr
*expr
,
917 source_range src_range
);
920 extern vec
<tree
> incomplete_record_decls
;
922 extern const char *c_get_sarif_source_language (const char *filename
);
924 extern const struct scoped_attribute_specs std_attribute_table
;
928 extern void run_c_tests (void);
929 } // namespace selftest
930 #endif /* #if CHECKING_P */
933 #endif /* ! GCC_C_TREE_H */