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 RS_DST_FLAG TREE_LANG_FLAG_0
82 #define RS_DST_FLAG_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) Rust::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 rust_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
) { rust_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 c_language_function
2024 /* Global state pertinent to the current function. Some C dialects
2025 extend this structure with additional fields. */
2027 struct GTY (()) c_language_function
2029 /* Vector of locally defined typedefs, for
2030 -Wunused-local-typedefs. */
2031 vec
<tree
, va_gc
> *local_typedefs
;
2034 // forked from gcc/cp/cp-tree.h omp_declare_target_attr
2036 struct GTY (()) omp_declare_target_attr
2041 // forked from gcc/cp/name-lookup.h cxx_binding
2043 /* Datatype that represents binding established by a declaration between
2044 a name and a C++ entity. */
2045 struct GTY (()) cxx_binding
2047 /* Link to chain together various bindings for this name. */
2048 cxx_binding
*previous
;
2049 /* The non-type entity this name is bound to. */
2051 /* The type entity this name is bound to. */
2054 bool value_is_inherited
: 1;
2056 bool type_is_hidden
: 1;
2059 // forked from gcc/cp/name-lookup.h cxx_saved_binding
2061 /* Datatype used to temporarily save C++ bindings (for implicit
2062 instantiations purposes and like). Implemented in decl.cc. */
2063 struct GTY (()) rust_cxx_saved_binding
2065 /* The name of the current binding. */
2067 /* The binding we're saving. */
2068 cxx_binding
*binding
;
2069 tree real_type_value
;
2072 // forked from gcc/cp/name-lookup.h resort_type_member_vec
2074 /* needed for GTY annotation */
2076 resort_type_member_vec (void *, void *, gt_pointer_operator
, void *);
2078 // forked from gcc/cp/cp-tree.h saved_scope
2082 struct GTY (()) saved_scope
2084 vec
<rust_cxx_saved_binding
, va_gc
> *old_bindings
;
2086 vec
<tree
, va_gc
> *decl_ns_list
;
2089 tree access_specifier
;
2091 vec
<tree
, va_gc
> *lang_base
;
2093 tree template_parms
;
2096 /* Only used for uses of this in trailing return type. */
2097 tree x_current_class_ptr
;
2098 tree x_current_class_ref
;
2100 int x_processing_template_decl
;
2101 int x_processing_specialization
;
2102 int x_processing_constraint
;
2103 int suppress_location_wrappers
;
2104 BOOL_BITFIELD x_processing_explicit_instantiation
: 1;
2105 BOOL_BITFIELD need_pop_function_context
: 1;
2107 /* Nonzero if we are parsing the discarded statement of a constexpr
2109 BOOL_BITFIELD discarded_stmt
: 1;
2110 /* Nonzero if we are parsing or instantiating the compound-statement
2111 of consteval if statement. Also set while processing an immediate
2113 BOOL_BITFIELD consteval_if_p
: 1;
2115 int unevaluated_operand
;
2116 int inhibit_evaluation_warnings
;
2117 int noexcept_operand
;
2120 hash_map
<tree
, tree
> *GTY ((skip
)) x_local_specializations
;
2121 vec
<omp_declare_target_attr
, va_gc
> *omp_declare_target_attribute
;
2123 struct saved_scope
*prev
;
2126 extern GTY (()) struct saved_scope
*scope_chain
;
2128 // forked from gcc/cp/name_lookup.h cp_class_binding
2130 struct GTY (()) rust_cp_class_binding
2133 /* The bound name. */
2137 // forked from gcc/cp/name_lookup.h cp_binding_level
2139 /* For each binding contour we allocate a binding_level structure
2140 which records the names defined in that contour.
2143 1) one for each function definition,
2144 where internal declarations of the parameters appear.
2145 2) one for each compound statement,
2146 to record its declarations.
2148 The current meaning of a name can be found by searching the levels
2149 from the current one out to the global one.
2151 Off to the side, may be the class_binding_level. This exists only
2152 to catch class-local declarations. It is otherwise nonexistent.
2154 Also there may be binding levels that catch cleanups that must be
2155 run when exceptions occur. Thus, to see whether a name is bound in
2156 the current scope, it is not enough to look in the
2157 CURRENT_BINDING_LEVEL. You should use lookup_name_current_level
2160 struct GTY (()) rust_cp_binding_level
2162 /* A chain of _DECL nodes for all variables, constants, functions,
2163 and typedef types. These are in the reverse of the order
2164 supplied. There may be OVERLOADs on this list, too, but they
2165 are wrapped in TREE_LISTs; the TREE_VALUE is the OVERLOAD. */
2168 /* Using directives. */
2169 vec
<tree
, va_gc
> *using_directives
;
2171 /* For the binding level corresponding to a class, the entities
2172 declared in the class or its base classes. */
2173 vec
<rust_cp_class_binding
, va_gc
> *class_shadowed
;
2175 /* Similar to class_shadowed, but for IDENTIFIER_TYPE_VALUE, and
2176 is used for all binding levels. The TREE_PURPOSE is the name of
2177 the entity, the TREE_TYPE is the associated type. In addition
2178 the TREE_VALUE is the IDENTIFIER_TYPE_VALUE before we entered
2182 /* For each level (except not the global one),
2183 a chain of BLOCK nodes for all the levels
2184 that were entered and exited one level down. */
2187 /* The entity (namespace, class, function) the scope of which this
2188 binding contour corresponds to. Otherwise NULL. */
2191 /* The binding level which this one is contained in (inherits from). */
2192 rust_cp_binding_level
*level_chain
;
2194 /* STATEMENT_LIST for statements in this binding contour.
2195 Only used at present for SK_CLEANUP temporary bindings. */
2196 tree statement_list
;
2198 /* Binding depth at which this level began. */
2201 /* The kind of scope that this object represents. However, a
2202 SK_TEMPLATE_SPEC scope is represented with KIND set to
2203 SK_TEMPLATE_PARMS and EXPLICIT_SPEC_P set to true. */
2204 ENUM_BITFIELD (scope_kind
) kind
: 4;
2206 /* True if this scope is an SK_TEMPLATE_SPEC scope. This field is
2207 only valid if KIND == SK_TEMPLATE_PARMS. */
2208 BOOL_BITFIELD explicit_spec_p
: 1;
2210 /* true means make a BLOCK for this level regardless of all else. */
2213 /* Nonzero if this level can safely have additional
2214 cleanup-needing variables added to it. */
2215 unsigned more_cleanups_ok
: 1;
2216 unsigned have_cleanups
: 1;
2218 /* Transient state set if this scope is of sk_class kind
2219 and is in the process of defining 'this_entity'. Reset
2220 on leaving the class definition to allow for the scope
2221 to be subsequently re-used as a non-defining scope for
2223 unsigned defining_class_p
: 1;
2225 /* True for SK_FUNCTION_PARMS of a requires-expression. */
2226 unsigned requires_expression
: 1;
2228 /* 22 bits left to fill a 32-bit word. */
2231 // forked from gcc/cp/decl.cc named_label_entry
2233 /* A list of all LABEL_DECLs in the function that have names. Here so
2234 we can clear out their names' definitions at the end of the
2235 function, and so we can check the validity of jumps to these labels. */
2237 struct GTY ((for_user
)) rust_named_label_entry
2239 tree name
; /* Name of decl. */
2241 tree label_decl
; /* LABEL_DECL, unless deleted local label. */
2243 rust_named_label_entry
*outer
; /* Outer shadowed chain. */
2245 /* The binding level to which the label is *currently* attached.
2246 This is initially set to the binding level in which the label
2247 is defined, but is modified as scopes are closed. */
2248 rust_cp_binding_level
*binding_level
;
2250 /* The head of the names list that was current when the label was
2251 defined, or the inner scope popped. These are the decls that will
2252 be skipped when jumping to the label. */
2253 tree names_in_scope
;
2255 /* A vector of all decls from all binding levels that would be
2256 crossed by a backward branch to the label. */
2257 vec
<tree
, va_gc
> *bad_decls
;
2259 /* The following bits are set after the label is defined, and are
2260 updated as scopes are popped. They indicate that a jump to the
2261 label will illegally enter a scope of the given flavor. */
2263 bool in_catch_scope
;
2265 bool in_transaction_scope
;
2266 bool in_constexpr_if
;
2267 bool in_consteval_if
;
2271 // forked from gcc/cp/cp-tree.h named_label_hash
2273 struct rust_named_label_hash
: ggc_remove
<rust_named_label_entry
*>
2275 typedef rust_named_label_entry
*value_type
;
2276 typedef tree compare_type
; /* An identifier. */
2278 inline static hashval_t
hash (value_type
);
2279 inline static bool equal (const value_type
, compare_type
);
2281 static const bool empty_zero_p
= true;
2282 inline static void mark_empty (value_type
&p
) { p
= NULL
; }
2283 inline static bool is_empty (value_type p
) { return !p
; }
2285 /* Nothing is deletable. Everything is insertable. */
2286 inline static bool is_deleted (value_type
) { return false; }
2287 inline static void mark_deleted (value_type
) { rust_unreachable (); }
2290 // forked from gcc/cp/cp-tree.h
2292 /* Global state pertinent to the current function.
2293 TODO: remove vestigial fields */
2295 struct GTY (()) language_function
2297 struct c_language_function base
;
2300 tree x_current_class_ptr
;
2301 tree x_current_class_ref
;
2302 tree x_eh_spec_block
;
2303 tree x_in_charge_parm
;
2305 tree x_return_value
;
2307 BOOL_BITFIELD returns_value
: 1;
2308 BOOL_BITFIELD returns_null
: 1;
2309 BOOL_BITFIELD returns_abnormally
: 1;
2310 BOOL_BITFIELD infinite_loop
: 1;
2311 BOOL_BITFIELD x_in_function_try_handler
: 1;
2312 BOOL_BITFIELD x_in_base_initializer
: 1;
2314 /* True if this function can throw an exception. */
2315 BOOL_BITFIELD can_throw
: 1;
2317 BOOL_BITFIELD invalid_constexpr
: 1;
2318 BOOL_BITFIELD throwing_cleanup
: 1;
2320 hash_table
<rust_named_label_hash
> *x_named_labels
;
2322 /* Tracking possibly infinite loops. This is a vec<tree> only because
2323 vec<bool> doesn't work with gtype. */
2324 vec
<tree
, va_gc
> *infinite_loops
;
2327 // forked from gcc/c-family/c-common.h ref_operator
2329 /* The various name of operator that appears in error messages. */
2334 /* array indexing */
2340 /* implicit conversion */
2341 RO_IMPLICIT_CONVERSION
,
2346 // forked from gcc/cp/cp-tree.h lang_decl_min
2348 /* DECL_LANG_SPECIFIC for the above codes. */
2350 struct GTY (()) lang_decl_min
2352 struct lang_decl_base base
; /* 32-bits. */
2354 /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
2356 In a FUNCTION_DECL for which DECL_THUNK_P does not hold,
2357 VAR_DECL, TYPE_DECL, or TEMPLATE_DECL, this is
2358 DECL_TEMPLATE_INFO. */
2361 /* In a DECL_THUNK_P FUNCTION_DECL, this is THUNK_VIRTUAL_OFFSET.
2362 In a lambda-capture proxy VAR_DECL, this is DECL_CAPTURED_VARIABLE.
2363 In a function-scope TREE_STATIC VAR_DECL or IMPLICIT_TYPEDEF_P TYPE_DECL,
2364 this is DECL_DISCRIMINATOR.
2365 In a DECL_LOCAL_DECL_P decl, this is the namespace decl it aliases.
2366 Otherwise, in a class-scope DECL, this is DECL_ACCESS. */
2370 // forked from gcc/cp/cp-tree.h lang_decl_fn
2372 /* Additional DECL_LANG_SPECIFIC information for functions. */
2374 struct GTY (()) lang_decl_fn
2376 struct lang_decl_min min
;
2378 /* In a overloaded operator, this is the compressed operator code. */
2379 unsigned ovl_op_code
: 6;
2380 unsigned global_ctor_p
: 1;
2381 unsigned global_dtor_p
: 1;
2383 unsigned static_function
: 1;
2384 unsigned pure_virtual
: 1;
2385 unsigned defaulted_p
: 1;
2386 unsigned has_in_charge_parm_p
: 1;
2387 unsigned has_vtt_parm_p
: 1;
2388 unsigned nonconverting
: 1;
2389 unsigned thunk_p
: 1;
2391 unsigned this_thunk_p
: 1;
2392 unsigned omp_declare_reduction_p
: 1;
2393 unsigned has_dependent_explicit_spec_p
: 1;
2394 unsigned immediate_fn_p
: 1;
2395 unsigned maybe_deleted
: 1;
2396 unsigned coroutine_p
: 1;
2397 unsigned implicit_constexpr
: 1;
2399 unsigned spare
: 10;
2401 /* 32-bits padding on 64-bit host. */
2403 /* For a non-thunk function decl, this is a tree list of
2404 friendly classes. For a thunk function decl, it is the
2405 thunked to function decl. */
2406 tree befriending_classes
;
2408 /* For a virtual FUNCTION_DECL for which
2409 DECL_THIS_THUNK_P does not hold, this is DECL_THUNKS. Both
2410 this pointer and result pointer adjusting thunks are
2411 chained here. This pointer thunks to return pointer thunks
2412 will be chained on the return pointer thunk.
2413 For a DECL_CONSTUCTOR_P FUNCTION_DECL, this is the base from
2414 whence we inherit. Otherwise, it is the class in which a
2415 (namespace-scope) friend is defined (if any). */
2420 /* In a non-thunk FUNCTION_DECL, this is DECL_CLONED_FUNCTION. */
2421 tree
GTY ((tag ("0"))) cloned_function
;
2423 /* In a FUNCTION_DECL for which THUNK_P holds this is the
2424 THUNK_FIXED_OFFSET. */
2425 HOST_WIDE_INT
GTY ((tag ("1"))) fixed_offset
;
2426 } GTY ((desc ("%1.thunk_p"))) u5
;
2428 tree
GTY (()) saved_auto_return_type
;
2431 // forked from gcc/cp/cp-tree.h lang_decl_ns
2433 /* DECL_LANG_SPECIFIC for namespaces. */
2435 struct GTY (()) lang_decl_ns
2437 struct lang_decl_base base
; /* 32 bits. */
2439 /* Inline children. Needs to be va_gc, because of PCH. */
2440 vec
<tree
, va_gc
> *inlinees
;
2442 /* Hash table of bound decls. It'd be nice to have this inline, but
2443 as the hash_map has a dtor, we can't then put this struct into a
2444 union (until moving to c++11). */
2445 hash_table
<rust_named_decl_hash
> *bindings
;
2448 // forked from gcc/cp/cp-tree.h lang_decl_parm
2450 /* DECL_LANG_SPECIFIC for parameters. */
2452 struct GTY (()) lang_decl_parm
2454 struct lang_decl_base base
; /* 32 bits. */
2459 // forked from gcc/cp/cp-tree.h lang_decl_decomp
2461 /* Additional DECL_LANG_SPECIFIC information for structured bindings. */
2463 struct GTY (()) lang_decl_decomp
2465 struct lang_decl_min min
;
2466 /* The artificial underlying "e" variable of the structured binding
2471 // forked from gcc/cp/cp-tree.h lang_decl
2473 /* DECL_LANG_SPECIFIC for all types. It would be nice to just make this a
2474 union rather than a struct containing a union as its only field, but
2475 tree.h declares it as a struct. */
2477 struct GTY (()) lang_decl
2479 union GTY ((desc ("%h.base.selector"))) lang_decl_u
2481 /* Nothing of only the base type exists. */
2482 struct lang_decl_base
GTY ((default)) base
;
2483 struct lang_decl_min
GTY ((tag ("lds_min"))) min
;
2484 struct lang_decl_fn
GTY ((tag ("lds_fn"))) fn
;
2485 struct lang_decl_ns
GTY ((tag ("lds_ns"))) ns
;
2486 struct lang_decl_parm
GTY ((tag ("lds_parm"))) parm
;
2487 struct lang_decl_decomp
GTY ((tag ("lds_decomp"))) decomp
;
2491 // forked from gcc/c-family/c-common.h c_fileinfo
2493 /* Information recorded about each file examined during compilation. */
2497 int time
; /* Time spent in the file. */
2499 /* Flags used only by C++.
2500 INTERFACE_ONLY nonzero means that we are in an "interface" section
2501 of the compiler. INTERFACE_UNKNOWN nonzero means we cannot trust
2502 the value of INTERFACE_ONLY. If INTERFACE_UNKNOWN is zero and
2503 INTERFACE_ONLY is zero, it means that we are responsible for
2504 exporting definitions that others might need. */
2505 short interface_only
;
2506 short interface_unknown
;
2509 // forked from gcc/c-family/c-common.h c_common_identifier
2511 /* Identifier part common to the C front ends. Inherits from
2512 tree_identifier, despite appearances. */
2513 struct GTY (()) c_common_identifier
2515 struct tree_common common
;
2516 struct cpp_hashnode node
; // from cpplib.h
2519 // forked from gcc/cp/cp-tree.h lang_identifier
2521 /* Language-dependent contents of an identifier. */
2523 struct GTY (()) lang_identifier
2525 struct c_common_identifier c_common
;
2526 cxx_binding
*bindings
;
2529 // forked from gcc/cp/cp-tree.h tree_overload
2531 /* OVL_HIDDEN_P nodes come before other nodes. */
2533 struct GTY (()) tree_overload
2535 struct tree_common common
;
2539 // forked from gcc/cp/cp-tree.h ovl_iterator
2544 const bool allow_inner
; /* Only used when checking. */
2547 explicit ovl_iterator (tree o
, bool allow
= false)
2548 : ovl (o
), allow_inner (allow
)
2552 operator bool () const { return ovl
; }
2553 ovl_iterator
&operator++ ()
2555 ovl
= TREE_CODE (ovl
) != OVERLOAD
? NULL_TREE
: OVL_CHAIN (ovl
);
2558 tree
operator* () const
2560 tree fn
= TREE_CODE (ovl
) != OVERLOAD
? ovl
: OVL_FUNCTION (ovl
);
2562 /* Check this is not an unexpected 2-dimensional overload. */
2563 gcc_checking_assert (allow_inner
|| TREE_CODE (fn
) != OVERLOAD
);
2567 bool operator== (const ovl_iterator
&o
) const { return ovl
== o
.ovl
; }
2568 tree
get_using () const
2570 gcc_checking_assert (using_p ());
2575 /* Whether this overload was introduced by a using decl. */
2576 bool using_p () const
2578 return (TREE_CODE (ovl
) == USING_DECL
2579 || (TREE_CODE (ovl
) == OVERLOAD
&& OVL_USING_P (ovl
)));
2581 /* Whether this using is being exported. */
2582 bool exporting_p () const { return OVL_EXPORT_P (get_using ()); }
2584 bool hidden_p () const
2586 return TREE_CODE (ovl
) == OVERLOAD
&& OVL_HIDDEN_P (ovl
);
2590 tree
remove_node (tree head
) { return remove_node (head
, ovl
); }
2591 tree
reveal_node (tree head
) { return reveal_node (head
, ovl
); }
2594 /* If we have a nested overload, point at the inner overload and
2595 return the next link on the outer one. */
2600 if (ovl
&& TREE_CODE (ovl
) == OVERLOAD
&& OVL_NESTED_P (ovl
))
2602 r
= OVL_CHAIN (ovl
);
2603 ovl
= OVL_FUNCTION (ovl
);
2607 /* Restore an outer nested overload. */
2608 void pop (tree outer
)
2610 gcc_checking_assert (!ovl
);
2615 /* We make these static functions to avoid the address of the
2616 iterator escaping the local context. */
2617 static tree
remove_node (tree head
, tree node
);
2618 static tree
reveal_node (tree ovl
, tree node
);
2621 // forked from gcc/cp/cp-tree.h lkp_iterator
2623 /* Iterator over a (potentially) 2 dimensional overload, which is
2624 produced by name lookup. */
2626 class lkp_iterator
: public ovl_iterator
2628 typedef ovl_iterator parent
;
2633 explicit lkp_iterator (tree o
) : parent (o
, true), outer (maybe_push ()) {}
2636 lkp_iterator
&operator++ ()
2638 bool repush
= !outer
;
2640 if (!parent::operator++ () && !repush
)
2647 outer
= maybe_push ();
2653 // forked from gcc/cp/cp-tree.h treee_pair_s
2655 struct GTY (()) rust_tree_pair_s
2661 // forked from gcc/cp/cp-tree.h tree_pair_p
2663 typedef rust_tree_pair_s
*rust_tree_pair_p
;
2665 // forked from gcc/cp/cp-tree.h lang_type
2667 /* This structure provides additional information above and beyond
2668 what is provide in the ordinary tree_type. In the past, we used it
2669 for the types of class types, template parameters types, typename
2670 types, and so forth. However, there can be many (tens to hundreds
2671 of thousands) of template parameter types in a compilation, and
2672 there's no need for this additional information in that case.
2673 Therefore, we now use this data structure only for class types.
2675 In the past, it was thought that there would be relatively few
2676 class types. However, in the presence of heavy use of templates,
2677 many (i.e., thousands) of classes can easily be generated.
2678 Therefore, we should endeavor to keep the size of this structure to
2680 struct GTY (()) lang_type
2682 unsigned char align
;
2684 unsigned has_type_conversion
: 1;
2685 unsigned has_copy_ctor
: 1;
2686 unsigned has_default_ctor
: 1;
2687 unsigned const_needs_init
: 1;
2688 unsigned ref_needs_init
: 1;
2689 unsigned has_const_copy_assign
: 1;
2690 unsigned use_template
: 2;
2692 unsigned has_mutable
: 1;
2693 unsigned com_interface
: 1;
2694 unsigned non_pod_class
: 1;
2695 unsigned nearly_empty_p
: 1;
2696 unsigned user_align
: 1;
2697 unsigned has_copy_assign
: 1;
2698 unsigned has_new
: 1;
2699 unsigned has_array_new
: 1;
2701 unsigned gets_delete
: 2;
2702 unsigned interface_only
: 1;
2703 unsigned interface_unknown
: 1;
2704 unsigned contains_empty_class_p
: 1;
2705 unsigned anon_aggr
: 1;
2706 unsigned non_zero_init
: 1;
2707 unsigned empty_p
: 1;
2708 /* 32 bits allocated. */
2710 unsigned vec_new_uses_cookie
: 1;
2711 unsigned declared_class
: 1;
2712 unsigned diamond_shaped
: 1;
2713 unsigned repeated_base
: 1;
2714 unsigned being_defined
: 1;
2715 unsigned debug_requested
: 1;
2716 unsigned fields_readonly
: 1;
2717 unsigned ptrmemfunc_flag
: 1;
2719 unsigned lazy_default_ctor
: 1;
2720 unsigned lazy_copy_ctor
: 1;
2721 unsigned lazy_copy_assign
: 1;
2722 unsigned lazy_destructor
: 1;
2723 unsigned has_const_copy_ctor
: 1;
2724 unsigned has_complex_copy_ctor
: 1;
2725 unsigned has_complex_copy_assign
: 1;
2726 unsigned non_aggregate
: 1;
2728 unsigned has_complex_dflt
: 1;
2729 unsigned has_list_ctor
: 1;
2730 unsigned non_std_layout
: 1;
2731 unsigned is_literal
: 1;
2732 unsigned lazy_move_ctor
: 1;
2733 unsigned lazy_move_assign
: 1;
2734 unsigned has_complex_move_ctor
: 1;
2735 unsigned has_complex_move_assign
: 1;
2737 unsigned has_constexpr_ctor
: 1;
2738 unsigned unique_obj_representations
: 1;
2739 unsigned unique_obj_representations_set
: 1;
2741 bool non_pod_aggregate
: 1;
2743 /* When adding a flag here, consider whether or not it ought to
2744 apply to a template instance if it applies to the template. If
2745 so, make sure to copy it in instantiate_class_template! */
2747 /* There are some bits left to fill out a 32-bit word. Keep track
2748 of this by updating the size of this bitfield whenever you add or
2753 vec
<rust_tree_pair_s
, va_gc
> *vcall_indices
;
2756 vec
<tree
, va_gc
> *vbases
;
2758 vec
<tree
, va_gc
> *pure_virtuals
;
2759 tree friend_classes
;
2760 vec
<tree
, va_gc
> *GTY ((reorder ("resort_type_member_vec"))) members
;
2763 tree befriending_classes
;
2764 /* In a RECORD_TYPE, information specific to Objective-C++, such
2765 as a list of adopted protocols or a pointer to a corresponding
2766 @interface. See objc/objc-act.h for details. */
2768 /* FIXME reuse another field? */
2774 // forked from gcc/cp/cp-tree.h cp_ref_qualifier
2776 enum rs_ref_qualifier
2779 REF_QUAL_LVALUE
= 1,
2783 // forked from gcc/cp/cp-tree.h tsubst_flags
2785 /* Bitmask flags to control type substitution. */
2788 tf_none
= 0, /* nothing special */
2789 tf_error
= 1 << 0, /* give error messages */
2790 tf_warning
= 1 << 1, /* give warnings too */
2791 tf_ignore_bad_quals
= 1 << 2, /* ignore bad cvr qualifiers */
2792 tf_keep_type_decl
= 1 << 3, /* retain typedef type decls
2793 (make_typename_type use) */
2794 tf_ptrmem_ok
= 1 << 4, /* pointers to member ok (internal
2795 instantiate_type use) */
2796 tf_user
= 1 << 5, /* found template must be a user template
2797 (lookup_template_class use) */
2798 tf_conv
= 1 << 6, /* We are determining what kind of
2799 conversion might be permissible,
2800 not actually performing the
2802 tf_decltype
= 1 << 7, /* We are the operand of decltype.
2803 Used to implement the special rules
2804 for calls in decltype (5.2.2/11). */
2805 tf_partial
= 1 << 8, /* Doing initial explicit argument
2806 substitution in fn_type_unification. */
2807 tf_fndecl_type
= 1 << 9, /* Substituting the type of a function
2809 tf_no_cleanup
= 1 << 10, /* Do not build a cleanup
2810 (build_target_expr and friends) */
2811 tf_norm
= 1 << 11, /* Build diagnostic information during
2812 constraint normalization. */
2813 /* Convenient substitution flags combinations. */
2814 tf_warning_or_error
= tf_warning
| tf_error
2817 // forked from gcc/cp/cp-tree.h cp_identifier_kind
2819 /* Kinds of identifiers. Values are carefully chosen. */
2820 enum cp_identifier_kind
2822 cik_normal
= 0, /* Not a special identifier. */
2823 cik_keyword
= 1, /* A keyword. */
2824 cik_ctor
= 2, /* Constructor (in-chg, complete or base). */
2825 cik_dtor
= 3, /* Destructor (in-chg, deleting, complete or
2827 cik_simple_op
= 4, /* Non-assignment operator name. */
2828 cik_assign_op
= 5, /* An assignment operator name. */
2829 cik_conv_op
= 6, /* Conversion operator name. */
2830 cik_reserved_for_udlit
= 7, /* Not yet in use */
2834 // forked from gcc/cp/cp-tree.h tag_types
2836 /* An enumeration of the kind of tags that C++ accepts. */
2839 none_type
= 0, /* Not a tag type. */
2840 record_type
, /* "struct" types. */
2841 class_type
, /* "class" types. */
2842 union_type
, /* "union" types. */
2843 enum_type
, /* "enum" types. */
2844 typename_type
, /* "typename" types. */
2845 scope_type
/* namespace or tagged type name followed by :: */
2848 // forked from gcc/cp/cp-tree.h tsubst_flags_t
2850 /* This type is used for parameters and variables which hold
2851 combinations of the flags in enum tsubst_flags. */
2852 typedef int tsubst_flags_t
;
2854 // forked from gcc/cp/cvt.cc convert_to_void
2856 // When an expression is used in a void context, its value is discarded and
2857 // no lvalue-rvalue and similar conversions happen [expr.static.cast/4,
2858 // stmt.expr/1, expr.comma/1]. This permits dereferencing an incomplete type
2859 // in a void context. The C++ standard does not define what an `access' to an
2860 // object is, but there is reason to believe that it is the lvalue to rvalue
2861 // conversion -- if it were not, `*&*p = 1' would violate [expr]/4 in that it
2862 // accesses `*p' not to calculate the value to be stored. But, dcl.type.cv/8
2863 // indicates that volatile semantics should be the same between C and C++
2864 // where ever possible. C leaves it implementation defined as to what
2865 // constitutes an access to a volatile. So, we interpret `*vp' as a read of
2866 // the volatile object `vp' points to, unless that is an incomplete type. For
2867 // volatile references we do not do this interpretation, because that would
2868 // make it impossible to ignore the reference return value from functions. We
2869 // issue warnings in the confusing cases.
2871 // The IMPLICIT is ICV_CAST when the user is explicitly converting an
2872 // expression to void via a cast. If an expression is being implicitly
2873 // converted, IMPLICIT indicates the context of the implicit conversion.
2875 /* Possible cases of implicit or explicit bad conversions to void. */
2878 ICV_CAST
, /* (explicit) conversion to void */
2879 ICV_SECOND_OF_COND
, /* second operand of conditional expression */
2880 ICV_THIRD_OF_COND
, /* third operand of conditional expression */
2881 ICV_RIGHT_OF_COMMA
, /* right operand of comma operator */
2882 ICV_LEFT_OF_COMMA
, /* left operand of comma operator */
2883 ICV_STATEMENT
, /* statement */
2884 ICV_THIRD_IN_FOR
/* for increment expression */
2887 /* BUILT_IN_FRONTEND function codes. */
2888 enum rs_built_in_function
2890 RS_BUILT_IN_IS_CONSTANT_EVALUATED
,
2891 RS_BUILT_IN_INTEGER_PACK
,
2892 RS_BUILT_IN_IS_CORRESPONDING_MEMBER
,
2893 RS_BUILT_IN_IS_POINTER_INTERCONVERTIBLE_WITH_CLASS
,
2894 RS_BUILT_IN_SOURCE_LOCATION
,
2898 // forked from gcc/cp/cp-tree.h compare_bounds_t
2901 /* Says how we should behave when comparing two arrays one of which
2902 has unknown bounds. */
2903 enum compare_bounds_t
2911 convert_to_void (tree expr
, impl_conv_void implicit
);
2913 // The lvalue-to-rvalue conversion (7.1) is applied if and only if the
2914 // expression is a glvalue of volatile-qualified type and it is one of the
2916 // * ( expression ), where expression is one of these expressions,
2917 // * id-expression (8.1.4),
2918 // * subscripting (8.2.1),
2919 // * class member access (8.2.5),
2920 // * indirection (8.3.1),
2921 // * pointer-to-member operation (8.5),
2922 // * conditional expression (8.16) where both the second and the third
2923 // operands are one of these expressions, or
2924 // * comma expression (8.19) where the right operand is one of these
2927 mark_discarded_use (tree expr
);
2929 // Mark EXP as read, not just set, for set but not used -Wunused warning
2932 mark_exp_read (tree exp
);
2934 // We've seen an actual use of EXPR. Possibly replace an outer variable
2935 // reference inside with its constant value or a lambda capture.
2937 mark_use (tree expr
, bool rvalue_p
, bool read_p
, location_t loc
,
2938 bool reject_builtin
);
2940 // Called whenever the expression EXPR is used in an rvalue context.
2941 // When REJECT_BUILTIN is true the expression is checked to make sure
2942 // it doesn't make it possible to obtain the address of a GCC built-in
2943 // function with no library fallback (or any of its bits, such as in
2944 // a conversion to bool).
2946 mark_rvalue_use (tree
, location_t
= UNKNOWN_LOCATION
,
2947 bool reject_builtin
= true);
2949 // Called whenever an expression is used in an lvalue context.
2951 mark_lvalue_use (tree expr
);
2953 // As above, but don't consider this use a read.
2955 mark_lvalue_use_nonread (tree expr
);
2957 // We are using a reference VAL for its value. Bash that reference all the way
2958 // down to its lowest form.
2960 convert_from_reference (tree val
);
2962 // Subroutine of convert_to_void. Warn if we're discarding something with
2963 // attribute [[nodiscard]].
2965 maybe_warn_nodiscard (tree expr
, impl_conv_void implicit
);
2968 expr_loc_or_loc (const_tree t
, location_t or_loc
);
2971 expr_loc_or_input_loc (const_tree t
);
2973 // FN is the callee of a CALL_EXPR or AGGR_INIT_EXPR; return the FUNCTION_DECL
2976 get_fndecl_from_callee (tree fn
);
2978 // FIXME some helpers from HIRCompileBase could probably be moved here over time
2980 // Return an expression for the address of BASE[INDEX], used in offset intrinsic
2982 pointer_offset_expression (tree base_tree
, tree index_tree
, location_t locus
);
2984 /* A tree node, together with a location, so that we can track locations
2985 (and ranges) during parsing.
2987 The location is redundant for node kinds that have locations,
2988 but not all node kinds do (e.g. constants, and references to
2989 params, locals, etc), so we stash a copy here. */
2991 extern location_t
rs_expr_location (const_tree
);
2994 is_empty_class (tree type
);
2996 extern tree
array_type_nelts_top (tree
);
2999 is_really_empty_class (tree
, bool);
3001 extern bool builtin_valid_in_constant_expr_p (const_tree
);
3003 extern bool maybe_constexpr_fn (tree
);
3005 extern bool var_in_maybe_constexpr_fn (tree
);
3008 rs_type_quals (const_tree type
);
3010 inline bool type_unknown_p (const_tree
);
3012 extern bool decl_maybe_constant_var_p (tree
);
3017 extern bool var_in_constexpr_fn (tree
);
3019 inline tree
ovl_first (tree
) ATTRIBUTE_PURE
;
3021 inline bool type_unknown_p (const_tree
);
3024 lookup_add (tree fns
, tree lookup
);
3027 ovl_make (tree fn
, tree next
= NULL_TREE
);
3029 extern int is_overloaded_fn (tree
) ATTRIBUTE_PURE
;
3031 extern bool maybe_add_lang_type_raw (tree
);
3033 extern rs_ref_qualifier
type_memfn_rqual (const_tree
);
3035 extern bool builtin_pack_fn_p (tree
);
3037 extern tree
make_conv_op_name (tree
);
3039 extern int type_memfn_quals (const_tree
);
3042 get_fileinfo (const char *);
3045 cxx_make_type (enum tree_code CXX_MEM_STAT_INFO
);
3048 build_cplus_array_type (tree
, tree
, int is_dep
= -1);
3050 extern bool is_byte_access_type (tree
);
3053 comptypes (tree
, tree
, int);
3055 extern tree
canonical_eh_spec (tree
);
3057 extern int cp_tree_operand_length (const_tree
);
3059 extern bool rs_tree_equal (tree
, tree
);
3061 extern bool compparms (const_tree
, const_tree
);
3064 rs_build_qualified_type_real (tree
, int, tsubst_flags_t
);
3065 #define rs_build_qualified_type(TYPE, QUALS) \
3066 rs_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error)
3067 extern bool cv_qualified_p (const_tree
);
3069 extern bool similar_type_p (tree
, tree
);
3071 extern bool rs_tree_equal (tree
, tree
);
3074 vector_targets_convertible_p (const_tree t1
, const_tree t2
);
3076 extern bool same_type_ignoring_top_level_qualifiers_p (tree
, tree
);
3078 extern bool comp_ptr_ttypes_const (tree
, tree
, compare_bounds_t
);
3081 get_class_binding_direct (tree
, tree
, bool want_type
= false);
3083 extern tree
skip_artificial_parms_for (const_tree
, tree
);
3086 lang_check_failed (const char *, int,
3087 const char *) ATTRIBUTE_NORETURN ATTRIBUTE_COLD
;
3089 extern tree
default_init_uninitialized_part (tree
);
3091 extern bool type_has_non_user_provided_default_constructor (tree
);
3093 extern bool default_ctor_p (const_tree
);
3095 extern bool user_provided_p (tree
);
3097 extern bool sufficient_parms_p (const_tree
);
3099 extern tree
next_initializable_field (tree
);
3101 extern tree
in_class_defaulted_default_constructor (tree
);
3103 extern bool is_instantiation_of_constexpr (tree
);
3106 check_for_uninitialized_const_var (tree
, bool, tsubst_flags_t
);
3108 extern bool reduced_constant_expression_p (tree
);
3110 extern tree
cv_unqualified (tree
);
3112 extern tree
cp_get_callee (tree
);
3113 extern tree
rs_get_callee_fndecl_nofold (tree
);
3115 extern bool is_nondependent_static_init_expression (tree
);
3117 extern tree
build_nop (tree
, tree
);
3119 extern bool scalarish_type_p (const_tree
);
3121 extern tree
is_bitfield_expr_with_lowered_type (const_tree
);
3123 extern tree
convert_bitfield_to_declared_type (tree
);
3126 cp_fold_maybe_rvalue (tree
, bool);
3128 extern tree
maybe_undo_parenthesized_ref (tree
);
3131 fold_offsetof (tree
, tree
= size_type_node
, tree_code ctx
= ERROR_MARK
);
3133 extern tree
cp_truthvalue_conversion (tree
, tsubst_flags_t
);
3136 fold_non_dependent_expr (tree
, tsubst_flags_t
= tf_warning_or_error
,
3137 bool = false, tree
= NULL_TREE
);
3139 extern int char_type_p (tree
);
3141 extern bool instantiation_dependent_expression_p (tree
);
3143 extern bool type_has_nontrivial_copy_init (const_tree
);
3145 extern tree
build_local_temp (tree
);
3147 extern bool is_normal_capture_proxy (tree
);
3149 extern bool reject_gcc_builtin (const_tree
, location_t
= UNKNOWN_LOCATION
);
3151 extern tree
resolve_nondeduced_context (tree
, tsubst_flags_t
);
3153 extern void cxx_incomplete_type_diagnostic (location_t
, const_tree
, const_tree
,
3156 extern void cxx_incomplete_type_error (location_t
, const_tree
, const_tree
);
3158 extern bool invalid_nonstatic_memfn_p (location_t
, tree
, tsubst_flags_t
);
3160 extern bool really_overloaded_fn (tree
) ATTRIBUTE_PURE
;
3162 extern tree
resolve_nondeduced_context_or_error (tree
, tsubst_flags_t
);
3164 extern tree
instantiate_non_dependent_or_null (tree
);
3166 extern void cxx_incomplete_type_inform (const_tree
);
3168 extern tree
strip_top_quals (tree
);
3170 extern bool undeduced_auto_decl (tree
);
3172 extern bool require_deduced_type (tree
, tsubst_flags_t
= tf_warning_or_error
);
3174 extern bool decl_constant_var_p (tree
);
3176 extern tree
build_new_constexpr_heap_type (tree
, tree
, tree
);
3178 extern bool is_empty_field (tree
);
3181 in_immediate_context ();
3183 extern tree
cp_get_callee_fndecl_nofold (tree
);
3186 cxx_mark_addressable (tree
, bool = false);
3188 extern tree
fold_builtin_source_location (location_t
);
3190 extern tree
build_address (tree
);
3192 extern bool bitfield_p (const_tree
);
3194 extern tree
rvalue (tree
);
3196 extern bool glvalue_p (const_tree
);
3198 extern cp_lvalue_kind
lvalue_kind (const_tree
);
3201 decl_constant_value (tree
, bool);
3203 extern tree
lookup_enumerator (tree
, tree
);
3206 is_class_type (tree
, int);
3208 extern tree
braced_lists_to_strings (tree
, tree
);
3211 fold_builtin_is_pointer_inverconvertible_with_class (location_t
, int, tree
*);
3213 extern bool layout_compatible_type_p (tree
, tree
);
3215 extern tree
finish_underlying_type (tree
);
3218 c_common_type_for_mode (machine_mode
, int);
3220 extern bool std_layout_type_p (const_tree
);
3222 extern tree
complete_type (tree
);
3224 extern tree
complete_type_or_else (tree
, tree
);
3226 extern void note_failed_type_completion_for_satisfaction (tree
);
3228 extern tree
complete_type_or_maybe_complain (tree
, tree
, tsubst_flags_t
);
3231 next_common_initial_seqence (tree
&, tree
&);
3233 extern bool null_member_pointer_value_p (tree
);
3236 fold_builtin_is_corresponding_member (location_t
, int, tree
*);
3238 extern tree
cp_fold_rvalue (tree
);
3241 maybe_constant_value (tree
, tree
= NULL_TREE
, bool = false);
3243 extern tree
lvalue_type (tree
);
3245 extern void lvalue_error (location_t
, enum lvalue_use
);
3248 cp_fold_maybe_rvalue (tree
, bool);
3250 extern tree
get_first_fn (tree
) ATTRIBUTE_PURE
;
3252 extern void explain_non_literal_class (tree
);
3254 extern bool reference_related_p (tree
, tree
);
3256 extern bool ordinary_char_type_p (tree
);
3258 extern bool array_string_literal_compatible_p (tree
, tree
);
3260 // forked from gcc/cp/cp-tree.h
3271 rs_build_qualified_type_real (tree
, int, tsubst_flags_t
);
3272 #define rs_build_qualified_type(TYPE, QUALS) \
3273 rs_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error)
3276 rs_walk_subtrees (tree
*, int *, walk_tree_fn
, void *, hash_set
<tree
> *);
3277 #define rs_walk_tree(tp, func, data, pset) \
3278 walk_tree_1 (tp, func, data, pset, rs_walk_subtrees)
3279 #define rs_walk_tree_without_duplicates(tp, func, data) \
3280 walk_tree_without_duplicates_1 (tp, func, data, rs_walk_subtrees)
3282 // forked from gcc/cp/cp-tree.h cp_expr_loc_or_loc
3285 rs_expr_loc_or_loc (const_tree t
, location_t or_loc
)
3287 location_t loc
= rs_expr_location (t
);
3288 if (loc
== UNKNOWN_LOCATION
)
3293 // forked from gcc/cp/cp-tree.h cp_expr_loc_or_input_loc
3296 rs_expr_loc_or_input_loc (const_tree t
)
3298 return rs_expr_loc_or_loc (t
, input_location
);
3301 // forked from gcc/cp/cp-tree.h type_unknown_p
3304 type_unknown_p (const_tree expr
)
3306 return TREE_TYPE (expr
) == unknown_type_node
;
3309 // forked from gcc/cp/cp-tree.h ovl_first
3311 /* Inline bodies. */
3314 ovl_first (tree node
)
3316 while (TREE_CODE (node
) == OVERLOAD
)
3317 node
= OVL_FUNCTION (node
);
3321 // forked from gcc/cp/cp-tree.h type_of_this_parm
3323 /* Return the type of the `this' parameter of FNTYPE. */
3326 type_of_this_parm (const_tree fntype
)
3328 function_args_iterator iter
;
3329 gcc_assert (TREE_CODE (fntype
) == METHOD_TYPE
);
3330 function_args_iter_init (&iter
, fntype
);
3331 return function_args_iter_cond (&iter
);
3334 // forked from gcc/cp/cp-tree.h class_of_this_parm
3336 /* Return the class of the `this' parameter of FNTYPE. */
3339 class_of_this_parm (const_tree fntype
)
3341 return TREE_TYPE (type_of_this_parm (fntype
));
3344 // forked from gcc/cp/cp-tree.h identifier_p
3346 /* Return a typed pointer version of T if it designates a
3347 C++ front-end identifier. */
3348 inline lang_identifier
*
3349 identifier_p (tree t
)
3351 if (TREE_CODE (t
) == IDENTIFIER_NODE
)
3352 return (lang_identifier
*) t
;
3356 // forked from gcc/c-family/c-common.h gnu_vector_type_p
3358 /* Return true if TYPE is a vector type that should be subject to the GNU
3359 vector extensions (as opposed to a vector type that is used only for
3360 the purposes of defining target-specific built-in functions). */
3363 gnu_vector_type_p (const_tree type
)
3365 return TREE_CODE (type
) == VECTOR_TYPE
&& !TYPE_INDIVISIBLE_P (type
);
3368 extern vec
<tree
, va_gc
> *
3369 make_tree_vector (void);
3372 release_tree_vector (vec
<tree
, va_gc
> *);
3374 /* Simplified unique_ptr clone to release a tree vec on exit. */
3379 typedef vec
<tree
, va_gc
> vec_t
;
3381 releasing_vec (vec_t
*v
) : v (v
) {}
3382 releasing_vec () : v (make_tree_vector ()) {}
3384 /* Copy ops are deliberately declared but not defined,
3385 copies must always be elided. */
3386 releasing_vec (const releasing_vec
&);
3387 releasing_vec
&operator= (const releasing_vec
&);
3389 vec_t
&operator* () const { return *v
; }
3390 vec_t
*operator-> () const { return v
; }
3391 vec_t
*get () const { return v
; }
3392 operator vec_t
* () const { return v
; }
3393 vec_t
**operator& () { return &v
; }
3395 /* Breaks pointer/value consistency for convenience. This takes ptrdiff_t
3396 rather than unsigned to avoid ambiguity with the built-in operator[]
3397 (bootstrap/91828). */
3398 tree
&operator[] (ptrdiff_t i
) const { return (*v
)[i
]; }
3400 tree
*begin () { return ::begin (v
); }
3401 tree
*end () { return ::end (v
); }
3405 release_tree_vector (v
);
3409 ~releasing_vec () { release_tree_vector (v
); }
3416 vec_safe_push (releasing_vec
&r
, const tree
&t CXX_MEM_STAT_INFO
)
3418 return vec_safe_push (*&r
, t PASS_MEM_STAT
);
3422 vec_safe_reserve (releasing_vec
&r
, unsigned n
,
3423 bool e
= false CXX_MEM_STAT_INFO
)
3425 return vec_safe_reserve (*&r
, n
, e PASS_MEM_STAT
);
3428 vec_safe_length (releasing_vec
&r
)
3430 return r
->length ();
3433 vec_safe_splice (releasing_vec
&r
, vec
<tree
, va_gc
> *p CXX_MEM_STAT_INFO
)
3435 vec_safe_splice (*&r
, p PASS_MEM_STAT
);
3439 null_node_p (const_tree expr
)
3441 STRIP_ANY_LOCATION_WRAPPER (expr
);
3442 return expr
== null_node
;
3446 cxx_incomplete_type_diagnostic (const_tree value
, const_tree type
,
3447 diagnostic_t diag_kind
)
3449 cxx_incomplete_type_diagnostic (rs_expr_loc_or_input_loc (value
), value
, type
,
3454 cxx_incomplete_type_error (const_tree value
, const_tree type
)
3456 cxx_incomplete_type_diagnostic (value
, type
, DK_ERROR
);
3460 location_of (tree t
);
3462 /* Helpers for IMPLICIT_RVALUE_P to look through automatic dereference. */
3465 implicit_rvalue_p (const_tree t
)
3467 if (REFERENCE_REF_P (t
))
3468 t
= TREE_OPERAND (t
, 0);
3469 return ((TREE_CODE (t
) == NON_LVALUE_EXPR
) && IMPLICIT_RVALUE_P (t
));
3472 set_implicit_rvalue_p (tree ot
)
3475 if (REFERENCE_REF_P (t
))
3476 t
= TREE_OPERAND (t
, 0);
3477 IMPLICIT_RVALUE_P (t
) = 1;
3483 maybe_constant_init (tree
, tree
= NULL_TREE
, bool = false);
3486 explain_invalid_constexpr_fn (tree fun
);
3488 extern bool potential_constant_expression (tree
);
3491 literal_type_p (tree t
);
3494 maybe_constexpr_fn (tree t
);
3497 fold_non_dependent_init (tree
, tsubst_flags_t
= tf_warning_or_error
,
3498 bool = false, tree
= NULL_TREE
);
3499 } // namespace Compile