1 // Copyright (C) 2020-2025 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 /* We used to have a variant type for lang_type. Keep the name of the
143 checking accessor for the sole survivor. */
144 #define LANG_TYPE_CLASS_CHECK(NODE) (TYPE_LANG_SPECIFIC (NODE))
146 /* Keep these checks in ascending code order. */
147 #define RECORD_OR_UNION_CODE_P(T) ((T) == RECORD_TYPE || (T) == UNION_TYPE)
148 #define OVERLOAD_TYPE_P(T) (CLASS_TYPE_P (T) || TREE_CODE (T) == ENUMERAL_TYPE)
150 /* Nonzero if this class is "empty" in the sense of the C++ ABI. */
151 #define CLASSTYPE_EMPTY_P(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->empty_p)
153 /* True if DECL is declared 'constexpr'. */
154 #define DECL_DECLARED_CONSTEXPR_P(DECL) \
155 DECL_LANG_FLAG_8 (VAR_OR_FUNCTION_DECL_CHECK (DECL))
157 #define VAR_OR_FUNCTION_DECL_CHECK(NODE) \
158 TREE_CHECK2 (NODE, VAR_DECL, FUNCTION_DECL)
160 // forked from gcc/cp/c-common.h c_tree_index
162 /* Standard named or nameless data types of the C compiler. */
170 CTI_UNDERLYING_WCHAR_TYPE
,
172 CTI_SIGNED_SIZE_TYPE
, /* For format checking only. */
173 CTI_UNSIGNED_PTRDIFF_TYPE
, /* For format checking only. */
176 CTI_WIDEST_INT_LIT_TYPE
,
177 CTI_WIDEST_UINT_LIT_TYPE
,
179 /* Types for <stdint.h>, that may not be defined on all
191 CTI_INT_LEAST16_TYPE
,
192 CTI_INT_LEAST32_TYPE
,
193 CTI_INT_LEAST64_TYPE
,
194 CTI_UINT_LEAST8_TYPE
,
195 CTI_UINT_LEAST16_TYPE
,
196 CTI_UINT_LEAST32_TYPE
,
197 CTI_UINT_LEAST64_TYPE
,
203 CTI_UINT_FAST16_TYPE
,
204 CTI_UINT_FAST32_TYPE
,
205 CTI_UINT_FAST64_TYPE
,
210 CTI_CHAR8_ARRAY_TYPE
,
211 CTI_CHAR16_ARRAY_TYPE
,
212 CTI_CHAR32_ARRAY_TYPE
,
213 CTI_WCHAR_ARRAY_TYPE
,
215 CTI_CONST_STRING_TYPE
,
217 /* Type for boolean expressions (bool in C++, int in C). */
220 CTI_TRUTHVALUE_FALSE
,
222 CTI_DEFAULT_FUNCTION_TYPE
,
226 /* These are not types, but we have to look them up all the time. */
227 CTI_FUNCTION_NAME_DECL
,
228 CTI_PRETTY_FUNCTION_NAME_DECL
,
229 CTI_C99_FUNCTION_NAME_DECL
,
232 /* Below here entities change during compilation. */
234 CTI_SAVED_FUNCTION_NAME_DECLS
,
239 // forked from gcc/c-family/c-common.h c_tree_index
241 extern GTY (()) tree c_global_trees
[CTI_MAX
];
243 // forked from gcc/cp/cp-tree.h cp_tree_index
248 CPTI_VTABLE_ENTRY_TYPE
,
250 CPTI_VTABLE_INDEX_TYPE
,
257 CPTI_EXPLICIT_VOID_LIST
,
265 CPTI_CTOR_IDENTIFIER
,
266 CPTI_COMPLETE_CTOR_IDENTIFIER
,
267 CPTI_BASE_CTOR_IDENTIFIER
,
268 CPTI_DTOR_IDENTIFIER
,
269 CPTI_COMPLETE_DTOR_IDENTIFIER
,
270 CPTI_BASE_DTOR_IDENTIFIER
,
271 CPTI_DELETING_DTOR_IDENTIFIER
,
272 CPTI_CONV_OP_IDENTIFIER
,
273 CPTI_DELTA_IDENTIFIER
,
274 CPTI_IN_CHARGE_IDENTIFIER
,
275 CPTI_VTT_PARM_IDENTIFIER
,
276 CPTI_AS_BASE_IDENTIFIER
,
277 CPTI_THIS_IDENTIFIER
,
279 CPTI_VPTR_IDENTIFIER
,
280 CPTI_GLOBAL_IDENTIFIER
,
281 CPTI_ANON_IDENTIFIER
,
282 CPTI_AUTO_IDENTIFIER
,
283 CPTI_DECLTYPE_AUTO_IDENTIFIER
,
284 CPTI_INIT_LIST_IDENTIFIER
,
285 CPTI_FOR_RANGE__IDENTIFIER
,
286 CPTI_FOR_BEGIN__IDENTIFIER
,
287 CPTI_FOR_END__IDENTIFIER
,
288 CPTI_FOR_RANGE_IDENTIFIER
,
289 CPTI_FOR_BEGIN_IDENTIFIER
,
290 CPTI_FOR_END_IDENTIFIER
,
291 CPTI_ABI_TAG_IDENTIFIER
,
292 CPTI_ALIGNED_IDENTIFIER
,
293 CPTI_BEGIN_IDENTIFIER
,
297 CPTI_TUPLE_ELEMENT_IDENTIFIER
,
298 CPTI_TUPLE_SIZE_IDENTIFIER
,
299 CPTI_TYPE_IDENTIFIER
,
300 CPTI_VALUE_IDENTIFIER
,
302 CPTI_CLOSURE_IDENTIFIER
,
303 CPTI_HEAP_UNINIT_IDENTIFIER
,
304 CPTI_HEAP_IDENTIFIER
,
305 CPTI_HEAP_DELETED_IDENTIFIER
,
306 CPTI_HEAP_VEC_UNINIT_IDENTIFIER
,
307 CPTI_HEAP_VEC_IDENTIFIER
,
311 CPTI_LANG_NAME_CPLUSPLUS
,
313 CPTI_EMPTY_EXCEPT_SPEC
,
314 CPTI_NOEXCEPT_TRUE_SPEC
,
315 CPTI_NOEXCEPT_FALSE_SPEC
,
316 CPTI_NOEXCEPT_DEFERRED_SPEC
,
324 /* Nodes after here change during compilation, or should not be in
325 the module's global tree table. Such nodes must be locatable
326 via name lookup or type-construction, as those are the only
327 cross-TU matching capabilities remaining. */
329 /* We must find these via the global namespace. */
333 /* These are created at init time, but the library/headers provide
337 CPTI_CALL_UNEXPECTED_FN
,
339 /* These are lazily inited. */
340 CPTI_CONST_TYPE_INFO_TYPE
,
341 CPTI_GET_EXCEPTION_PTR_FN
,
344 CPTI_ALLOCATE_EXCEPTION_FN
,
345 CPTI_FREE_EXCEPTION_FN
,
348 CPTI_ATEXIT_FN_PTR_TYPE
,
353 CPTI_SOURCE_LOCATION_IMPL
,
355 CPTI_FALLBACK_DFLOAT32_TYPE
,
356 CPTI_FALLBACK_DFLOAT64_TYPE
,
357 CPTI_FALLBACK_DFLOAT128_TYPE
,
362 // forked from gcc/cp/cp-tree.h cp_global_trees
364 extern GTY (()) tree cp_global_trees
[CPTI_MAX
];
366 #define wchar_decl_node cp_global_trees[CPTI_WCHAR_DECL]
367 #define vtable_entry_type cp_global_trees[CPTI_VTABLE_ENTRY_TYPE]
368 /* The type used to represent an offset by which to adjust the `this'
369 pointer in pointer-to-member types. */
370 #define delta_type_node cp_global_trees[CPTI_DELTA_TYPE]
371 /* The type used to represent an index into the vtable. */
372 #define vtable_index_type cp_global_trees[CPTI_VTABLE_INDEX_TYPE]
374 #define class_type_node cp_global_trees[CPTI_CLASS_TYPE]
375 #define unknown_type_node cp_global_trees[CPTI_UNKNOWN_TYPE]
376 #define init_list_type_node cp_global_trees[CPTI_INIT_LIST_TYPE]
377 #define explicit_void_list_node cp_global_trees[CPTI_EXPLICIT_VOID_LIST]
378 #define vtbl_type_node cp_global_trees[CPTI_VTBL_TYPE]
379 #define vtbl_ptr_type_node cp_global_trees[CPTI_VTBL_PTR_TYPE]
380 #define std_node cp_global_trees[CPTI_STD]
381 #define abi_node cp_global_trees[CPTI_ABI]
382 #define global_namespace cp_global_trees[CPTI_GLOBAL]
383 #define const_type_info_type_node cp_global_trees[CPTI_CONST_TYPE_INFO_TYPE]
384 #define conv_op_marker cp_global_trees[CPTI_CONV_OP_MARKER]
385 #define abort_fndecl cp_global_trees[CPTI_ABORT_FNDECL]
386 #define current_aggr cp_global_trees[CPTI_AGGR_TAG]
387 #define nullptr_node cp_global_trees[CPTI_NULLPTR]
388 #define nullptr_type_node cp_global_trees[CPTI_NULLPTR_TYPE]
389 /* std::align_val_t */
390 #define align_type_node cp_global_trees[CPTI_ALIGN_TYPE]
392 #define char8_type_node c_global_trees[CTI_CHAR8_TYPE]
393 #define char16_type_node c_global_trees[CTI_CHAR16_TYPE]
394 #define char32_type_node c_global_trees[CTI_CHAR32_TYPE]
395 #define wchar_type_node c_global_trees[CTI_WCHAR_TYPE]
396 #define underlying_wchar_type_node c_global_trees[CTI_UNDERLYING_WCHAR_TYPE]
397 #define wint_type_node c_global_trees[CTI_WINT_TYPE]
398 #define signed_size_type_node c_global_trees[CTI_SIGNED_SIZE_TYPE]
399 #define unsigned_ptrdiff_type_node c_global_trees[CTI_UNSIGNED_PTRDIFF_TYPE]
400 #define intmax_type_node c_global_trees[CTI_INTMAX_TYPE]
401 #define uintmax_type_node c_global_trees[CTI_UINTMAX_TYPE]
402 #define widest_integer_literal_type_node c_global_trees[CTI_WIDEST_INT_LIT_TYPE]
403 #define widest_unsigned_literal_type_node \
404 c_global_trees[CTI_WIDEST_UINT_LIT_TYPE]
406 #define sig_atomic_type_node c_global_trees[CTI_SIG_ATOMIC_TYPE]
407 #define int8_type_node c_global_trees[CTI_INT8_TYPE]
408 #define int16_type_node c_global_trees[CTI_INT16_TYPE]
409 #define int32_type_node c_global_trees[CTI_INT32_TYPE]
410 #define int64_type_node c_global_trees[CTI_INT64_TYPE]
411 #define uint8_type_node c_global_trees[CTI_UINT8_TYPE]
412 #define c_uint16_type_node c_global_trees[CTI_UINT16_TYPE]
413 #define c_uint32_type_node c_global_trees[CTI_UINT32_TYPE]
414 #define c_uint64_type_node c_global_trees[CTI_UINT64_TYPE]
415 #define int_least8_type_node c_global_trees[CTI_INT_LEAST8_TYPE]
416 #define int_least16_type_node c_global_trees[CTI_INT_LEAST16_TYPE]
417 #define int_least32_type_node c_global_trees[CTI_INT_LEAST32_TYPE]
418 #define int_least64_type_node c_global_trees[CTI_INT_LEAST64_TYPE]
419 #define uint_least8_type_node c_global_trees[CTI_UINT_LEAST8_TYPE]
420 #define uint_least16_type_node c_global_trees[CTI_UINT_LEAST16_TYPE]
421 #define uint_least32_type_node c_global_trees[CTI_UINT_LEAST32_TYPE]
422 #define uint_least64_type_node c_global_trees[CTI_UINT_LEAST64_TYPE]
423 #define int_fast8_type_node c_global_trees[CTI_INT_FAST8_TYPE]
424 #define int_fast16_type_node c_global_trees[CTI_INT_FAST16_TYPE]
425 #define int_fast32_type_node c_global_trees[CTI_INT_FAST32_TYPE]
426 #define int_fast64_type_node c_global_trees[CTI_INT_FAST64_TYPE]
427 #define uint_fast8_type_node c_global_trees[CTI_UINT_FAST8_TYPE]
428 #define uint_fast16_type_node c_global_trees[CTI_UINT_FAST16_TYPE]
429 #define uint_fast32_type_node c_global_trees[CTI_UINT_FAST32_TYPE]
430 #define uint_fast64_type_node c_global_trees[CTI_UINT_FAST64_TYPE]
431 #define intptr_type_node c_global_trees[CTI_INTPTR_TYPE]
432 #define uintptr_type_node c_global_trees[CTI_UINTPTR_TYPE]
434 #define truthvalue_type_node c_global_trees[CTI_TRUTHVALUE_TYPE]
435 #define truthvalue_true_node c_global_trees[CTI_TRUTHVALUE_TRUE]
436 #define truthvalue_false_node c_global_trees[CTI_TRUTHVALUE_FALSE]
438 #define char_array_type_node c_global_trees[CTI_CHAR_ARRAY_TYPE]
439 #define char8_array_type_node c_global_trees[CTI_CHAR8_ARRAY_TYPE]
440 #define char16_array_type_node c_global_trees[CTI_CHAR16_ARRAY_TYPE]
441 #define char32_array_type_node c_global_trees[CTI_CHAR32_ARRAY_TYPE]
442 #define wchar_array_type_node c_global_trees[CTI_WCHAR_ARRAY_TYPE]
443 #define string_type_node c_global_trees[CTI_STRING_TYPE]
444 #define const_string_type_node c_global_trees[CTI_CONST_STRING_TYPE]
446 #define default_function_type c_global_trees[CTI_DEFAULT_FUNCTION_TYPE]
448 #define function_name_decl_node c_global_trees[CTI_FUNCTION_NAME_DECL]
449 #define pretty_function_name_decl_node \
450 c_global_trees[CTI_PRETTY_FUNCTION_NAME_DECL]
451 #define c99_function_name_decl_node c_global_trees[CTI_C99_FUNCTION_NAME_DECL]
452 #define saved_function_name_decls c_global_trees[CTI_SAVED_FUNCTION_NAME_DECLS]
454 /* The node for C++ `__null'. */
455 #define null_node c_global_trees[CTI_NULL]
457 /* We cache these tree nodes so as to call get_identifier less frequently.
458 For identifiers for functions, including special member functions such
459 as ctors and assignment operators, the nodes can be used (among other
460 things) to iterate over their overloads defined by/for a type. For
463 tree ovlid = assign_op_identifier;
464 tree overloads = get_class_binding (type, ovlid);
465 for (ovl_iterator it (overloads); it; ++it) { ... }
467 iterates over the set of implicitly and explicitly defined overloads
468 of the assignment operator for type (including the copy and move
469 assignment operators, whether deleted or not). */
471 /* The name of a constructor that takes an in-charge parameter to
472 decide whether or not to construct virtual base classes. */
473 #define ctor_identifier cp_global_trees[CPTI_CTOR_IDENTIFIER]
474 /* The name of a constructor that constructs virtual base classes. */
475 #define complete_ctor_identifier cp_global_trees[CPTI_COMPLETE_CTOR_IDENTIFIER]
476 /* The name of a constructor that does not construct virtual base classes. */
477 #define base_ctor_identifier cp_global_trees[CPTI_BASE_CTOR_IDENTIFIER]
478 /* The name of a destructor that takes an in-charge parameter to
479 decide whether or not to destroy virtual base classes and whether
480 or not to delete the object. */
481 #define dtor_identifier cp_global_trees[CPTI_DTOR_IDENTIFIER]
482 /* The name of a destructor that destroys virtual base classes. */
483 #define complete_dtor_identifier cp_global_trees[CPTI_COMPLETE_DTOR_IDENTIFIER]
484 /* The name of a destructor that does not destroy virtual base
486 #define base_dtor_identifier cp_global_trees[CPTI_BASE_DTOR_IDENTIFIER]
487 /* The name of a destructor that destroys virtual base classes, and
488 then deletes the entire object. */
489 #define deleting_dtor_identifier cp_global_trees[CPTI_DELETING_DTOR_IDENTIFIER]
491 /* The name used for conversion operators -- but note that actual
492 conversion functions use special identifiers outside the identifier
494 #define conv_op_identifier cp_global_trees[CPTI_CONV_OP_IDENTIFIER]
496 #define delta_identifier cp_global_trees[CPTI_DELTA_IDENTIFIER]
497 #define in_charge_identifier cp_global_trees[CPTI_IN_CHARGE_IDENTIFIER]
498 /* The name of the parameter that contains a pointer to the VTT to use
499 for this subobject constructor or destructor. */
500 #define vtt_parm_identifier cp_global_trees[CPTI_VTT_PARM_IDENTIFIER]
501 #define as_base_identifier cp_global_trees[CPTI_AS_BASE_IDENTIFIER]
502 #define this_identifier cp_global_trees[CPTI_THIS_IDENTIFIER]
503 #define pfn_identifier cp_global_trees[CPTI_PFN_IDENTIFIER]
504 #define vptr_identifier cp_global_trees[CPTI_VPTR_IDENTIFIER]
505 /* The name of the ::, std & anon namespaces. */
506 #define global_identifier cp_global_trees[CPTI_GLOBAL_IDENTIFIER]
507 #define anon_identifier cp_global_trees[CPTI_ANON_IDENTIFIER]
508 /* auto and declspec(auto) identifiers. */
509 #define auto_identifier cp_global_trees[CPTI_AUTO_IDENTIFIER]
510 #define decltype_auto_identifier cp_global_trees[CPTI_DECLTYPE_AUTO_IDENTIFIER]
511 #define init_list_identifier cp_global_trees[CPTI_INIT_LIST_IDENTIFIER]
512 #define for_range__identifier cp_global_trees[CPTI_FOR_RANGE__IDENTIFIER]
513 #define for_begin__identifier cp_global_trees[CPTI_FOR_BEGIN__IDENTIFIER]
514 #define for_end__identifier cp_global_trees[CPTI_FOR_END__IDENTIFIER]
515 #define for_range_identifier cp_global_trees[CPTI_FOR_RANGE_IDENTIFIER]
516 #define for_begin_identifier cp_global_trees[CPTI_FOR_BEGIN_IDENTIFIER]
517 #define for_end_identifier cp_global_trees[CPTI_FOR_END_IDENTIFIER]
518 #define abi_tag_identifier cp_global_trees[CPTI_ABI_TAG_IDENTIFIER]
519 #define aligned_identifier cp_global_trees[CPTI_ALIGNED_IDENTIFIER]
520 #define begin_identifier cp_global_trees[CPTI_BEGIN_IDENTIFIER]
521 #define end_identifier cp_global_trees[CPTI_END_IDENTIFIER]
522 #define get__identifier cp_global_trees[CPTI_GET_IDENTIFIER]
523 #define gnu_identifier cp_global_trees[CPTI_GNU_IDENTIFIER]
524 #define tuple_element_identifier cp_global_trees[CPTI_TUPLE_ELEMENT_IDENTIFIER]
525 #define tuple_size_identifier cp_global_trees[CPTI_TUPLE_SIZE_IDENTIFIER]
526 #define type_identifier cp_global_trees[CPTI_TYPE_IDENTIFIER]
527 #define value_identifier cp_global_trees[CPTI_VALUE_IDENTIFIER]
528 #define fun_identifier cp_global_trees[CPTI_FUN_IDENTIFIER]
529 #define closure_identifier cp_global_trees[CPTI_CLOSURE_IDENTIFIER]
530 #define heap_uninit_identifier cp_global_trees[CPTI_HEAP_UNINIT_IDENTIFIER]
531 #define heap_identifier cp_global_trees[CPTI_HEAP_IDENTIFIER]
532 #define heap_deleted_identifier cp_global_trees[CPTI_HEAP_DELETED_IDENTIFIER]
533 #define heap_vec_uninit_identifier \
534 cp_global_trees[CPTI_HEAP_VEC_UNINIT_IDENTIFIER]
535 #define heap_vec_identifier cp_global_trees[CPTI_HEAP_VEC_IDENTIFIER]
536 #define omp_identifier cp_global_trees[CPTI_OMP_IDENTIFIER]
537 #define lang_name_c cp_global_trees[CPTI_LANG_NAME_C]
538 #define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS]
540 /* Exception specifiers used for throw(), noexcept(true),
541 noexcept(false) and deferred noexcept. We rely on these being
543 #define empty_except_spec cp_global_trees[CPTI_EMPTY_EXCEPT_SPEC]
544 #define noexcept_true_spec cp_global_trees[CPTI_NOEXCEPT_TRUE_SPEC]
545 #define noexcept_false_spec cp_global_trees[CPTI_NOEXCEPT_FALSE_SPEC]
546 #define noexcept_deferred_spec cp_global_trees[CPTI_NOEXCEPT_DEFERRED_SPEC]
548 /* Exception handling function declarations. */
549 #define terminate_fn cp_global_trees[CPTI_TERMINATE_FN]
550 #define call_unexpected_fn cp_global_trees[CPTI_CALL_UNEXPECTED_FN]
551 #define get_exception_ptr_fn cp_global_trees[CPTI_GET_EXCEPTION_PTR_FN]
552 #define begin_catch_fn cp_global_trees[CPTI_BEGIN_CATCH_FN]
553 #define end_catch_fn cp_global_trees[CPTI_END_CATCH_FN]
554 #define allocate_exception_fn cp_global_trees[CPTI_ALLOCATE_EXCEPTION_FN]
555 #define free_exception_fn cp_global_trees[CPTI_FREE_EXCEPTION_FN]
556 #define throw_fn cp_global_trees[CPTI_THROW_FN]
557 #define rethrow_fn cp_global_trees[CPTI_RETHROW_FN]
559 /* The type of the function-pointer argument to "__cxa_atexit" (or
560 "std::atexit", if "__cxa_atexit" is not being used). */
561 #define atexit_fn_ptr_type_node cp_global_trees[CPTI_ATEXIT_FN_PTR_TYPE]
563 /* A pointer to `std::atexit'. */
564 #define atexit_node cp_global_trees[CPTI_ATEXIT]
566 /* A pointer to `__dso_handle'. */
567 #define dso_handle_node cp_global_trees[CPTI_DSO_HANDLE]
569 /* The declaration of the dynamic_cast runtime. */
570 #define dynamic_cast_node cp_global_trees[CPTI_DCAST]
572 /* The type of a destructor. */
573 #define cleanup_type cp_global_trees[CPTI_CLEANUP_TYPE]
575 /* The type of the vtt parameter passed to subobject constructors and
577 #define vtt_parm_type cp_global_trees[CPTI_VTT_PARM_TYPE]
579 /* A node which matches any template argument. */
580 #define any_targ_node cp_global_trees[CPTI_ANY_TARG]
582 /* std::source_location::__impl class. */
583 #define source_location_impl cp_global_trees[CPTI_SOURCE_LOCATION_IMPL]
585 /* These two accessors should only be used by OVL manipulators.
586 Other users should use iterators and convenience functions. */
587 #define OVL_FUNCTION(NODE) \
588 (((struct tree_overload *) OVERLOAD_CHECK (NODE))->function)
589 #define OVL_CHAIN(NODE) \
590 (((struct tree_overload *) OVERLOAD_CHECK (NODE))->common.chain)
592 /* If set, this or a subsequent overload contains decls that need deduping. */
593 #define OVL_DEDUP_P(NODE) TREE_LANG_FLAG_0 (OVERLOAD_CHECK (NODE))
594 /* If set, this was imported in a using declaration. */
595 #define OVL_USING_P(NODE) TREE_LANG_FLAG_1 (OVERLOAD_CHECK (NODE))
596 /* If set, this overload is a hidden decl. */
597 #define OVL_HIDDEN_P(NODE) TREE_LANG_FLAG_2 (OVERLOAD_CHECK (NODE))
598 /* If set, this overload contains a nested overload. */
599 #define OVL_NESTED_P(NODE) TREE_LANG_FLAG_3 (OVERLOAD_CHECK (NODE))
600 /* If set, this overload was constructed during lookup. */
601 #define OVL_LOOKUP_P(NODE) TREE_LANG_FLAG_4 (OVERLOAD_CHECK (NODE))
602 /* If set, this OVL_USING_P overload is exported. */
603 #define OVL_EXPORT_P(NODE) TREE_LANG_FLAG_5 (OVERLOAD_CHECK (NODE))
605 /* The first decl of an overload. */
606 #define OVL_FIRST(NODE) Rust::ovl_first (NODE)
607 /* The name of the overload set. */
608 #define OVL_NAME(NODE) DECL_NAME (OVL_FIRST (NODE))
610 /* Whether this is a set of overloaded functions. TEMPLATE_DECLS are
611 always wrapped in an OVERLOAD, so we don't need to check them
613 #define OVL_P(NODE) \
614 (TREE_CODE (NODE) == FUNCTION_DECL || TREE_CODE (NODE) == OVERLOAD)
615 /* Whether this is a single member overload. */
616 #define OVL_SINGLE_P(NODE) (TREE_CODE (NODE) != OVERLOAD || !OVL_CHAIN (NODE))
618 /* Nonzero means that this type has an X() constructor. */
619 #define TYPE_HAS_DEFAULT_CONSTRUCTOR(NODE) \
620 (LANG_TYPE_CLASS_CHECK (NODE)->has_default_ctor)
622 /* Nonzero means that NODE (a class type) has a default constructor --
623 but that it has not yet been declared. */
624 #define CLASSTYPE_LAZY_DEFAULT_CTOR(NODE) \
625 (LANG_TYPE_CLASS_CHECK (NODE)->lazy_default_ctor)
627 /* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These
628 are the constructors that take an in-charge parameter. */
629 #define CLASSTYPE_CONSTRUCTORS(NODE) \
630 (get_class_binding_direct (NODE, ctor_identifier))
632 /* In a TREE_LIST in an attribute list, indicates that the attribute
633 must be applied at instantiation time. */
634 #define ATTR_IS_DEPENDENT(NODE) TREE_LANG_FLAG_0 (TREE_LIST_CHECK (NODE))
636 /* In a TREE_LIST in the argument of attribute abi_tag, indicates that the tag
637 was inherited from a template parameter, not explicitly indicated. */
638 #define ABI_TAG_IMPLICIT(NODE) TREE_LANG_FLAG_0 (TREE_LIST_CHECK (NODE))
640 /* In a TREE_LIST for a parameter-declaration-list, indicates that all the
641 parameters in the list have declarators enclosed in (). */
642 #define PARENTHESIZED_LIST_P(NODE) TREE_LANG_FLAG_0 (TREE_LIST_CHECK (NODE))
644 /* Non zero if this is a using decl for a dependent scope. */
645 #define DECL_DEPENDENT_P(NODE) DECL_LANG_FLAG_0 (USING_DECL_CHECK (NODE))
647 /* The scope named in a using decl. */
648 #define USING_DECL_SCOPE(NODE) DECL_RESULT_FLD (USING_DECL_CHECK (NODE))
650 /* The decls named by a using decl. */
651 #define USING_DECL_DECLS(NODE) DECL_INITIAL (USING_DECL_CHECK (NODE))
653 /* Non zero if the using decl refers to a dependent type. */
654 #define USING_DECL_TYPENAME_P(NODE) DECL_LANG_FLAG_1 (USING_DECL_CHECK (NODE))
656 /* True if member using decl NODE refers to a non-inherited NODE. */
657 #define USING_DECL_UNRELATED_P(NODE) DECL_LANG_FLAG_2 (USING_DECL_CHECK (NODE))
659 /* Nonzero if NODE declares a function. */
660 #define DECL_DECLARES_FUNCTION_P(NODE) (TREE_CODE (NODE) == FUNCTION_DECL)
662 /* Nonzero for a NODE which declares a type. */
663 #define DECL_DECLARES_TYPE_P(NODE) (TREE_CODE (NODE) == TYPE_DECL)
666 #define IDENTIFIER_KIND_BIT_0(NODE) \
667 TREE_LANG_FLAG_0 (IDENTIFIER_NODE_CHECK (NODE))
668 #define IDENTIFIER_KIND_BIT_1(NODE) \
669 TREE_LANG_FLAG_1 (IDENTIFIER_NODE_CHECK (NODE))
670 #define IDENTIFIER_KIND_BIT_2(NODE) \
671 TREE_LANG_FLAG_2 (IDENTIFIER_NODE_CHECK (NODE))
673 /* Used by various search routines. */
674 #define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_4 (IDENTIFIER_NODE_CHECK (NODE))
676 /* Nonzero if this identifier is used as a virtual function name somewhere
677 (optimizes searches). */
678 #define IDENTIFIER_VIRTUAL_P(NODE) \
679 TREE_LANG_FLAG_5 (IDENTIFIER_NODE_CHECK (NODE))
681 /* True if this identifier is a reserved word. C_RID_CODE (node) is
682 then the RID_* value of the keyword. Value 1. */
683 #define IDENTIFIER_KEYWORD_P(NODE) \
684 ((!IDENTIFIER_KIND_BIT_2 (NODE)) & (!IDENTIFIER_KIND_BIT_1 (NODE)) \
685 & IDENTIFIER_KIND_BIT_0 (NODE))
687 /* True if this identifier is the name of a constructor or
688 destructor. Value 2 or 3. */
689 #define IDENTIFIER_CDTOR_P(NODE) \
690 ((!IDENTIFIER_KIND_BIT_2 (NODE)) & IDENTIFIER_KIND_BIT_1 (NODE))
692 /* True if this identifier is the name of a constructor. Value 2. */
693 #define IDENTIFIER_CTOR_P(NODE) \
694 (IDENTIFIER_CDTOR_P (NODE) & (!IDENTIFIER_KIND_BIT_0 (NODE)))
696 /* True if this identifier is the name of a destructor. Value 3. */
697 #define IDENTIFIER_DTOR_P(NODE) \
698 (IDENTIFIER_CDTOR_P (NODE) & IDENTIFIER_KIND_BIT_0 (NODE))
700 /* True if this identifier is for any operator name (including
701 conversions). Value 4, 5, 6 or 7. */
702 #define IDENTIFIER_ANY_OP_P(NODE) (IDENTIFIER_KIND_BIT_2 (NODE))
704 /* True if this identifier is for an overloaded operator. Values 4, 5. */
705 #define IDENTIFIER_OVL_OP_P(NODE) \
706 (IDENTIFIER_ANY_OP_P (NODE) & (!IDENTIFIER_KIND_BIT_1 (NODE)))
708 /* True if this identifier is for any assignment. Values 5. */
709 #define IDENTIFIER_ASSIGN_OP_P(NODE) \
710 (IDENTIFIER_OVL_OP_P (NODE) & IDENTIFIER_KIND_BIT_0 (NODE))
712 /* True if this identifier is the name of a type-conversion
713 operator. Value 7. */
714 #define IDENTIFIER_CONV_OP_P(NODE) \
715 (IDENTIFIER_ANY_OP_P (NODE) & IDENTIFIER_KIND_BIT_1 (NODE) \
716 & (!IDENTIFIER_KIND_BIT_0 (NODE)))
718 /* True if this identifier is a new or delete operator. */
719 #define IDENTIFIER_NEWDEL_OP_P(NODE) \
720 (IDENTIFIER_OVL_OP_P (NODE) \
721 && IDENTIFIER_OVL_OP_FLAGS (NODE) & OVL_OP_FLAG_ALLOC)
723 /* True if this identifier is a new operator. */
724 #define IDENTIFIER_NEW_OP_P(NODE) \
725 (IDENTIFIER_OVL_OP_P (NODE) \
726 && (IDENTIFIER_OVL_OP_FLAGS (NODE) \
727 & (OVL_OP_FLAG_ALLOC | OVL_OP_FLAG_DELETE)) \
728 == OVL_OP_FLAG_ALLOC)
730 /* Nonzero if the class NODE has multiple paths to the same (virtual)
732 #define CLASSTYPE_DIAMOND_SHAPED_P(NODE) \
733 (LANG_TYPE_CLASS_CHECK (NODE)->diamond_shaped)
735 /* Nonzero if the class NODE has multiple instances of the same base
737 #define CLASSTYPE_REPEATED_BASE_P(NODE) \
738 (LANG_TYPE_CLASS_CHECK (NODE)->repeated_base)
740 /* The member function with which the vtable will be emitted:
741 the first noninline non-pure-virtual member function. NULL_TREE
742 if there is no key function or if this is a class template */
743 #define CLASSTYPE_KEY_METHOD(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->key_method)
745 /* Vector of members. During definition, it is unordered and only
746 member functions are present. After completion it is sorted and
747 contains both member functions and non-functions. STAT_HACK is
748 involved to preserve oneslot per name invariant. */
749 #define CLASSTYPE_MEMBER_VEC(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->members)
751 /* For class templates, this is a TREE_LIST of all member data,
752 functions, types, and friends in the order of declaration.
753 The TREE_PURPOSE of each TREE_LIST is NULL_TREE for a friend,
754 and the RECORD_TYPE for the class template otherwise. */
755 #define CLASSTYPE_DECL_LIST(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->decl_list)
757 /* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These
758 are the constructors that take an in-charge parameter. */
759 #define CLASSTYPE_CONSTRUCTORS(NODE) \
760 (get_class_binding_direct (NODE, ctor_identifier))
762 /* A FUNCTION_DECL for the destructor for NODE. This is the
763 destructors that take an in-charge parameter. If
764 CLASSTYPE_LAZY_DESTRUCTOR is true, then this entry will be NULL
765 until the destructor is created with lazily_declare_fn. */
766 #define CLASSTYPE_DESTRUCTOR(NODE) \
767 (get_class_binding_direct (NODE, dtor_identifier))
769 /* Nonzero if NODE has a primary base class, i.e., a base class with
770 which it shares the virtual function table pointer. */
771 #define CLASSTYPE_HAS_PRIMARY_BASE_P(NODE) \
772 (CLASSTYPE_PRIMARY_BINFO (NODE) != NULL_TREE)
774 /* If non-NULL, this is the binfo for the primary base class, i.e.,
775 the base class which contains the virtual function table pointer
777 #define CLASSTYPE_PRIMARY_BINFO(NODE) \
778 (LANG_TYPE_CLASS_CHECK (NODE)->primary_base)
780 /* The type corresponding to NODE when NODE is used as a base class,
781 i.e., NODE without virtual base classes or tail padding. */
782 #define CLASSTYPE_AS_BASE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->as_base)
784 /* Nonzero if NODE is a user-defined conversion operator. */
785 #define DECL_CONV_FN_P(NODE) IDENTIFIER_CONV_OP_P (DECL_NAME (NODE))
787 /* The type to which conversion operator FN converts to. */
788 #define DECL_CONV_FN_TYPE(FN) \
789 TREE_TYPE ((gcc_checking_assert (DECL_CONV_FN_P (FN)), DECL_NAME (FN)))
791 /* Returns nonzero iff TYPE1 and TYPE2 are the same type, in the usual
793 #define same_type_p(TYPE1, TYPE2) comptypes ((TYPE1), (TYPE2), COMPARE_STRICT)
795 /* Nonzero if T is a type that could resolve to any kind of concrete type
796 at instantiation time. */
797 #define WILDCARD_TYPE_P(T) \
798 (TREE_CODE (T) == TEMPLATE_TYPE_PARM || TREE_CODE (T) == TYPENAME_TYPE \
799 || TREE_CODE (T) == TYPEOF_TYPE \
800 || TREE_CODE (T) == BOUND_TEMPLATE_TEMPLATE_PARM \
801 || TREE_CODE (T) == DECLTYPE_TYPE \
802 || TREE_CODE (T) == DEPENDENT_OPERATOR_TYPE)
804 /* Nonzero if T is a class (or struct or union) type. Also nonzero
805 for template type parameters, typename types, and instantiated
806 template template parameters. Keep these checks in ascending code
808 #define MAYBE_CLASS_TYPE_P(T) (WILDCARD_TYPE_P (T) || CLASS_TYPE_P (T))
810 /* 1 iff FUNCTION_TYPE or METHOD_TYPE has a ref-qualifier (either & or &&). */
811 #define FUNCTION_REF_QUALIFIED(NODE) \
812 TREE_LANG_FLAG_4 (FUNC_OR_METHOD_CHECK (NODE))
814 /* 1 iff FUNCTION_TYPE or METHOD_TYPE has &&-ref-qualifier. */
815 #define FUNCTION_RVALUE_QUALIFIED(NODE) \
816 TREE_LANG_FLAG_5 (FUNC_OR_METHOD_CHECK (NODE))
818 /* Get the POINTER_TYPE to the METHOD_TYPE associated with this
819 pointer to member function. TYPE_PTRMEMFUNC_P _must_ be true,
820 before using this macro. */
821 #define TYPE_PTRMEMFUNC_FN_TYPE(NODE) \
822 (rs_build_qualified_type (TREE_TYPE (TYPE_FIELDS (NODE)), \
823 rs_type_quals (NODE)))
825 /* As above, but can be used in places that want an lvalue at the expense
826 of not necessarily having the correct cv-qualifiers. */
827 #define TYPE_PTRMEMFUNC_FN_TYPE_RAW(NODE) (TREE_TYPE (TYPE_FIELDS (NODE)))
829 /* True if this type is dependent. This predicate is only valid if
830 TYPE_DEPENDENT_P_VALID is true. */
831 #define TYPE_DEPENDENT_P(NODE) TYPE_LANG_FLAG_0 (NODE)
833 /* True if dependent_type_p has been called for this type, with the
834 result that TYPE_DEPENDENT_P is valid. */
835 #define TYPE_DEPENDENT_P_VALID(NODE) TYPE_LANG_FLAG_6 (NODE)
837 /* Nonzero for _TYPE node means that this type does not have a trivial
838 destructor. Therefore, destroying an object of this type will
839 involve a call to a destructor. This can apply to objects of
840 ARRAY_TYPE if the type of the elements needs a destructor. */
841 #define TYPE_HAS_NONTRIVIAL_DESTRUCTOR(NODE) (TYPE_LANG_FLAG_4 (NODE))
843 /* For FUNCTION_TYPE or METHOD_TYPE, a list of the exceptions that
844 this type can raise. Each TREE_VALUE is a _TYPE. The TREE_VALUE
845 will be NULL_TREE to indicate a throw specification of `()', or
846 no exceptions allowed. For a noexcept specification, TREE_VALUE
847 is NULL_TREE and TREE_PURPOSE is the constant-expression. For
848 a deferred noexcept-specification, TREE_PURPOSE is a DEFERRED_NOEXCEPT
849 (for templates) or an OVERLOAD list of functions (for implicitly
850 declared functions). */
851 #define TYPE_RAISES_EXCEPTIONS(NODE) \
852 TYPE_LANG_SLOT_1 (FUNC_OR_METHOD_CHECK (NODE))
854 /* Identifiers map directly to block or class-scope bindings.
855 Namespace-scope bindings are held in hash tables on the respective
856 namespaces. The identifier bindings are the innermost active
857 binding, from whence you can get the decl and/or implicit-typedef
858 of an elaborated type. When not bound to a local entity the
860 #define IDENTIFIER_BINDING(NODE) (LANG_IDENTIFIER_CAST (NODE)->bindings)
862 #define LANG_IDENTIFIER_CAST(NODE) \
863 ((struct lang_identifier *) IDENTIFIER_NODE_CHECK (NODE))
865 /* IF_STMT accessors. These give access to the condition of the if
866 statement, the then block of the if statement, and the else block
867 of the if statement if it exists. */
868 #define IF_COND(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 0)
869 #define THEN_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 1)
870 #define ELSE_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 2)
871 #define IF_SCOPE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 3)
872 #define IF_STMT_CONSTEXPR_P(NODE) TREE_LANG_FLAG_0 (IF_STMT_CHECK (NODE))
873 #define IF_STMT_CONSTEVAL_P(NODE) TREE_LANG_FLAG_2 (IF_STMT_CHECK (NODE))
875 /* The expression in question for a DECLTYPE_TYPE. */
876 #define DECLTYPE_TYPE_EXPR(NODE) (TYPE_VALUES_RAW (DECLTYPE_TYPE_CHECK (NODE)))
878 #define SET_CLASSTYPE_INTERFACE_UNKNOWN_X(NODE, X) \
879 (LANG_TYPE_CLASS_CHECK (NODE)->interface_unknown = !!(X))
881 /* Nonzero if this class is included from a header file which employs
882 `#pragma interface', and it is not included in its implementation file. */
883 #define CLASSTYPE_INTERFACE_ONLY(NODE) \
884 (LANG_TYPE_CLASS_CHECK (NODE)->interface_only)
886 #define TYPE_NAME_STRING(NODE) (IDENTIFIER_POINTER (TYPE_IDENTIFIER (NODE)))
887 #define TYPE_NAME_LENGTH(NODE) (IDENTIFIER_LENGTH (TYPE_IDENTIFIER (NODE)))
889 /* Whether a PARM_DECL represents a local parameter in a
890 requires-expression. */
891 #define CONSTRAINT_VAR_P(NODE) DECL_LANG_FLAG_2 (TREE_CHECK (NODE, PARM_DECL))
893 /* In a CALL_EXPR appearing in a template, true if Koenig lookup
894 should be performed at instantiation time. */
895 #define KOENIG_LOOKUP_P(NODE) TREE_LANG_FLAG_0 (CALL_EXPR_CHECK (NODE))
897 /* The index of a user-declared parameter in its function, starting at 1.
898 All artificial parameters will have index 0. */
899 #define DECL_PARM_INDEX(NODE) (LANG_DECL_PARM_CHECK (NODE)->index)
901 /* The level of a user-declared parameter in its function, starting at 1.
902 A parameter of the function will have level 1; a parameter of the first
903 nested function declarator (i.e. t in void f (void (*p)(T t))) will have
905 #define DECL_PARM_LEVEL(NODE) (LANG_DECL_PARM_CHECK (NODE)->level)
907 /* These flags are used by the conversion code.
908 CONV_IMPLICIT : Perform implicit conversions (standard and user-defined).
909 CONV_STATIC : Perform the explicit conversions for static_cast.
910 CONV_CONST : Perform the explicit conversions for const_cast.
911 CONV_REINTERPRET: Perform the explicit conversions for reinterpret_cast.
912 CONV_PRIVATE : Perform upcasts to private bases.
913 CONV_FORCE_TEMP : Require a new temporary when converting to the same
916 #define CONV_IMPLICIT 1
917 #define CONV_STATIC 2
919 #define CONV_REINTERPRET 8
920 #define CONV_PRIVATE 16
921 #define CONV_FORCE_TEMP 32
923 #define CONV_OLD_CONVERT \
924 (CONV_IMPLICIT | CONV_STATIC | CONV_CONST | CONV_REINTERPRET)
925 #define CONV_C_CAST \
926 (CONV_IMPLICIT | CONV_STATIC | CONV_CONST | CONV_REINTERPRET | CONV_PRIVATE \
928 #define CONV_BACKEND_CONVERT (CONV_OLD_CONVERT | CONV_FOLD)
930 /* Used by build_expr_type_conversion to indicate which types are
931 acceptable as arguments to the expression under consideration. */
933 #define WANT_INT 1 /* integer types, including bool */
934 #define WANT_FLOAT 2 /* floating point types */
935 #define WANT_ENUM 4 /* enumerated types */
936 #define WANT_POINTER 8 /* pointer types */
937 #define WANT_NULL 16 /* null pointer constant */
938 #define WANT_VECTOR_OR_COMPLEX 32 /* vector or complex types */
939 #define WANT_ARITH (WANT_INT | WANT_FLOAT | WANT_VECTOR_OR_COMPLEX)
941 /* Used with comptypes, and related functions, to guide type
944 #define COMPARE_STRICT \
945 0 /* Just check if the types are the \
947 #define COMPARE_BASE \
948 1 /* Check to see if the second type is \
949 derived from the first. */
950 #define COMPARE_DERIVED \
951 2 /* Like COMPARE_BASE, but in \
953 #define COMPARE_REDECLARATION \
954 4 /* The comparison is being done when \
955 another declaration of an existing \
957 #define COMPARE_STRUCTURAL \
958 8 /* The comparison is intended to be \
959 structural. The actual comparison \
960 will be identical to \
963 /* Used with start function. */
964 #define SF_DEFAULT 0 /* No flags. */
965 #define SF_PRE_PARSED \
966 1 /* The function declaration has \
967 already been parsed. */
968 #define SF_INCLASS_INLINE \
969 2 /* The function is an inline, defined \
970 in the class body. */
972 /* Used with start_decl's initialized parameter. */
973 #define SD_UNINITIALIZED 0
974 #define SD_INITIALIZED 1
975 /* Like SD_INITIALIZED, but also mark the new decl as DECL_DECOMPOSITION_P. */
976 #define SD_DECOMPOSITION 2
977 #define SD_DEFAULTED 3
980 /* Returns nonzero iff TYPE1 and TYPE2 are the same type, in the usual
982 #define same_type_p(TYPE1, TYPE2) comptypes ((TYPE1), (TYPE2), COMPARE_STRICT)
984 /* Returns true if NODE is a pointer-to-data-member. */
985 #define TYPE_PTRDATAMEM_P(NODE) (TREE_CODE (NODE) == OFFSET_TYPE)
987 /* Nonzero if this type is const-qualified. */
988 #define RS_TYPE_CONST_P(NODE) ((rs_type_quals (NODE) & TYPE_QUAL_CONST) != 0)
990 /* The _DECL for this _TYPE. */
991 #define TYPE_MAIN_DECL(NODE) (TYPE_STUB_DECL (TYPE_MAIN_VARIANT (NODE)))
993 /* Nonzero for a VAR_DECL iff an explicit initializer was provided
994 or a non-trivial constructor is called. */
995 #define DECL_NONTRIVIALLY_INITIALIZED_P(NODE) \
996 (TREE_LANG_FLAG_6 (VAR_DECL_CHECK (NODE)))
998 /* Nonzero if DECL was declared with '= default' (maybe implicitly). */
999 #define DECL_DEFAULTED_FN(DECL) (LANG_DECL_FN_CHECK (DECL)->defaulted_p)
1001 /* Nonzero for a class type means that the class type has a
1002 user-declared constructor. */
1003 #define TYPE_HAS_USER_CONSTRUCTOR(NODE) (TYPE_LANG_FLAG_1 (NODE))
1005 /* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These
1006 are the constructors that take an in-charge parameter. */
1007 #define CLASSTYPE_CONSTRUCTORS(NODE) \
1008 (get_class_binding_direct (NODE, ctor_identifier))
1010 /* Nonzero if the DECL was initialized in the class definition itself,
1011 rather than outside the class. This is used for both static member
1012 VAR_DECLS, and FUNCTION_DECLS that are defined in the class. */
1013 #define DECL_INITIALIZED_IN_CLASS_P(DECL) \
1014 (DECL_LANG_SPECIFIC (VAR_OR_FUNCTION_DECL_CHECK (DECL)) \
1015 ->u.base.initialized_in_class)
1017 /* Nonzero if DECL is explicitly defaulted in the class body. */
1018 #define DECL_DEFAULTED_IN_CLASS_P(DECL) \
1019 (DECL_DEFAULTED_FN (DECL) && DECL_INITIALIZED_IN_CLASS_P (DECL))
1021 /* Nonzero for FUNCTION_DECL means that this decl is a non-static
1023 #define DECL_NONSTATIC_MEMBER_FUNCTION_P(NODE) \
1024 (TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE)
1026 /* For FUNCTION_DECLs: nonzero means that this function is a
1027 constructor or a destructor with an extra in-charge parameter to
1028 control whether or not virtual bases are constructed. */
1029 #define DECL_HAS_IN_CHARGE_PARM_P(NODE) \
1030 (LANG_DECL_FN_CHECK (NODE)->has_in_charge_parm_p)
1032 /* Nonzero if the VTT parm has been added to NODE. */
1033 #define DECL_HAS_VTT_PARM_P(NODE) (LANG_DECL_FN_CHECK (NODE)->has_vtt_parm_p)
1035 /* Given a FUNCTION_DECL, returns the first TREE_LIST out of TYPE_ARG_TYPES
1036 which refers to a user-written parameter. */
1037 #define FUNCTION_FIRST_USER_PARMTYPE(NODE) \
1038 skip_artificial_parms_for ((NODE), TYPE_ARG_TYPES (TREE_TYPE (NODE)))
1040 /* Similarly, but for DECL_ARGUMENTS. */
1041 #define FUNCTION_FIRST_USER_PARM(NODE) \
1042 skip_artificial_parms_for ((NODE), DECL_ARGUMENTS (NODE))
1044 /* For FUNCTION_DECLs and TEMPLATE_DECLs: nonzero means that this function
1045 is a constructor. */
1046 #define DECL_CONSTRUCTOR_P(NODE) DECL_CXX_CONSTRUCTOR_P (NODE)
1048 /* Nonzero if DECL was declared with '= delete'. */
1049 #define DECL_DELETED_FN(DECL) \
1050 (LANG_DECL_FN_CHECK (DECL)->min.base.threadprivate_or_deleted_p)
1052 /* Nonzero if DECL was declared with '= default' (maybe implicitly). */
1053 #define DECL_DEFAULTED_FN(DECL) (LANG_DECL_FN_CHECK (DECL)->defaulted_p)
1055 /* True if NODE is a brace-enclosed initializer. */
1056 #define BRACE_ENCLOSED_INITIALIZER_P(NODE) \
1057 (TREE_CODE (NODE) == CONSTRUCTOR && TREE_TYPE (NODE) == init_list_type_node)
1059 /* True if FNDECL is an immediate function. */
1060 #define DECL_IMMEDIATE_FUNCTION_P(NODE) \
1061 (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE)) \
1062 ? LANG_DECL_FN_CHECK (NODE)->immediate_fn_p \
1064 #define SET_DECL_IMMEDIATE_FUNCTION_P(NODE) \
1065 (retrofit_lang_decl (FUNCTION_DECL_CHECK (NODE)), \
1066 LANG_DECL_FN_CHECK (NODE)->immediate_fn_p = true)
1068 /* True if this CONSTRUCTOR should not be used as a variable initializer
1069 because it was loaded from a constexpr variable with mutable fields. */
1070 #define CONSTRUCTOR_MUTABLE_POISON(NODE) \
1071 (TREE_LANG_FLAG_2 (CONSTRUCTOR_CHECK (NODE)))
1073 /* For a pointer-to-member constant `X::Y' this is the _DECL for
1075 #define PTRMEM_CST_MEMBER(NODE) \
1076 (((ptrmem_cst_t) PTRMEM_CST_CHECK (NODE))->member)
1078 /* Indicates whether a COMPONENT_REF or a SCOPE_REF has been parenthesized, an
1079 INDIRECT_REF comes from parenthesizing a _DECL, or a PAREN_EXPR identifies a
1080 parenthesized initializer relevant for decltype(auto). Currently only set
1081 some of the time in C++14 mode. */
1083 #define REF_PARENTHESIZED_P(NODE) \
1084 TREE_LANG_FLAG_2 (TREE_CHECK5 ((NODE), COMPONENT_REF, INDIRECT_REF, \
1085 SCOPE_REF, VIEW_CONVERT_EXPR, PAREN_EXPR))
1087 /* Returns true if NODE is a pointer-to-member. */
1088 #define TYPE_PTRMEM_P(NODE) \
1089 (TYPE_PTRDATAMEM_P (NODE) || TYPE_PTRMEMFUNC_P (NODE))
1091 /* Returns true if NODE is a pointer or a pointer-to-member. */
1092 #define TYPE_PTR_OR_PTRMEM_P(NODE) (TYPE_PTR_P (NODE) || TYPE_PTRMEM_P (NODE))
1094 /* Nonzero if NODE is an artificial VAR_DECL for a C++17 structured binding
1095 declaration or one of VAR_DECLs for the user identifiers in it. */
1096 #define DECL_DECOMPOSITION_P(NODE) \
1097 (VAR_P (NODE) && DECL_LANG_SPECIFIC (NODE) \
1098 ? DECL_LANG_SPECIFIC (NODE)->u.base.selector == lds_decomp \
1101 /* The underlying artificial VAR_DECL for structured binding. */
1102 #define DECL_DECOMP_BASE(NODE) (LANG_DECL_DECOMP_CHECK (NODE)->base)
1104 /* Nonzero if either DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P or
1105 DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P is true of NODE. */
1106 #define DECL_MAYBE_IN_CHARGE_CDTOR_P(NODE) \
1107 (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (NODE) \
1108 || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (NODE))
1110 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor, but not the
1111 specialized in-charge constructor, in-charge deleting constructor,
1112 or the base destructor. */
1113 #define DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P(NODE) \
1114 (DECL_NAME (NODE) == dtor_identifier)
1116 /* Nonzero if NODE (a _DECL) is a cloned constructor or
1118 #define DECL_CLONED_FUNCTION_P(NODE) \
1119 (DECL_NAME (NODE) && IDENTIFIER_CDTOR_P (DECL_NAME (NODE)) \
1120 && !DECL_MAYBE_IN_CHARGE_CDTOR_P (NODE))
1122 /* If DECL_CLONED_FUNCTION_P holds, this is the function that was
1124 #define DECL_CLONED_FUNCTION(NODE) \
1125 (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE))->u.fn.u5.cloned_function)
1127 /* Nonzero if NODE (a _DECL) is a cloned constructor or
1129 #define DECL_CLONED_FUNCTION_P(NODE) \
1130 (DECL_NAME (NODE) && IDENTIFIER_CDTOR_P (DECL_NAME (NODE)) \
1131 && !DECL_MAYBE_IN_CHARGE_CDTOR_P (NODE))
1133 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor, but not either the
1134 specialized in-charge constructor or the specialized not-in-charge
1136 #define DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P(NODE) \
1137 (DECL_NAME (NODE) == ctor_identifier)
1139 /* The current C++-specific per-function global variables. */
1141 #define cp_function_chain (cfun->language)
1143 /* In a constructor destructor, the point at which all derived class
1144 destroying/construction has been done. I.e., just before a
1145 constructor returns, or before any base class destroying will be done
1148 #define cdtor_label cp_function_chain->x_cdtor_label
1150 /* When we're processing a member function, current_class_ptr is the
1151 PARM_DECL for the `this' pointer. The current_class_ref is an
1152 expression for `*this'. */
1154 #define current_class_ptr \
1155 (*(cfun && cp_function_chain ? &cp_function_chain->x_current_class_ptr \
1156 : &scope_chain->x_current_class_ptr))
1157 #define current_class_ref \
1158 (*(cfun && cp_function_chain ? &cp_function_chain->x_current_class_ref \
1159 : &scope_chain->x_current_class_ref))
1161 /* The EH_SPEC_BLOCK for the exception-specifiers for the current
1162 function, if any. */
1164 #define current_eh_spec_block cp_function_chain->x_eh_spec_block
1166 /* The `__in_chrg' parameter for the current function. Only used for
1167 constructors and destructors. */
1169 #define current_in_charge_parm cp_function_chain->x_in_charge_parm
1171 /* The `__vtt_parm' parameter for the current function. Only used for
1172 constructors and destructors. */
1174 #define current_vtt_parm cp_function_chain->x_vtt_parm
1176 /* A boolean flag to control whether we need to clean up the return value if a
1177 local destructor throws. Only used in functions that return by value a
1178 class with a destructor. Which 'tors don't, so we can use the same
1179 field as current_vtt_parm. */
1181 #define current_retval_sentinel current_vtt_parm
1183 /* Set to 0 at beginning of a function definition, set to 1 if
1184 a return statement that specifies a return value is seen. */
1186 #define current_function_returns_value cp_function_chain->returns_value
1188 /* Set to 0 at beginning of a function definition, set to 1 if
1189 a return statement with no argument is seen. */
1191 #define current_function_returns_null cp_function_chain->returns_null
1193 /* Set to 0 at beginning of a function definition, set to 1 if
1194 a call to a noreturn function is seen. */
1196 #define current_function_returns_abnormally \
1197 cp_function_chain->returns_abnormally
1199 /* Set to 0 at beginning of a function definition, set to 1 if we see an
1200 obvious infinite loop. This can have false positives and false
1201 negatives, so it should only be used as a heuristic. */
1203 #define current_function_infinite_loop cp_function_chain->infinite_loop
1205 /* Nonzero if we are processing a base initializer. Zero elsewhere. */
1206 #define in_base_initializer cp_function_chain->x_in_base_initializer
1208 #define in_function_try_handler cp_function_chain->x_in_function_try_handler
1210 /* Expression always returned from function, or error_mark_node
1211 otherwise, for use by the automatic named return value optimization. */
1213 #define current_function_return_value (cp_function_chain->x_return_value)
1215 #define current_class_type scope_chain->class_type
1217 #define in_discarded_stmt scope_chain->discarded_stmt
1218 #define in_consteval_if_p scope_chain->consteval_if_p
1220 /* Nonzero means that this type is being defined. I.e., the left brace
1221 starting the definition of this type has been seen. */
1222 #define TYPE_BEING_DEFINED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->being_defined)
1224 /* Nonzero for FUNCTION_DECL means that this decl is a static
1226 #define DECL_STATIC_FUNCTION_P(NODE) \
1227 (LANG_DECL_FN_CHECK (NODE)->static_function)
1229 /* Nonzero for FUNCTION_DECL means that this decl is a non-static
1231 #define DECL_NONSTATIC_MEMBER_FUNCTION_P(NODE) \
1232 (TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE)
1234 /* Nonzero for FUNCTION_DECL means that this decl is a member function
1235 (static or non-static). */
1236 #define DECL_FUNCTION_MEMBER_P(NODE) \
1237 (DECL_NONSTATIC_MEMBER_FUNCTION_P (NODE) || DECL_STATIC_FUNCTION_P (NODE))
1239 /* Nonzero if NODE is the target for genericization of 'return' stmts
1240 in constructors/destructors of targetm.cxx.cdtor_returns_this targets. */
1241 #define LABEL_DECL_CDTOR(NODE) DECL_LANG_FLAG_2 (LABEL_DECL_CHECK (NODE))
1243 /* Nonzero if this NOP_EXPR is a reinterpret_cast. Such conversions
1244 are not constexprs. Other NOP_EXPRs are. */
1245 #define REINTERPRET_CAST_P(NODE) TREE_LANG_FLAG_0 (NOP_EXPR_CHECK (NODE))
1247 /* Returns true if NODE is an object type:
1251 An object type is a (possibly cv-qualified) type that is not a
1252 function type, not a reference type, and not a void type.
1254 Keep these checks in ascending order, for speed. */
1255 #define TYPE_OBJ_P(NODE) \
1256 (!TYPE_REF_P (NODE) && !VOID_TYPE_P (NODE) && !FUNC_OR_METHOD_TYPE_P (NODE))
1258 /* Returns true if NODE is a pointer to an object. Keep these checks
1259 in ascending tree code order. */
1260 #define TYPE_PTROB_P(NODE) (TYPE_PTR_P (NODE) && TYPE_OBJ_P (TREE_TYPE (NODE)))
1262 /* True if this CONSTRUCTOR contains PLACEHOLDER_EXPRs referencing the
1263 CONSTRUCTOR's type not nested inside another CONSTRUCTOR marked with
1264 CONSTRUCTOR_PLACEHOLDER_BOUNDARY. */
1265 #define CONSTRUCTOR_PLACEHOLDER_BOUNDARY(NODE) \
1266 (TREE_LANG_FLAG_5 (CONSTRUCTOR_CHECK (NODE)))
1268 #define AGGR_INIT_EXPR_SLOT(NODE) TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 2)
1270 /* True if this TARGET_EXPR expresses direct-initialization of an object
1271 to be named later. */
1272 #define TARGET_EXPR_DIRECT_INIT_P(NODE) \
1273 TREE_LANG_FLAG_2 (TARGET_EXPR_CHECK (NODE))
1275 /* Nonzero if DECL is a declaration of __builtin_constant_p. */
1276 #define DECL_IS_BUILTIN_CONSTANT_P(NODE) \
1277 (TREE_CODE (NODE) == FUNCTION_DECL \
1278 && DECL_BUILT_IN_CLASS (NODE) == BUILT_IN_NORMAL \
1279 && DECL_FUNCTION_CODE (NODE) == BUILT_IN_CONSTANT_P)
1281 /* True iff this represents an lvalue being treated as an rvalue during return
1282 or throw as per [class.copy.elision]. */
1283 #define IMPLICIT_RVALUE_P(NODE) \
1284 TREE_LANG_FLAG_3 (TREE_CHECK2 ((NODE), NON_LVALUE_EXPR, STATIC_CAST_EXPR))
1286 /* Nonzero for _DECL means that this decl appears in (or will appear
1287 in) as a member in a RECORD_TYPE or UNION_TYPE node. It is also for
1288 detecting circularity in case members are multiply defined. In the
1289 case of a VAR_DECL, it means that no definition has been seen, even
1290 if an initializer has been. */
1291 #define DECL_IN_AGGR_P(NODE) (DECL_LANG_FLAG_3 (NODE))
1293 /* Nonzero means that this class type is a non-standard-layout class. */
1294 #define CLASSTYPE_NON_STD_LAYOUT(NODE) \
1295 (LANG_TYPE_CLASS_CHECK (NODE)->non_std_layout)
1297 /* Nonzero for FIELD_DECL node means that this field is a base class
1298 of the parent object, as opposed to a member field. */
1299 #define DECL_FIELD_IS_BASE(NODE) DECL_LANG_FLAG_6 (FIELD_DECL_CHECK (NODE))
1301 /* Nonzero if TYPE is an anonymous union type. */
1302 #define ANON_UNION_TYPE_P(NODE) \
1303 (TREE_CODE (NODE) == UNION_TYPE && ANON_AGGR_TYPE_P (NODE))
1305 /* For an ANON_AGGR_TYPE_P the single FIELD_DECL it is used with. */
1306 #define ANON_AGGR_TYPE_FIELD(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->typeinfo_var)
1308 /* Nonzero if TYPE is an anonymous union or struct type. We have to use a
1309 flag for this because "A union for which objects or pointers are
1310 declared is not an anonymous union" [class.union]. */
1311 #define ANON_AGGR_TYPE_P(NODE) \
1312 (CLASS_TYPE_P (NODE) && LANG_TYPE_CLASS_CHECK (NODE)->anon_aggr)
1313 #define SET_ANON_AGGR_TYPE_P(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->anon_aggr = 1)
1315 /* Nonzero if T is a class type but not a union. */
1316 #define NON_UNION_CLASS_TYPE_P(T) \
1317 (TREE_CODE (T) == RECORD_TYPE && TYPE_LANG_FLAG_5 (T))
1319 /* Determines whether an ENUMERAL_TYPE has an explicit
1321 #define ENUM_FIXED_UNDERLYING_TYPE_P(NODE) (TYPE_LANG_FLAG_5 (NODE))
1323 /* Returns the underlying type of the given enumeration type. The
1324 underlying type is determined in different ways, depending on the
1325 properties of the enum:
1327 - In C++0x, the underlying type can be explicitly specified, e.g.,
1329 enum E1 : char { ... } // underlying type is char
1331 - In a C++0x scoped enumeration, the underlying type is int
1332 unless otherwises specified:
1334 enum class E2 { ... } // underlying type is int
1336 - Otherwise, the underlying type is determined based on the
1337 values of the enumerators. In this case, the
1338 ENUM_UNDERLYING_TYPE will not be set until after the definition
1339 of the enumeration is completed by finish_enum. */
1340 #define ENUM_UNDERLYING_TYPE(TYPE) TREE_TYPE (ENUMERAL_TYPE_CHECK (TYPE))
1342 /* Nonzero if this type is volatile-qualified. */
1343 #define RS_TYPE_VOLATILE_P(NODE) \
1344 ((rs_type_quals (NODE) & TYPE_QUAL_VOLATILE) != 0)
1346 /* Nonzero means that this type is either complete or being defined, so we
1347 can do lookup in it. */
1348 #define COMPLETE_OR_OPEN_TYPE_P(NODE) \
1349 (COMPLETE_TYPE_P (NODE) || (CLASS_TYPE_P (NODE) && TYPE_BEING_DEFINED (NODE)))
1351 /* Indicates when overload resolution may resolve to a pointer to
1352 member function. [expr.unary.op]/3 */
1353 #define PTRMEM_OK_P(NODE) \
1354 TREE_LANG_FLAG_0 (TREE_CHECK3 ((NODE), ADDR_EXPR, OFFSET_REF, SCOPE_REF))
1356 /* Returns nonzero iff NODE is a declaration for the global function
1358 #define DECL_MAIN_P(NODE) \
1359 (DECL_NAME (NODE) != NULL_TREE && MAIN_NAME_P (DECL_NAME (NODE)) \
1362 /* Nonzero if the variable was declared to be thread-local.
1363 We need a special C++ version of this test because the middle-end
1364 DECL_THREAD_LOCAL_P uses the symtab, so we can't use it for
1366 #define RS_DECL_THREAD_LOCAL_P(NODE) (TREE_LANG_FLAG_0 (VAR_DECL_CHECK (NODE)))
1368 #define COND_EXPR_IS_VEC_DELETE(NODE) TREE_LANG_FLAG_0 (COND_EXPR_CHECK (NODE))
1370 /* RANGE_FOR_STMT accessors. These give access to the declarator,
1371 expression, body, and scope of the statement, respectively. */
1372 #define RANGE_FOR_DECL(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 0)
1373 #define RANGE_FOR_EXPR(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 1)
1374 #define RANGE_FOR_BODY(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 2)
1375 #define RANGE_FOR_SCOPE(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 3)
1376 #define RANGE_FOR_UNROLL(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 4)
1377 #define RANGE_FOR_INIT_STMT(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 5)
1378 #define RANGE_FOR_IVDEP(NODE) TREE_LANG_FLAG_6 (RANGE_FOR_STMT_CHECK (NODE))
1380 #define CP_DECL_CONTEXT(NODE) \
1381 (!DECL_FILE_SCOPE_P (NODE) ? DECL_CONTEXT (NODE) : global_namespace)
1382 #define CP_TYPE_CONTEXT(NODE) \
1383 (!TYPE_FILE_SCOPE_P (NODE) ? TYPE_CONTEXT (NODE) : global_namespace)
1384 #define FROB_CONTEXT(NODE) \
1385 ((NODE) == global_namespace ? DECL_CONTEXT (NODE) : (NODE))
1387 /* Nonzero if NODE is the std namespace. */
1388 #define DECL_NAMESPACE_STD_P(NODE) ((NODE) == std_node)
1390 /* Whether the namepace is an inline namespace. */
1391 #define DECL_NAMESPACE_INLINE_P(NODE) \
1392 TREE_LANG_FLAG_0 (NAMESPACE_DECL_CHECK (NODE))
1394 #define CP_DECL_CONTEXT(NODE) \
1395 (!DECL_FILE_SCOPE_P (NODE) ? DECL_CONTEXT (NODE) : global_namespace)
1397 /* Based off of TYPE_UNNAMED_P. */
1398 #define LAMBDA_TYPE_P(NODE) \
1399 (TREE_CODE (NODE) == RECORD_TYPE && TYPE_LINKAGE_IDENTIFIER (NODE) \
1400 && IDENTIFIER_LAMBDA_P (TYPE_LINKAGE_IDENTIFIER (NODE)))
1402 /* Macros to make error reporting functions' lives easier. */
1403 #define TYPE_LINKAGE_IDENTIFIER(NODE) \
1404 (TYPE_IDENTIFIER (TYPE_MAIN_VARIANT (NODE)))
1406 /* Identifiers used for lambda types are almost anonymous. Use this
1407 spare flag to distinguish them (they also have the anonymous flag). */
1408 #define IDENTIFIER_LAMBDA_P(NODE) \
1409 (IDENTIFIER_NODE_CHECK (NODE)->base.protected_flag)
1411 /* If NODE, a FUNCTION_DECL, is a C++11 inheriting constructor, then this
1412 is the constructor it inherits from. */
1413 #define DECL_INHERITED_CTOR(NODE) \
1414 (DECL_DECLARES_FUNCTION_P (NODE) && DECL_CONSTRUCTOR_P (NODE) \
1415 ? LANG_DECL_FN_CHECK (NODE)->context \
1418 /* True if the class type TYPE is a literal type. */
1419 #define CLASSTYPE_LITERAL_P(TYPE) (LANG_TYPE_CLASS_CHECK (TYPE)->is_literal)
1421 /* Nonzero if NODE (a FUNCTION_DECL or TEMPLATE_DECL)
1423 #define DECL_DESTRUCTOR_P(NODE) DECL_CXX_DESTRUCTOR_P (NODE)
1425 /* Nonzero if TYPE has a trivial destructor. From [class.dtor]:
1427 A destructor is trivial if it is an implicitly declared
1430 - all of the direct base classes of its class have trivial
1433 - for all of the non-static data members of its class that are
1434 of class type (or array thereof), each such class has a
1435 trivial destructor. */
1436 #define TYPE_HAS_TRIVIAL_DESTRUCTOR(NODE) \
1437 (!TYPE_HAS_NONTRIVIAL_DESTRUCTOR (NODE))
1439 /* Nonzero means that NODE (a class type) has a destructor -- but that
1440 it has not yet been declared. */
1441 #define CLASSTYPE_LAZY_DESTRUCTOR(NODE) \
1442 (LANG_TYPE_CLASS_CHECK (NODE)->lazy_destructor)
1444 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a complete
1446 #define DECL_COMPLETE_CONSTRUCTOR_P(NODE) \
1447 (DECL_NAME (NODE) == complete_ctor_identifier)
1449 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a base
1451 #define DECL_BASE_CONSTRUCTOR_P(NODE) (DECL_NAME (NODE) == base_ctor_identifier)
1453 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor, but not either the
1454 specialized in-charge constructor or the specialized not-in-charge
1456 #define DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P(NODE) \
1457 (DECL_NAME (NODE) == ctor_identifier)
1459 /* Nonzero if NODE (a FUNCTION_DECL) is a copy constructor. */
1460 #define DECL_COPY_CONSTRUCTOR_P(NODE) \
1461 (DECL_CONSTRUCTOR_P (NODE) && copy_fn_p (NODE) > 0)
1463 /* Nonzero if NODE (a FUNCTION_DECL) is a move constructor. */
1464 #define DECL_MOVE_CONSTRUCTOR_P(NODE) \
1465 (DECL_CONSTRUCTOR_P (NODE) && move_fn_p (NODE))
1467 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor, but not the
1468 specialized in-charge constructor, in-charge deleting constructor,
1469 or the base destructor. */
1470 #define DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P(NODE) \
1471 (DECL_NAME (NODE) == dtor_identifier)
1473 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete
1475 #define DECL_COMPLETE_DESTRUCTOR_P(NODE) \
1476 (DECL_NAME (NODE) == complete_dtor_identifier)
1478 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a base
1480 #define DECL_BASE_DESTRUCTOR_P(NODE) (DECL_NAME (NODE) == base_dtor_identifier)
1482 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete
1483 object that deletes the object after it has been destroyed. */
1484 #define DECL_DELETING_DESTRUCTOR_P(NODE) \
1485 (DECL_NAME (NODE) == deleting_dtor_identifier)
1487 /* Nonzero if either DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P or
1488 DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P is true of NODE. */
1489 #define DECL_MAYBE_IN_CHARGE_CDTOR_P(NODE) \
1490 (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (NODE) \
1491 || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (NODE))
1493 /* Nonzero if NODE (a _DECL) is a cloned constructor or
1495 #define DECL_CLONED_FUNCTION_P(NODE) \
1496 (DECL_NAME (NODE) && IDENTIFIER_CDTOR_P (DECL_NAME (NODE)) \
1497 && !DECL_MAYBE_IN_CHARGE_CDTOR_P (NODE))
1499 /* If DECL_CLONED_FUNCTION_P holds, this is the function that was
1501 #define DECL_CLONED_FUNCTION(NODE) \
1502 (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE))->u.fn.u5.cloned_function)
1504 /* Nonzero means that an object of this type cannot be initialized using
1505 an initializer list. */
1506 #define CLASSTYPE_NON_AGGREGATE(NODE) \
1507 (LANG_TYPE_CLASS_CHECK (NODE)->non_aggregate)
1508 #define TYPE_NON_AGGREGATE_CLASS(NODE) \
1509 (CLASS_TYPE_P (NODE) && CLASSTYPE_NON_AGGREGATE (NODE))
1511 /* Nonzero for class type means that the default constructor is trivial. */
1512 #define TYPE_HAS_TRIVIAL_DFLT(NODE) \
1513 (TYPE_HAS_DEFAULT_CONSTRUCTOR (NODE) && !TYPE_HAS_COMPLEX_DFLT (NODE))
1515 /* Nonzero if this class has a constexpr constructor other than a copy/move
1516 constructor. Note that a class can have constexpr constructors for
1517 static initialization even if it isn't a literal class. */
1518 #define TYPE_HAS_CONSTEXPR_CTOR(NODE) \
1519 (LANG_TYPE_CLASS_CHECK (NODE)->has_constexpr_ctor)
1521 /* Nonzero if there is no trivial default constructor for this class. */
1522 #define TYPE_HAS_COMPLEX_DFLT(NODE) \
1523 (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_dflt)
1527 An aggregate is an array or a class with no user-provided
1528 constructors, no brace-or-equal-initializers for non-static data
1529 members, no private or protected non-static data members, no
1530 base classes, and no virtual functions.
1532 As an extension, we also treat vectors as aggregates. Keep these
1533 checks in ascending code order. */
1534 #define CP_AGGREGATE_TYPE_P(TYPE) \
1535 (gnu_vector_type_p (TYPE) || TREE_CODE (TYPE) == ARRAY_TYPE \
1536 || (CLASS_TYPE_P (TYPE) && COMPLETE_TYPE_P (TYPE) \
1537 && !CLASSTYPE_NON_AGGREGATE (TYPE)))
1539 /* Nonzero for a FIELD_DECL means that this member object type
1541 #define DECL_MUTABLE_P(NODE) (DECL_LANG_FLAG_0 (FIELD_DECL_CHECK (NODE)))
1543 #if defined ENABLE_TREE_CHECKING
1545 #define LANG_DECL_MIN_CHECK(NODE) \
1547 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1548 if (!LANG_DECL_HAS_MIN (NODE)) \
1549 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1553 /* We want to be able to check DECL_CONSTRUCTOR_P and such on a function
1554 template, not just on a FUNCTION_DECL. So when looking for things in
1555 lang_decl_fn, look down through a TEMPLATE_DECL into its result. */
1556 #define LANG_DECL_FN_CHECK(NODE) \
1558 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1559 if (!DECL_DECLARES_FUNCTION_P (NODE) || lt->u.base.selector != lds_fn) \
1560 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1564 #define LANG_DECL_NS_CHECK(NODE) \
1566 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1567 if (TREE_CODE (NODE) != NAMESPACE_DECL || lt->u.base.selector != lds_ns) \
1568 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1572 #define LANG_DECL_PARM_CHECK(NODE) \
1574 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1575 if (TREE_CODE (NODE) != PARM_DECL || lt->u.base.selector != lds_parm) \
1576 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1580 #define LANG_DECL_DECOMP_CHECK(NODE) \
1582 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1583 if (!VAR_P (NODE) || lt->u.base.selector != lds_decomp) \
1584 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1590 #define LANG_DECL_MIN_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.min)
1592 #define LANG_DECL_FN_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.fn)
1594 #define LANG_DECL_NS_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.ns)
1596 #define LANG_DECL_PARM_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.parm)
1598 #define LANG_DECL_DECOMP_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.decomp)
1600 #endif /* ENABLE_TREE_CHECKING */
1602 // Below macros are copied from gcc/c-family/c-common.h
1604 /* In a FIELD_DECL, nonzero if the decl was originally a bitfield. */
1605 #define DECL_C_BIT_FIELD(NODE) (DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) == 1)
1606 #define SET_DECL_C_BIT_FIELD(NODE) \
1607 (DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) = 1)
1608 #define CLEAR_DECL_C_BIT_FIELD(NODE) \
1609 (DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) = 0)
1611 /* True if the decl was an unnamed bitfield. */
1612 #define DECL_UNNAMED_BIT_FIELD(NODE) \
1613 (DECL_C_BIT_FIELD (NODE) && !DECL_NAME (NODE))
1615 /* 1 iff NODE is function-local. */
1616 #define DECL_FUNCTION_SCOPE_P(NODE) \
1617 (DECL_CONTEXT (NODE) && TREE_CODE (DECL_CONTEXT (NODE)) == FUNCTION_DECL)
1619 /* Nonzero if this type is const-qualified, but not
1620 volatile-qualified. Other qualifiers are ignored. This macro is
1621 used to test whether or not it is OK to bind an rvalue to a
1623 #define RS_TYPE_CONST_NON_VOLATILE_P(NODE) \
1624 ((rs_type_quals (NODE) & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)) \
1627 /* Returns true if TYPE is an integral or enumeration name. Keep
1628 these checks in ascending code order. */
1629 #define INTEGRAL_OR_ENUMERATION_TYPE_P(TYPE) \
1630 (TREE_CODE (TYPE) == ENUMERAL_TYPE || RS_INTEGRAL_TYPE_P (TYPE))
1632 /* Nonzero for a VAR_DECL that was initialized with a
1633 constant-expression. */
1634 #define DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P(NODE) \
1635 (TREE_LANG_FLAG_2 (VAR_DECL_CHECK (NODE)))
1637 /* WHILE_STMT accessors. These give access to the condition of the
1638 while statement and the body of the while statement, respectively. */
1639 #define WHILE_COND(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 0)
1640 #define WHILE_BODY(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 1)
1642 /* FOR_STMT accessors. These give access to the init statement,
1643 condition, update expression, and body of the for statement,
1645 #define FOR_INIT_STMT(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 0)
1646 #define FOR_COND(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 1)
1647 #define FOR_EXPR(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 2)
1648 #define FOR_BODY(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 3)
1649 #define FOR_SCOPE(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 4)
1651 #define SWITCH_STMT_COND(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 0)
1652 #define SWITCH_STMT_BODY(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 1)
1653 #define SWITCH_STMT_TYPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 2)
1654 #define SWITCH_STMT_SCOPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 3)
1656 /* Nonzero if NODE is the target for genericization of 'break' stmts. */
1657 #define LABEL_DECL_BREAK(NODE) DECL_LANG_FLAG_0 (LABEL_DECL_CHECK (NODE))
1659 /* Nonzero if NODE is the target for genericization of 'continue' stmts. */
1660 #define LABEL_DECL_CONTINUE(NODE) DECL_LANG_FLAG_1 (LABEL_DECL_CHECK (NODE))
1662 // Above macros are copied from gcc/c-family/c-common.h
1664 // Below macros are copied from gcc/cp/name-lookup.h
1666 /* Lookup walker marking. */
1667 #define LOOKUP_SEEN_P(NODE) TREE_VISITED (NODE)
1668 #define LOOKUP_FOUND_P(NODE) \
1669 TREE_LANG_FLAG_4 (TREE_CHECK4 (NODE, RECORD_TYPE, UNION_TYPE, ENUMERAL_TYPE, \
1672 // Above macros are copied from gcc/cp/name-lookup.h
1674 // Below macros are copied from gcc/cp/name-lookup.cc
1676 /* Create an overload suitable for recording an artificial TYPE_DECL
1677 and another decl. We use this machanism to implement the struct
1680 #define STAT_HACK_P(N) ((N) && TREE_CODE (N) == OVERLOAD && OVL_LOOKUP_P (N))
1681 #define STAT_TYPE_VISIBLE_P(N) TREE_USED (OVERLOAD_CHECK (N))
1682 #define STAT_TYPE(N) TREE_TYPE (N)
1683 #define STAT_DECL(N) OVL_FUNCTION (N)
1684 #define STAT_VISIBLE(N) OVL_CHAIN (N)
1685 #define MAYBE_STAT_DECL(N) (STAT_HACK_P (N) ? STAT_DECL (N) : N)
1686 #define MAYBE_STAT_TYPE(N) (STAT_HACK_P (N) ? STAT_TYPE (N) : NULL_TREE)
1688 /* When a STAT_HACK_P is true, OVL_USING_P and OVL_EXPORT_P are valid
1689 and apply to the hacked type. */
1691 /* For regular (maybe) overloaded functions, we have OVL_HIDDEN_P.
1692 But we also need to indicate hiddenness on implicit type decls
1693 (injected friend classes), and (coming soon) decls injected from
1694 block-scope externs. It is too awkward to press the existing
1695 overload marking for that. If we have a hidden non-function, we
1696 always create a STAT_HACK, and use these two markers as needed. */
1697 #define STAT_TYPE_HIDDEN_P(N) OVL_HIDDEN_P (N)
1698 #define STAT_DECL_HIDDEN_P(N) OVL_DEDUP_P (N)
1700 /* The binding level currently in effect. */
1702 #define current_binding_level \
1703 (*(cfun && cp_function_chain && cp_function_chain->bindings \
1704 ? &cp_function_chain->bindings \
1705 : &scope_chain->bindings))
1707 // Above macros are copied from gcc/cp/name-lookup.cc
1709 /* The various kinds of special functions. If you add to this list,
1710 you should update special_function_p as well. */
1711 enum special_function_kind
1713 sfk_none
= 0, /* Not a special function. This enumeral
1714 must have value zero; see
1715 special_function_p. */
1716 /* The following are ordered, for use by member synthesis fns. */
1717 sfk_destructor
, /* A destructor. */
1718 sfk_constructor
, /* A constructor. */
1719 sfk_inheriting_constructor
, /* An inheriting constructor */
1720 sfk_copy_constructor
, /* A copy constructor. */
1721 sfk_move_constructor
, /* A move constructor. */
1722 sfk_copy_assignment
, /* A copy assignment operator. */
1723 sfk_move_assignment
, /* A move assignment operator. */
1724 /* The following are unordered. */
1725 sfk_complete_destructor
, /* A destructor for complete objects. */
1726 sfk_base_destructor
, /* A destructor for base subobjects. */
1727 sfk_deleting_destructor
, /* A destructor for complete objects that
1728 deletes the object after it has been
1730 sfk_conversion
, /* A conversion operator. */
1731 sfk_deduction_guide
, /* A class template deduction guide. */
1732 sfk_comparison
, /* A comparison operator (e.g. ==, <, <=>). */
1733 sfk_virtual_destructor
/* Used by member synthesis fns. */
1736 /* Places where an lvalue, or modifiable lvalue, may be required.
1737 Used to select diagnostic messages in lvalue_error and
1748 /* A class for recording information about access failures (e.g. private
1749 fields), so that we can potentially supply a fix-it hint about
1750 an accessor (from a context in which the constness of the object
1753 class access_failure_info
1756 access_failure_info ()
1757 : m_was_inaccessible (false), m_basetype_path (NULL_TREE
),
1758 m_decl (NULL_TREE
), m_diag_decl (NULL_TREE
)
1761 void record_access_failure (tree basetype_path
, tree decl
, tree diag_decl
);
1763 bool was_inaccessible_p () const { return m_was_inaccessible
; }
1764 tree
get_decl () const { return m_decl
; }
1765 tree
get_diag_decl () const { return m_diag_decl
; }
1766 tree
get_any_accessor (bool const_p
) const;
1767 void maybe_suggest_accessor (bool const_p
) const;
1768 static void add_fixit_hint (rich_location
*richloc
, tree accessor
);
1771 bool m_was_inaccessible
;
1772 tree m_basetype_path
;
1777 /* The various kinds of access check during parsing. */
1780 dk_no_deferred
= 0, /* Check access immediately */
1781 dk_deferred
= 1, /* Deferred check */
1782 dk_no_check
= 2 /* No access check */
1785 /* The representation of a deferred access check. */
1787 struct GTY (()) deferred_access_check
1789 /* The base class in which the declaration is referenced. */
1791 /* The declaration whose access must be checked. */
1793 /* The declaration that should be used in the error message. */
1795 /* The location of this access. */
1799 struct GTY (()) tree_template_info
1801 struct tree_base base
;
1804 vec
<deferred_access_check
, va_gc
> *deferred_access_checks
;
1807 /* The various kinds of lvalues we distinguish. */
1808 enum cp_lvalue_kind_flags
1810 clk_none
= 0, /* Things that are not an lvalue. */
1811 clk_ordinary
= 1, /* An ordinary lvalue. */
1812 clk_rvalueref
= 2, /* An xvalue (rvalue formed using an rvalue reference) */
1813 clk_class
= 4, /* A prvalue of class or array type. */
1814 clk_bitfield
= 8, /* An lvalue for a bit-field. */
1815 clk_packed
= 16, /* An lvalue for a packed field. */
1816 clk_implicit_rval
= 1 << 5 /* An lvalue being treated as an xvalue. */
1819 /* This type is used for parameters and variables which hold
1820 combinations of the flags in enum cp_lvalue_kind_flags. */
1821 typedef int cp_lvalue_kind
;
1823 // forked from gcc/cp/name_lookup.h scope_kind
1825 /* The kinds of scopes we recognize. */
1828 sk_block
= 0, /* An ordinary block scope. This enumerator must
1829 have the value zero because "cp_binding_level"
1830 is initialized by using "memset" to set the
1831 contents to zero, and the default scope kind
1833 sk_cleanup
, /* A scope for (pseudo-)scope for cleanup. It is
1834 pseudo in that it is transparent to name lookup
1836 sk_try
, /* A try-block. */
1837 sk_catch
, /* A catch-block. */
1838 sk_for
, /* The scope of the variable declared in a
1840 sk_cond
, /* The scope of the variable declared in the condition
1841 of an if or switch statement. */
1842 sk_function_parms
, /* The scope containing function parameters. */
1843 sk_class
, /* The scope containing the members of a class. */
1844 sk_scoped_enum
, /* The scope containing the enumerators of a C++11
1845 scoped enumeration. */
1846 sk_namespace
, /* The scope containing the members of a
1847 namespace, including the global scope. */
1848 sk_template_parms
, /* A scope for template parameters. */
1849 sk_template_spec
, /* Like sk_template_parms, but for an explicit
1850 specialization. Since, by definition, an
1851 explicit specialization is introduced by
1852 "template <>", this scope is always empty. */
1853 sk_transaction
, /* A synchronized or atomic statement. */
1854 sk_omp
/* An OpenMP structured block. */
1857 // forked from gcc/cp/cp-tree.h cp_built_in_function
1859 /* BUILT_IN_FRONTEND function codes. */
1860 enum cp_built_in_function
1862 CP_BUILT_IN_IS_CONSTANT_EVALUATED
,
1863 CP_BUILT_IN_INTEGER_PACK
,
1864 CP_BUILT_IN_IS_CORRESPONDING_MEMBER
,
1865 CP_BUILT_IN_IS_POINTER_INTERCONVERTIBLE_WITH_CLASS
,
1866 CP_BUILT_IN_SOURCE_LOCATION
,
1870 // forked from gcc/cp/cp-tree.h warning_sentinel
1872 /* RAII sentinel to disable certain warnings during template substitution
1875 class warning_sentinel
1880 warning_sentinel (int &flag
, bool suppress
= true) : flag (flag
), val (flag
)
1885 ~warning_sentinel () { flag
= val
; }
1888 // forked from gcc/cp/cp-tree.h uid_sensitive_constexpr_evaluation_checker
1890 /* Used to determine whether uid_sensitive_constexpr_evaluation_p was
1891 called and returned true, indicating that we've restricted constexpr
1892 evaluation in order to avoid UID generation. We use this to control
1893 updates to the fold_cache and cv_cache. */
1895 struct uid_sensitive_constexpr_evaluation_checker
1897 const unsigned saved_counter
;
1898 uid_sensitive_constexpr_evaluation_checker ();
1899 bool evaluation_restricted_p () const;
1902 // forked from gcc/cp/cp-tree.h iloc_sentinel
1904 /* RAII sentinel to temporarily override input_location. This will not set
1905 input_location to UNKNOWN_LOCATION or BUILTINS_LOCATION. */
1909 location_t saved_loc
;
1912 iloc_sentinel (location_t loc
) : saved_loc (input_location
)
1914 if (loc
>= RESERVED_LOCATION_COUNT
)
1915 input_location
= loc
;
1917 ~iloc_sentinel () { input_location
= saved_loc
; }
1920 // forked from gcc/cp/cp-tree.h ptrmem_cst
1922 struct GTY (()) ptrmem_cst
1924 struct tree_common common
;
1928 typedef struct ptrmem_cst
*ptrmem_cst_t
;
1930 // forked from gcc/cp/cp-tree.h named_decl_hash
1932 /* hash traits for declarations. Hashes potential overload sets via
1935 struct rust_named_decl_hash
: ggc_remove
<tree
>
1937 typedef tree value_type
; /* A DECL or OVERLOAD */
1938 typedef tree compare_type
; /* An identifier. */
1940 inline static hashval_t
hash (const value_type decl
);
1941 inline static bool equal (const value_type existing
, compare_type candidate
);
1943 static const bool empty_zero_p
= true;
1944 static inline void mark_empty (value_type
&p
) { p
= NULL_TREE
; }
1945 static inline bool is_empty (value_type p
) { return !p
; }
1947 /* Nothing is deletable. Everything is insertable. */
1948 static bool is_deleted (value_type
) { return false; }
1949 static void mark_deleted (value_type
) { rust_unreachable (); }
1952 // forked from gcc/cp/cp-tree.h lang_decl_selector
1954 /* Discriminator values for lang_decl. */
1956 enum lang_decl_selector
1965 // forked from gcc/cp/cp-tree.h lang_decl_base
1967 /* Flags shared by all forms of DECL_LANG_SPECIFIC.
1969 Some of the flags live here only to make lang_decl_min/fn smaller. Do
1970 not make this struct larger than 32 bits. */
1972 struct GTY (()) lang_decl_base
1974 ENUM_BITFIELD (lang_decl_selector
) selector
: 3;
1975 unsigned use_template
: 2;
1976 unsigned not_really_extern
: 1; /* var or fn */
1977 unsigned initialized_in_class
: 1; /* var or fn */
1979 unsigned threadprivate_or_deleted_p
: 1; /* var or fn */
1980 /* anticipated_p is no longer used for anticipated_decls (fn, type
1981 or template). It is used as DECL_OMP_PRIVATIZED_MEMBER in
1983 unsigned anticipated_p
: 1;
1984 unsigned friend_or_tls
: 1; /* var, fn, type or template */
1985 unsigned unknown_bound_p
: 1; /* var */
1986 unsigned odr_used
: 1; /* var or fn */
1987 unsigned concept_p
: 1; /* applies to vars and functions */
1988 unsigned var_declared_inline_p
: 1; /* var */
1989 unsigned dependent_init_p
: 1; /* var */
1991 /* The following apply to VAR, FUNCTION, TYPE, CONCEPT, & NAMESPACE
1993 unsigned module_purview_p
: 1; /* in module purview (not GMF) */
1994 unsigned module_import_p
: 1; /* from an import */
1995 unsigned module_entity_p
: 1; /* is in the entitity ary &
1997 /* VAR_DECL or FUNCTION_DECL has attached decls. */
1998 unsigned module_attached_p
: 1;
2000 /* 12 spare bits. */
2003 /* True for DECL codes which have template info and access. */
2004 #define LANG_DECL_HAS_MIN(NODE) \
2005 (VAR_OR_FUNCTION_DECL_P (NODE) || TREE_CODE (NODE) == FIELD_DECL \
2006 || TREE_CODE (NODE) == CONST_DECL || TREE_CODE (NODE) == TYPE_DECL \
2007 || TREE_CODE (NODE) == TEMPLATE_DECL || TREE_CODE (NODE) == USING_DECL \
2008 || TREE_CODE (NODE) == CONCEPT_DECL)
2010 // forked from gcc/c-family-common.h c_language_function
2012 /* Global state pertinent to the current function. Some C dialects
2013 extend this structure with additional fields. */
2015 struct GTY (()) c_language_function
2017 /* Vector of locally defined typedefs, for
2018 -Wunused-local-typedefs. */
2019 vec
<tree
, va_gc
> *local_typedefs
;
2022 // forked from gcc/cp/cp-tree.h omp_declare_target_attr
2024 struct GTY (()) omp_declare_target_attr
2029 // forked from gcc/cp/name-lookup.h cxx_binding
2031 /* Datatype that represents binding established by a declaration between
2032 a name and a C++ entity. */
2033 struct GTY (()) cxx_binding
2035 /* Link to chain together various bindings for this name. */
2036 cxx_binding
*previous
;
2037 /* The non-type entity this name is bound to. */
2039 /* The type entity this name is bound to. */
2042 bool value_is_inherited
: 1;
2044 bool type_is_hidden
: 1;
2047 // forked from gcc/cp/name-lookup.h cxx_saved_binding
2049 /* Datatype used to temporarily save C++ bindings (for implicit
2050 instantiations purposes and like). Implemented in decl.cc. */
2051 struct GTY (()) rust_cxx_saved_binding
2053 /* The name of the current binding. */
2055 /* The binding we're saving. */
2056 cxx_binding
*binding
;
2057 tree real_type_value
;
2060 // forked from gcc/cp/name-lookup.h resort_type_member_vec
2062 /* needed for GTY annotation */
2064 resort_type_member_vec (void *, void *, gt_pointer_operator
, void *);
2066 // forked from gcc/cp/cp-tree.h saved_scope
2070 struct GTY (()) saved_scope
2072 vec
<rust_cxx_saved_binding
, va_gc
> *old_bindings
;
2074 vec
<tree
, va_gc
> *decl_ns_list
;
2077 tree access_specifier
;
2079 vec
<tree
, va_gc
> *lang_base
;
2081 tree template_parms
;
2084 /* Only used for uses of this in trailing return type. */
2085 tree x_current_class_ptr
;
2086 tree x_current_class_ref
;
2088 int x_processing_template_decl
;
2089 int x_processing_specialization
;
2090 int x_processing_constraint
;
2091 int suppress_location_wrappers
;
2092 BOOL_BITFIELD x_processing_explicit_instantiation
: 1;
2093 BOOL_BITFIELD need_pop_function_context
: 1;
2095 /* Nonzero if we are parsing the discarded statement of a constexpr
2097 BOOL_BITFIELD discarded_stmt
: 1;
2098 /* Nonzero if we are parsing or instantiating the compound-statement
2099 of consteval if statement. Also set while processing an immediate
2101 BOOL_BITFIELD consteval_if_p
: 1;
2103 int unevaluated_operand
;
2104 int inhibit_evaluation_warnings
;
2105 int noexcept_operand
;
2108 hash_map
<tree
, tree
> *GTY ((skip
)) x_local_specializations
;
2109 vec
<omp_declare_target_attr
, va_gc
> *omp_declare_target_attribute
;
2111 struct saved_scope
*prev
;
2114 extern GTY (()) struct saved_scope
*scope_chain
;
2116 // forked from gcc/cp/name_lookup.h cp_class_binding
2118 struct GTY (()) rust_cp_class_binding
2121 /* The bound name. */
2125 // forked from gcc/cp/name_lookup.h cp_binding_level
2127 /* For each binding contour we allocate a binding_level structure
2128 which records the names defined in that contour.
2131 1) one for each function definition,
2132 where internal declarations of the parameters appear.
2133 2) one for each compound statement,
2134 to record its declarations.
2136 The current meaning of a name can be found by searching the levels
2137 from the current one out to the global one.
2139 Off to the side, may be the class_binding_level. This exists only
2140 to catch class-local declarations. It is otherwise nonexistent.
2142 Also there may be binding levels that catch cleanups that must be
2143 run when exceptions occur. Thus, to see whether a name is bound in
2144 the current scope, it is not enough to look in the
2145 CURRENT_BINDING_LEVEL. You should use lookup_name_current_level
2148 struct GTY (()) rust_cp_binding_level
2150 /* A chain of _DECL nodes for all variables, constants, functions,
2151 and typedef types. These are in the reverse of the order
2152 supplied. There may be OVERLOADs on this list, too, but they
2153 are wrapped in TREE_LISTs; the TREE_VALUE is the OVERLOAD. */
2156 /* Using directives. */
2157 vec
<tree
, va_gc
> *using_directives
;
2159 /* For the binding level corresponding to a class, the entities
2160 declared in the class or its base classes. */
2161 vec
<rust_cp_class_binding
, va_gc
> *class_shadowed
;
2163 /* Similar to class_shadowed, but for IDENTIFIER_TYPE_VALUE, and
2164 is used for all binding levels. The TREE_PURPOSE is the name of
2165 the entity, the TREE_TYPE is the associated type. In addition
2166 the TREE_VALUE is the IDENTIFIER_TYPE_VALUE before we entered
2170 /* For each level (except not the global one),
2171 a chain of BLOCK nodes for all the levels
2172 that were entered and exited one level down. */
2175 /* The entity (namespace, class, function) the scope of which this
2176 binding contour corresponds to. Otherwise NULL. */
2179 /* The binding level which this one is contained in (inherits from). */
2180 rust_cp_binding_level
*level_chain
;
2182 /* STATEMENT_LIST for statements in this binding contour.
2183 Only used at present for SK_CLEANUP temporary bindings. */
2184 tree statement_list
;
2186 /* Binding depth at which this level began. */
2189 /* The kind of scope that this object represents. However, a
2190 SK_TEMPLATE_SPEC scope is represented with KIND set to
2191 SK_TEMPLATE_PARMS and EXPLICIT_SPEC_P set to true. */
2192 ENUM_BITFIELD (scope_kind
) kind
: 4;
2194 /* True if this scope is an SK_TEMPLATE_SPEC scope. This field is
2195 only valid if KIND == SK_TEMPLATE_PARMS. */
2196 BOOL_BITFIELD explicit_spec_p
: 1;
2198 /* true means make a BLOCK for this level regardless of all else. */
2201 /* Nonzero if this level can safely have additional
2202 cleanup-needing variables added to it. */
2203 unsigned more_cleanups_ok
: 1;
2204 unsigned have_cleanups
: 1;
2206 /* Transient state set if this scope is of sk_class kind
2207 and is in the process of defining 'this_entity'. Reset
2208 on leaving the class definition to allow for the scope
2209 to be subsequently re-used as a non-defining scope for
2211 unsigned defining_class_p
: 1;
2213 /* True for SK_FUNCTION_PARMS of a requires-expression. */
2214 unsigned requires_expression
: 1;
2216 /* 22 bits left to fill a 32-bit word. */
2219 // forked from gcc/cp/decl.cc named_label_entry
2221 /* A list of all LABEL_DECLs in the function that have names. Here so
2222 we can clear out their names' definitions at the end of the
2223 function, and so we can check the validity of jumps to these labels. */
2225 struct GTY ((for_user
)) rust_named_label_entry
2227 tree name
; /* Name of decl. */
2229 tree label_decl
; /* LABEL_DECL, unless deleted local label. */
2231 rust_named_label_entry
*outer
; /* Outer shadowed chain. */
2233 /* The binding level to which the label is *currently* attached.
2234 This is initially set to the binding level in which the label
2235 is defined, but is modified as scopes are closed. */
2236 rust_cp_binding_level
*binding_level
;
2238 /* The head of the names list that was current when the label was
2239 defined, or the inner scope popped. These are the decls that will
2240 be skipped when jumping to the label. */
2241 tree names_in_scope
;
2243 /* A vector of all decls from all binding levels that would be
2244 crossed by a backward branch to the label. */
2245 vec
<tree
, va_gc
> *bad_decls
;
2247 /* The following bits are set after the label is defined, and are
2248 updated as scopes are popped. They indicate that a jump to the
2249 label will illegally enter a scope of the given flavor. */
2251 bool in_catch_scope
;
2253 bool in_transaction_scope
;
2254 bool in_constexpr_if
;
2255 bool in_consteval_if
;
2259 // forked from gcc/cp/cp-tree.h named_label_hash
2261 struct rust_named_label_hash
: ggc_remove
<rust_named_label_entry
*>
2263 typedef rust_named_label_entry
*value_type
;
2264 typedef tree compare_type
; /* An identifier. */
2266 inline static hashval_t
hash (value_type
);
2267 inline static bool equal (const value_type
, compare_type
);
2269 static const bool empty_zero_p
= true;
2270 inline static void mark_empty (value_type
&p
) { p
= NULL
; }
2271 inline static bool is_empty (value_type p
) { return !p
; }
2273 /* Nothing is deletable. Everything is insertable. */
2274 inline static bool is_deleted (value_type
) { return false; }
2275 inline static void mark_deleted (value_type
) { rust_unreachable (); }
2278 // forked from gcc/cp/cp-tree.h
2280 /* Global state pertinent to the current function.
2281 TODO: remove vestigial fields */
2283 struct GTY (()) language_function
2285 struct c_language_function base
;
2288 tree x_current_class_ptr
;
2289 tree x_current_class_ref
;
2290 tree x_eh_spec_block
;
2291 tree x_in_charge_parm
;
2293 tree x_return_value
;
2295 BOOL_BITFIELD returns_value
: 1;
2296 BOOL_BITFIELD returns_null
: 1;
2297 BOOL_BITFIELD returns_abnormally
: 1;
2298 BOOL_BITFIELD infinite_loop
: 1;
2299 BOOL_BITFIELD x_in_function_try_handler
: 1;
2300 BOOL_BITFIELD x_in_base_initializer
: 1;
2302 /* True if this function can throw an exception. */
2303 BOOL_BITFIELD can_throw
: 1;
2305 BOOL_BITFIELD invalid_constexpr
: 1;
2306 BOOL_BITFIELD throwing_cleanup
: 1;
2308 hash_table
<rust_named_label_hash
> *x_named_labels
;
2310 /* Tracking possibly infinite loops. This is a vec<tree> only because
2311 vec<bool> doesn't work with gtype. */
2312 vec
<tree
, va_gc
> *infinite_loops
;
2315 // forked from gcc/c-family/c-common.h ref_operator
2317 /* The various name of operator that appears in error messages. */
2322 /* array indexing */
2328 /* implicit conversion */
2329 RO_IMPLICIT_CONVERSION
,
2334 // forked from gcc/cp/cp-tree.h lang_decl_min
2336 /* DECL_LANG_SPECIFIC for the above codes. */
2338 struct GTY (()) lang_decl_min
2340 struct lang_decl_base base
; /* 32-bits. */
2342 /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
2344 In a FUNCTION_DECL for which DECL_THUNK_P does not hold,
2345 VAR_DECL, TYPE_DECL, or TEMPLATE_DECL, this is
2346 DECL_TEMPLATE_INFO. */
2349 /* In a DECL_THUNK_P FUNCTION_DECL, this is THUNK_VIRTUAL_OFFSET.
2350 In a lambda-capture proxy VAR_DECL, this is DECL_CAPTURED_VARIABLE.
2351 In a function-scope TREE_STATIC VAR_DECL or IMPLICIT_TYPEDEF_P TYPE_DECL,
2352 this is DECL_DISCRIMINATOR.
2353 In a DECL_LOCAL_DECL_P decl, this is the namespace decl it aliases.
2354 Otherwise, in a class-scope DECL, this is DECL_ACCESS. */
2358 // forked from gcc/cp/cp-tree.h lang_decl_fn
2360 /* Additional DECL_LANG_SPECIFIC information for functions. */
2362 struct GTY (()) lang_decl_fn
2364 struct lang_decl_min min
;
2366 /* In a overloaded operator, this is the compressed operator code. */
2367 unsigned ovl_op_code
: 6;
2368 unsigned global_ctor_p
: 1;
2369 unsigned global_dtor_p
: 1;
2371 unsigned static_function
: 1;
2372 unsigned pure_virtual
: 1;
2373 unsigned defaulted_p
: 1;
2374 unsigned has_in_charge_parm_p
: 1;
2375 unsigned has_vtt_parm_p
: 1;
2376 unsigned nonconverting
: 1;
2377 unsigned thunk_p
: 1;
2379 unsigned this_thunk_p
: 1;
2380 unsigned omp_declare_reduction_p
: 1;
2381 unsigned has_dependent_explicit_spec_p
: 1;
2382 unsigned immediate_fn_p
: 1;
2383 unsigned maybe_deleted
: 1;
2384 unsigned coroutine_p
: 1;
2385 unsigned implicit_constexpr
: 1;
2387 unsigned spare
: 10;
2389 /* 32-bits padding on 64-bit host. */
2391 /* For a non-thunk function decl, this is a tree list of
2392 friendly classes. For a thunk function decl, it is the
2393 thunked to function decl. */
2394 tree befriending_classes
;
2396 /* For a virtual FUNCTION_DECL for which
2397 DECL_THIS_THUNK_P does not hold, this is DECL_THUNKS. Both
2398 this pointer and result pointer adjusting thunks are
2399 chained here. This pointer thunks to return pointer thunks
2400 will be chained on the return pointer thunk.
2401 For a DECL_CONSTUCTOR_P FUNCTION_DECL, this is the base from
2402 whence we inherit. Otherwise, it is the class in which a
2403 (namespace-scope) friend is defined (if any). */
2408 /* In a non-thunk FUNCTION_DECL, this is DECL_CLONED_FUNCTION. */
2409 tree
GTY ((tag ("0"))) cloned_function
;
2411 /* In a FUNCTION_DECL for which THUNK_P holds this is the
2412 THUNK_FIXED_OFFSET. */
2413 HOST_WIDE_INT
GTY ((tag ("1"))) fixed_offset
;
2414 } GTY ((desc ("%1.thunk_p"))) u5
;
2416 tree
GTY (()) saved_auto_return_type
;
2419 // forked from gcc/cp/cp-tree.h lang_decl_ns
2421 /* DECL_LANG_SPECIFIC for namespaces. */
2423 struct GTY (()) lang_decl_ns
2425 struct lang_decl_base base
; /* 32 bits. */
2427 /* Inline children. Needs to be va_gc, because of PCH. */
2428 vec
<tree
, va_gc
> *inlinees
;
2430 /* Hash table of bound decls. It'd be nice to have this inline, but
2431 as the hash_map has a dtor, we can't then put this struct into a
2432 union (until moving to c++11). */
2433 hash_table
<rust_named_decl_hash
> *bindings
;
2436 // forked from gcc/cp/cp-tree.h lang_decl_parm
2438 /* DECL_LANG_SPECIFIC for parameters. */
2440 struct GTY (()) lang_decl_parm
2442 struct lang_decl_base base
; /* 32 bits. */
2447 // forked from gcc/cp/cp-tree.h lang_decl_decomp
2449 /* Additional DECL_LANG_SPECIFIC information for structured bindings. */
2451 struct GTY (()) lang_decl_decomp
2453 struct lang_decl_min min
;
2454 /* The artificial underlying "e" variable of the structured binding
2459 // forked from gcc/cp/cp-tree.h lang_decl
2461 /* DECL_LANG_SPECIFIC for all types. It would be nice to just make this a
2462 union rather than a struct containing a union as its only field, but
2463 tree.h declares it as a struct. */
2465 struct GTY (()) lang_decl
2467 union GTY ((desc ("%h.base.selector"))) lang_decl_u
2469 /* Nothing of only the base type exists. */
2470 struct lang_decl_base
GTY ((default)) base
;
2471 struct lang_decl_min
GTY ((tag ("lds_min"))) min
;
2472 struct lang_decl_fn
GTY ((tag ("lds_fn"))) fn
;
2473 struct lang_decl_ns
GTY ((tag ("lds_ns"))) ns
;
2474 struct lang_decl_parm
GTY ((tag ("lds_parm"))) parm
;
2475 struct lang_decl_decomp
GTY ((tag ("lds_decomp"))) decomp
;
2479 // forked from gcc/c-family/c-common.h c_fileinfo
2481 /* Information recorded about each file examined during compilation. */
2485 int time
; /* Time spent in the file. */
2487 /* Flags used only by C++.
2488 INTERFACE_ONLY nonzero means that we are in an "interface" section
2489 of the compiler. INTERFACE_UNKNOWN nonzero means we cannot trust
2490 the value of INTERFACE_ONLY. If INTERFACE_UNKNOWN is zero and
2491 INTERFACE_ONLY is zero, it means that we are responsible for
2492 exporting definitions that others might need. */
2493 short interface_only
;
2494 short interface_unknown
;
2497 // forked from gcc/c-family/c-common.h c_common_identifier
2499 /* Identifier part common to the C front ends. Inherits from
2500 tree_identifier, despite appearances. */
2501 struct GTY (()) c_common_identifier
2503 struct tree_common common
;
2504 struct cpp_hashnode node
; // from cpplib.h
2507 // forked from gcc/cp/cp-tree.h lang_identifier
2509 /* Language-dependent contents of an identifier. */
2511 struct GTY (()) lang_identifier
2513 struct c_common_identifier c_common
;
2514 cxx_binding
*bindings
;
2517 // forked from gcc/cp/cp-tree.h tree_overload
2519 /* OVL_HIDDEN_P nodes come before other nodes. */
2521 struct GTY (()) tree_overload
2523 struct tree_common common
;
2527 // forked from gcc/cp/cp-tree.h ovl_iterator
2532 const bool allow_inner
; /* Only used when checking. */
2535 explicit ovl_iterator (tree o
, bool allow
= false)
2536 : ovl (o
), allow_inner (allow
)
2540 operator bool () const { return ovl
; }
2541 ovl_iterator
&operator++ ()
2543 ovl
= TREE_CODE (ovl
) != OVERLOAD
? NULL_TREE
: OVL_CHAIN (ovl
);
2546 tree
operator* () const
2548 tree fn
= TREE_CODE (ovl
) != OVERLOAD
? ovl
: OVL_FUNCTION (ovl
);
2550 /* Check this is not an unexpected 2-dimensional overload. */
2551 gcc_checking_assert (allow_inner
|| TREE_CODE (fn
) != OVERLOAD
);
2555 bool operator== (const ovl_iterator
&o
) const { return ovl
== o
.ovl
; }
2556 tree
get_using () const
2558 gcc_checking_assert (using_p ());
2563 /* Whether this overload was introduced by a using decl. */
2564 bool using_p () const
2566 return (TREE_CODE (ovl
) == USING_DECL
2567 || (TREE_CODE (ovl
) == OVERLOAD
&& OVL_USING_P (ovl
)));
2569 /* Whether this using is being exported. */
2570 bool exporting_p () const { return OVL_EXPORT_P (get_using ()); }
2572 bool hidden_p () const
2574 return TREE_CODE (ovl
) == OVERLOAD
&& OVL_HIDDEN_P (ovl
);
2578 tree
remove_node (tree head
) { return remove_node (head
, ovl
); }
2579 tree
reveal_node (tree head
) { return reveal_node (head
, ovl
); }
2582 /* If we have a nested overload, point at the inner overload and
2583 return the next link on the outer one. */
2588 if (ovl
&& TREE_CODE (ovl
) == OVERLOAD
&& OVL_NESTED_P (ovl
))
2590 r
= OVL_CHAIN (ovl
);
2591 ovl
= OVL_FUNCTION (ovl
);
2595 /* Restore an outer nested overload. */
2596 void pop (tree outer
)
2598 gcc_checking_assert (!ovl
);
2603 /* We make these static functions to avoid the address of the
2604 iterator escaping the local context. */
2605 static tree
remove_node (tree head
, tree node
);
2606 static tree
reveal_node (tree ovl
, tree node
);
2609 // forked from gcc/cp/cp-tree.h lkp_iterator
2611 /* Iterator over a (potentially) 2 dimensional overload, which is
2612 produced by name lookup. */
2614 class lkp_iterator
: public ovl_iterator
2616 typedef ovl_iterator parent
;
2621 explicit lkp_iterator (tree o
) : parent (o
, true), outer (maybe_push ()) {}
2624 lkp_iterator
&operator++ ()
2626 bool repush
= !outer
;
2628 if (!parent::operator++ () && !repush
)
2635 outer
= maybe_push ();
2641 // forked from gcc/cp/cp-tree.h treee_pair_s
2643 struct GTY (()) rust_tree_pair_s
2649 // forked from gcc/cp/cp-tree.h tree_pair_p
2651 typedef rust_tree_pair_s
*rust_tree_pair_p
;
2653 // forked from gcc/cp/cp-tree.h lang_type
2655 /* This structure provides additional information above and beyond
2656 what is provide in the ordinary tree_type. In the past, we used it
2657 for the types of class types, template parameters types, typename
2658 types, and so forth. However, there can be many (tens to hundreds
2659 of thousands) of template parameter types in a compilation, and
2660 there's no need for this additional information in that case.
2661 Therefore, we now use this data structure only for class types.
2663 In the past, it was thought that there would be relatively few
2664 class types. However, in the presence of heavy use of templates,
2665 many (i.e., thousands) of classes can easily be generated.
2666 Therefore, we should endeavor to keep the size of this structure to
2668 struct GTY (()) lang_type
2670 unsigned char align
;
2672 unsigned has_type_conversion
: 1;
2673 unsigned has_copy_ctor
: 1;
2674 unsigned has_default_ctor
: 1;
2675 unsigned const_needs_init
: 1;
2676 unsigned ref_needs_init
: 1;
2677 unsigned has_const_copy_assign
: 1;
2678 unsigned use_template
: 2;
2680 unsigned has_mutable
: 1;
2681 unsigned com_interface
: 1;
2682 unsigned non_pod_class
: 1;
2683 unsigned nearly_empty_p
: 1;
2684 unsigned user_align
: 1;
2685 unsigned has_copy_assign
: 1;
2686 unsigned has_new
: 1;
2687 unsigned has_array_new
: 1;
2689 unsigned gets_delete
: 2;
2690 unsigned interface_only
: 1;
2691 unsigned interface_unknown
: 1;
2692 unsigned contains_empty_class_p
: 1;
2693 unsigned anon_aggr
: 1;
2694 unsigned non_zero_init
: 1;
2695 unsigned empty_p
: 1;
2696 /* 32 bits allocated. */
2698 unsigned vec_new_uses_cookie
: 1;
2699 unsigned declared_class
: 1;
2700 unsigned diamond_shaped
: 1;
2701 unsigned repeated_base
: 1;
2702 unsigned being_defined
: 1;
2703 unsigned debug_requested
: 1;
2704 unsigned fields_readonly
: 1;
2705 unsigned ptrmemfunc_flag
: 1;
2707 unsigned lazy_default_ctor
: 1;
2708 unsigned lazy_copy_ctor
: 1;
2709 unsigned lazy_copy_assign
: 1;
2710 unsigned lazy_destructor
: 1;
2711 unsigned has_const_copy_ctor
: 1;
2712 unsigned has_complex_copy_ctor
: 1;
2713 unsigned has_complex_copy_assign
: 1;
2714 unsigned non_aggregate
: 1;
2716 unsigned has_complex_dflt
: 1;
2717 unsigned has_list_ctor
: 1;
2718 unsigned non_std_layout
: 1;
2719 unsigned is_literal
: 1;
2720 unsigned lazy_move_ctor
: 1;
2721 unsigned lazy_move_assign
: 1;
2722 unsigned has_complex_move_ctor
: 1;
2723 unsigned has_complex_move_assign
: 1;
2725 unsigned has_constexpr_ctor
: 1;
2726 unsigned unique_obj_representations
: 1;
2727 unsigned unique_obj_representations_set
: 1;
2729 bool non_pod_aggregate
: 1;
2731 /* When adding a flag here, consider whether or not it ought to
2732 apply to a template instance if it applies to the template. If
2733 so, make sure to copy it in instantiate_class_template! */
2735 /* There are some bits left to fill out a 32-bit word. Keep track
2736 of this by updating the size of this bitfield whenever you add or
2741 vec
<rust_tree_pair_s
, va_gc
> *vcall_indices
;
2744 vec
<tree
, va_gc
> *vbases
;
2746 vec
<tree
, va_gc
> *pure_virtuals
;
2747 tree friend_classes
;
2748 vec
<tree
, va_gc
> *GTY ((reorder ("resort_type_member_vec"))) members
;
2751 tree befriending_classes
;
2752 /* In a RECORD_TYPE, information specific to Objective-C++, such
2753 as a list of adopted protocols or a pointer to a corresponding
2754 @interface. See objc/objc-act.h for details. */
2756 /* FIXME reuse another field? */
2762 // forked from gcc/cp/cp-tree.h cp_ref_qualifier
2764 enum rs_ref_qualifier
2767 REF_QUAL_LVALUE
= 1,
2771 // forked from gcc/cp/cp-tree.h tsubst_flags
2773 /* Bitmask flags to control type substitution. */
2776 tf_none
= 0, /* nothing special */
2777 tf_error
= 1 << 0, /* give error messages */
2778 tf_warning
= 1 << 1, /* give warnings too */
2779 tf_ignore_bad_quals
= 1 << 2, /* ignore bad cvr qualifiers */
2780 tf_keep_type_decl
= 1 << 3, /* retain typedef type decls
2781 (make_typename_type use) */
2782 tf_ptrmem_ok
= 1 << 4, /* pointers to member ok (internal
2783 instantiate_type use) */
2784 tf_user
= 1 << 5, /* found template must be a user template
2785 (lookup_template_class use) */
2786 tf_conv
= 1 << 6, /* We are determining what kind of
2787 conversion might be permissible,
2788 not actually performing the
2790 tf_decltype
= 1 << 7, /* We are the operand of decltype.
2791 Used to implement the special rules
2792 for calls in decltype (5.2.2/11). */
2793 tf_partial
= 1 << 8, /* Doing initial explicit argument
2794 substitution in fn_type_unification. */
2795 tf_fndecl_type
= 1 << 9, /* Substituting the type of a function
2797 tf_no_cleanup
= 1 << 10, /* Do not build a cleanup
2798 (build_target_expr and friends) */
2799 tf_norm
= 1 << 11, /* Build diagnostic information during
2800 constraint normalization. */
2801 /* Convenient substitution flags combinations. */
2802 tf_warning_or_error
= tf_warning
| tf_error
2805 // forked from gcc/cp/cp-tree.h cp_identifier_kind
2807 /* Kinds of identifiers. Values are carefully chosen. */
2808 enum cp_identifier_kind
2810 cik_normal
= 0, /* Not a special identifier. */
2811 cik_keyword
= 1, /* A keyword. */
2812 cik_ctor
= 2, /* Constructor (in-chg, complete or base). */
2813 cik_dtor
= 3, /* Destructor (in-chg, deleting, complete or
2815 cik_simple_op
= 4, /* Non-assignment operator name. */
2816 cik_assign_op
= 5, /* An assignment operator name. */
2817 cik_conv_op
= 6, /* Conversion operator name. */
2818 cik_reserved_for_udlit
= 7, /* Not yet in use */
2822 // forked from gcc/cp/cp-tree.h tag_types
2824 /* An enumeration of the kind of tags that C++ accepts. */
2827 none_type
= 0, /* Not a tag type. */
2828 record_type
, /* "struct" types. */
2829 class_type
, /* "class" types. */
2830 union_type
, /* "union" types. */
2831 enum_type
, /* "enum" types. */
2832 typename_type
, /* "typename" types. */
2833 scope_type
/* namespace or tagged type name followed by :: */
2836 // forked from gcc/cp/cp-tree.h tsubst_flags_t
2838 /* This type is used for parameters and variables which hold
2839 combinations of the flags in enum tsubst_flags. */
2840 typedef int tsubst_flags_t
;
2842 // forked from gcc/cp/cvt.cc convert_to_void
2844 // When an expression is used in a void context, its value is discarded and
2845 // no lvalue-rvalue and similar conversions happen [expr.static.cast/4,
2846 // stmt.expr/1, expr.comma/1]. This permits dereferencing an incomplete type
2847 // in a void context. The C++ standard does not define what an `access' to an
2848 // object is, but there is reason to believe that it is the lvalue to rvalue
2849 // conversion -- if it were not, `*&*p = 1' would violate [expr]/4 in that it
2850 // accesses `*p' not to calculate the value to be stored. But, dcl.type.cv/8
2851 // indicates that volatile semantics should be the same between C and C++
2852 // where ever possible. C leaves it implementation defined as to what
2853 // constitutes an access to a volatile. So, we interpret `*vp' as a read of
2854 // the volatile object `vp' points to, unless that is an incomplete type. For
2855 // volatile references we do not do this interpretation, because that would
2856 // make it impossible to ignore the reference return value from functions. We
2857 // issue warnings in the confusing cases.
2859 // The IMPLICIT is ICV_CAST when the user is explicitly converting an
2860 // expression to void via a cast. If an expression is being implicitly
2861 // converted, IMPLICIT indicates the context of the implicit conversion.
2863 /* Possible cases of implicit or explicit bad conversions to void. */
2866 ICV_CAST
, /* (explicit) conversion to void */
2867 ICV_SECOND_OF_COND
, /* second operand of conditional expression */
2868 ICV_THIRD_OF_COND
, /* third operand of conditional expression */
2869 ICV_RIGHT_OF_COMMA
, /* right operand of comma operator */
2870 ICV_LEFT_OF_COMMA
, /* left operand of comma operator */
2871 ICV_STATEMENT
, /* statement */
2872 ICV_THIRD_IN_FOR
/* for increment expression */
2875 /* BUILT_IN_FRONTEND function codes. */
2876 enum rs_built_in_function
2878 RS_BUILT_IN_IS_CONSTANT_EVALUATED
,
2879 RS_BUILT_IN_INTEGER_PACK
,
2880 RS_BUILT_IN_IS_CORRESPONDING_MEMBER
,
2881 RS_BUILT_IN_IS_POINTER_INTERCONVERTIBLE_WITH_CLASS
,
2882 RS_BUILT_IN_SOURCE_LOCATION
,
2886 // forked from gcc/cp/cp-tree.h compare_bounds_t
2889 /* Says how we should behave when comparing two arrays one of which
2890 has unknown bounds. */
2891 enum compare_bounds_t
2899 convert_to_void (tree expr
, impl_conv_void implicit
);
2901 // The lvalue-to-rvalue conversion (7.1) is applied if and only if the
2902 // expression is a glvalue of volatile-qualified type and it is one of the
2904 // * ( expression ), where expression is one of these expressions,
2905 // * id-expression (8.1.4),
2906 // * subscripting (8.2.1),
2907 // * class member access (8.2.5),
2908 // * indirection (8.3.1),
2909 // * pointer-to-member operation (8.5),
2910 // * conditional expression (8.16) where both the second and the third
2911 // operands are one of these expressions, or
2912 // * comma expression (8.19) where the right operand is one of these
2915 mark_discarded_use (tree expr
);
2917 // Mark EXP as read, not just set, for set but not used -Wunused warning
2920 mark_exp_read (tree exp
);
2922 // We've seen an actual use of EXPR. Possibly replace an outer variable
2923 // reference inside with its constant value or a lambda capture.
2925 mark_use (tree expr
, bool rvalue_p
, bool read_p
, location_t loc
,
2926 bool reject_builtin
);
2928 // Called whenever the expression EXPR is used in an rvalue context.
2929 // When REJECT_BUILTIN is true the expression is checked to make sure
2930 // it doesn't make it possible to obtain the address of a GCC built-in
2931 // function with no library fallback (or any of its bits, such as in
2932 // a conversion to bool).
2934 mark_rvalue_use (tree
, location_t
= UNKNOWN_LOCATION
,
2935 bool reject_builtin
= true);
2937 // Called whenever an expression is used in an lvalue context.
2939 mark_lvalue_use (tree expr
);
2941 // As above, but don't consider this use a read.
2943 mark_lvalue_use_nonread (tree expr
);
2945 // We are using a reference VAL for its value. Bash that reference all the way
2946 // down to its lowest form.
2948 convert_from_reference (tree val
);
2950 // Subroutine of convert_to_void. Warn if we're discarding something with
2951 // attribute [[nodiscard]].
2953 maybe_warn_nodiscard (tree expr
, impl_conv_void implicit
);
2956 expr_loc_or_loc (const_tree t
, location_t or_loc
);
2959 expr_loc_or_input_loc (const_tree t
);
2961 // FN is the callee of a CALL_EXPR or AGGR_INIT_EXPR; return the FUNCTION_DECL
2964 get_fndecl_from_callee (tree fn
);
2966 // FIXME some helpers from HIRCompileBase could probably be moved here over time
2968 // Return an expression for the address of BASE[INDEX], used in offset intrinsic
2970 pointer_offset_expression (tree base_tree
, tree index_tree
, location_t locus
);
2972 /* A tree node, together with a location, so that we can track locations
2973 (and ranges) during parsing.
2975 The location is redundant for node kinds that have locations,
2976 but not all node kinds do (e.g. constants, and references to
2977 params, locals, etc), so we stash a copy here. */
2979 extern location_t
rs_expr_location (const_tree
);
2982 is_empty_class (tree type
);
2985 is_really_empty_class (tree
, bool);
2987 extern bool builtin_valid_in_constant_expr_p (const_tree
);
2989 extern bool maybe_constexpr_fn (tree
);
2991 extern bool var_in_maybe_constexpr_fn (tree
);
2994 rs_type_quals (const_tree type
);
2996 inline bool type_unknown_p (const_tree
);
2998 extern bool decl_maybe_constant_var_p (tree
);
3003 extern bool var_in_constexpr_fn (tree
);
3005 inline tree
ovl_first (tree
) ATTRIBUTE_PURE
;
3007 inline bool type_unknown_p (const_tree
);
3010 lookup_add (tree fns
, tree lookup
);
3013 ovl_make (tree fn
, tree next
= NULL_TREE
);
3015 extern int is_overloaded_fn (tree
) ATTRIBUTE_PURE
;
3017 extern bool maybe_add_lang_type_raw (tree
);
3019 extern rs_ref_qualifier
type_memfn_rqual (const_tree
);
3021 extern bool builtin_pack_fn_p (tree
);
3023 extern tree
make_conv_op_name (tree
);
3025 extern int type_memfn_quals (const_tree
);
3028 get_fileinfo (const char *);
3031 cxx_make_type (enum tree_code CXX_MEM_STAT_INFO
);
3034 build_cplus_array_type (tree
, tree
, int is_dep
= -1);
3036 extern bool is_byte_access_type (tree
);
3039 comptypes (tree
, tree
, int);
3041 extern tree
canonical_eh_spec (tree
);
3043 extern int cp_tree_operand_length (const_tree
);
3045 extern bool rs_tree_equal (tree
, tree
);
3047 extern bool compparms (const_tree
, const_tree
);
3050 rs_build_qualified_type_real (tree
, int, tsubst_flags_t
);
3051 #define rs_build_qualified_type(TYPE, QUALS) \
3052 rs_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error)
3053 extern bool cv_qualified_p (const_tree
);
3055 extern bool similar_type_p (tree
, tree
);
3057 extern bool rs_tree_equal (tree
, tree
);
3060 vector_targets_convertible_p (const_tree t1
, const_tree t2
);
3062 extern bool same_type_ignoring_top_level_qualifiers_p (tree
, tree
);
3064 extern bool comp_ptr_ttypes_const (tree
, tree
, compare_bounds_t
);
3067 get_class_binding_direct (tree
, tree
, bool want_type
= false);
3069 extern tree
skip_artificial_parms_for (const_tree
, tree
);
3072 lang_check_failed (const char *, int,
3073 const char *) ATTRIBUTE_NORETURN ATTRIBUTE_COLD
;
3075 extern tree
default_init_uninitialized_part (tree
);
3077 extern bool type_has_non_user_provided_default_constructor (tree
);
3079 extern bool default_ctor_p (const_tree
);
3081 extern bool user_provided_p (tree
);
3083 extern bool sufficient_parms_p (const_tree
);
3085 extern tree
next_initializable_field (tree
);
3087 extern tree
in_class_defaulted_default_constructor (tree
);
3089 extern bool is_instantiation_of_constexpr (tree
);
3092 check_for_uninitialized_const_var (tree
, bool, tsubst_flags_t
);
3094 extern bool reduced_constant_expression_p (tree
);
3096 extern tree
cv_unqualified (tree
);
3098 extern tree
cp_get_callee (tree
);
3099 extern tree
rs_get_callee_fndecl_nofold (tree
);
3101 extern bool is_nondependent_static_init_expression (tree
);
3103 extern tree
build_nop (tree
, tree
);
3105 extern bool scalarish_type_p (const_tree
);
3107 extern tree
is_bitfield_expr_with_lowered_type (const_tree
);
3109 extern tree
convert_bitfield_to_declared_type (tree
);
3112 cp_fold_maybe_rvalue (tree
, bool);
3114 extern tree
maybe_undo_parenthesized_ref (tree
);
3117 fold_offsetof (tree
, tree
= size_type_node
, tree_code ctx
= ERROR_MARK
);
3119 extern tree
cp_truthvalue_conversion (tree
, tsubst_flags_t
);
3122 fold_non_dependent_expr (tree
, tsubst_flags_t
= tf_warning_or_error
,
3123 bool = false, tree
= NULL_TREE
);
3125 extern int char_type_p (tree
);
3127 extern bool instantiation_dependent_expression_p (tree
);
3129 extern bool type_has_nontrivial_copy_init (const_tree
);
3131 extern tree
build_local_temp (tree
);
3133 extern bool is_normal_capture_proxy (tree
);
3135 extern bool reject_gcc_builtin (const_tree
, location_t
= UNKNOWN_LOCATION
);
3137 extern tree
resolve_nondeduced_context (tree
, tsubst_flags_t
);
3139 extern void cxx_incomplete_type_diagnostic (location_t
, const_tree
, const_tree
,
3142 extern void cxx_incomplete_type_error (location_t
, const_tree
, const_tree
);
3144 extern bool invalid_nonstatic_memfn_p (location_t
, tree
, tsubst_flags_t
);
3146 extern bool really_overloaded_fn (tree
) ATTRIBUTE_PURE
;
3148 extern tree
resolve_nondeduced_context_or_error (tree
, tsubst_flags_t
);
3150 extern tree
instantiate_non_dependent_or_null (tree
);
3152 extern void cxx_incomplete_type_inform (const_tree
);
3154 extern tree
strip_top_quals (tree
);
3156 extern bool undeduced_auto_decl (tree
);
3158 extern bool require_deduced_type (tree
, tsubst_flags_t
= tf_warning_or_error
);
3160 extern bool decl_constant_var_p (tree
);
3162 extern tree
build_new_constexpr_heap_type (tree
, tree
, tree
);
3164 extern bool is_empty_field (tree
);
3167 in_immediate_context ();
3169 extern tree
cp_get_callee_fndecl_nofold (tree
);
3172 cxx_mark_addressable (tree
, bool = false);
3174 extern tree
fold_builtin_source_location (location_t
);
3176 extern tree
build_address (tree
);
3178 extern bool bitfield_p (const_tree
);
3180 extern tree
rvalue (tree
);
3182 extern bool glvalue_p (const_tree
);
3184 extern cp_lvalue_kind
lvalue_kind (const_tree
);
3187 decl_constant_value (tree
, bool);
3189 extern tree
lookup_enumerator (tree
, tree
);
3192 is_class_type (tree
, int);
3194 extern tree
braced_lists_to_strings (tree
, tree
);
3197 fold_builtin_is_pointer_inverconvertible_with_class (location_t
, int, tree
*);
3199 extern bool layout_compatible_type_p (tree
, tree
);
3201 extern tree
finish_underlying_type (tree
);
3204 c_common_type_for_mode (machine_mode
, int);
3206 extern bool std_layout_type_p (const_tree
);
3208 extern tree
complete_type (tree
);
3210 extern tree
complete_type_or_else (tree
, tree
);
3212 extern void note_failed_type_completion_for_satisfaction (tree
);
3214 extern tree
complete_type_or_maybe_complain (tree
, tree
, tsubst_flags_t
);
3217 next_common_initial_seqence (tree
&, tree
&);
3219 extern bool null_member_pointer_value_p (tree
);
3222 fold_builtin_is_corresponding_member (location_t
, int, tree
*);
3224 extern tree
cp_fold_rvalue (tree
);
3227 maybe_constant_value (tree
, tree
= NULL_TREE
, bool = false);
3229 extern tree
lvalue_type (tree
);
3231 extern void lvalue_error (location_t
, enum lvalue_use
);
3234 cp_fold_maybe_rvalue (tree
, bool);
3236 extern tree
get_first_fn (tree
) ATTRIBUTE_PURE
;
3238 extern void explain_non_literal_class (tree
);
3240 extern bool reference_related_p (tree
, tree
);
3242 extern bool ordinary_char_type_p (tree
);
3244 extern bool array_string_literal_compatible_p (tree
, tree
);
3246 // forked from gcc/cp/cp-tree.h
3257 rs_build_qualified_type_real (tree
, int, tsubst_flags_t
);
3258 #define rs_build_qualified_type(TYPE, QUALS) \
3259 rs_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error)
3262 rs_walk_subtrees (tree
*, int *, walk_tree_fn
, void *, hash_set
<tree
> *);
3263 #define rs_walk_tree(tp, func, data, pset) \
3264 walk_tree_1 (tp, func, data, pset, rs_walk_subtrees)
3265 #define rs_walk_tree_without_duplicates(tp, func, data) \
3266 walk_tree_without_duplicates_1 (tp, func, data, rs_walk_subtrees)
3268 // forked from gcc/cp/cp-tree.h cp_expr_loc_or_loc
3271 rs_expr_loc_or_loc (const_tree t
, location_t or_loc
)
3273 location_t loc
= rs_expr_location (t
);
3274 if (loc
== UNKNOWN_LOCATION
)
3279 // forked from gcc/cp/cp-tree.h cp_expr_loc_or_input_loc
3282 rs_expr_loc_or_input_loc (const_tree t
)
3284 return rs_expr_loc_or_loc (t
, input_location
);
3287 // forked from gcc/cp/cp-tree.h type_unknown_p
3290 type_unknown_p (const_tree expr
)
3292 return TREE_TYPE (expr
) == unknown_type_node
;
3295 // forked from gcc/cp/cp-tree.h ovl_first
3297 /* Inline bodies. */
3300 ovl_first (tree node
)
3302 while (TREE_CODE (node
) == OVERLOAD
)
3303 node
= OVL_FUNCTION (node
);
3307 // forked from gcc/cp/cp-tree.h type_of_this_parm
3309 /* Return the type of the `this' parameter of FNTYPE. */
3312 type_of_this_parm (const_tree fntype
)
3314 function_args_iterator iter
;
3315 gcc_assert (TREE_CODE (fntype
) == METHOD_TYPE
);
3316 function_args_iter_init (&iter
, fntype
);
3317 return function_args_iter_cond (&iter
);
3320 // forked from gcc/cp/cp-tree.h class_of_this_parm
3322 /* Return the class of the `this' parameter of FNTYPE. */
3325 class_of_this_parm (const_tree fntype
)
3327 return TREE_TYPE (type_of_this_parm (fntype
));
3330 // forked from gcc/cp/cp-tree.h identifier_p
3332 /* Return a typed pointer version of T if it designates a
3333 C++ front-end identifier. */
3334 inline lang_identifier
*
3335 identifier_p (tree t
)
3337 if (TREE_CODE (t
) == IDENTIFIER_NODE
)
3338 return (lang_identifier
*) t
;
3342 // forked from gcc/c-family/c-common.h gnu_vector_type_p
3344 /* Return true if TYPE is a vector type that should be subject to the GNU
3345 vector extensions (as opposed to a vector type that is used only for
3346 the purposes of defining target-specific built-in functions). */
3349 gnu_vector_type_p (const_tree type
)
3351 return TREE_CODE (type
) == VECTOR_TYPE
&& !TYPE_INDIVISIBLE_P (type
);
3354 extern vec
<tree
, va_gc
> *
3355 make_tree_vector (void);
3358 release_tree_vector (vec
<tree
, va_gc
> *);
3360 /* Simplified unique_ptr clone to release a tree vec on exit. */
3365 typedef vec
<tree
, va_gc
> vec_t
;
3367 releasing_vec (vec_t
*v
) : v (v
) {}
3368 releasing_vec () : v (make_tree_vector ()) {}
3370 /* Copy ops are deliberately declared but not defined,
3371 copies must always be elided. */
3372 releasing_vec (const releasing_vec
&);
3373 releasing_vec
&operator= (const releasing_vec
&);
3375 vec_t
&operator* () const { return *v
; }
3376 vec_t
*operator-> () const { return v
; }
3377 vec_t
*get () const { return v
; }
3378 operator vec_t
* () const { return v
; }
3379 vec_t
**operator& () { return &v
; }
3381 /* Breaks pointer/value consistency for convenience. This takes ptrdiff_t
3382 rather than unsigned to avoid ambiguity with the built-in operator[]
3383 (bootstrap/91828). */
3384 tree
&operator[] (ptrdiff_t i
) const { return (*v
)[i
]; }
3386 tree
*begin () { return ::begin (v
); }
3387 tree
*end () { return ::end (v
); }
3391 release_tree_vector (v
);
3395 ~releasing_vec () { release_tree_vector (v
); }
3402 vec_safe_push (releasing_vec
&r
, const tree
&t CXX_MEM_STAT_INFO
)
3404 return vec_safe_push (*&r
, t PASS_MEM_STAT
);
3408 vec_safe_reserve (releasing_vec
&r
, unsigned n
,
3409 bool e
= false CXX_MEM_STAT_INFO
)
3411 return vec_safe_reserve (*&r
, n
, e PASS_MEM_STAT
);
3414 vec_safe_length (releasing_vec
&r
)
3416 return r
->length ();
3419 vec_safe_splice (releasing_vec
&r
, vec
<tree
, va_gc
> *p CXX_MEM_STAT_INFO
)
3421 vec_safe_splice (*&r
, p PASS_MEM_STAT
);
3425 null_node_p (const_tree expr
)
3427 STRIP_ANY_LOCATION_WRAPPER (expr
);
3428 return expr
== null_node
;
3432 cxx_incomplete_type_diagnostic (const_tree value
, const_tree type
,
3433 diagnostic_t diag_kind
)
3435 cxx_incomplete_type_diagnostic (rs_expr_loc_or_input_loc (value
), value
, type
,
3440 cxx_incomplete_type_error (const_tree value
, const_tree type
)
3442 cxx_incomplete_type_diagnostic (value
, type
, DK_ERROR
);
3446 location_of (tree t
);
3448 /* Helpers for IMPLICIT_RVALUE_P to look through automatic dereference. */
3451 implicit_rvalue_p (const_tree t
)
3453 if (REFERENCE_REF_P (t
))
3454 t
= TREE_OPERAND (t
, 0);
3455 return ((TREE_CODE (t
) == NON_LVALUE_EXPR
) && IMPLICIT_RVALUE_P (t
));
3458 set_implicit_rvalue_p (tree ot
)
3461 if (REFERENCE_REF_P (t
))
3462 t
= TREE_OPERAND (t
, 0);
3463 IMPLICIT_RVALUE_P (t
) = 1;
3469 maybe_constant_init (tree
, tree
= NULL_TREE
, bool = false);
3472 explain_invalid_constexpr_fn (tree fun
);
3474 extern bool potential_constant_expression (tree
);
3477 literal_type_p (tree t
);
3480 maybe_constexpr_fn (tree t
);
3483 fold_non_dependent_init (tree
, tsubst_flags_t
= tf_warning_or_error
,
3484 bool = false, tree
= NULL_TREE
);
3485 } // namespace Compile