1 // Copyright (C) 2020-2024 Free Software Foundation, Inc.
3 // This file is part of GCC.
5 // GCC is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation; either version 3, or (at your option) any later
10 // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 // You should have received a copy of the GNU General Public License
16 // along with GCC; see the file COPYING3. If not see
17 // <http://www.gnu.org/licenses/>.
22 #include "rust-system.h"
23 #include "coretypes.h"
26 #include "splay-tree.h"
28 /* Returns true if NODE is a pointer. */
29 #define TYPE_PTR_P(NODE) (TREE_CODE (NODE) == POINTER_TYPE)
31 /* Returns true if NODE is a reference. */
32 #define TYPE_REF_P(NODE) (TREE_CODE (NODE) == REFERENCE_TYPE)
34 /* Returns true if NODE is a pointer or a reference. */
35 #define INDIRECT_TYPE_P(NODE) (TYPE_PTR_P (NODE) || TYPE_REF_P (NODE))
37 /* [basic.fundamental]
39 Types bool, char, wchar_t, and the signed and unsigned integer types
40 are collectively called integral types.
42 Note that INTEGRAL_TYPE_P, as defined in tree.h, allows enumeration
43 types as well, which is incorrect in C++. Keep these checks in
44 ascending code order. */
45 #define RS_INTEGRAL_TYPE_P(TYPE) \
46 (TREE_CODE (TYPE) == BOOLEAN_TYPE || TREE_CODE (TYPE) == INTEGER_TYPE)
48 /* [basic.fundamental]
50 Integral and floating types are collectively called arithmetic
53 As a GNU extension, we also accept complex types.
55 Keep these checks in ascending code order. */
56 #define ARITHMETIC_TYPE_P(TYPE) \
57 (RS_INTEGRAL_TYPE_P (TYPE) || TREE_CODE (TYPE) == REAL_TYPE \
58 || TREE_CODE (TYPE) == COMPLEX_TYPE)
60 /* True iff TYPE is cv decltype(nullptr). */
61 #define NULLPTR_TYPE_P(TYPE) (TREE_CODE (TYPE) == NULLPTR_TYPE)
65 Arithmetic types, enumeration types, pointer types,
66 pointer-to-member types, and std::nullptr_t are collectively called
69 Keep these checks in ascending code order. */
70 #define SCALAR_TYPE_P(TYPE) \
71 (TREE_CODE (TYPE) == ENUMERAL_TYPE || ARITHMETIC_TYPE_P (TYPE) \
72 || TYPE_PTR_P (TYPE) || NULLPTR_TYPE_P (TYPE))
74 /* True if NODE is an implicit INDIRECT_REF from convert_from_reference. */
75 #define REFERENCE_REF_P(NODE) \
76 (INDIRECT_REF_P (NODE) && TREE_TYPE (TREE_OPERAND (NODE, 0)) \
77 && TYPE_REF_P (TREE_TYPE (TREE_OPERAND ((NODE), 0))))
79 // this is a helper to differentiate RECORD types between actual records and
81 #define SLICE_FLAG TREE_LANG_FLAG_0
82 #define SLICE_TYPE_P(TYPE) \
83 (TREE_CODE (TYPE) == RECORD_TYPE && TREE_LANG_FLAG_0 (TYPE))
86 #define RS_CLOSURE_FLAG TREE_LANG_FLAG_1
87 #define RS_CLOSURE_TYPE_P(TYPE) \
88 (TREE_CODE (TYPE) == RECORD_TYPE && TREE_LANG_FLAG_1 (TYPE))
90 /* Returns true if NODE is a pointer to member function type. */
91 #define TYPE_PTRMEMFUNC_P(NODE) \
92 (TREE_CODE (NODE) == RECORD_TYPE && TYPE_PTRMEMFUNC_FLAG (NODE))
94 #define TYPE_PTRMEMFUNC_FLAG(NODE) (TYPE_LANG_FLAG_2 (RECORD_TYPE_CHECK (NODE)))
96 #define TYPE_PTRMEMFUNC_FN_TYPE_RAW(NODE) (TREE_TYPE (TYPE_FIELDS (NODE)))
98 /* True if NODE is a compound-literal, i.e., a brace-enclosed
99 initializer cast to a particular type. This is mostly only set during
100 template parsing; once the initializer has been digested into an actual
101 value of the type, the expression is represented by a TARGET_EXPR. */
102 #define COMPOUND_LITERAL_P(NODE) \
103 (TREE_CODE (NODE) == CONSTRUCTOR && TREE_HAS_CONSTRUCTOR (NODE))
105 /* When appearing in an INDIRECT_REF, it means that the tree structure
106 underneath is actually a call to a constructor. This is needed
107 when the constructor must initialize local storage (which can
108 be automatically destroyed), rather than allowing it to allocate
111 When appearing in a SAVE_EXPR, it means that underneath
112 is a call to a constructor.
114 When appearing in a CONSTRUCTOR, the expression is an unconverted
117 When appearing in a FIELD_DECL, it means that this field
118 has been duly initialized in its constructor. */
119 #define TREE_HAS_CONSTRUCTOR(NODE) (TREE_LANG_FLAG_4 (NODE))
121 /* Nonzero if T is a class type. Zero for template type parameters,
122 typename types, and so forth. */
123 #define CLASS_TYPE_P(T) \
124 (RECORD_OR_UNION_CODE_P (TREE_CODE (T)) && TYPE_LANG_FLAG_5 (T))
128 A class that declares or inherits a virtual function is called a
129 polymorphic class. */
130 #define TYPE_POLYMORPHIC_P(NODE) (TREE_LANG_FLAG_2 (NODE))
132 /* Nonzero if this class has a virtual function table pointer. */
133 #define TYPE_CONTAINS_VPTR_P(NODE) \
134 (TYPE_POLYMORPHIC_P (NODE) || CLASSTYPE_VBASECLASSES (NODE))
136 /* A vector of BINFOs for the direct and indirect virtual base classes
137 that this type uses in a post-order depth-first left-to-right
138 order. (In other words, these bases appear in the order that they
139 should be initialized.) */
140 #define CLASSTYPE_VBASECLASSES(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->vbases)
142 /* A vector of BINFOs for the direct and indirect virtual base classes
143 that this type uses in a post-order depth-first left-to-right
144 order. (In other words, these bases appear in the order that they
145 should be initialized.) */
146 #define CLASSTYPE_VBASECLASSES(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->vbases)
148 /* We used to have a variant type for lang_type. Keep the name of the
149 checking accessor for the sole survivor. */
150 #define LANG_TYPE_CLASS_CHECK(NODE) (TYPE_LANG_SPECIFIC (NODE))
152 /* Keep these checks in ascending code order. */
153 #define RECORD_OR_UNION_CODE_P(T) ((T) == RECORD_TYPE || (T) == UNION_TYPE)
154 #define OVERLOAD_TYPE_P(T) (CLASS_TYPE_P (T) || TREE_CODE (T) == ENUMERAL_TYPE)
156 /* Nonzero if this class is "empty" in the sense of the C++ ABI. */
157 #define CLASSTYPE_EMPTY_P(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->empty_p)
159 /* True if DECL is declared 'constexpr'. */
160 #define DECL_DECLARED_CONSTEXPR_P(DECL) \
161 DECL_LANG_FLAG_8 (VAR_OR_FUNCTION_DECL_CHECK (DECL))
163 #define VAR_OR_FUNCTION_DECL_CHECK(NODE) \
164 TREE_CHECK2 (NODE, VAR_DECL, FUNCTION_DECL)
166 // forked from gcc/cp/c-common.h c_tree_index
168 /* Standard named or nameless data types of the C compiler. */
176 CTI_UNDERLYING_WCHAR_TYPE
,
178 CTI_SIGNED_SIZE_TYPE
, /* For format checking only. */
179 CTI_UNSIGNED_PTRDIFF_TYPE
, /* For format checking only. */
182 CTI_WIDEST_INT_LIT_TYPE
,
183 CTI_WIDEST_UINT_LIT_TYPE
,
185 /* Types for <stdint.h>, that may not be defined on all
197 CTI_INT_LEAST16_TYPE
,
198 CTI_INT_LEAST32_TYPE
,
199 CTI_INT_LEAST64_TYPE
,
200 CTI_UINT_LEAST8_TYPE
,
201 CTI_UINT_LEAST16_TYPE
,
202 CTI_UINT_LEAST32_TYPE
,
203 CTI_UINT_LEAST64_TYPE
,
209 CTI_UINT_FAST16_TYPE
,
210 CTI_UINT_FAST32_TYPE
,
211 CTI_UINT_FAST64_TYPE
,
216 CTI_CHAR8_ARRAY_TYPE
,
217 CTI_CHAR16_ARRAY_TYPE
,
218 CTI_CHAR32_ARRAY_TYPE
,
219 CTI_WCHAR_ARRAY_TYPE
,
221 CTI_CONST_STRING_TYPE
,
223 /* Type for boolean expressions (bool in C++, int in C). */
226 CTI_TRUTHVALUE_FALSE
,
228 CTI_DEFAULT_FUNCTION_TYPE
,
232 /* These are not types, but we have to look them up all the time. */
233 CTI_FUNCTION_NAME_DECL
,
234 CTI_PRETTY_FUNCTION_NAME_DECL
,
235 CTI_C99_FUNCTION_NAME_DECL
,
238 /* Below here entities change during compilation. */
240 CTI_SAVED_FUNCTION_NAME_DECLS
,
245 // forked from gcc/c-family/c-common.h c_tree_index
247 extern GTY (()) tree c_global_trees
[CTI_MAX
];
249 // forked from gcc/cp/cp-tree.h cp_tree_index
254 CPTI_VTABLE_ENTRY_TYPE
,
256 CPTI_VTABLE_INDEX_TYPE
,
263 CPTI_EXPLICIT_VOID_LIST
,
271 CPTI_CTOR_IDENTIFIER
,
272 CPTI_COMPLETE_CTOR_IDENTIFIER
,
273 CPTI_BASE_CTOR_IDENTIFIER
,
274 CPTI_DTOR_IDENTIFIER
,
275 CPTI_COMPLETE_DTOR_IDENTIFIER
,
276 CPTI_BASE_DTOR_IDENTIFIER
,
277 CPTI_DELETING_DTOR_IDENTIFIER
,
278 CPTI_CONV_OP_IDENTIFIER
,
279 CPTI_DELTA_IDENTIFIER
,
280 CPTI_IN_CHARGE_IDENTIFIER
,
281 CPTI_VTT_PARM_IDENTIFIER
,
282 CPTI_AS_BASE_IDENTIFIER
,
283 CPTI_THIS_IDENTIFIER
,
285 CPTI_VPTR_IDENTIFIER
,
286 CPTI_GLOBAL_IDENTIFIER
,
287 CPTI_ANON_IDENTIFIER
,
288 CPTI_AUTO_IDENTIFIER
,
289 CPTI_DECLTYPE_AUTO_IDENTIFIER
,
290 CPTI_INIT_LIST_IDENTIFIER
,
291 CPTI_FOR_RANGE__IDENTIFIER
,
292 CPTI_FOR_BEGIN__IDENTIFIER
,
293 CPTI_FOR_END__IDENTIFIER
,
294 CPTI_FOR_RANGE_IDENTIFIER
,
295 CPTI_FOR_BEGIN_IDENTIFIER
,
296 CPTI_FOR_END_IDENTIFIER
,
297 CPTI_ABI_TAG_IDENTIFIER
,
298 CPTI_ALIGNED_IDENTIFIER
,
299 CPTI_BEGIN_IDENTIFIER
,
303 CPTI_TUPLE_ELEMENT_IDENTIFIER
,
304 CPTI_TUPLE_SIZE_IDENTIFIER
,
305 CPTI_TYPE_IDENTIFIER
,
306 CPTI_VALUE_IDENTIFIER
,
308 CPTI_CLOSURE_IDENTIFIER
,
309 CPTI_HEAP_UNINIT_IDENTIFIER
,
310 CPTI_HEAP_IDENTIFIER
,
311 CPTI_HEAP_DELETED_IDENTIFIER
,
312 CPTI_HEAP_VEC_UNINIT_IDENTIFIER
,
313 CPTI_HEAP_VEC_IDENTIFIER
,
317 CPTI_LANG_NAME_CPLUSPLUS
,
319 CPTI_EMPTY_EXCEPT_SPEC
,
320 CPTI_NOEXCEPT_TRUE_SPEC
,
321 CPTI_NOEXCEPT_FALSE_SPEC
,
322 CPTI_NOEXCEPT_DEFERRED_SPEC
,
330 /* Nodes after here change during compilation, or should not be in
331 the module's global tree table. Such nodes must be locatable
332 via name lookup or type-construction, as those are the only
333 cross-TU matching capabilities remaining. */
335 /* We must find these via the global namespace. */
339 /* These are created at init time, but the library/headers provide
343 CPTI_CALL_UNEXPECTED_FN
,
345 /* These are lazily inited. */
346 CPTI_CONST_TYPE_INFO_TYPE
,
347 CPTI_GET_EXCEPTION_PTR_FN
,
350 CPTI_ALLOCATE_EXCEPTION_FN
,
351 CPTI_FREE_EXCEPTION_FN
,
354 CPTI_ATEXIT_FN_PTR_TYPE
,
359 CPTI_SOURCE_LOCATION_IMPL
,
361 CPTI_FALLBACK_DFLOAT32_TYPE
,
362 CPTI_FALLBACK_DFLOAT64_TYPE
,
363 CPTI_FALLBACK_DFLOAT128_TYPE
,
368 // forked from gcc/cp/cp-tree.h cp_global_trees
370 extern GTY (()) tree cp_global_trees
[CPTI_MAX
];
372 #define wchar_decl_node cp_global_trees[CPTI_WCHAR_DECL]
373 #define vtable_entry_type cp_global_trees[CPTI_VTABLE_ENTRY_TYPE]
374 /* The type used to represent an offset by which to adjust the `this'
375 pointer in pointer-to-member types. */
376 #define delta_type_node cp_global_trees[CPTI_DELTA_TYPE]
377 /* The type used to represent an index into the vtable. */
378 #define vtable_index_type cp_global_trees[CPTI_VTABLE_INDEX_TYPE]
380 #define class_type_node cp_global_trees[CPTI_CLASS_TYPE]
381 #define unknown_type_node cp_global_trees[CPTI_UNKNOWN_TYPE]
382 #define init_list_type_node cp_global_trees[CPTI_INIT_LIST_TYPE]
383 #define explicit_void_list_node cp_global_trees[CPTI_EXPLICIT_VOID_LIST]
384 #define vtbl_type_node cp_global_trees[CPTI_VTBL_TYPE]
385 #define vtbl_ptr_type_node cp_global_trees[CPTI_VTBL_PTR_TYPE]
386 #define std_node cp_global_trees[CPTI_STD]
387 #define abi_node cp_global_trees[CPTI_ABI]
388 #define global_namespace cp_global_trees[CPTI_GLOBAL]
389 #define const_type_info_type_node cp_global_trees[CPTI_CONST_TYPE_INFO_TYPE]
390 #define conv_op_marker cp_global_trees[CPTI_CONV_OP_MARKER]
391 #define abort_fndecl cp_global_trees[CPTI_ABORT_FNDECL]
392 #define current_aggr cp_global_trees[CPTI_AGGR_TAG]
393 #define nullptr_node cp_global_trees[CPTI_NULLPTR]
394 #define nullptr_type_node cp_global_trees[CPTI_NULLPTR_TYPE]
395 /* std::align_val_t */
396 #define align_type_node cp_global_trees[CPTI_ALIGN_TYPE]
398 #define char8_type_node c_global_trees[CTI_CHAR8_TYPE]
399 #define char16_type_node c_global_trees[CTI_CHAR16_TYPE]
400 #define char32_type_node c_global_trees[CTI_CHAR32_TYPE]
401 #define wchar_type_node c_global_trees[CTI_WCHAR_TYPE]
402 #define underlying_wchar_type_node c_global_trees[CTI_UNDERLYING_WCHAR_TYPE]
403 #define wint_type_node c_global_trees[CTI_WINT_TYPE]
404 #define signed_size_type_node c_global_trees[CTI_SIGNED_SIZE_TYPE]
405 #define unsigned_ptrdiff_type_node c_global_trees[CTI_UNSIGNED_PTRDIFF_TYPE]
406 #define intmax_type_node c_global_trees[CTI_INTMAX_TYPE]
407 #define uintmax_type_node c_global_trees[CTI_UINTMAX_TYPE]
408 #define widest_integer_literal_type_node c_global_trees[CTI_WIDEST_INT_LIT_TYPE]
409 #define widest_unsigned_literal_type_node \
410 c_global_trees[CTI_WIDEST_UINT_LIT_TYPE]
412 #define sig_atomic_type_node c_global_trees[CTI_SIG_ATOMIC_TYPE]
413 #define int8_type_node c_global_trees[CTI_INT8_TYPE]
414 #define int16_type_node c_global_trees[CTI_INT16_TYPE]
415 #define int32_type_node c_global_trees[CTI_INT32_TYPE]
416 #define int64_type_node c_global_trees[CTI_INT64_TYPE]
417 #define uint8_type_node c_global_trees[CTI_UINT8_TYPE]
418 #define c_uint16_type_node c_global_trees[CTI_UINT16_TYPE]
419 #define c_uint32_type_node c_global_trees[CTI_UINT32_TYPE]
420 #define c_uint64_type_node c_global_trees[CTI_UINT64_TYPE]
421 #define int_least8_type_node c_global_trees[CTI_INT_LEAST8_TYPE]
422 #define int_least16_type_node c_global_trees[CTI_INT_LEAST16_TYPE]
423 #define int_least32_type_node c_global_trees[CTI_INT_LEAST32_TYPE]
424 #define int_least64_type_node c_global_trees[CTI_INT_LEAST64_TYPE]
425 #define uint_least8_type_node c_global_trees[CTI_UINT_LEAST8_TYPE]
426 #define uint_least16_type_node c_global_trees[CTI_UINT_LEAST16_TYPE]
427 #define uint_least32_type_node c_global_trees[CTI_UINT_LEAST32_TYPE]
428 #define uint_least64_type_node c_global_trees[CTI_UINT_LEAST64_TYPE]
429 #define int_fast8_type_node c_global_trees[CTI_INT_FAST8_TYPE]
430 #define int_fast16_type_node c_global_trees[CTI_INT_FAST16_TYPE]
431 #define int_fast32_type_node c_global_trees[CTI_INT_FAST32_TYPE]
432 #define int_fast64_type_node c_global_trees[CTI_INT_FAST64_TYPE]
433 #define uint_fast8_type_node c_global_trees[CTI_UINT_FAST8_TYPE]
434 #define uint_fast16_type_node c_global_trees[CTI_UINT_FAST16_TYPE]
435 #define uint_fast32_type_node c_global_trees[CTI_UINT_FAST32_TYPE]
436 #define uint_fast64_type_node c_global_trees[CTI_UINT_FAST64_TYPE]
437 #define intptr_type_node c_global_trees[CTI_INTPTR_TYPE]
438 #define uintptr_type_node c_global_trees[CTI_UINTPTR_TYPE]
440 #define truthvalue_type_node c_global_trees[CTI_TRUTHVALUE_TYPE]
441 #define truthvalue_true_node c_global_trees[CTI_TRUTHVALUE_TRUE]
442 #define truthvalue_false_node c_global_trees[CTI_TRUTHVALUE_FALSE]
444 #define char_array_type_node c_global_trees[CTI_CHAR_ARRAY_TYPE]
445 #define char8_array_type_node c_global_trees[CTI_CHAR8_ARRAY_TYPE]
446 #define char16_array_type_node c_global_trees[CTI_CHAR16_ARRAY_TYPE]
447 #define char32_array_type_node c_global_trees[CTI_CHAR32_ARRAY_TYPE]
448 #define wchar_array_type_node c_global_trees[CTI_WCHAR_ARRAY_TYPE]
449 #define string_type_node c_global_trees[CTI_STRING_TYPE]
450 #define const_string_type_node c_global_trees[CTI_CONST_STRING_TYPE]
452 #define default_function_type c_global_trees[CTI_DEFAULT_FUNCTION_TYPE]
454 #define function_name_decl_node c_global_trees[CTI_FUNCTION_NAME_DECL]
455 #define pretty_function_name_decl_node \
456 c_global_trees[CTI_PRETTY_FUNCTION_NAME_DECL]
457 #define c99_function_name_decl_node c_global_trees[CTI_C99_FUNCTION_NAME_DECL]
458 #define saved_function_name_decls c_global_trees[CTI_SAVED_FUNCTION_NAME_DECLS]
460 /* The node for C++ `__null'. */
461 #define null_node c_global_trees[CTI_NULL]
463 /* We cache these tree nodes so as to call get_identifier less frequently.
464 For identifiers for functions, including special member functions such
465 as ctors and assignment operators, the nodes can be used (among other
466 things) to iterate over their overloads defined by/for a type. For
469 tree ovlid = assign_op_identifier;
470 tree overloads = get_class_binding (type, ovlid);
471 for (ovl_iterator it (overloads); it; ++it) { ... }
473 iterates over the set of implicitly and explicitly defined overloads
474 of the assignment operator for type (including the copy and move
475 assignment operators, whether deleted or not). */
477 /* The name of a constructor that takes an in-charge parameter to
478 decide whether or not to construct virtual base classes. */
479 #define ctor_identifier cp_global_trees[CPTI_CTOR_IDENTIFIER]
480 /* The name of a constructor that constructs virtual base classes. */
481 #define complete_ctor_identifier cp_global_trees[CPTI_COMPLETE_CTOR_IDENTIFIER]
482 /* The name of a constructor that does not construct virtual base classes. */
483 #define base_ctor_identifier cp_global_trees[CPTI_BASE_CTOR_IDENTIFIER]
484 /* The name of a destructor that takes an in-charge parameter to
485 decide whether or not to destroy virtual base classes and whether
486 or not to delete the object. */
487 #define dtor_identifier cp_global_trees[CPTI_DTOR_IDENTIFIER]
488 /* The name of a destructor that destroys virtual base classes. */
489 #define complete_dtor_identifier cp_global_trees[CPTI_COMPLETE_DTOR_IDENTIFIER]
490 /* The name of a destructor that does not destroy virtual base
492 #define base_dtor_identifier cp_global_trees[CPTI_BASE_DTOR_IDENTIFIER]
493 /* The name of a destructor that destroys virtual base classes, and
494 then deletes the entire object. */
495 #define deleting_dtor_identifier cp_global_trees[CPTI_DELETING_DTOR_IDENTIFIER]
497 /* The name used for conversion operators -- but note that actual
498 conversion functions use special identifiers outside the identifier
500 #define conv_op_identifier cp_global_trees[CPTI_CONV_OP_IDENTIFIER]
502 #define delta_identifier cp_global_trees[CPTI_DELTA_IDENTIFIER]
503 #define in_charge_identifier cp_global_trees[CPTI_IN_CHARGE_IDENTIFIER]
504 /* The name of the parameter that contains a pointer to the VTT to use
505 for this subobject constructor or destructor. */
506 #define vtt_parm_identifier cp_global_trees[CPTI_VTT_PARM_IDENTIFIER]
507 #define as_base_identifier cp_global_trees[CPTI_AS_BASE_IDENTIFIER]
508 #define this_identifier cp_global_trees[CPTI_THIS_IDENTIFIER]
509 #define pfn_identifier cp_global_trees[CPTI_PFN_IDENTIFIER]
510 #define vptr_identifier cp_global_trees[CPTI_VPTR_IDENTIFIER]
511 /* The name of the ::, std & anon namespaces. */
512 #define global_identifier cp_global_trees[CPTI_GLOBAL_IDENTIFIER]
513 #define anon_identifier cp_global_trees[CPTI_ANON_IDENTIFIER]
514 /* auto and declspec(auto) identifiers. */
515 #define auto_identifier cp_global_trees[CPTI_AUTO_IDENTIFIER]
516 #define decltype_auto_identifier cp_global_trees[CPTI_DECLTYPE_AUTO_IDENTIFIER]
517 #define init_list_identifier cp_global_trees[CPTI_INIT_LIST_IDENTIFIER]
518 #define for_range__identifier cp_global_trees[CPTI_FOR_RANGE__IDENTIFIER]
519 #define for_begin__identifier cp_global_trees[CPTI_FOR_BEGIN__IDENTIFIER]
520 #define for_end__identifier cp_global_trees[CPTI_FOR_END__IDENTIFIER]
521 #define for_range_identifier cp_global_trees[CPTI_FOR_RANGE_IDENTIFIER]
522 #define for_begin_identifier cp_global_trees[CPTI_FOR_BEGIN_IDENTIFIER]
523 #define for_end_identifier cp_global_trees[CPTI_FOR_END_IDENTIFIER]
524 #define abi_tag_identifier cp_global_trees[CPTI_ABI_TAG_IDENTIFIER]
525 #define aligned_identifier cp_global_trees[CPTI_ALIGNED_IDENTIFIER]
526 #define begin_identifier cp_global_trees[CPTI_BEGIN_IDENTIFIER]
527 #define end_identifier cp_global_trees[CPTI_END_IDENTIFIER]
528 #define get__identifier cp_global_trees[CPTI_GET_IDENTIFIER]
529 #define gnu_identifier cp_global_trees[CPTI_GNU_IDENTIFIER]
530 #define tuple_element_identifier cp_global_trees[CPTI_TUPLE_ELEMENT_IDENTIFIER]
531 #define tuple_size_identifier cp_global_trees[CPTI_TUPLE_SIZE_IDENTIFIER]
532 #define type_identifier cp_global_trees[CPTI_TYPE_IDENTIFIER]
533 #define value_identifier cp_global_trees[CPTI_VALUE_IDENTIFIER]
534 #define fun_identifier cp_global_trees[CPTI_FUN_IDENTIFIER]
535 #define closure_identifier cp_global_trees[CPTI_CLOSURE_IDENTIFIER]
536 #define heap_uninit_identifier cp_global_trees[CPTI_HEAP_UNINIT_IDENTIFIER]
537 #define heap_identifier cp_global_trees[CPTI_HEAP_IDENTIFIER]
538 #define heap_deleted_identifier cp_global_trees[CPTI_HEAP_DELETED_IDENTIFIER]
539 #define heap_vec_uninit_identifier \
540 cp_global_trees[CPTI_HEAP_VEC_UNINIT_IDENTIFIER]
541 #define heap_vec_identifier cp_global_trees[CPTI_HEAP_VEC_IDENTIFIER]
542 #define omp_identifier cp_global_trees[CPTI_OMP_IDENTIFIER]
543 #define lang_name_c cp_global_trees[CPTI_LANG_NAME_C]
544 #define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS]
546 /* Exception specifiers used for throw(), noexcept(true),
547 noexcept(false) and deferred noexcept. We rely on these being
549 #define empty_except_spec cp_global_trees[CPTI_EMPTY_EXCEPT_SPEC]
550 #define noexcept_true_spec cp_global_trees[CPTI_NOEXCEPT_TRUE_SPEC]
551 #define noexcept_false_spec cp_global_trees[CPTI_NOEXCEPT_FALSE_SPEC]
552 #define noexcept_deferred_spec cp_global_trees[CPTI_NOEXCEPT_DEFERRED_SPEC]
554 /* Exception handling function declarations. */
555 #define terminate_fn cp_global_trees[CPTI_TERMINATE_FN]
556 #define call_unexpected_fn cp_global_trees[CPTI_CALL_UNEXPECTED_FN]
557 #define get_exception_ptr_fn cp_global_trees[CPTI_GET_EXCEPTION_PTR_FN]
558 #define begin_catch_fn cp_global_trees[CPTI_BEGIN_CATCH_FN]
559 #define end_catch_fn cp_global_trees[CPTI_END_CATCH_FN]
560 #define allocate_exception_fn cp_global_trees[CPTI_ALLOCATE_EXCEPTION_FN]
561 #define free_exception_fn cp_global_trees[CPTI_FREE_EXCEPTION_FN]
562 #define throw_fn cp_global_trees[CPTI_THROW_FN]
563 #define rethrow_fn cp_global_trees[CPTI_RETHROW_FN]
565 /* The type of the function-pointer argument to "__cxa_atexit" (or
566 "std::atexit", if "__cxa_atexit" is not being used). */
567 #define atexit_fn_ptr_type_node cp_global_trees[CPTI_ATEXIT_FN_PTR_TYPE]
569 /* A pointer to `std::atexit'. */
570 #define atexit_node cp_global_trees[CPTI_ATEXIT]
572 /* A pointer to `__dso_handle'. */
573 #define dso_handle_node cp_global_trees[CPTI_DSO_HANDLE]
575 /* The declaration of the dynamic_cast runtime. */
576 #define dynamic_cast_node cp_global_trees[CPTI_DCAST]
578 /* The type of a destructor. */
579 #define cleanup_type cp_global_trees[CPTI_CLEANUP_TYPE]
581 /* The type of the vtt parameter passed to subobject constructors and
583 #define vtt_parm_type cp_global_trees[CPTI_VTT_PARM_TYPE]
585 /* A node which matches any template argument. */
586 #define any_targ_node cp_global_trees[CPTI_ANY_TARG]
588 /* std::source_location::__impl class. */
589 #define source_location_impl cp_global_trees[CPTI_SOURCE_LOCATION_IMPL]
591 /* These two accessors should only be used by OVL manipulators.
592 Other users should use iterators and convenience functions. */
593 #define OVL_FUNCTION(NODE) \
594 (((struct tree_overload *) OVERLOAD_CHECK (NODE))->function)
595 #define OVL_CHAIN(NODE) \
596 (((struct tree_overload *) OVERLOAD_CHECK (NODE))->common.chain)
598 /* If set, this or a subsequent overload contains decls that need deduping. */
599 #define OVL_DEDUP_P(NODE) TREE_LANG_FLAG_0 (OVERLOAD_CHECK (NODE))
600 /* If set, this was imported in a using declaration. */
601 #define OVL_USING_P(NODE) TREE_LANG_FLAG_1 (OVERLOAD_CHECK (NODE))
602 /* If set, this overload is a hidden decl. */
603 #define OVL_HIDDEN_P(NODE) TREE_LANG_FLAG_2 (OVERLOAD_CHECK (NODE))
604 /* If set, this overload contains a nested overload. */
605 #define OVL_NESTED_P(NODE) TREE_LANG_FLAG_3 (OVERLOAD_CHECK (NODE))
606 /* If set, this overload was constructed during lookup. */
607 #define OVL_LOOKUP_P(NODE) TREE_LANG_FLAG_4 (OVERLOAD_CHECK (NODE))
608 /* If set, this OVL_USING_P overload is exported. */
609 #define OVL_EXPORT_P(NODE) TREE_LANG_FLAG_5 (OVERLOAD_CHECK (NODE))
611 /* The first decl of an overload. */
612 #define OVL_FIRST(NODE) ovl_first (NODE)
613 /* The name of the overload set. */
614 #define OVL_NAME(NODE) DECL_NAME (OVL_FIRST (NODE))
616 /* Whether this is a set of overloaded functions. TEMPLATE_DECLS are
617 always wrapped in an OVERLOAD, so we don't need to check them
619 #define OVL_P(NODE) \
620 (TREE_CODE (NODE) == FUNCTION_DECL || TREE_CODE (NODE) == OVERLOAD)
621 /* Whether this is a single member overload. */
622 #define OVL_SINGLE_P(NODE) (TREE_CODE (NODE) != OVERLOAD || !OVL_CHAIN (NODE))
624 /* Nonzero means that this type has an X() constructor. */
625 #define TYPE_HAS_DEFAULT_CONSTRUCTOR(NODE) \
626 (LANG_TYPE_CLASS_CHECK (NODE)->has_default_ctor)
628 /* Nonzero means that NODE (a class type) has a default constructor --
629 but that it has not yet been declared. */
630 #define CLASSTYPE_LAZY_DEFAULT_CTOR(NODE) \
631 (LANG_TYPE_CLASS_CHECK (NODE)->lazy_default_ctor)
633 /* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These
634 are the constructors that take an in-charge parameter. */
635 #define CLASSTYPE_CONSTRUCTORS(NODE) \
636 (get_class_binding_direct (NODE, ctor_identifier))
638 /* In a TREE_LIST in an attribute list, indicates that the attribute
639 must be applied at instantiation time. */
640 #define ATTR_IS_DEPENDENT(NODE) TREE_LANG_FLAG_0 (TREE_LIST_CHECK (NODE))
642 /* In a TREE_LIST in the argument of attribute abi_tag, indicates that the tag
643 was inherited from a template parameter, not explicitly indicated. */
644 #define ABI_TAG_IMPLICIT(NODE) TREE_LANG_FLAG_0 (TREE_LIST_CHECK (NODE))
646 /* In a TREE_LIST for a parameter-declaration-list, indicates that all the
647 parameters in the list have declarators enclosed in (). */
648 #define PARENTHESIZED_LIST_P(NODE) TREE_LANG_FLAG_0 (TREE_LIST_CHECK (NODE))
650 /* Non zero if this is a using decl for a dependent scope. */
651 #define DECL_DEPENDENT_P(NODE) DECL_LANG_FLAG_0 (USING_DECL_CHECK (NODE))
653 /* The scope named in a using decl. */
654 #define USING_DECL_SCOPE(NODE) DECL_RESULT_FLD (USING_DECL_CHECK (NODE))
656 /* The decls named by a using decl. */
657 #define USING_DECL_DECLS(NODE) DECL_INITIAL (USING_DECL_CHECK (NODE))
659 /* Non zero if the using decl refers to a dependent type. */
660 #define USING_DECL_TYPENAME_P(NODE) DECL_LANG_FLAG_1 (USING_DECL_CHECK (NODE))
662 /* True if member using decl NODE refers to a non-inherited NODE. */
663 #define USING_DECL_UNRELATED_P(NODE) DECL_LANG_FLAG_2 (USING_DECL_CHECK (NODE))
665 /* Nonzero if NODE declares a function. */
666 #define DECL_DECLARES_FUNCTION_P(NODE) (TREE_CODE (NODE) == FUNCTION_DECL)
668 /* Nonzero for a NODE which declares a type. */
669 #define DECL_DECLARES_TYPE_P(NODE) (TREE_CODE (NODE) == TYPE_DECL)
672 #define IDENTIFIER_KIND_BIT_0(NODE) \
673 TREE_LANG_FLAG_0 (IDENTIFIER_NODE_CHECK (NODE))
674 #define IDENTIFIER_KIND_BIT_1(NODE) \
675 TREE_LANG_FLAG_1 (IDENTIFIER_NODE_CHECK (NODE))
676 #define IDENTIFIER_KIND_BIT_2(NODE) \
677 TREE_LANG_FLAG_2 (IDENTIFIER_NODE_CHECK (NODE))
679 /* Used by various search routines. */
680 #define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_4 (IDENTIFIER_NODE_CHECK (NODE))
682 /* Nonzero if this identifier is used as a virtual function name somewhere
683 (optimizes searches). */
684 #define IDENTIFIER_VIRTUAL_P(NODE) \
685 TREE_LANG_FLAG_5 (IDENTIFIER_NODE_CHECK (NODE))
687 /* True if this identifier is a reserved word. C_RID_CODE (node) is
688 then the RID_* value of the keyword. Value 1. */
689 #define IDENTIFIER_KEYWORD_P(NODE) \
690 ((!IDENTIFIER_KIND_BIT_2 (NODE)) & (!IDENTIFIER_KIND_BIT_1 (NODE)) \
691 & IDENTIFIER_KIND_BIT_0 (NODE))
693 /* True if this identifier is the name of a constructor or
694 destructor. Value 2 or 3. */
695 #define IDENTIFIER_CDTOR_P(NODE) \
696 ((!IDENTIFIER_KIND_BIT_2 (NODE)) & IDENTIFIER_KIND_BIT_1 (NODE))
698 /* True if this identifier is the name of a constructor. Value 2. */
699 #define IDENTIFIER_CTOR_P(NODE) \
700 (IDENTIFIER_CDTOR_P (NODE) & (!IDENTIFIER_KIND_BIT_0 (NODE)))
702 /* True if this identifier is the name of a destructor. Value 3. */
703 #define IDENTIFIER_DTOR_P(NODE) \
704 (IDENTIFIER_CDTOR_P (NODE) & IDENTIFIER_KIND_BIT_0 (NODE))
706 /* True if this identifier is for any operator name (including
707 conversions). Value 4, 5, 6 or 7. */
708 #define IDENTIFIER_ANY_OP_P(NODE) (IDENTIFIER_KIND_BIT_2 (NODE))
710 /* True if this identifier is for an overloaded operator. Values 4, 5. */
711 #define IDENTIFIER_OVL_OP_P(NODE) \
712 (IDENTIFIER_ANY_OP_P (NODE) & (!IDENTIFIER_KIND_BIT_1 (NODE)))
714 /* True if this identifier is for any assignment. Values 5. */
715 #define IDENTIFIER_ASSIGN_OP_P(NODE) \
716 (IDENTIFIER_OVL_OP_P (NODE) & IDENTIFIER_KIND_BIT_0 (NODE))
718 /* True if this identifier is the name of a type-conversion
719 operator. Value 7. */
720 #define IDENTIFIER_CONV_OP_P(NODE) \
721 (IDENTIFIER_ANY_OP_P (NODE) & IDENTIFIER_KIND_BIT_1 (NODE) \
722 & (!IDENTIFIER_KIND_BIT_0 (NODE)))
724 /* True if this identifier is a new or delete operator. */
725 #define IDENTIFIER_NEWDEL_OP_P(NODE) \
726 (IDENTIFIER_OVL_OP_P (NODE) \
727 && IDENTIFIER_OVL_OP_FLAGS (NODE) & OVL_OP_FLAG_ALLOC)
729 /* True if this identifier is a new operator. */
730 #define IDENTIFIER_NEW_OP_P(NODE) \
731 (IDENTIFIER_OVL_OP_P (NODE) \
732 && (IDENTIFIER_OVL_OP_FLAGS (NODE) \
733 & (OVL_OP_FLAG_ALLOC | OVL_OP_FLAG_DELETE)) \
734 == OVL_OP_FLAG_ALLOC)
736 /* Nonzero if the class NODE has multiple paths to the same (virtual)
738 #define CLASSTYPE_DIAMOND_SHAPED_P(NODE) \
739 (LANG_TYPE_CLASS_CHECK (NODE)->diamond_shaped)
741 /* Nonzero if the class NODE has multiple instances of the same base
743 #define CLASSTYPE_REPEATED_BASE_P(NODE) \
744 (LANG_TYPE_CLASS_CHECK (NODE)->repeated_base)
746 /* The member function with which the vtable will be emitted:
747 the first noninline non-pure-virtual member function. NULL_TREE
748 if there is no key function or if this is a class template */
749 #define CLASSTYPE_KEY_METHOD(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->key_method)
751 /* Vector of members. During definition, it is unordered and only
752 member functions are present. After completion it is sorted and
753 contains both member functions and non-functions. STAT_HACK is
754 involved to preserve oneslot per name invariant. */
755 #define CLASSTYPE_MEMBER_VEC(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->members)
757 /* For class templates, this is a TREE_LIST of all member data,
758 functions, types, and friends in the order of declaration.
759 The TREE_PURPOSE of each TREE_LIST is NULL_TREE for a friend,
760 and the RECORD_TYPE for the class template otherwise. */
761 #define CLASSTYPE_DECL_LIST(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->decl_list)
763 /* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These
764 are the constructors that take an in-charge parameter. */
765 #define CLASSTYPE_CONSTRUCTORS(NODE) \
766 (get_class_binding_direct (NODE, ctor_identifier))
768 /* A FUNCTION_DECL for the destructor for NODE. This is the
769 destructors that take an in-charge parameter. If
770 CLASSTYPE_LAZY_DESTRUCTOR is true, then this entry will be NULL
771 until the destructor is created with lazily_declare_fn. */
772 #define CLASSTYPE_DESTRUCTOR(NODE) \
773 (get_class_binding_direct (NODE, dtor_identifier))
775 /* Nonzero if NODE has a primary base class, i.e., a base class with
776 which it shares the virtual function table pointer. */
777 #define CLASSTYPE_HAS_PRIMARY_BASE_P(NODE) \
778 (CLASSTYPE_PRIMARY_BINFO (NODE) != NULL_TREE)
780 /* If non-NULL, this is the binfo for the primary base class, i.e.,
781 the base class which contains the virtual function table pointer
783 #define CLASSTYPE_PRIMARY_BINFO(NODE) \
784 (LANG_TYPE_CLASS_CHECK (NODE)->primary_base)
786 /* A vector of BINFOs for the direct and indirect virtual base classes
787 that this type uses in a post-order depth-first left-to-right
788 order. (In other words, these bases appear in the order that they
789 should be initialized.) */
790 #define CLASSTYPE_VBASECLASSES(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->vbases)
792 /* The type corresponding to NODE when NODE is used as a base class,
793 i.e., NODE without virtual base classes or tail padding. */
794 #define CLASSTYPE_AS_BASE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->as_base)
796 /* Nonzero if NODE is a user-defined conversion operator. */
797 #define DECL_CONV_FN_P(NODE) IDENTIFIER_CONV_OP_P (DECL_NAME (NODE))
799 /* The type to which conversion operator FN converts to. */
800 #define DECL_CONV_FN_TYPE(FN) \
801 TREE_TYPE ((gcc_checking_assert (DECL_CONV_FN_P (FN)), DECL_NAME (FN)))
803 /* Returns nonzero iff TYPE1 and TYPE2 are the same type, in the usual
805 #define same_type_p(TYPE1, TYPE2) comptypes ((TYPE1), (TYPE2), COMPARE_STRICT)
807 /* Nonzero if T is a type that could resolve to any kind of concrete type
808 at instantiation time. */
809 #define WILDCARD_TYPE_P(T) \
810 (TREE_CODE (T) == TEMPLATE_TYPE_PARM || TREE_CODE (T) == TYPENAME_TYPE \
811 || TREE_CODE (T) == TYPEOF_TYPE \
812 || TREE_CODE (T) == BOUND_TEMPLATE_TEMPLATE_PARM \
813 || TREE_CODE (T) == DECLTYPE_TYPE \
814 || TREE_CODE (T) == DEPENDENT_OPERATOR_TYPE)
816 /* Nonzero if T is a class (or struct or union) type. Also nonzero
817 for template type parameters, typename types, and instantiated
818 template template parameters. Keep these checks in ascending code
820 #define MAYBE_CLASS_TYPE_P(T) (WILDCARD_TYPE_P (T) || CLASS_TYPE_P (T))
822 /* 1 iff FUNCTION_TYPE or METHOD_TYPE has a ref-qualifier (either & or &&). */
823 #define FUNCTION_REF_QUALIFIED(NODE) \
824 TREE_LANG_FLAG_4 (FUNC_OR_METHOD_CHECK (NODE))
826 /* 1 iff FUNCTION_TYPE or METHOD_TYPE has &&-ref-qualifier. */
827 #define FUNCTION_RVALUE_QUALIFIED(NODE) \
828 TREE_LANG_FLAG_5 (FUNC_OR_METHOD_CHECK (NODE))
830 /* Get the POINTER_TYPE to the METHOD_TYPE associated with this
831 pointer to member function. TYPE_PTRMEMFUNC_P _must_ be true,
832 before using this macro. */
833 #define TYPE_PTRMEMFUNC_FN_TYPE(NODE) \
834 (rs_build_qualified_type (TREE_TYPE (TYPE_FIELDS (NODE)), \
835 rs_type_quals (NODE)))
837 /* As above, but can be used in places that want an lvalue at the expense
838 of not necessarily having the correct cv-qualifiers. */
839 #define TYPE_PTRMEMFUNC_FN_TYPE_RAW(NODE) (TREE_TYPE (TYPE_FIELDS (NODE)))
841 /* True if this type is dependent. This predicate is only valid if
842 TYPE_DEPENDENT_P_VALID is true. */
843 #define TYPE_DEPENDENT_P(NODE) TYPE_LANG_FLAG_0 (NODE)
845 /* True if dependent_type_p has been called for this type, with the
846 result that TYPE_DEPENDENT_P is valid. */
847 #define TYPE_DEPENDENT_P_VALID(NODE) TYPE_LANG_FLAG_6 (NODE)
849 /* Nonzero for _TYPE node means that this type does not have a trivial
850 destructor. Therefore, destroying an object of this type will
851 involve a call to a destructor. This can apply to objects of
852 ARRAY_TYPE if the type of the elements needs a destructor. */
853 #define TYPE_HAS_NONTRIVIAL_DESTRUCTOR(NODE) (TYPE_LANG_FLAG_4 (NODE))
855 /* For FUNCTION_TYPE or METHOD_TYPE, a list of the exceptions that
856 this type can raise. Each TREE_VALUE is a _TYPE. The TREE_VALUE
857 will be NULL_TREE to indicate a throw specification of `()', or
858 no exceptions allowed. For a noexcept specification, TREE_VALUE
859 is NULL_TREE and TREE_PURPOSE is the constant-expression. For
860 a deferred noexcept-specification, TREE_PURPOSE is a DEFERRED_NOEXCEPT
861 (for templates) or an OVERLOAD list of functions (for implicitly
862 declared functions). */
863 #define TYPE_RAISES_EXCEPTIONS(NODE) \
864 TYPE_LANG_SLOT_1 (FUNC_OR_METHOD_CHECK (NODE))
866 /* Identifiers map directly to block or class-scope bindings.
867 Namespace-scope bindings are held in hash tables on the respective
868 namespaces. The identifier bindings are the innermost active
869 binding, from whence you can get the decl and/or implicit-typedef
870 of an elaborated type. When not bound to a local entity the
872 #define IDENTIFIER_BINDING(NODE) (LANG_IDENTIFIER_CAST (NODE)->bindings)
874 #define LANG_IDENTIFIER_CAST(NODE) \
875 ((struct lang_identifier *) IDENTIFIER_NODE_CHECK (NODE))
877 /* IF_STMT accessors. These give access to the condition of the if
878 statement, the then block of the if statement, and the else block
879 of the if statement if it exists. */
880 #define IF_COND(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 0)
881 #define THEN_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 1)
882 #define ELSE_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 2)
883 #define IF_SCOPE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 3)
884 #define IF_STMT_CONSTEXPR_P(NODE) TREE_LANG_FLAG_0 (IF_STMT_CHECK (NODE))
885 #define IF_STMT_CONSTEVAL_P(NODE) TREE_LANG_FLAG_2 (IF_STMT_CHECK (NODE))
887 /* The expression in question for a DECLTYPE_TYPE. */
888 #define DECLTYPE_TYPE_EXPR(NODE) (TYPE_VALUES_RAW (DECLTYPE_TYPE_CHECK (NODE)))
890 #define SET_CLASSTYPE_INTERFACE_UNKNOWN_X(NODE, X) \
891 (LANG_TYPE_CLASS_CHECK (NODE)->interface_unknown = !!(X))
893 /* Nonzero if this class is included from a header file which employs
894 `#pragma interface', and it is not included in its implementation file. */
895 #define CLASSTYPE_INTERFACE_ONLY(NODE) \
896 (LANG_TYPE_CLASS_CHECK (NODE)->interface_only)
898 #define TYPE_NAME_STRING(NODE) (IDENTIFIER_POINTER (TYPE_IDENTIFIER (NODE)))
899 #define TYPE_NAME_LENGTH(NODE) (IDENTIFIER_LENGTH (TYPE_IDENTIFIER (NODE)))
901 /* Whether a PARM_DECL represents a local parameter in a
902 requires-expression. */
903 #define CONSTRAINT_VAR_P(NODE) DECL_LANG_FLAG_2 (TREE_CHECK (NODE, PARM_DECL))
905 /* In a CALL_EXPR appearing in a template, true if Koenig lookup
906 should be performed at instantiation time. */
907 #define KOENIG_LOOKUP_P(NODE) TREE_LANG_FLAG_0 (CALL_EXPR_CHECK (NODE))
909 /* The index of a user-declared parameter in its function, starting at 1.
910 All artificial parameters will have index 0. */
911 #define DECL_PARM_INDEX(NODE) (LANG_DECL_PARM_CHECK (NODE)->index)
913 /* The level of a user-declared parameter in its function, starting at 1.
914 A parameter of the function will have level 1; a parameter of the first
915 nested function declarator (i.e. t in void f (void (*p)(T t))) will have
917 #define DECL_PARM_LEVEL(NODE) (LANG_DECL_PARM_CHECK (NODE)->level)
919 /* These flags are used by the conversion code.
920 CONV_IMPLICIT : Perform implicit conversions (standard and user-defined).
921 CONV_STATIC : Perform the explicit conversions for static_cast.
922 CONV_CONST : Perform the explicit conversions for const_cast.
923 CONV_REINTERPRET: Perform the explicit conversions for reinterpret_cast.
924 CONV_PRIVATE : Perform upcasts to private bases.
925 CONV_FORCE_TEMP : Require a new temporary when converting to the same
928 #define CONV_IMPLICIT 1
929 #define CONV_STATIC 2
931 #define CONV_REINTERPRET 8
932 #define CONV_PRIVATE 16
933 #define CONV_FORCE_TEMP 32
935 #define CONV_OLD_CONVERT \
936 (CONV_IMPLICIT | CONV_STATIC | CONV_CONST | CONV_REINTERPRET)
937 #define CONV_C_CAST \
938 (CONV_IMPLICIT | CONV_STATIC | CONV_CONST | CONV_REINTERPRET | CONV_PRIVATE \
940 #define CONV_BACKEND_CONVERT (CONV_OLD_CONVERT | CONV_FOLD)
942 /* Used by build_expr_type_conversion to indicate which types are
943 acceptable as arguments to the expression under consideration. */
945 #define WANT_INT 1 /* integer types, including bool */
946 #define WANT_FLOAT 2 /* floating point types */
947 #define WANT_ENUM 4 /* enumerated types */
948 #define WANT_POINTER 8 /* pointer types */
949 #define WANT_NULL 16 /* null pointer constant */
950 #define WANT_VECTOR_OR_COMPLEX 32 /* vector or complex types */
951 #define WANT_ARITH (WANT_INT | WANT_FLOAT | WANT_VECTOR_OR_COMPLEX)
953 /* Used with comptypes, and related functions, to guide type
956 #define COMPARE_STRICT \
957 0 /* Just check if the types are the \
959 #define COMPARE_BASE \
960 1 /* Check to see if the second type is \
961 derived from the first. */
962 #define COMPARE_DERIVED \
963 2 /* Like COMPARE_BASE, but in \
965 #define COMPARE_REDECLARATION \
966 4 /* The comparison is being done when \
967 another declaration of an existing \
969 #define COMPARE_STRUCTURAL \
970 8 /* The comparison is intended to be \
971 structural. The actual comparison \
972 will be identical to \
975 /* Used with start function. */
976 #define SF_DEFAULT 0 /* No flags. */
977 #define SF_PRE_PARSED \
978 1 /* The function declaration has \
979 already been parsed. */
980 #define SF_INCLASS_INLINE \
981 2 /* The function is an inline, defined \
982 in the class body. */
984 /* Used with start_decl's initialized parameter. */
985 #define SD_UNINITIALIZED 0
986 #define SD_INITIALIZED 1
987 /* Like SD_INITIALIZED, but also mark the new decl as DECL_DECOMPOSITION_P. */
988 #define SD_DECOMPOSITION 2
989 #define SD_DEFAULTED 3
992 /* Returns nonzero iff TYPE1 and TYPE2 are the same type, in the usual
994 #define same_type_p(TYPE1, TYPE2) comptypes ((TYPE1), (TYPE2), COMPARE_STRICT)
996 /* Returns true if NODE is a pointer-to-data-member. */
997 #define TYPE_PTRDATAMEM_P(NODE) (TREE_CODE (NODE) == OFFSET_TYPE)
999 /* Nonzero if this type is const-qualified. */
1000 #define RS_TYPE_CONST_P(NODE) ((rs_type_quals (NODE) & TYPE_QUAL_CONST) != 0)
1002 /* The _DECL for this _TYPE. */
1003 #define TYPE_MAIN_DECL(NODE) (TYPE_STUB_DECL (TYPE_MAIN_VARIANT (NODE)))
1005 /* Nonzero for a VAR_DECL iff an explicit initializer was provided
1006 or a non-trivial constructor is called. */
1007 #define DECL_NONTRIVIALLY_INITIALIZED_P(NODE) \
1008 (TREE_LANG_FLAG_6 (VAR_DECL_CHECK (NODE)))
1010 /* Nonzero if DECL was declared with '= default' (maybe implicitly). */
1011 #define DECL_DEFAULTED_FN(DECL) (LANG_DECL_FN_CHECK (DECL)->defaulted_p)
1013 /* Nonzero for a class type means that the class type has a
1014 user-declared constructor. */
1015 #define TYPE_HAS_USER_CONSTRUCTOR(NODE) (TYPE_LANG_FLAG_1 (NODE))
1017 /* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These
1018 are the constructors that take an in-charge parameter. */
1019 #define CLASSTYPE_CONSTRUCTORS(NODE) \
1020 (get_class_binding_direct (NODE, ctor_identifier))
1022 /* Nonzero if the DECL was initialized in the class definition itself,
1023 rather than outside the class. This is used for both static member
1024 VAR_DECLS, and FUNCTION_DECLS that are defined in the class. */
1025 #define DECL_INITIALIZED_IN_CLASS_P(DECL) \
1026 (DECL_LANG_SPECIFIC (VAR_OR_FUNCTION_DECL_CHECK (DECL)) \
1027 ->u.base.initialized_in_class)
1029 /* Nonzero if DECL is explicitly defaulted in the class body. */
1030 #define DECL_DEFAULTED_IN_CLASS_P(DECL) \
1031 (DECL_DEFAULTED_FN (DECL) && DECL_INITIALIZED_IN_CLASS_P (DECL))
1033 /* Nonzero for FUNCTION_DECL means that this decl is a non-static
1035 #define DECL_NONSTATIC_MEMBER_FUNCTION_P(NODE) \
1036 (TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE)
1038 /* For FUNCTION_DECLs: nonzero means that this function is a
1039 constructor or a destructor with an extra in-charge parameter to
1040 control whether or not virtual bases are constructed. */
1041 #define DECL_HAS_IN_CHARGE_PARM_P(NODE) \
1042 (LANG_DECL_FN_CHECK (NODE)->has_in_charge_parm_p)
1044 /* Nonzero if the VTT parm has been added to NODE. */
1045 #define DECL_HAS_VTT_PARM_P(NODE) (LANG_DECL_FN_CHECK (NODE)->has_vtt_parm_p)
1047 /* Given a FUNCTION_DECL, returns the first TREE_LIST out of TYPE_ARG_TYPES
1048 which refers to a user-written parameter. */
1049 #define FUNCTION_FIRST_USER_PARMTYPE(NODE) \
1050 skip_artificial_parms_for ((NODE), TYPE_ARG_TYPES (TREE_TYPE (NODE)))
1052 /* Similarly, but for DECL_ARGUMENTS. */
1053 #define FUNCTION_FIRST_USER_PARM(NODE) \
1054 skip_artificial_parms_for ((NODE), DECL_ARGUMENTS (NODE))
1056 /* For FUNCTION_DECLs and TEMPLATE_DECLs: nonzero means that this function
1057 is a constructor. */
1058 #define DECL_CONSTRUCTOR_P(NODE) DECL_CXX_CONSTRUCTOR_P (NODE)
1060 /* Nonzero if DECL was declared with '= delete'. */
1061 #define DECL_DELETED_FN(DECL) \
1062 (LANG_DECL_FN_CHECK (DECL)->min.base.threadprivate_or_deleted_p)
1064 /* Nonzero if DECL was declared with '= default' (maybe implicitly). */
1065 #define DECL_DEFAULTED_FN(DECL) (LANG_DECL_FN_CHECK (DECL)->defaulted_p)
1067 /* True if NODE is a brace-enclosed initializer. */
1068 #define BRACE_ENCLOSED_INITIALIZER_P(NODE) \
1069 (TREE_CODE (NODE) == CONSTRUCTOR && TREE_TYPE (NODE) == init_list_type_node)
1071 /* True if FNDECL is an immediate function. */
1072 #define DECL_IMMEDIATE_FUNCTION_P(NODE) \
1073 (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE)) \
1074 ? LANG_DECL_FN_CHECK (NODE)->immediate_fn_p \
1076 #define SET_DECL_IMMEDIATE_FUNCTION_P(NODE) \
1077 (retrofit_lang_decl (FUNCTION_DECL_CHECK (NODE)), \
1078 LANG_DECL_FN_CHECK (NODE)->immediate_fn_p = true)
1080 /* True if this CONSTRUCTOR should not be used as a variable initializer
1081 because it was loaded from a constexpr variable with mutable fields. */
1082 #define CONSTRUCTOR_MUTABLE_POISON(NODE) \
1083 (TREE_LANG_FLAG_2 (CONSTRUCTOR_CHECK (NODE)))
1085 /* For a pointer-to-member constant `X::Y' this is the _DECL for
1087 #define PTRMEM_CST_MEMBER(NODE) \
1088 (((ptrmem_cst_t) PTRMEM_CST_CHECK (NODE))->member)
1090 /* Indicates whether a COMPONENT_REF or a SCOPE_REF has been parenthesized, an
1091 INDIRECT_REF comes from parenthesizing a _DECL, or a PAREN_EXPR identifies a
1092 parenthesized initializer relevant for decltype(auto). Currently only set
1093 some of the time in C++14 mode. */
1095 #define REF_PARENTHESIZED_P(NODE) \
1096 TREE_LANG_FLAG_2 (TREE_CHECK5 ((NODE), COMPONENT_REF, INDIRECT_REF, \
1097 SCOPE_REF, VIEW_CONVERT_EXPR, PAREN_EXPR))
1099 /* Returns true if NODE is a pointer-to-member. */
1100 #define TYPE_PTRMEM_P(NODE) \
1101 (TYPE_PTRDATAMEM_P (NODE) || TYPE_PTRMEMFUNC_P (NODE))
1103 /* Returns true if NODE is a pointer or a pointer-to-member. */
1104 #define TYPE_PTR_OR_PTRMEM_P(NODE) (TYPE_PTR_P (NODE) || TYPE_PTRMEM_P (NODE))
1106 /* Nonzero if NODE is an artificial VAR_DECL for a C++17 structured binding
1107 declaration or one of VAR_DECLs for the user identifiers in it. */
1108 #define DECL_DECOMPOSITION_P(NODE) \
1109 (VAR_P (NODE) && DECL_LANG_SPECIFIC (NODE) \
1110 ? DECL_LANG_SPECIFIC (NODE)->u.base.selector == lds_decomp \
1113 /* The underlying artificial VAR_DECL for structured binding. */
1114 #define DECL_DECOMP_BASE(NODE) (LANG_DECL_DECOMP_CHECK (NODE)->base)
1116 /* Nonzero if either DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P or
1117 DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P is true of NODE. */
1118 #define DECL_MAYBE_IN_CHARGE_CDTOR_P(NODE) \
1119 (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (NODE) \
1120 || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (NODE))
1122 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor, but not the
1123 specialized in-charge constructor, in-charge deleting constructor,
1124 or the base destructor. */
1125 #define DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P(NODE) \
1126 (DECL_NAME (NODE) == dtor_identifier)
1128 /* Nonzero if NODE (a _DECL) is a cloned constructor or
1130 #define DECL_CLONED_FUNCTION_P(NODE) \
1131 (DECL_NAME (NODE) && IDENTIFIER_CDTOR_P (DECL_NAME (NODE)) \
1132 && !DECL_MAYBE_IN_CHARGE_CDTOR_P (NODE))
1134 /* If DECL_CLONED_FUNCTION_P holds, this is the function that was
1136 #define DECL_CLONED_FUNCTION(NODE) \
1137 (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE))->u.fn.u5.cloned_function)
1139 /* Nonzero if NODE (a _DECL) is a cloned constructor or
1141 #define DECL_CLONED_FUNCTION_P(NODE) \
1142 (DECL_NAME (NODE) && IDENTIFIER_CDTOR_P (DECL_NAME (NODE)) \
1143 && !DECL_MAYBE_IN_CHARGE_CDTOR_P (NODE))
1145 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor, but not either the
1146 specialized in-charge constructor or the specialized not-in-charge
1148 #define DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P(NODE) \
1149 (DECL_NAME (NODE) == ctor_identifier)
1151 /* The current C++-specific per-function global variables. */
1153 #define cp_function_chain (cfun->language)
1155 /* In a constructor destructor, the point at which all derived class
1156 destroying/construction has been done. I.e., just before a
1157 constructor returns, or before any base class destroying will be done
1160 #define cdtor_label cp_function_chain->x_cdtor_label
1162 /* When we're processing a member function, current_class_ptr is the
1163 PARM_DECL for the `this' pointer. The current_class_ref is an
1164 expression for `*this'. */
1166 #define current_class_ptr \
1167 (*(cfun && cp_function_chain ? &cp_function_chain->x_current_class_ptr \
1168 : &scope_chain->x_current_class_ptr))
1169 #define current_class_ref \
1170 (*(cfun && cp_function_chain ? &cp_function_chain->x_current_class_ref \
1171 : &scope_chain->x_current_class_ref))
1173 /* The EH_SPEC_BLOCK for the exception-specifiers for the current
1174 function, if any. */
1176 #define current_eh_spec_block cp_function_chain->x_eh_spec_block
1178 /* The `__in_chrg' parameter for the current function. Only used for
1179 constructors and destructors. */
1181 #define current_in_charge_parm cp_function_chain->x_in_charge_parm
1183 /* The `__vtt_parm' parameter for the current function. Only used for
1184 constructors and destructors. */
1186 #define current_vtt_parm cp_function_chain->x_vtt_parm
1188 /* A boolean flag to control whether we need to clean up the return value if a
1189 local destructor throws. Only used in functions that return by value a
1190 class with a destructor. Which 'tors don't, so we can use the same
1191 field as current_vtt_parm. */
1193 #define current_retval_sentinel current_vtt_parm
1195 /* Set to 0 at beginning of a function definition, set to 1 if
1196 a return statement that specifies a return value is seen. */
1198 #define current_function_returns_value cp_function_chain->returns_value
1200 /* Set to 0 at beginning of a function definition, set to 1 if
1201 a return statement with no argument is seen. */
1203 #define current_function_returns_null cp_function_chain->returns_null
1205 /* Set to 0 at beginning of a function definition, set to 1 if
1206 a call to a noreturn function is seen. */
1208 #define current_function_returns_abnormally \
1209 cp_function_chain->returns_abnormally
1211 /* Set to 0 at beginning of a function definition, set to 1 if we see an
1212 obvious infinite loop. This can have false positives and false
1213 negatives, so it should only be used as a heuristic. */
1215 #define current_function_infinite_loop cp_function_chain->infinite_loop
1217 /* Nonzero if we are processing a base initializer. Zero elsewhere. */
1218 #define in_base_initializer cp_function_chain->x_in_base_initializer
1220 #define in_function_try_handler cp_function_chain->x_in_function_try_handler
1222 /* Expression always returned from function, or error_mark_node
1223 otherwise, for use by the automatic named return value optimization. */
1225 #define current_function_return_value (cp_function_chain->x_return_value)
1227 #define current_class_type scope_chain->class_type
1229 #define in_discarded_stmt scope_chain->discarded_stmt
1230 #define in_consteval_if_p scope_chain->consteval_if_p
1232 /* Nonzero means that this type is being defined. I.e., the left brace
1233 starting the definition of this type has been seen. */
1234 #define TYPE_BEING_DEFINED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->being_defined)
1236 /* Nonzero for FUNCTION_DECL means that this decl is a static
1238 #define DECL_STATIC_FUNCTION_P(NODE) \
1239 (LANG_DECL_FN_CHECK (NODE)->static_function)
1241 /* Nonzero for FUNCTION_DECL means that this decl is a non-static
1243 #define DECL_NONSTATIC_MEMBER_FUNCTION_P(NODE) \
1244 (TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE)
1246 /* Nonzero for FUNCTION_DECL means that this decl is a member function
1247 (static or non-static). */
1248 #define DECL_FUNCTION_MEMBER_P(NODE) \
1249 (DECL_NONSTATIC_MEMBER_FUNCTION_P (NODE) || DECL_STATIC_FUNCTION_P (NODE))
1251 /* Nonzero if NODE is the target for genericization of 'return' stmts
1252 in constructors/destructors of targetm.cxx.cdtor_returns_this targets. */
1253 #define LABEL_DECL_CDTOR(NODE) DECL_LANG_FLAG_2 (LABEL_DECL_CHECK (NODE))
1255 /* Nonzero if this NOP_EXPR is a reinterpret_cast. Such conversions
1256 are not constexprs. Other NOP_EXPRs are. */
1257 #define REINTERPRET_CAST_P(NODE) TREE_LANG_FLAG_0 (NOP_EXPR_CHECK (NODE))
1259 /* Returns true if NODE is an object type:
1263 An object type is a (possibly cv-qualified) type that is not a
1264 function type, not a reference type, and not a void type.
1266 Keep these checks in ascending order, for speed. */
1267 #define TYPE_OBJ_P(NODE) \
1268 (!TYPE_REF_P (NODE) && !VOID_TYPE_P (NODE) && !FUNC_OR_METHOD_TYPE_P (NODE))
1270 /* Returns true if NODE is a pointer to an object. Keep these checks
1271 in ascending tree code order. */
1272 #define TYPE_PTROB_P(NODE) (TYPE_PTR_P (NODE) && TYPE_OBJ_P (TREE_TYPE (NODE)))
1274 /* True if this CONSTRUCTOR contains PLACEHOLDER_EXPRs referencing the
1275 CONSTRUCTOR's type not nested inside another CONSTRUCTOR marked with
1276 CONSTRUCTOR_PLACEHOLDER_BOUNDARY. */
1277 #define CONSTRUCTOR_PLACEHOLDER_BOUNDARY(NODE) \
1278 (TREE_LANG_FLAG_5 (CONSTRUCTOR_CHECK (NODE)))
1280 #define AGGR_INIT_EXPR_SLOT(NODE) TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 2)
1282 /* True if this TARGET_EXPR expresses direct-initialization of an object
1283 to be named later. */
1284 #define TARGET_EXPR_DIRECT_INIT_P(NODE) \
1285 TREE_LANG_FLAG_2 (TARGET_EXPR_CHECK (NODE))
1287 /* Nonzero if DECL is a declaration of __builtin_constant_p. */
1288 #define DECL_IS_BUILTIN_CONSTANT_P(NODE) \
1289 (TREE_CODE (NODE) == FUNCTION_DECL \
1290 && DECL_BUILT_IN_CLASS (NODE) == BUILT_IN_NORMAL \
1291 && DECL_FUNCTION_CODE (NODE) == BUILT_IN_CONSTANT_P)
1293 /* True iff this represents an lvalue being treated as an rvalue during return
1294 or throw as per [class.copy.elision]. */
1295 #define IMPLICIT_RVALUE_P(NODE) \
1296 TREE_LANG_FLAG_3 (TREE_CHECK2 ((NODE), NON_LVALUE_EXPR, STATIC_CAST_EXPR))
1298 /* Nonzero for _DECL means that this decl appears in (or will appear
1299 in) as a member in a RECORD_TYPE or UNION_TYPE node. It is also for
1300 detecting circularity in case members are multiply defined. In the
1301 case of a VAR_DECL, it means that no definition has been seen, even
1302 if an initializer has been. */
1303 #define DECL_IN_AGGR_P(NODE) (DECL_LANG_FLAG_3 (NODE))
1305 /* Nonzero means that this class type is a non-standard-layout class. */
1306 #define CLASSTYPE_NON_STD_LAYOUT(NODE) \
1307 (LANG_TYPE_CLASS_CHECK (NODE)->non_std_layout)
1309 /* Nonzero for FIELD_DECL node means that this field is a base class
1310 of the parent object, as opposed to a member field. */
1311 #define DECL_FIELD_IS_BASE(NODE) DECL_LANG_FLAG_6 (FIELD_DECL_CHECK (NODE))
1313 /* Nonzero if TYPE is an anonymous union type. */
1314 #define ANON_UNION_TYPE_P(NODE) \
1315 (TREE_CODE (NODE) == UNION_TYPE && ANON_AGGR_TYPE_P (NODE))
1317 /* For an ANON_AGGR_TYPE_P the single FIELD_DECL it is used with. */
1318 #define ANON_AGGR_TYPE_FIELD(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->typeinfo_var)
1320 /* Nonzero if TYPE is an anonymous union or struct type. We have to use a
1321 flag for this because "A union for which objects or pointers are
1322 declared is not an anonymous union" [class.union]. */
1323 #define ANON_AGGR_TYPE_P(NODE) \
1324 (CLASS_TYPE_P (NODE) && LANG_TYPE_CLASS_CHECK (NODE)->anon_aggr)
1325 #define SET_ANON_AGGR_TYPE_P(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->anon_aggr = 1)
1327 /* Nonzero if T is a class type but not a union. */
1328 #define NON_UNION_CLASS_TYPE_P(T) \
1329 (TREE_CODE (T) == RECORD_TYPE && TYPE_LANG_FLAG_5 (T))
1331 /* Determines whether an ENUMERAL_TYPE has an explicit
1333 #define ENUM_FIXED_UNDERLYING_TYPE_P(NODE) (TYPE_LANG_FLAG_5 (NODE))
1335 /* Returns the underlying type of the given enumeration type. The
1336 underlying type is determined in different ways, depending on the
1337 properties of the enum:
1339 - In C++0x, the underlying type can be explicitly specified, e.g.,
1341 enum E1 : char { ... } // underlying type is char
1343 - In a C++0x scoped enumeration, the underlying type is int
1344 unless otherwises specified:
1346 enum class E2 { ... } // underlying type is int
1348 - Otherwise, the underlying type is determined based on the
1349 values of the enumerators. In this case, the
1350 ENUM_UNDERLYING_TYPE will not be set until after the definition
1351 of the enumeration is completed by finish_enum. */
1352 #define ENUM_UNDERLYING_TYPE(TYPE) TREE_TYPE (ENUMERAL_TYPE_CHECK (TYPE))
1354 /* Nonzero if this type is volatile-qualified. */
1355 #define RS_TYPE_VOLATILE_P(NODE) \
1356 ((rs_type_quals (NODE) & TYPE_QUAL_VOLATILE) != 0)
1358 /* Nonzero means that this type is either complete or being defined, so we
1359 can do lookup in it. */
1360 #define COMPLETE_OR_OPEN_TYPE_P(NODE) \
1361 (COMPLETE_TYPE_P (NODE) || (CLASS_TYPE_P (NODE) && TYPE_BEING_DEFINED (NODE)))
1363 /* Indicates when overload resolution may resolve to a pointer to
1364 member function. [expr.unary.op]/3 */
1365 #define PTRMEM_OK_P(NODE) \
1366 TREE_LANG_FLAG_0 (TREE_CHECK3 ((NODE), ADDR_EXPR, OFFSET_REF, SCOPE_REF))
1368 /* Returns nonzero iff NODE is a declaration for the global function
1370 #define DECL_MAIN_P(NODE) \
1371 (DECL_NAME (NODE) != NULL_TREE && MAIN_NAME_P (DECL_NAME (NODE)) \
1374 /* Nonzero if the variable was declared to be thread-local.
1375 We need a special C++ version of this test because the middle-end
1376 DECL_THREAD_LOCAL_P uses the symtab, so we can't use it for
1378 #define RS_DECL_THREAD_LOCAL_P(NODE) (TREE_LANG_FLAG_0 (VAR_DECL_CHECK (NODE)))
1380 #define COND_EXPR_IS_VEC_DELETE(NODE) TREE_LANG_FLAG_0 (COND_EXPR_CHECK (NODE))
1382 /* RANGE_FOR_STMT accessors. These give access to the declarator,
1383 expression, body, and scope of the statement, respectively. */
1384 #define RANGE_FOR_DECL(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 0)
1385 #define RANGE_FOR_EXPR(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 1)
1386 #define RANGE_FOR_BODY(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 2)
1387 #define RANGE_FOR_SCOPE(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 3)
1388 #define RANGE_FOR_UNROLL(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 4)
1389 #define RANGE_FOR_INIT_STMT(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 5)
1390 #define RANGE_FOR_IVDEP(NODE) TREE_LANG_FLAG_6 (RANGE_FOR_STMT_CHECK (NODE))
1392 #define CP_DECL_CONTEXT(NODE) \
1393 (!DECL_FILE_SCOPE_P (NODE) ? DECL_CONTEXT (NODE) : global_namespace)
1394 #define CP_TYPE_CONTEXT(NODE) \
1395 (!TYPE_FILE_SCOPE_P (NODE) ? TYPE_CONTEXT (NODE) : global_namespace)
1396 #define FROB_CONTEXT(NODE) \
1397 ((NODE) == global_namespace ? DECL_CONTEXT (NODE) : (NODE))
1399 /* Nonzero if NODE is the std namespace. */
1400 #define DECL_NAMESPACE_STD_P(NODE) ((NODE) == std_node)
1402 /* Whether the namepace is an inline namespace. */
1403 #define DECL_NAMESPACE_INLINE_P(NODE) \
1404 TREE_LANG_FLAG_0 (NAMESPACE_DECL_CHECK (NODE))
1406 #define CP_DECL_CONTEXT(NODE) \
1407 (!DECL_FILE_SCOPE_P (NODE) ? DECL_CONTEXT (NODE) : global_namespace)
1409 /* Based off of TYPE_UNNAMED_P. */
1410 #define LAMBDA_TYPE_P(NODE) \
1411 (TREE_CODE (NODE) == RECORD_TYPE && TYPE_LINKAGE_IDENTIFIER (NODE) \
1412 && IDENTIFIER_LAMBDA_P (TYPE_LINKAGE_IDENTIFIER (NODE)))
1414 /* Macros to make error reporting functions' lives easier. */
1415 #define TYPE_LINKAGE_IDENTIFIER(NODE) \
1416 (TYPE_IDENTIFIER (TYPE_MAIN_VARIANT (NODE)))
1418 /* Identifiers used for lambda types are almost anonymous. Use this
1419 spare flag to distinguish them (they also have the anonymous flag). */
1420 #define IDENTIFIER_LAMBDA_P(NODE) \
1421 (IDENTIFIER_NODE_CHECK (NODE)->base.protected_flag)
1423 /* If NODE, a FUNCTION_DECL, is a C++11 inheriting constructor, then this
1424 is the constructor it inherits from. */
1425 #define DECL_INHERITED_CTOR(NODE) \
1426 (DECL_DECLARES_FUNCTION_P (NODE) && DECL_CONSTRUCTOR_P (NODE) \
1427 ? LANG_DECL_FN_CHECK (NODE)->context \
1430 /* True if the class type TYPE is a literal type. */
1431 #define CLASSTYPE_LITERAL_P(TYPE) (LANG_TYPE_CLASS_CHECK (TYPE)->is_literal)
1433 /* Nonzero if NODE (a FUNCTION_DECL or TEMPLATE_DECL)
1435 #define DECL_DESTRUCTOR_P(NODE) DECL_CXX_DESTRUCTOR_P (NODE)
1437 /* Nonzero if TYPE has a trivial destructor. From [class.dtor]:
1439 A destructor is trivial if it is an implicitly declared
1442 - all of the direct base classes of its class have trivial
1445 - for all of the non-static data members of its class that are
1446 of class type (or array thereof), each such class has a
1447 trivial destructor. */
1448 #define TYPE_HAS_TRIVIAL_DESTRUCTOR(NODE) \
1449 (!TYPE_HAS_NONTRIVIAL_DESTRUCTOR (NODE))
1451 /* Nonzero means that NODE (a class type) has a destructor -- but that
1452 it has not yet been declared. */
1453 #define CLASSTYPE_LAZY_DESTRUCTOR(NODE) \
1454 (LANG_TYPE_CLASS_CHECK (NODE)->lazy_destructor)
1456 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a complete
1458 #define DECL_COMPLETE_CONSTRUCTOR_P(NODE) \
1459 (DECL_NAME (NODE) == complete_ctor_identifier)
1461 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a base
1463 #define DECL_BASE_CONSTRUCTOR_P(NODE) (DECL_NAME (NODE) == base_ctor_identifier)
1465 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor, but not either the
1466 specialized in-charge constructor or the specialized not-in-charge
1468 #define DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P(NODE) \
1469 (DECL_NAME (NODE) == ctor_identifier)
1471 /* Nonzero if NODE (a FUNCTION_DECL) is a copy constructor. */
1472 #define DECL_COPY_CONSTRUCTOR_P(NODE) \
1473 (DECL_CONSTRUCTOR_P (NODE) && copy_fn_p (NODE) > 0)
1475 /* Nonzero if NODE (a FUNCTION_DECL) is a move constructor. */
1476 #define DECL_MOVE_CONSTRUCTOR_P(NODE) \
1477 (DECL_CONSTRUCTOR_P (NODE) && move_fn_p (NODE))
1479 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor, but not the
1480 specialized in-charge constructor, in-charge deleting constructor,
1481 or the base destructor. */
1482 #define DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P(NODE) \
1483 (DECL_NAME (NODE) == dtor_identifier)
1485 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete
1487 #define DECL_COMPLETE_DESTRUCTOR_P(NODE) \
1488 (DECL_NAME (NODE) == complete_dtor_identifier)
1490 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a base
1492 #define DECL_BASE_DESTRUCTOR_P(NODE) (DECL_NAME (NODE) == base_dtor_identifier)
1494 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete
1495 object that deletes the object after it has been destroyed. */
1496 #define DECL_DELETING_DESTRUCTOR_P(NODE) \
1497 (DECL_NAME (NODE) == deleting_dtor_identifier)
1499 /* Nonzero if either DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P or
1500 DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P is true of NODE. */
1501 #define DECL_MAYBE_IN_CHARGE_CDTOR_P(NODE) \
1502 (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (NODE) \
1503 || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (NODE))
1505 /* Nonzero if NODE (a _DECL) is a cloned constructor or
1507 #define DECL_CLONED_FUNCTION_P(NODE) \
1508 (DECL_NAME (NODE) && IDENTIFIER_CDTOR_P (DECL_NAME (NODE)) \
1509 && !DECL_MAYBE_IN_CHARGE_CDTOR_P (NODE))
1511 /* If DECL_CLONED_FUNCTION_P holds, this is the function that was
1513 #define DECL_CLONED_FUNCTION(NODE) \
1514 (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE))->u.fn.u5.cloned_function)
1516 /* Nonzero means that an object of this type cannot be initialized using
1517 an initializer list. */
1518 #define CLASSTYPE_NON_AGGREGATE(NODE) \
1519 (LANG_TYPE_CLASS_CHECK (NODE)->non_aggregate)
1520 #define TYPE_NON_AGGREGATE_CLASS(NODE) \
1521 (CLASS_TYPE_P (NODE) && CLASSTYPE_NON_AGGREGATE (NODE))
1523 /* Nonzero for class type means that the default constructor is trivial. */
1524 #define TYPE_HAS_TRIVIAL_DFLT(NODE) \
1525 (TYPE_HAS_DEFAULT_CONSTRUCTOR (NODE) && !TYPE_HAS_COMPLEX_DFLT (NODE))
1527 /* Nonzero if this class has a constexpr constructor other than a copy/move
1528 constructor. Note that a class can have constexpr constructors for
1529 static initialization even if it isn't a literal class. */
1530 #define TYPE_HAS_CONSTEXPR_CTOR(NODE) \
1531 (LANG_TYPE_CLASS_CHECK (NODE)->has_constexpr_ctor)
1533 /* Nonzero if there is no trivial default constructor for this class. */
1534 #define TYPE_HAS_COMPLEX_DFLT(NODE) \
1535 (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_dflt)
1539 An aggregate is an array or a class with no user-provided
1540 constructors, no brace-or-equal-initializers for non-static data
1541 members, no private or protected non-static data members, no
1542 base classes, and no virtual functions.
1544 As an extension, we also treat vectors as aggregates. Keep these
1545 checks in ascending code order. */
1546 #define CP_AGGREGATE_TYPE_P(TYPE) \
1547 (gnu_vector_type_p (TYPE) || TREE_CODE (TYPE) == ARRAY_TYPE \
1548 || (CLASS_TYPE_P (TYPE) && COMPLETE_TYPE_P (TYPE) \
1549 && !CLASSTYPE_NON_AGGREGATE (TYPE)))
1551 /* Nonzero for a FIELD_DECL means that this member object type
1553 #define DECL_MUTABLE_P(NODE) (DECL_LANG_FLAG_0 (FIELD_DECL_CHECK (NODE)))
1555 #if defined ENABLE_TREE_CHECKING
1557 #define LANG_DECL_MIN_CHECK(NODE) \
1559 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1560 if (!LANG_DECL_HAS_MIN (NODE)) \
1561 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1565 /* We want to be able to check DECL_CONSTRUCTOR_P and such on a function
1566 template, not just on a FUNCTION_DECL. So when looking for things in
1567 lang_decl_fn, look down through a TEMPLATE_DECL into its result. */
1568 #define LANG_DECL_FN_CHECK(NODE) \
1570 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1571 if (!DECL_DECLARES_FUNCTION_P (NODE) || lt->u.base.selector != lds_fn) \
1572 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1576 #define LANG_DECL_NS_CHECK(NODE) \
1578 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1579 if (TREE_CODE (NODE) != NAMESPACE_DECL || lt->u.base.selector != lds_ns) \
1580 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1584 #define LANG_DECL_PARM_CHECK(NODE) \
1586 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1587 if (TREE_CODE (NODE) != PARM_DECL || lt->u.base.selector != lds_parm) \
1588 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1592 #define LANG_DECL_DECOMP_CHECK(NODE) \
1594 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1595 if (!VAR_P (NODE) || lt->u.base.selector != lds_decomp) \
1596 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1602 #define LANG_DECL_MIN_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.min)
1604 #define LANG_DECL_FN_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.fn)
1606 #define LANG_DECL_NS_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.ns)
1608 #define LANG_DECL_PARM_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.parm)
1610 #define LANG_DECL_DECOMP_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.decomp)
1612 #endif /* ENABLE_TREE_CHECKING */
1614 // Below macros are copied from gcc/c-family/c-common.h
1616 /* In a FIELD_DECL, nonzero if the decl was originally a bitfield. */
1617 #define DECL_C_BIT_FIELD(NODE) (DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) == 1)
1618 #define SET_DECL_C_BIT_FIELD(NODE) \
1619 (DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) = 1)
1620 #define CLEAR_DECL_C_BIT_FIELD(NODE) \
1621 (DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) = 0)
1623 /* True if the decl was an unnamed bitfield. */
1624 #define DECL_UNNAMED_BIT_FIELD(NODE) \
1625 (DECL_C_BIT_FIELD (NODE) && !DECL_NAME (NODE))
1627 /* 1 iff NODE is function-local. */
1628 #define DECL_FUNCTION_SCOPE_P(NODE) \
1629 (DECL_CONTEXT (NODE) && TREE_CODE (DECL_CONTEXT (NODE)) == FUNCTION_DECL)
1631 /* Nonzero if this type is const-qualified, but not
1632 volatile-qualified. Other qualifiers are ignored. This macro is
1633 used to test whether or not it is OK to bind an rvalue to a
1635 #define RS_TYPE_CONST_NON_VOLATILE_P(NODE) \
1636 ((rs_type_quals (NODE) & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)) \
1639 /* Returns true if TYPE is an integral or enumeration name. Keep
1640 these checks in ascending code order. */
1641 #define INTEGRAL_OR_ENUMERATION_TYPE_P(TYPE) \
1642 (TREE_CODE (TYPE) == ENUMERAL_TYPE || RS_INTEGRAL_TYPE_P (TYPE))
1644 /* Nonzero for a VAR_DECL that was initialized with a
1645 constant-expression. */
1646 #define DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P(NODE) \
1647 (TREE_LANG_FLAG_2 (VAR_DECL_CHECK (NODE)))
1649 /* WHILE_STMT accessors. These give access to the condition of the
1650 while statement and the body of the while statement, respectively. */
1651 #define WHILE_COND(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 0)
1652 #define WHILE_BODY(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 1)
1654 /* FOR_STMT accessors. These give access to the init statement,
1655 condition, update expression, and body of the for statement,
1657 #define FOR_INIT_STMT(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 0)
1658 #define FOR_COND(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 1)
1659 #define FOR_EXPR(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 2)
1660 #define FOR_BODY(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 3)
1661 #define FOR_SCOPE(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 4)
1663 #define SWITCH_STMT_COND(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 0)
1664 #define SWITCH_STMT_BODY(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 1)
1665 #define SWITCH_STMT_TYPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 2)
1666 #define SWITCH_STMT_SCOPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 3)
1668 /* Nonzero if NODE is the target for genericization of 'break' stmts. */
1669 #define LABEL_DECL_BREAK(NODE) DECL_LANG_FLAG_0 (LABEL_DECL_CHECK (NODE))
1671 /* Nonzero if NODE is the target for genericization of 'continue' stmts. */
1672 #define LABEL_DECL_CONTINUE(NODE) DECL_LANG_FLAG_1 (LABEL_DECL_CHECK (NODE))
1674 // Above macros are copied from gcc/c-family/c-common.h
1676 // Below macros are copied from gcc/cp/name-lookup.h
1678 /* Lookup walker marking. */
1679 #define LOOKUP_SEEN_P(NODE) TREE_VISITED (NODE)
1680 #define LOOKUP_FOUND_P(NODE) \
1681 TREE_LANG_FLAG_4 (TREE_CHECK4 (NODE, RECORD_TYPE, UNION_TYPE, ENUMERAL_TYPE, \
1684 // Above macros are copied from gcc/cp/name-lookup.h
1686 // Below macros are copied from gcc/cp/name-lookup.cc
1688 /* Create an overload suitable for recording an artificial TYPE_DECL
1689 and another decl. We use this machanism to implement the struct
1692 #define STAT_HACK_P(N) ((N) && TREE_CODE (N) == OVERLOAD && OVL_LOOKUP_P (N))
1693 #define STAT_TYPE_VISIBLE_P(N) TREE_USED (OVERLOAD_CHECK (N))
1694 #define STAT_TYPE(N) TREE_TYPE (N)
1695 #define STAT_DECL(N) OVL_FUNCTION (N)
1696 #define STAT_VISIBLE(N) OVL_CHAIN (N)
1697 #define MAYBE_STAT_DECL(N) (STAT_HACK_P (N) ? STAT_DECL (N) : N)
1698 #define MAYBE_STAT_TYPE(N) (STAT_HACK_P (N) ? STAT_TYPE (N) : NULL_TREE)
1700 /* When a STAT_HACK_P is true, OVL_USING_P and OVL_EXPORT_P are valid
1701 and apply to the hacked type. */
1703 /* For regular (maybe) overloaded functions, we have OVL_HIDDEN_P.
1704 But we also need to indicate hiddenness on implicit type decls
1705 (injected friend classes), and (coming soon) decls injected from
1706 block-scope externs. It is too awkward to press the existing
1707 overload marking for that. If we have a hidden non-function, we
1708 always create a STAT_HACK, and use these two markers as needed. */
1709 #define STAT_TYPE_HIDDEN_P(N) OVL_HIDDEN_P (N)
1710 #define STAT_DECL_HIDDEN_P(N) OVL_DEDUP_P (N)
1712 /* The binding level currently in effect. */
1714 #define current_binding_level \
1715 (*(cfun && cp_function_chain && cp_function_chain->bindings \
1716 ? &cp_function_chain->bindings \
1717 : &scope_chain->bindings))
1719 // Above macros are copied from gcc/cp/name-lookup.cc
1721 /* The various kinds of special functions. If you add to this list,
1722 you should update special_function_p as well. */
1723 enum special_function_kind
1725 sfk_none
= 0, /* Not a special function. This enumeral
1726 must have value zero; see
1727 special_function_p. */
1728 /* The following are ordered, for use by member synthesis fns. */
1729 sfk_destructor
, /* A destructor. */
1730 sfk_constructor
, /* A constructor. */
1731 sfk_inheriting_constructor
, /* An inheriting constructor */
1732 sfk_copy_constructor
, /* A copy constructor. */
1733 sfk_move_constructor
, /* A move constructor. */
1734 sfk_copy_assignment
, /* A copy assignment operator. */
1735 sfk_move_assignment
, /* A move assignment operator. */
1736 /* The following are unordered. */
1737 sfk_complete_destructor
, /* A destructor for complete objects. */
1738 sfk_base_destructor
, /* A destructor for base subobjects. */
1739 sfk_deleting_destructor
, /* A destructor for complete objects that
1740 deletes the object after it has been
1742 sfk_conversion
, /* A conversion operator. */
1743 sfk_deduction_guide
, /* A class template deduction guide. */
1744 sfk_comparison
, /* A comparison operator (e.g. ==, <, <=>). */
1745 sfk_virtual_destructor
/* Used by member synthesis fns. */
1748 /* Places where an lvalue, or modifiable lvalue, may be required.
1749 Used to select diagnostic messages in lvalue_error and
1760 /* A class for recording information about access failures (e.g. private
1761 fields), so that we can potentially supply a fix-it hint about
1762 an accessor (from a context in which the constness of the object
1765 class access_failure_info
1768 access_failure_info ()
1769 : m_was_inaccessible (false), m_basetype_path (NULL_TREE
),
1770 m_decl (NULL_TREE
), m_diag_decl (NULL_TREE
)
1773 void record_access_failure (tree basetype_path
, tree decl
, tree diag_decl
);
1775 bool was_inaccessible_p () const { return m_was_inaccessible
; }
1776 tree
get_decl () const { return m_decl
; }
1777 tree
get_diag_decl () const { return m_diag_decl
; }
1778 tree
get_any_accessor (bool const_p
) const;
1779 void maybe_suggest_accessor (bool const_p
) const;
1780 static void add_fixit_hint (rich_location
*richloc
, tree accessor
);
1783 bool m_was_inaccessible
;
1784 tree m_basetype_path
;
1789 /* The various kinds of access check during parsing. */
1792 dk_no_deferred
= 0, /* Check access immediately */
1793 dk_deferred
= 1, /* Deferred check */
1794 dk_no_check
= 2 /* No access check */
1797 /* The representation of a deferred access check. */
1799 struct GTY (()) deferred_access_check
1801 /* The base class in which the declaration is referenced. */
1803 /* The declaration whose access must be checked. */
1805 /* The declaration that should be used in the error message. */
1807 /* The location of this access. */
1811 struct GTY (()) tree_template_info
1813 struct tree_base base
;
1816 vec
<deferred_access_check
, va_gc
> *deferred_access_checks
;
1819 /* The various kinds of lvalues we distinguish. */
1820 enum cp_lvalue_kind_flags
1822 clk_none
= 0, /* Things that are not an lvalue. */
1823 clk_ordinary
= 1, /* An ordinary lvalue. */
1824 clk_rvalueref
= 2, /* An xvalue (rvalue formed using an rvalue reference) */
1825 clk_class
= 4, /* A prvalue of class or array type. */
1826 clk_bitfield
= 8, /* An lvalue for a bit-field. */
1827 clk_packed
= 16, /* An lvalue for a packed field. */
1828 clk_implicit_rval
= 1 << 5 /* An lvalue being treated as an xvalue. */
1831 /* This type is used for parameters and variables which hold
1832 combinations of the flags in enum cp_lvalue_kind_flags. */
1833 typedef int cp_lvalue_kind
;
1835 // forked from gcc/cp/name_lookup.h scope_kind
1837 /* The kinds of scopes we recognize. */
1840 sk_block
= 0, /* An ordinary block scope. This enumerator must
1841 have the value zero because "cp_binding_level"
1842 is initialized by using "memset" to set the
1843 contents to zero, and the default scope kind
1845 sk_cleanup
, /* A scope for (pseudo-)scope for cleanup. It is
1846 pseudo in that it is transparent to name lookup
1848 sk_try
, /* A try-block. */
1849 sk_catch
, /* A catch-block. */
1850 sk_for
, /* The scope of the variable declared in a
1852 sk_cond
, /* The scope of the variable declared in the condition
1853 of an if or switch statement. */
1854 sk_function_parms
, /* The scope containing function parameters. */
1855 sk_class
, /* The scope containing the members of a class. */
1856 sk_scoped_enum
, /* The scope containing the enumerators of a C++11
1857 scoped enumeration. */
1858 sk_namespace
, /* The scope containing the members of a
1859 namespace, including the global scope. */
1860 sk_template_parms
, /* A scope for template parameters. */
1861 sk_template_spec
, /* Like sk_template_parms, but for an explicit
1862 specialization. Since, by definition, an
1863 explicit specialization is introduced by
1864 "template <>", this scope is always empty. */
1865 sk_transaction
, /* A synchronized or atomic statement. */
1866 sk_omp
/* An OpenMP structured block. */
1869 // forked from gcc/cp/cp-tree.h cp_built_in_function
1871 /* BUILT_IN_FRONTEND function codes. */
1872 enum cp_built_in_function
1874 CP_BUILT_IN_IS_CONSTANT_EVALUATED
,
1875 CP_BUILT_IN_INTEGER_PACK
,
1876 CP_BUILT_IN_IS_CORRESPONDING_MEMBER
,
1877 CP_BUILT_IN_IS_POINTER_INTERCONVERTIBLE_WITH_CLASS
,
1878 CP_BUILT_IN_SOURCE_LOCATION
,
1882 // forked from gcc/cp/cp-tree.h warning_sentinel
1884 /* RAII sentinel to disable certain warnings during template substitution
1887 class warning_sentinel
1892 warning_sentinel (int &flag
, bool suppress
= true) : flag (flag
), val (flag
)
1897 ~warning_sentinel () { flag
= val
; }
1900 // forked from gcc/cp/cp-tree.h uid_sensitive_constexpr_evaluation_checker
1902 /* Used to determine whether uid_sensitive_constexpr_evaluation_p was
1903 called and returned true, indicating that we've restricted constexpr
1904 evaluation in order to avoid UID generation. We use this to control
1905 updates to the fold_cache and cv_cache. */
1907 struct uid_sensitive_constexpr_evaluation_checker
1909 const unsigned saved_counter
;
1910 uid_sensitive_constexpr_evaluation_checker ();
1911 bool evaluation_restricted_p () const;
1914 // forked from gcc/cp/cp-tree.h iloc_sentinel
1916 /* RAII sentinel to temporarily override input_location. This will not set
1917 input_location to UNKNOWN_LOCATION or BUILTINS_LOCATION. */
1921 location_t saved_loc
;
1924 iloc_sentinel (location_t loc
) : saved_loc (input_location
)
1926 if (loc
>= RESERVED_LOCATION_COUNT
)
1927 input_location
= loc
;
1929 ~iloc_sentinel () { input_location
= saved_loc
; }
1932 // forked from gcc/cp/cp-tree.h ptrmem_cst
1934 struct GTY (()) ptrmem_cst
1936 struct tree_common common
;
1940 typedef struct ptrmem_cst
*ptrmem_cst_t
;
1942 // forked from gcc/cp/cp-tree.h named_decl_hash
1944 /* hash traits for declarations. Hashes potential overload sets via
1947 struct named_decl_hash
: ggc_remove
<tree
>
1949 typedef tree value_type
; /* A DECL or OVERLOAD */
1950 typedef tree compare_type
; /* An identifier. */
1952 inline static hashval_t
hash (const value_type decl
);
1953 inline static bool equal (const value_type existing
, compare_type candidate
);
1955 static const bool empty_zero_p
= true;
1956 static inline void mark_empty (value_type
&p
) { p
= NULL_TREE
; }
1957 static inline bool is_empty (value_type p
) { return !p
; }
1959 /* Nothing is deletable. Everything is insertable. */
1960 static bool is_deleted (value_type
) { return false; }
1961 static void mark_deleted (value_type
) { gcc_unreachable (); }
1964 // forked from gcc/cp/cp-tree.h lang_decl_selector
1966 /* Discriminator values for lang_decl. */
1968 enum lang_decl_selector
1977 // forked from gcc/cp/cp-tree.h lang_decl_base
1979 /* Flags shared by all forms of DECL_LANG_SPECIFIC.
1981 Some of the flags live here only to make lang_decl_min/fn smaller. Do
1982 not make this struct larger than 32 bits. */
1984 struct GTY (()) lang_decl_base
1986 ENUM_BITFIELD (lang_decl_selector
) selector
: 3;
1987 unsigned use_template
: 2;
1988 unsigned not_really_extern
: 1; /* var or fn */
1989 unsigned initialized_in_class
: 1; /* var or fn */
1991 unsigned threadprivate_or_deleted_p
: 1; /* var or fn */
1992 /* anticipated_p is no longer used for anticipated_decls (fn, type
1993 or template). It is used as DECL_OMP_PRIVATIZED_MEMBER in
1995 unsigned anticipated_p
: 1;
1996 unsigned friend_or_tls
: 1; /* var, fn, type or template */
1997 unsigned unknown_bound_p
: 1; /* var */
1998 unsigned odr_used
: 1; /* var or fn */
1999 unsigned concept_p
: 1; /* applies to vars and functions */
2000 unsigned var_declared_inline_p
: 1; /* var */
2001 unsigned dependent_init_p
: 1; /* var */
2003 /* The following apply to VAR, FUNCTION, TYPE, CONCEPT, & NAMESPACE
2005 unsigned module_purview_p
: 1; /* in module purview (not GMF) */
2006 unsigned module_import_p
: 1; /* from an import */
2007 unsigned module_entity_p
: 1; /* is in the entitity ary &
2009 /* VAR_DECL or FUNCTION_DECL has attached decls. */
2010 unsigned module_attached_p
: 1;
2012 /* 12 spare bits. */
2015 /* True for DECL codes which have template info and access. */
2016 #define LANG_DECL_HAS_MIN(NODE) \
2017 (VAR_OR_FUNCTION_DECL_P (NODE) || TREE_CODE (NODE) == FIELD_DECL \
2018 || TREE_CODE (NODE) == CONST_DECL || TREE_CODE (NODE) == TYPE_DECL \
2019 || TREE_CODE (NODE) == TEMPLATE_DECL || TREE_CODE (NODE) == USING_DECL \
2020 || TREE_CODE (NODE) == CONCEPT_DECL)
2022 // forked from gcc/c-family-common.h stmt_tree_s
2024 /* Information about a statement tree. */
2026 struct GTY (()) stmt_tree_s
2028 /* A stack of statement lists being collected. */
2029 vec
<tree
, va_gc
> *x_cur_stmt_list
;
2031 /* In C++, Nonzero if we should treat statements as full
2032 expressions. In particular, this variable is non-zero if at the
2033 end of a statement we should destroy any temporaries created
2034 during that statement. Similarly, if, at the end of a block, we
2035 should destroy any local variables in this block. Normally, this
2036 variable is nonzero, since those are the normal semantics of
2039 This flag has no effect in C. */
2040 int stmts_are_full_exprs_p
;
2043 // forked from gcc/c-family-common.h stmt_tree_s
2045 typedef struct stmt_tree_s
*stmt_tree
;
2047 // forked from gcc/c-family-common.h c_language_function
2049 /* Global state pertinent to the current function. Some C dialects
2050 extend this structure with additional fields. */
2052 struct GTY (()) c_language_function
2054 /* While we are parsing the function, this contains information
2055 about the statement-tree that we are building. */
2056 struct stmt_tree_s x_stmt_tree
;
2058 /* Vector of locally defined typedefs, for
2059 -Wunused-local-typedefs. */
2060 vec
<tree
, va_gc
> *local_typedefs
;
2063 // forked from gcc/cp/cp-tree.h omp_declare_target_attr
2065 struct GTY (()) omp_declare_target_attr
2070 // forked from gcc/cp/name-lookup.h cxx_binding
2072 /* Datatype that represents binding established by a declaration between
2073 a name and a C++ entity. */
2074 struct GTY (()) cxx_binding
2076 /* Link to chain together various bindings for this name. */
2077 cxx_binding
*previous
;
2078 /* The non-type entity this name is bound to. */
2080 /* The type entity this name is bound to. */
2083 bool value_is_inherited
: 1;
2085 bool type_is_hidden
: 1;
2088 // forked from gcc/cp/name-lookup.h cxx_saved_binding
2090 /* Datatype used to temporarily save C++ bindings (for implicit
2091 instantiations purposes and like). Implemented in decl.cc. */
2092 struct GTY (()) cxx_saved_binding
2094 /* The name of the current binding. */
2096 /* The binding we're saving. */
2097 cxx_binding
*binding
;
2098 tree real_type_value
;
2101 // forked from gcc/cp/cp-tree.h saved_scope
2105 struct GTY (()) saved_scope
2107 vec
<cxx_saved_binding
, va_gc
> *old_bindings
;
2109 vec
<tree
, va_gc
> *decl_ns_list
;
2112 tree access_specifier
;
2114 vec
<tree
, va_gc
> *lang_base
;
2116 tree template_parms
;
2119 /* Only used for uses of this in trailing return type. */
2120 tree x_current_class_ptr
;
2121 tree x_current_class_ref
;
2123 int x_processing_template_decl
;
2124 int x_processing_specialization
;
2125 int x_processing_constraint
;
2126 int suppress_location_wrappers
;
2127 BOOL_BITFIELD x_processing_explicit_instantiation
: 1;
2128 BOOL_BITFIELD need_pop_function_context
: 1;
2130 /* Nonzero if we are parsing the discarded statement of a constexpr
2132 BOOL_BITFIELD discarded_stmt
: 1;
2133 /* Nonzero if we are parsing or instantiating the compound-statement
2134 of consteval if statement. Also set while processing an immediate
2136 BOOL_BITFIELD consteval_if_p
: 1;
2138 int unevaluated_operand
;
2139 int inhibit_evaluation_warnings
;
2140 int noexcept_operand
;
2143 struct stmt_tree_s x_stmt_tree
;
2145 hash_map
<tree
, tree
> *GTY ((skip
)) x_local_specializations
;
2146 vec
<omp_declare_target_attr
, va_gc
> *omp_declare_target_attribute
;
2148 struct saved_scope
*prev
;
2151 extern GTY (()) struct saved_scope
*scope_chain
;
2153 // forked from gcc/cp/cp-tree.h named_label_hash
2155 struct named_label_entry
; /* Defined in decl.cc. */
2157 struct named_label_hash
: ggc_remove
<named_label_entry
*>
2159 typedef named_label_entry
*value_type
;
2160 typedef tree compare_type
; /* An identifier. */
2162 inline static hashval_t
hash (value_type
);
2163 inline static bool equal (const value_type
, compare_type
);
2165 static const bool empty_zero_p
= true;
2166 inline static void mark_empty (value_type
&p
) { p
= NULL
; }
2167 inline static bool is_empty (value_type p
) { return !p
; }
2169 /* Nothing is deletable. Everything is insertable. */
2170 inline static bool is_deleted (value_type
) { return false; }
2171 inline static void mark_deleted (value_type
) { gcc_unreachable (); }
2174 // forked from gcc/cp/cp-tree.h
2176 /* Global state pertinent to the current function. */
2178 struct GTY (()) language_function
2180 struct c_language_function base
;
2183 tree x_current_class_ptr
;
2184 tree x_current_class_ref
;
2185 tree x_eh_spec_block
;
2186 tree x_in_charge_parm
;
2188 tree x_return_value
;
2190 BOOL_BITFIELD returns_value
: 1;
2191 BOOL_BITFIELD returns_null
: 1;
2192 BOOL_BITFIELD returns_abnormally
: 1;
2193 BOOL_BITFIELD infinite_loop
: 1;
2194 BOOL_BITFIELD x_in_function_try_handler
: 1;
2195 BOOL_BITFIELD x_in_base_initializer
: 1;
2197 /* True if this function can throw an exception. */
2198 BOOL_BITFIELD can_throw
: 1;
2200 BOOL_BITFIELD invalid_constexpr
: 1;
2201 BOOL_BITFIELD throwing_cleanup
: 1;
2203 hash_table
<named_label_hash
> *x_named_labels
;
2205 /* Tracking possibly infinite loops. This is a vec<tree> only because
2206 vec<bool> doesn't work with gtype. */
2207 vec
<tree
, va_gc
> *infinite_loops
;
2210 // forked from gcc/c-family/c-common.h ref_operator
2212 /* The various name of operator that appears in error messages. */
2217 /* array indexing */
2223 /* implicit conversion */
2224 RO_IMPLICIT_CONVERSION
,
2229 // forked from gcc/cp/cp-tree.h lang_decl_min
2231 /* DECL_LANG_SPECIFIC for the above codes. */
2233 struct GTY (()) lang_decl_min
2235 struct lang_decl_base base
; /* 32-bits. */
2237 /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
2239 In a FUNCTION_DECL for which DECL_THUNK_P does not hold,
2240 VAR_DECL, TYPE_DECL, or TEMPLATE_DECL, this is
2241 DECL_TEMPLATE_INFO. */
2244 /* In a DECL_THUNK_P FUNCTION_DECL, this is THUNK_VIRTUAL_OFFSET.
2245 In a lambda-capture proxy VAR_DECL, this is DECL_CAPTURED_VARIABLE.
2246 In a function-scope TREE_STATIC VAR_DECL or IMPLICIT_TYPEDEF_P TYPE_DECL,
2247 this is DECL_DISCRIMINATOR.
2248 In a DECL_LOCAL_DECL_P decl, this is the namespace decl it aliases.
2249 Otherwise, in a class-scope DECL, this is DECL_ACCESS. */
2253 // forked from gcc/cp/cp-tree.h lang_decl_fn
2255 /* Additional DECL_LANG_SPECIFIC information for functions. */
2257 struct GTY (()) lang_decl_fn
2259 struct lang_decl_min min
;
2261 /* In a overloaded operator, this is the compressed operator code. */
2262 unsigned ovl_op_code
: 6;
2263 unsigned global_ctor_p
: 1;
2264 unsigned global_dtor_p
: 1;
2266 unsigned static_function
: 1;
2267 unsigned pure_virtual
: 1;
2268 unsigned defaulted_p
: 1;
2269 unsigned has_in_charge_parm_p
: 1;
2270 unsigned has_vtt_parm_p
: 1;
2271 unsigned pending_inline_p
: 1;
2272 unsigned nonconverting
: 1;
2273 unsigned thunk_p
: 1;
2275 unsigned this_thunk_p
: 1;
2276 unsigned omp_declare_reduction_p
: 1;
2277 unsigned has_dependent_explicit_spec_p
: 1;
2278 unsigned immediate_fn_p
: 1;
2279 unsigned maybe_deleted
: 1;
2280 unsigned coroutine_p
: 1;
2281 unsigned implicit_constexpr
: 1;
2285 /* 32-bits padding on 64-bit host. */
2287 /* For a non-thunk function decl, this is a tree list of
2288 friendly classes. For a thunk function decl, it is the
2289 thunked to function decl. */
2290 tree befriending_classes
;
2292 /* For a virtual FUNCTION_DECL for which
2293 DECL_THIS_THUNK_P does not hold, this is DECL_THUNKS. Both
2294 this pointer and result pointer adjusting thunks are
2295 chained here. This pointer thunks to return pointer thunks
2296 will be chained on the return pointer thunk.
2297 For a DECL_CONSTUCTOR_P FUNCTION_DECL, this is the base from
2298 whence we inherit. Otherwise, it is the class in which a
2299 (namespace-scope) friend is defined (if any). */
2304 /* In a non-thunk FUNCTION_DECL, this is DECL_CLONED_FUNCTION. */
2305 tree
GTY ((tag ("0"))) cloned_function
;
2307 /* In a FUNCTION_DECL for which THUNK_P holds this is the
2308 THUNK_FIXED_OFFSET. */
2309 HOST_WIDE_INT
GTY ((tag ("1"))) fixed_offset
;
2310 } GTY ((desc ("%1.thunk_p"))) u5
;
2314 struct cp_token_cache
*GTY ((tag ("1"))) pending_inline_info
;
2315 tree
GTY ((tag ("0"))) saved_auto_return_type
;
2316 } GTY ((desc ("%1.pending_inline_p"))) u
;
2319 // forked from gcc/cp/cp-tree.h lang_decl_ns
2321 /* DECL_LANG_SPECIFIC for namespaces. */
2323 struct GTY (()) lang_decl_ns
2325 struct lang_decl_base base
; /* 32 bits. */
2327 /* Inline children. Needs to be va_gc, because of PCH. */
2328 vec
<tree
, va_gc
> *inlinees
;
2330 /* Hash table of bound decls. It'd be nice to have this inline, but
2331 as the hash_map has a dtor, we can't then put this struct into a
2332 union (until moving to c++11). */
2333 hash_table
<named_decl_hash
> *bindings
;
2336 // forked from gcc/cp/cp-tree.h lang_decl_parm
2338 /* DECL_LANG_SPECIFIC for parameters. */
2340 struct GTY (()) lang_decl_parm
2342 struct lang_decl_base base
; /* 32 bits. */
2347 // forked from gcc/cp/cp-tree.h lang_decl_decomp
2349 /* Additional DECL_LANG_SPECIFIC information for structured bindings. */
2351 struct GTY (()) lang_decl_decomp
2353 struct lang_decl_min min
;
2354 /* The artificial underlying "e" variable of the structured binding
2359 // forked from gcc/cp/cp-tree.h lang_decl
2361 /* DECL_LANG_SPECIFIC for all types. It would be nice to just make this a
2362 union rather than a struct containing a union as its only field, but
2363 tree.h declares it as a struct. */
2365 struct GTY (()) lang_decl
2367 union GTY ((desc ("%h.base.selector"))) lang_decl_u
2369 /* Nothing of only the base type exists. */
2370 struct lang_decl_base
GTY ((default)) base
;
2371 struct lang_decl_min
GTY ((tag ("lds_min"))) min
;
2372 struct lang_decl_fn
GTY ((tag ("lds_fn"))) fn
;
2373 struct lang_decl_ns
GTY ((tag ("lds_ns"))) ns
;
2374 struct lang_decl_parm
GTY ((tag ("lds_parm"))) parm
;
2375 struct lang_decl_decomp
GTY ((tag ("lds_decomp"))) decomp
;
2379 // forked from gcc/c-family/c-common.h c_fileinfo
2381 /* Information recorded about each file examined during compilation. */
2385 int time
; /* Time spent in the file. */
2387 /* Flags used only by C++.
2388 INTERFACE_ONLY nonzero means that we are in an "interface" section
2389 of the compiler. INTERFACE_UNKNOWN nonzero means we cannot trust
2390 the value of INTERFACE_ONLY. If INTERFACE_UNKNOWN is zero and
2391 INTERFACE_ONLY is zero, it means that we are responsible for
2392 exporting definitions that others might need. */
2393 short interface_only
;
2394 short interface_unknown
;
2397 // forked from gcc/c-family/c-common.h c_common_identifier
2399 /* Identifier part common to the C front ends. Inherits from
2400 tree_identifier, despite appearances. */
2401 struct GTY (()) c_common_identifier
2403 struct tree_common common
;
2404 struct cpp_hashnode node
; // from cpplib.h
2407 // forked from gcc/cp/cp-tree.h lang_identifier
2409 /* Language-dependent contents of an identifier. */
2411 struct GTY (()) lang_identifier
2413 struct c_common_identifier c_common
;
2414 cxx_binding
*bindings
;
2417 // forked from gcc/cp/cp-tree.h tree_overload
2419 /* OVL_HIDDEN_P nodes come before other nodes. */
2421 struct GTY (()) tree_overload
2423 struct tree_common common
;
2427 // forked from gcc/cp/cp-tree.h ovl_iterator
2432 const bool allow_inner
; /* Only used when checking. */
2435 explicit ovl_iterator (tree o
, bool allow
= false)
2436 : ovl (o
), allow_inner (allow
)
2440 operator bool () const { return ovl
; }
2441 ovl_iterator
&operator++ ()
2443 ovl
= TREE_CODE (ovl
) != OVERLOAD
? NULL_TREE
: OVL_CHAIN (ovl
);
2446 tree
operator* () const
2448 tree fn
= TREE_CODE (ovl
) != OVERLOAD
? ovl
: OVL_FUNCTION (ovl
);
2450 /* Check this is not an unexpected 2-dimensional overload. */
2451 gcc_checking_assert (allow_inner
|| TREE_CODE (fn
) != OVERLOAD
);
2455 bool operator== (const ovl_iterator
&o
) const { return ovl
== o
.ovl
; }
2456 tree
get_using () const
2458 gcc_checking_assert (using_p ());
2463 /* Whether this overload was introduced by a using decl. */
2464 bool using_p () const
2466 return (TREE_CODE (ovl
) == USING_DECL
2467 || (TREE_CODE (ovl
) == OVERLOAD
&& OVL_USING_P (ovl
)));
2469 /* Whether this using is being exported. */
2470 bool exporting_p () const { return OVL_EXPORT_P (get_using ()); }
2472 bool hidden_p () const
2474 return TREE_CODE (ovl
) == OVERLOAD
&& OVL_HIDDEN_P (ovl
);
2478 tree
remove_node (tree head
) { return remove_node (head
, ovl
); }
2479 tree
reveal_node (tree head
) { return reveal_node (head
, ovl
); }
2482 /* If we have a nested overload, point at the inner overload and
2483 return the next link on the outer one. */
2488 if (ovl
&& TREE_CODE (ovl
) == OVERLOAD
&& OVL_NESTED_P (ovl
))
2490 r
= OVL_CHAIN (ovl
);
2491 ovl
= OVL_FUNCTION (ovl
);
2495 /* Restore an outer nested overload. */
2496 void pop (tree outer
)
2498 gcc_checking_assert (!ovl
);
2503 /* We make these static functions to avoid the address of the
2504 iterator escaping the local context. */
2505 static tree
remove_node (tree head
, tree node
);
2506 static tree
reveal_node (tree ovl
, tree node
);
2509 // forked from gcc/cp/cp-tree.h lkp_iterator
2511 /* Iterator over a (potentially) 2 dimensional overload, which is
2512 produced by name lookup. */
2514 class lkp_iterator
: public ovl_iterator
2516 typedef ovl_iterator parent
;
2521 explicit lkp_iterator (tree o
) : parent (o
, true), outer (maybe_push ()) {}
2524 lkp_iterator
&operator++ ()
2526 bool repush
= !outer
;
2528 if (!parent::operator++ () && !repush
)
2535 outer
= maybe_push ();
2541 // forked from gcc/cp/cp-tree.h treee_pair_s
2543 struct GTY (()) tree_pair_s
2549 // forked from gcc/cp/cp-tree.h tree_pair_p
2551 typedef tree_pair_s
*tree_pair_p
;
2553 // forked from gcc/cp/cp-tree.h lang_type
2555 /* This structure provides additional information above and beyond
2556 what is provide in the ordinary tree_type. In the past, we used it
2557 for the types of class types, template parameters types, typename
2558 types, and so forth. However, there can be many (tens to hundreds
2559 of thousands) of template parameter types in a compilation, and
2560 there's no need for this additional information in that case.
2561 Therefore, we now use this data structure only for class types.
2563 In the past, it was thought that there would be relatively few
2564 class types. However, in the presence of heavy use of templates,
2565 many (i.e., thousands) of classes can easily be generated.
2566 Therefore, we should endeavor to keep the size of this structure to
2568 struct GTY (()) lang_type
2570 unsigned char align
;
2572 unsigned has_type_conversion
: 1;
2573 unsigned has_copy_ctor
: 1;
2574 unsigned has_default_ctor
: 1;
2575 unsigned const_needs_init
: 1;
2576 unsigned ref_needs_init
: 1;
2577 unsigned has_const_copy_assign
: 1;
2578 unsigned use_template
: 2;
2580 unsigned has_mutable
: 1;
2581 unsigned com_interface
: 1;
2582 unsigned non_pod_class
: 1;
2583 unsigned nearly_empty_p
: 1;
2584 unsigned user_align
: 1;
2585 unsigned has_copy_assign
: 1;
2586 unsigned has_new
: 1;
2587 unsigned has_array_new
: 1;
2589 unsigned gets_delete
: 2;
2590 unsigned interface_only
: 1;
2591 unsigned interface_unknown
: 1;
2592 unsigned contains_empty_class_p
: 1;
2593 unsigned anon_aggr
: 1;
2594 unsigned non_zero_init
: 1;
2595 unsigned empty_p
: 1;
2596 /* 32 bits allocated. */
2598 unsigned vec_new_uses_cookie
: 1;
2599 unsigned declared_class
: 1;
2600 unsigned diamond_shaped
: 1;
2601 unsigned repeated_base
: 1;
2602 unsigned being_defined
: 1;
2603 unsigned debug_requested
: 1;
2604 unsigned fields_readonly
: 1;
2605 unsigned ptrmemfunc_flag
: 1;
2607 unsigned lazy_default_ctor
: 1;
2608 unsigned lazy_copy_ctor
: 1;
2609 unsigned lazy_copy_assign
: 1;
2610 unsigned lazy_destructor
: 1;
2611 unsigned has_const_copy_ctor
: 1;
2612 unsigned has_complex_copy_ctor
: 1;
2613 unsigned has_complex_copy_assign
: 1;
2614 unsigned non_aggregate
: 1;
2616 unsigned has_complex_dflt
: 1;
2617 unsigned has_list_ctor
: 1;
2618 unsigned non_std_layout
: 1;
2619 unsigned is_literal
: 1;
2620 unsigned lazy_move_ctor
: 1;
2621 unsigned lazy_move_assign
: 1;
2622 unsigned has_complex_move_ctor
: 1;
2623 unsigned has_complex_move_assign
: 1;
2625 unsigned has_constexpr_ctor
: 1;
2626 unsigned unique_obj_representations
: 1;
2627 unsigned unique_obj_representations_set
: 1;
2629 bool non_pod_aggregate
: 1;
2631 /* When adding a flag here, consider whether or not it ought to
2632 apply to a template instance if it applies to the template. If
2633 so, make sure to copy it in instantiate_class_template! */
2635 /* There are some bits left to fill out a 32-bit word. Keep track
2636 of this by updating the size of this bitfield whenever you add or
2641 vec
<tree_pair_s
, va_gc
> *vcall_indices
;
2644 vec
<tree
, va_gc
> *vbases
;
2646 vec
<tree
, va_gc
> *pure_virtuals
;
2647 tree friend_classes
;
2648 vec
<tree
, va_gc
> *GTY ((reorder ("resort_type_member_vec"))) members
;
2651 tree befriending_classes
;
2652 /* In a RECORD_TYPE, information specific to Objective-C++, such
2653 as a list of adopted protocols or a pointer to a corresponding
2654 @interface. See objc/objc-act.h for details. */
2656 /* FIXME reuse another field? */
2662 // forked from gcc/cp/cp-tree.h cp_ref_qualifier
2664 enum rs_ref_qualifier
2667 REF_QUAL_LVALUE
= 1,
2671 // forked from gcc/cp/cp-tree.h tsubst_flags
2673 /* Bitmask flags to control type substitution. */
2676 tf_none
= 0, /* nothing special */
2677 tf_error
= 1 << 0, /* give error messages */
2678 tf_warning
= 1 << 1, /* give warnings too */
2679 tf_ignore_bad_quals
= 1 << 2, /* ignore bad cvr qualifiers */
2680 tf_keep_type_decl
= 1 << 3, /* retain typedef type decls
2681 (make_typename_type use) */
2682 tf_ptrmem_ok
= 1 << 4, /* pointers to member ok (internal
2683 instantiate_type use) */
2684 tf_user
= 1 << 5, /* found template must be a user template
2685 (lookup_template_class use) */
2686 tf_conv
= 1 << 6, /* We are determining what kind of
2687 conversion might be permissible,
2688 not actually performing the
2690 tf_decltype
= 1 << 7, /* We are the operand of decltype.
2691 Used to implement the special rules
2692 for calls in decltype (5.2.2/11). */
2693 tf_partial
= 1 << 8, /* Doing initial explicit argument
2694 substitution in fn_type_unification. */
2695 tf_fndecl_type
= 1 << 9, /* Substituting the type of a function
2697 tf_no_cleanup
= 1 << 10, /* Do not build a cleanup
2698 (build_target_expr and friends) */
2699 tf_norm
= 1 << 11, /* Build diagnostic information during
2700 constraint normalization. */
2701 /* Convenient substitution flags combinations. */
2702 tf_warning_or_error
= tf_warning
| tf_error
2705 // forked from gcc/cp/cp-tree.h cp_identifier_kind
2707 /* Kinds of identifiers. Values are carefully chosen. */
2708 enum cp_identifier_kind
2710 cik_normal
= 0, /* Not a special identifier. */
2711 cik_keyword
= 1, /* A keyword. */
2712 cik_ctor
= 2, /* Constructor (in-chg, complete or base). */
2713 cik_dtor
= 3, /* Destructor (in-chg, deleting, complete or
2715 cik_simple_op
= 4, /* Non-assignment operator name. */
2716 cik_assign_op
= 5, /* An assignment operator name. */
2717 cik_conv_op
= 6, /* Conversion operator name. */
2718 cik_reserved_for_udlit
= 7, /* Not yet in use */
2722 // forked from gcc/cp/cp-tree.h tag_types
2724 /* An enumeration of the kind of tags that C++ accepts. */
2727 none_type
= 0, /* Not a tag type. */
2728 record_type
, /* "struct" types. */
2729 class_type
, /* "class" types. */
2730 union_type
, /* "union" types. */
2731 enum_type
, /* "enum" types. */
2732 typename_type
, /* "typename" types. */
2733 scope_type
/* namespace or tagged type name followed by :: */
2736 // forked from gcc/cp/cp-tree.h tsubst_flags_t
2738 /* This type is used for parameters and variables which hold
2739 combinations of the flags in enum tsubst_flags. */
2740 typedef int tsubst_flags_t
;
2742 // forked from gcc/cp/cvt.cc convert_to_void
2744 // When an expression is used in a void context, its value is discarded and
2745 // no lvalue-rvalue and similar conversions happen [expr.static.cast/4,
2746 // stmt.expr/1, expr.comma/1]. This permits dereferencing an incomplete type
2747 // in a void context. The C++ standard does not define what an `access' to an
2748 // object is, but there is reason to believe that it is the lvalue to rvalue
2749 // conversion -- if it were not, `*&*p = 1' would violate [expr]/4 in that it
2750 // accesses `*p' not to calculate the value to be stored. But, dcl.type.cv/8
2751 // indicates that volatile semantics should be the same between C and C++
2752 // where ever possible. C leaves it implementation defined as to what
2753 // constitutes an access to a volatile. So, we interpret `*vp' as a read of
2754 // the volatile object `vp' points to, unless that is an incomplete type. For
2755 // volatile references we do not do this interpretation, because that would
2756 // make it impossible to ignore the reference return value from functions. We
2757 // issue warnings in the confusing cases.
2759 // The IMPLICIT is ICV_CAST when the user is explicitly converting an
2760 // expression to void via a cast. If an expression is being implicitly
2761 // converted, IMPLICIT indicates the context of the implicit conversion.
2763 /* Possible cases of implicit or explicit bad conversions to void. */
2766 ICV_CAST
, /* (explicit) conversion to void */
2767 ICV_SECOND_OF_COND
, /* second operand of conditional expression */
2768 ICV_THIRD_OF_COND
, /* third operand of conditional expression */
2769 ICV_RIGHT_OF_COMMA
, /* right operand of comma operator */
2770 ICV_LEFT_OF_COMMA
, /* left operand of comma operator */
2771 ICV_STATEMENT
, /* statement */
2772 ICV_THIRD_IN_FOR
/* for increment expression */
2775 /* BUILT_IN_FRONTEND function codes. */
2776 enum rs_built_in_function
2778 RS_BUILT_IN_IS_CONSTANT_EVALUATED
,
2779 RS_BUILT_IN_INTEGER_PACK
,
2780 RS_BUILT_IN_IS_CORRESPONDING_MEMBER
,
2781 RS_BUILT_IN_IS_POINTER_INTERCONVERTIBLE_WITH_CLASS
,
2782 RS_BUILT_IN_SOURCE_LOCATION
,
2786 // forked from gcc/cp/cp-tree.h compare_bounds_t
2789 /* Says how we should behave when comparing two arrays one of which
2790 has unknown bounds. */
2791 enum compare_bounds_t
2799 convert_to_void (tree expr
, impl_conv_void implicit
);
2801 // The lvalue-to-rvalue conversion (7.1) is applied if and only if the
2802 // expression is a glvalue of volatile-qualified type and it is one of the
2804 // * ( expression ), where expression is one of these expressions,
2805 // * id-expression (8.1.4),
2806 // * subscripting (8.2.1),
2807 // * class member access (8.2.5),
2808 // * indirection (8.3.1),
2809 // * pointer-to-member operation (8.5),
2810 // * conditional expression (8.16) where both the second and the third
2811 // operands are one of these expressions, or
2812 // * comma expression (8.19) where the right operand is one of these
2815 mark_discarded_use (tree expr
);
2817 // Mark EXP as read, not just set, for set but not used -Wunused warning
2820 mark_exp_read (tree exp
);
2822 // We've seen an actual use of EXPR. Possibly replace an outer variable
2823 // reference inside with its constant value or a lambda capture.
2825 mark_use (tree expr
, bool rvalue_p
, bool read_p
, location_t loc
,
2826 bool reject_builtin
);
2828 // Called whenever the expression EXPR is used in an rvalue context.
2829 // When REJECT_BUILTIN is true the expression is checked to make sure
2830 // it doesn't make it possible to obtain the address of a GCC built-in
2831 // function with no library fallback (or any of its bits, such as in
2832 // a conversion to bool).
2834 mark_rvalue_use (tree
, location_t
= UNKNOWN_LOCATION
,
2835 bool reject_builtin
= true);
2837 // Called whenever an expression is used in an lvalue context.
2839 mark_lvalue_use (tree expr
);
2841 // As above, but don't consider this use a read.
2843 mark_lvalue_use_nonread (tree expr
);
2845 // We are using a reference VAL for its value. Bash that reference all the way
2846 // down to its lowest form.
2848 convert_from_reference (tree val
);
2850 // Subroutine of convert_to_void. Warn if we're discarding something with
2851 // attribute [[nodiscard]].
2853 maybe_warn_nodiscard (tree expr
, impl_conv_void implicit
);
2856 expr_loc_or_loc (const_tree t
, location_t or_loc
);
2859 expr_loc_or_input_loc (const_tree t
);
2861 // FN is the callee of a CALL_EXPR or AGGR_INIT_EXPR; return the FUNCTION_DECL
2864 get_fndecl_from_callee (tree fn
);
2866 // FIXME some helpers from HIRCompileBase could probably be moved here over time
2868 // Return an expression for the address of BASE[INDEX], used in offset intrinsic
2870 pointer_offset_expression (tree base_tree
, tree index_tree
, location_t locus
);
2872 /* A tree node, together with a location, so that we can track locations
2873 (and ranges) during parsing.
2875 The location is redundant for node kinds that have locations,
2876 but not all node kinds do (e.g. constants, and references to
2877 params, locals, etc), so we stash a copy here. */
2879 extern location_t
rs_expr_location (const_tree
);
2882 is_empty_class (tree type
);
2884 extern tree
array_type_nelts_top (tree
);
2887 is_really_empty_class (tree
, bool);
2889 extern bool builtin_valid_in_constant_expr_p (const_tree
);
2891 extern bool maybe_constexpr_fn (tree
);
2893 extern bool var_in_maybe_constexpr_fn (tree
);
2896 rs_type_quals (const_tree type
);
2898 inline bool type_unknown_p (const_tree
);
2900 extern bool decl_maybe_constant_var_p (tree
);
2905 extern bool var_in_constexpr_fn (tree
);
2907 inline tree
ovl_first (tree
) ATTRIBUTE_PURE
;
2909 inline bool type_unknown_p (const_tree
);
2912 lookup_add (tree fns
, tree lookup
);
2915 ovl_make (tree fn
, tree next
= NULL_TREE
);
2917 extern int is_overloaded_fn (tree
) ATTRIBUTE_PURE
;
2919 extern bool maybe_add_lang_type_raw (tree
);
2921 extern rs_ref_qualifier
type_memfn_rqual (const_tree
);
2923 extern bool builtin_pack_fn_p (tree
);
2925 extern tree
make_conv_op_name (tree
);
2927 extern int type_memfn_quals (const_tree
);
2930 get_fileinfo (const char *);
2933 cxx_make_type (enum tree_code CXX_MEM_STAT_INFO
);
2936 build_cplus_array_type (tree
, tree
, int is_dep
= -1);
2938 extern bool is_byte_access_type (tree
);
2941 comptypes (tree
, tree
, int);
2943 extern tree
canonical_eh_spec (tree
);
2945 extern int cp_tree_operand_length (const_tree
);
2947 extern bool rs_tree_equal (tree
, tree
);
2949 extern bool compparms (const_tree
, const_tree
);
2952 rs_build_qualified_type_real (tree
, int, tsubst_flags_t
);
2953 #define rs_build_qualified_type(TYPE, QUALS) \
2954 rs_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error)
2955 extern bool cv_qualified_p (const_tree
);
2957 extern bool similar_type_p (tree
, tree
);
2959 extern bool rs_tree_equal (tree
, tree
);
2962 vector_targets_convertible_p (const_tree t1
, const_tree t2
);
2964 extern bool same_type_ignoring_top_level_qualifiers_p (tree
, tree
);
2966 extern bool comp_ptr_ttypes_const (tree
, tree
, compare_bounds_t
);
2969 get_class_binding_direct (tree
, tree
, bool want_type
= false);
2971 extern tree
skip_artificial_parms_for (const_tree
, tree
);
2974 lang_check_failed (const char *, int,
2975 const char *) ATTRIBUTE_NORETURN ATTRIBUTE_COLD
;
2977 extern tree
default_init_uninitialized_part (tree
);
2979 extern bool type_has_non_user_provided_default_constructor (tree
);
2981 extern bool default_ctor_p (const_tree
);
2983 extern bool user_provided_p (tree
);
2985 extern bool sufficient_parms_p (const_tree
);
2987 extern tree
next_initializable_field (tree
);
2989 extern tree
in_class_defaulted_default_constructor (tree
);
2991 extern bool is_instantiation_of_constexpr (tree
);
2994 check_for_uninitialized_const_var (tree
, bool, tsubst_flags_t
);
2996 extern bool reduced_constant_expression_p (tree
);
2998 extern tree
cv_unqualified (tree
);
3000 extern tree
cp_get_callee (tree
);
3001 extern tree
rs_get_callee_fndecl_nofold (tree
);
3003 extern bool is_nondependent_static_init_expression (tree
);
3005 extern tree
build_nop (tree
, tree
);
3007 extern bool scalarish_type_p (const_tree
);
3009 extern tree
is_bitfield_expr_with_lowered_type (const_tree
);
3011 extern tree
convert_bitfield_to_declared_type (tree
);
3014 cp_fold_maybe_rvalue (tree
, bool);
3016 extern tree
maybe_undo_parenthesized_ref (tree
);
3019 fold_offsetof (tree
, tree
= size_type_node
, tree_code ctx
= ERROR_MARK
);
3021 extern tree
cp_truthvalue_conversion (tree
, tsubst_flags_t
);
3024 fold_non_dependent_expr (tree
, tsubst_flags_t
= tf_warning_or_error
,
3025 bool = false, tree
= NULL_TREE
);
3027 extern int char_type_p (tree
);
3029 extern bool instantiation_dependent_expression_p (tree
);
3031 extern bool type_has_nontrivial_copy_init (const_tree
);
3033 extern tree
build_local_temp (tree
);
3035 extern bool is_normal_capture_proxy (tree
);
3037 extern bool reject_gcc_builtin (const_tree
, location_t
= UNKNOWN_LOCATION
);
3039 extern tree
resolve_nondeduced_context (tree
, tsubst_flags_t
);
3041 extern void cxx_incomplete_type_diagnostic (location_t
, const_tree
, const_tree
,
3044 extern void cxx_incomplete_type_error (location_t
, const_tree
, const_tree
);
3046 extern bool invalid_nonstatic_memfn_p (location_t
, tree
, tsubst_flags_t
);
3048 extern bool really_overloaded_fn (tree
) ATTRIBUTE_PURE
;
3050 extern tree
resolve_nondeduced_context_or_error (tree
, tsubst_flags_t
);
3052 extern tree
instantiate_non_dependent_or_null (tree
);
3054 extern void cxx_incomplete_type_inform (const_tree
);
3056 extern tree
strip_top_quals (tree
);
3058 extern bool undeduced_auto_decl (tree
);
3060 extern bool require_deduced_type (tree
, tsubst_flags_t
= tf_warning_or_error
);
3062 extern bool decl_constant_var_p (tree
);
3064 extern tree
build_new_constexpr_heap_type (tree
, tree
, tree
);
3066 extern bool is_empty_field (tree
);
3069 in_immediate_context ();
3071 extern tree
cp_get_callee_fndecl_nofold (tree
);
3074 cxx_mark_addressable (tree
, bool = false);
3076 extern tree
fold_builtin_source_location (location_t
);
3078 extern tree
build_address (tree
);
3080 extern bool bitfield_p (const_tree
);
3082 extern tree
rvalue (tree
);
3084 extern bool glvalue_p (const_tree
);
3086 extern cp_lvalue_kind
lvalue_kind (const_tree
);
3089 decl_constant_value (tree
, bool);
3091 extern tree
lookup_enumerator (tree
, tree
);
3094 is_class_type (tree
, int);
3096 extern tree
braced_lists_to_strings (tree
, tree
);
3099 fold_builtin_is_pointer_inverconvertible_with_class (location_t
, int, tree
*);
3101 extern bool layout_compatible_type_p (tree
, tree
);
3103 extern tree
finish_underlying_type (tree
);
3106 c_common_type_for_mode (machine_mode
, int);
3108 extern bool std_layout_type_p (const_tree
);
3110 extern tree
complete_type (tree
);
3112 extern tree
complete_type_or_else (tree
, tree
);
3114 extern void note_failed_type_completion_for_satisfaction (tree
);
3116 extern tree
complete_type_or_maybe_complain (tree
, tree
, tsubst_flags_t
);
3119 next_common_initial_seqence (tree
&, tree
&);
3121 extern bool null_member_pointer_value_p (tree
);
3124 fold_builtin_is_corresponding_member (location_t
, int, tree
*);
3126 extern tree
cp_fold_rvalue (tree
);
3129 maybe_constant_value (tree
, tree
= NULL_TREE
, bool = false);
3131 extern tree
lvalue_type (tree
);
3133 extern void lvalue_error (location_t
, enum lvalue_use
);
3136 cp_fold_maybe_rvalue (tree
, bool);
3138 extern tree
get_first_fn (tree
) ATTRIBUTE_PURE
;
3140 extern void explain_non_literal_class (tree
);
3142 extern bool reference_related_p (tree
, tree
);
3144 extern bool ordinary_char_type_p (tree
);
3146 extern bool array_string_literal_compatible_p (tree
, tree
);
3148 // forked from gcc/cp/cp-tree.h
3159 rs_build_qualified_type_real (tree
, int, tsubst_flags_t
);
3160 #define rs_build_qualified_type(TYPE, QUALS) \
3161 rs_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error)
3164 rs_walk_subtrees (tree
*, int *, walk_tree_fn
, void *, hash_set
<tree
> *);
3165 #define rs_walk_tree(tp, func, data, pset) \
3166 walk_tree_1 (tp, func, data, pset, rs_walk_subtrees)
3167 #define rs_walk_tree_without_duplicates(tp, func, data) \
3168 walk_tree_without_duplicates_1 (tp, func, data, rs_walk_subtrees)
3170 // forked from gcc/cp/cp-tree.h cp_expr_loc_or_loc
3173 rs_expr_loc_or_loc (const_tree t
, location_t or_loc
)
3175 location_t loc
= rs_expr_location (t
);
3176 if (loc
== UNKNOWN_LOCATION
)
3181 // forked from gcc/cp/cp-tree.h cp_expr_loc_or_input_loc
3184 rs_expr_loc_or_input_loc (const_tree t
)
3186 return rs_expr_loc_or_loc (t
, input_location
);
3189 // forked from gcc/cp/cp-tree.h type_unknown_p
3192 type_unknown_p (const_tree expr
)
3194 return TREE_TYPE (expr
) == unknown_type_node
;
3197 // forked from gcc/cp/cp-tree.h ovl_first
3199 /* Inline bodies. */
3202 ovl_first (tree node
)
3204 while (TREE_CODE (node
) == OVERLOAD
)
3205 node
= OVL_FUNCTION (node
);
3209 // forked from gcc/cp/cp-tree.h type_of_this_parm
3211 /* Return the type of the `this' parameter of FNTYPE. */
3214 type_of_this_parm (const_tree fntype
)
3216 function_args_iterator iter
;
3217 gcc_assert (TREE_CODE (fntype
) == METHOD_TYPE
);
3218 function_args_iter_init (&iter
, fntype
);
3219 return function_args_iter_cond (&iter
);
3222 // forked from gcc/cp/cp-tree.h class_of_this_parm
3224 /* Return the class of the `this' parameter of FNTYPE. */
3227 class_of_this_parm (const_tree fntype
)
3229 return TREE_TYPE (type_of_this_parm (fntype
));
3232 // forked from gcc/cp/cp-tree.h identifier_p
3234 /* Return a typed pointer version of T if it designates a
3235 C++ front-end identifier. */
3236 inline lang_identifier
*
3237 identifier_p (tree t
)
3239 if (TREE_CODE (t
) == IDENTIFIER_NODE
)
3240 return (lang_identifier
*) t
;
3244 // forked from gcc/c-family/c-common.h gnu_vector_type_p
3246 /* Return true if TYPE is a vector type that should be subject to the GNU
3247 vector extensions (as opposed to a vector type that is used only for
3248 the purposes of defining target-specific built-in functions). */
3251 gnu_vector_type_p (const_tree type
)
3253 return TREE_CODE (type
) == VECTOR_TYPE
&& !TYPE_INDIVISIBLE_P (type
);
3256 extern vec
<tree
, va_gc
> *
3257 make_tree_vector (void);
3260 release_tree_vector (vec
<tree
, va_gc
> *);
3262 /* Simplified unique_ptr clone to release a tree vec on exit. */
3267 typedef vec
<tree
, va_gc
> vec_t
;
3269 releasing_vec (vec_t
*v
) : v (v
) {}
3270 releasing_vec () : v (make_tree_vector ()) {}
3272 /* Copy ops are deliberately declared but not defined,
3273 copies must always be elided. */
3274 releasing_vec (const releasing_vec
&);
3275 releasing_vec
&operator= (const releasing_vec
&);
3277 vec_t
&operator* () const { return *v
; }
3278 vec_t
*operator-> () const { return v
; }
3279 vec_t
*get () const { return v
; }
3280 operator vec_t
* () const { return v
; }
3281 vec_t
**operator& () { return &v
; }
3283 /* Breaks pointer/value consistency for convenience. This takes ptrdiff_t
3284 rather than unsigned to avoid ambiguity with the built-in operator[]
3285 (bootstrap/91828). */
3286 tree
&operator[] (ptrdiff_t i
) const { return (*v
)[i
]; }
3288 tree
*begin () { return ::begin (v
); }
3289 tree
*end () { return ::end (v
); }
3293 release_tree_vector (v
);
3297 ~releasing_vec () { release_tree_vector (v
); }
3304 vec_safe_push (releasing_vec
&r
, const tree
&t CXX_MEM_STAT_INFO
)
3306 return vec_safe_push (*&r
, t PASS_MEM_STAT
);
3310 vec_safe_reserve (releasing_vec
&r
, unsigned n
,
3311 bool e
= false CXX_MEM_STAT_INFO
)
3313 return vec_safe_reserve (*&r
, n
, e PASS_MEM_STAT
);
3316 vec_safe_length (releasing_vec
&r
)
3318 return r
->length ();
3321 vec_safe_splice (releasing_vec
&r
, vec
<tree
, va_gc
> *p CXX_MEM_STAT_INFO
)
3323 vec_safe_splice (*&r
, p PASS_MEM_STAT
);
3327 null_node_p (const_tree expr
)
3329 STRIP_ANY_LOCATION_WRAPPER (expr
);
3330 return expr
== null_node
;
3334 cxx_incomplete_type_diagnostic (const_tree value
, const_tree type
,
3335 diagnostic_t diag_kind
)
3337 cxx_incomplete_type_diagnostic (rs_expr_loc_or_input_loc (value
), value
, type
,
3342 cxx_incomplete_type_error (const_tree value
, const_tree type
)
3344 cxx_incomplete_type_diagnostic (value
, type
, DK_ERROR
);
3348 location_of (tree t
);
3350 /* Helpers for IMPLICIT_RVALUE_P to look through automatic dereference. */
3353 implicit_rvalue_p (const_tree t
)
3355 if (REFERENCE_REF_P (t
))
3356 t
= TREE_OPERAND (t
, 0);
3357 return ((TREE_CODE (t
) == NON_LVALUE_EXPR
) && IMPLICIT_RVALUE_P (t
));
3360 set_implicit_rvalue_p (tree ot
)
3363 if (REFERENCE_REF_P (t
))
3364 t
= TREE_OPERAND (t
, 0);
3365 IMPLICIT_RVALUE_P (t
) = 1;
3371 maybe_constant_init (tree
, tree
= NULL_TREE
, bool = false);
3374 explain_invalid_constexpr_fn (tree fun
);
3376 extern bool potential_constant_expression (tree
);
3379 literal_type_p (tree t
);
3382 maybe_constexpr_fn (tree t
);
3385 fold_non_dependent_init (tree
, tsubst_flags_t
= tf_warning_or_error
,
3386 bool = false, tree
= NULL_TREE
);
3387 } // namespace Compile