]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/rust/backend/rust-tree.h
Update copyright years.
[thirdparty/gcc.git] / gcc / rust / backend / rust-tree.h
1 // Copyright (C) 2020-2024 Free Software Foundation, Inc.
2
3 // This file is part of GCC.
4
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
8 // version.
9
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
13 // for more details.
14
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/>.
18
19 #ifndef RUST_TREE
20 #define RUST_TREE
21
22 #include "rust-system.h"
23 #include "coretypes.h"
24 #include "tree.h"
25 #include "cpplib.h"
26 #include "splay-tree.h"
27
28 /* Returns true if NODE is a pointer. */
29 #define TYPE_PTR_P(NODE) (TREE_CODE (NODE) == POINTER_TYPE)
30
31 /* Returns true if NODE is a reference. */
32 #define TYPE_REF_P(NODE) (TREE_CODE (NODE) == REFERENCE_TYPE)
33
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))
36
37 /* [basic.fundamental]
38
39 Types bool, char, wchar_t, and the signed and unsigned integer types
40 are collectively called integral types.
41
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)
47
48 /* [basic.fundamental]
49
50 Integral and floating types are collectively called arithmetic
51 types.
52
53 As a GNU extension, we also accept complex types.
54
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)
59
60 /* True iff TYPE is cv decltype(nullptr). */
61 #define NULLPTR_TYPE_P(TYPE) (TREE_CODE (TYPE) == NULLPTR_TYPE)
62
63 /* [basic.types]
64
65 Arithmetic types, enumeration types, pointer types,
66 pointer-to-member types, and std::nullptr_t are collectively called
67 scalar types.
68
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))
73
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))))
78
79 // this is a helper to differentiate RECORD types between actual records and
80 // slices
81 #define SLICE_FLAG TREE_LANG_FLAG_0
82 #define SLICE_TYPE_P(TYPE) \
83 (TREE_CODE (TYPE) == RECORD_TYPE && TREE_LANG_FLAG_0 (TYPE))
84
85 // lambda?
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))
89
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))
93
94 #define TYPE_PTRMEMFUNC_FLAG(NODE) (TYPE_LANG_FLAG_2 (RECORD_TYPE_CHECK (NODE)))
95
96 #define TYPE_PTRMEMFUNC_FN_TYPE_RAW(NODE) (TREE_TYPE (TYPE_FIELDS (NODE)))
97
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))
104
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
109 space from the heap.
110
111 When appearing in a SAVE_EXPR, it means that underneath
112 is a call to a constructor.
113
114 When appearing in a CONSTRUCTOR, the expression is an unconverted
115 compound literal.
116
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))
120
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))
125
126 /* [class.virtual]
127
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))
131
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))
135
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)
141
142 /* A vector of BINFOs for the direct and indirect virtual base classes
143 that this type uses in a post-order depth-first left-to-right
144 order. (In other words, these bases appear in the order that they
145 should be initialized.) */
146 #define CLASSTYPE_VBASECLASSES(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->vbases)
147
148 /* We used to have a variant type for lang_type. Keep the name of the
149 checking accessor for the sole survivor. */
150 #define LANG_TYPE_CLASS_CHECK(NODE) (TYPE_LANG_SPECIFIC (NODE))
151
152 /* Keep these checks in ascending code order. */
153 #define RECORD_OR_UNION_CODE_P(T) ((T) == RECORD_TYPE || (T) == UNION_TYPE)
154 #define OVERLOAD_TYPE_P(T) (CLASS_TYPE_P (T) || TREE_CODE (T) == ENUMERAL_TYPE)
155
156 /* Nonzero if this class is "empty" in the sense of the C++ ABI. */
157 #define CLASSTYPE_EMPTY_P(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->empty_p)
158
159 /* True if DECL is declared 'constexpr'. */
160 #define DECL_DECLARED_CONSTEXPR_P(DECL) \
161 DECL_LANG_FLAG_8 (VAR_OR_FUNCTION_DECL_CHECK (DECL))
162
163 #define VAR_OR_FUNCTION_DECL_CHECK(NODE) \
164 TREE_CHECK2 (NODE, VAR_DECL, FUNCTION_DECL)
165
166 // forked from gcc/cp/c-common.h c_tree_index
167
168 /* Standard named or nameless data types of the C compiler. */
169
170 enum c_tree_index
171 {
172 CTI_CHAR8_TYPE,
173 CTI_CHAR16_TYPE,
174 CTI_CHAR32_TYPE,
175 CTI_WCHAR_TYPE,
176 CTI_UNDERLYING_WCHAR_TYPE,
177 CTI_WINT_TYPE,
178 CTI_SIGNED_SIZE_TYPE, /* For format checking only. */
179 CTI_UNSIGNED_PTRDIFF_TYPE, /* For format checking only. */
180 CTI_INTMAX_TYPE,
181 CTI_UINTMAX_TYPE,
182 CTI_WIDEST_INT_LIT_TYPE,
183 CTI_WIDEST_UINT_LIT_TYPE,
184
185 /* Types for <stdint.h>, that may not be defined on all
186 targets. */
187 CTI_SIG_ATOMIC_TYPE,
188 CTI_INT8_TYPE,
189 CTI_INT16_TYPE,
190 CTI_INT32_TYPE,
191 CTI_INT64_TYPE,
192 CTI_UINT8_TYPE,
193 CTI_UINT16_TYPE,
194 CTI_UINT32_TYPE,
195 CTI_UINT64_TYPE,
196 CTI_INT_LEAST8_TYPE,
197 CTI_INT_LEAST16_TYPE,
198 CTI_INT_LEAST32_TYPE,
199 CTI_INT_LEAST64_TYPE,
200 CTI_UINT_LEAST8_TYPE,
201 CTI_UINT_LEAST16_TYPE,
202 CTI_UINT_LEAST32_TYPE,
203 CTI_UINT_LEAST64_TYPE,
204 CTI_INT_FAST8_TYPE,
205 CTI_INT_FAST16_TYPE,
206 CTI_INT_FAST32_TYPE,
207 CTI_INT_FAST64_TYPE,
208 CTI_UINT_FAST8_TYPE,
209 CTI_UINT_FAST16_TYPE,
210 CTI_UINT_FAST32_TYPE,
211 CTI_UINT_FAST64_TYPE,
212 CTI_INTPTR_TYPE,
213 CTI_UINTPTR_TYPE,
214
215 CTI_CHAR_ARRAY_TYPE,
216 CTI_CHAR8_ARRAY_TYPE,
217 CTI_CHAR16_ARRAY_TYPE,
218 CTI_CHAR32_ARRAY_TYPE,
219 CTI_WCHAR_ARRAY_TYPE,
220 CTI_STRING_TYPE,
221 CTI_CONST_STRING_TYPE,
222
223 /* Type for boolean expressions (bool in C++, int in C). */
224 CTI_TRUTHVALUE_TYPE,
225 CTI_TRUTHVALUE_TRUE,
226 CTI_TRUTHVALUE_FALSE,
227
228 CTI_DEFAULT_FUNCTION_TYPE,
229
230 CTI_NULL,
231
232 /* These are not types, but we have to look them up all the time. */
233 CTI_FUNCTION_NAME_DECL,
234 CTI_PRETTY_FUNCTION_NAME_DECL,
235 CTI_C99_FUNCTION_NAME_DECL,
236
237 CTI_MODULE_HWM,
238 /* Below here entities change during compilation. */
239
240 CTI_SAVED_FUNCTION_NAME_DECLS,
241
242 CTI_MAX
243 };
244
245 // forked from gcc/c-family/c-common.h c_tree_index
246
247 extern GTY (()) tree c_global_trees[CTI_MAX];
248
249 // forked from gcc/cp/cp-tree.h cp_tree_index
250
251 enum cp_tree_index
252 {
253 CPTI_WCHAR_DECL,
254 CPTI_VTABLE_ENTRY_TYPE,
255 CPTI_DELTA_TYPE,
256 CPTI_VTABLE_INDEX_TYPE,
257 CPTI_CLEANUP_TYPE,
258 CPTI_VTT_PARM_TYPE,
259
260 CPTI_CLASS_TYPE,
261 CPTI_UNKNOWN_TYPE,
262 CPTI_INIT_LIST_TYPE,
263 CPTI_EXPLICIT_VOID_LIST,
264 CPTI_VTBL_TYPE,
265 CPTI_VTBL_PTR_TYPE,
266 CPTI_GLOBAL,
267 CPTI_ABORT_FNDECL,
268 CPTI_AGGR_TAG,
269 CPTI_CONV_OP_MARKER,
270
271 CPTI_CTOR_IDENTIFIER,
272 CPTI_COMPLETE_CTOR_IDENTIFIER,
273 CPTI_BASE_CTOR_IDENTIFIER,
274 CPTI_DTOR_IDENTIFIER,
275 CPTI_COMPLETE_DTOR_IDENTIFIER,
276 CPTI_BASE_DTOR_IDENTIFIER,
277 CPTI_DELETING_DTOR_IDENTIFIER,
278 CPTI_CONV_OP_IDENTIFIER,
279 CPTI_DELTA_IDENTIFIER,
280 CPTI_IN_CHARGE_IDENTIFIER,
281 CPTI_VTT_PARM_IDENTIFIER,
282 CPTI_AS_BASE_IDENTIFIER,
283 CPTI_THIS_IDENTIFIER,
284 CPTI_PFN_IDENTIFIER,
285 CPTI_VPTR_IDENTIFIER,
286 CPTI_GLOBAL_IDENTIFIER,
287 CPTI_ANON_IDENTIFIER,
288 CPTI_AUTO_IDENTIFIER,
289 CPTI_DECLTYPE_AUTO_IDENTIFIER,
290 CPTI_INIT_LIST_IDENTIFIER,
291 CPTI_FOR_RANGE__IDENTIFIER,
292 CPTI_FOR_BEGIN__IDENTIFIER,
293 CPTI_FOR_END__IDENTIFIER,
294 CPTI_FOR_RANGE_IDENTIFIER,
295 CPTI_FOR_BEGIN_IDENTIFIER,
296 CPTI_FOR_END_IDENTIFIER,
297 CPTI_ABI_TAG_IDENTIFIER,
298 CPTI_ALIGNED_IDENTIFIER,
299 CPTI_BEGIN_IDENTIFIER,
300 CPTI_END_IDENTIFIER,
301 CPTI_GET_IDENTIFIER,
302 CPTI_GNU_IDENTIFIER,
303 CPTI_TUPLE_ELEMENT_IDENTIFIER,
304 CPTI_TUPLE_SIZE_IDENTIFIER,
305 CPTI_TYPE_IDENTIFIER,
306 CPTI_VALUE_IDENTIFIER,
307 CPTI_FUN_IDENTIFIER,
308 CPTI_CLOSURE_IDENTIFIER,
309 CPTI_HEAP_UNINIT_IDENTIFIER,
310 CPTI_HEAP_IDENTIFIER,
311 CPTI_HEAP_DELETED_IDENTIFIER,
312 CPTI_HEAP_VEC_UNINIT_IDENTIFIER,
313 CPTI_HEAP_VEC_IDENTIFIER,
314 CPTI_OMP_IDENTIFIER,
315
316 CPTI_LANG_NAME_C,
317 CPTI_LANG_NAME_CPLUSPLUS,
318
319 CPTI_EMPTY_EXCEPT_SPEC,
320 CPTI_NOEXCEPT_TRUE_SPEC,
321 CPTI_NOEXCEPT_FALSE_SPEC,
322 CPTI_NOEXCEPT_DEFERRED_SPEC,
323
324 CPTI_NULLPTR,
325 CPTI_NULLPTR_TYPE,
326
327 CPTI_ANY_TARG,
328
329 CPTI_MODULE_HWM,
330 /* Nodes after here change during compilation, or should not be in
331 the module's global tree table. Such nodes must be locatable
332 via name lookup or type-construction, as those are the only
333 cross-TU matching capabilities remaining. */
334
335 /* We must find these via the global namespace. */
336 CPTI_STD,
337 CPTI_ABI,
338
339 /* These are created at init time, but the library/headers provide
340 definitions. */
341 CPTI_ALIGN_TYPE,
342 CPTI_TERMINATE_FN,
343 CPTI_CALL_UNEXPECTED_FN,
344
345 /* These are lazily inited. */
346 CPTI_CONST_TYPE_INFO_TYPE,
347 CPTI_GET_EXCEPTION_PTR_FN,
348 CPTI_BEGIN_CATCH_FN,
349 CPTI_END_CATCH_FN,
350 CPTI_ALLOCATE_EXCEPTION_FN,
351 CPTI_FREE_EXCEPTION_FN,
352 CPTI_THROW_FN,
353 CPTI_RETHROW_FN,
354 CPTI_ATEXIT_FN_PTR_TYPE,
355 CPTI_ATEXIT,
356 CPTI_DSO_HANDLE,
357 CPTI_DCAST,
358
359 CPTI_SOURCE_LOCATION_IMPL,
360
361 CPTI_FALLBACK_DFLOAT32_TYPE,
362 CPTI_FALLBACK_DFLOAT64_TYPE,
363 CPTI_FALLBACK_DFLOAT128_TYPE,
364
365 CPTI_MAX
366 };
367
368 // forked from gcc/cp/cp-tree.h cp_global_trees
369
370 extern GTY (()) tree cp_global_trees[CPTI_MAX];
371
372 #define wchar_decl_node cp_global_trees[CPTI_WCHAR_DECL]
373 #define vtable_entry_type cp_global_trees[CPTI_VTABLE_ENTRY_TYPE]
374 /* The type used to represent an offset by which to adjust the `this'
375 pointer in pointer-to-member types. */
376 #define delta_type_node cp_global_trees[CPTI_DELTA_TYPE]
377 /* The type used to represent an index into the vtable. */
378 #define vtable_index_type cp_global_trees[CPTI_VTABLE_INDEX_TYPE]
379
380 #define class_type_node cp_global_trees[CPTI_CLASS_TYPE]
381 #define unknown_type_node cp_global_trees[CPTI_UNKNOWN_TYPE]
382 #define init_list_type_node cp_global_trees[CPTI_INIT_LIST_TYPE]
383 #define explicit_void_list_node cp_global_trees[CPTI_EXPLICIT_VOID_LIST]
384 #define vtbl_type_node cp_global_trees[CPTI_VTBL_TYPE]
385 #define vtbl_ptr_type_node cp_global_trees[CPTI_VTBL_PTR_TYPE]
386 #define std_node cp_global_trees[CPTI_STD]
387 #define abi_node cp_global_trees[CPTI_ABI]
388 #define global_namespace cp_global_trees[CPTI_GLOBAL]
389 #define const_type_info_type_node cp_global_trees[CPTI_CONST_TYPE_INFO_TYPE]
390 #define conv_op_marker cp_global_trees[CPTI_CONV_OP_MARKER]
391 #define abort_fndecl cp_global_trees[CPTI_ABORT_FNDECL]
392 #define current_aggr cp_global_trees[CPTI_AGGR_TAG]
393 #define nullptr_node cp_global_trees[CPTI_NULLPTR]
394 #define nullptr_type_node cp_global_trees[CPTI_NULLPTR_TYPE]
395 /* std::align_val_t */
396 #define align_type_node cp_global_trees[CPTI_ALIGN_TYPE]
397
398 #define char8_type_node c_global_trees[CTI_CHAR8_TYPE]
399 #define char16_type_node c_global_trees[CTI_CHAR16_TYPE]
400 #define char32_type_node c_global_trees[CTI_CHAR32_TYPE]
401 #define wchar_type_node c_global_trees[CTI_WCHAR_TYPE]
402 #define underlying_wchar_type_node c_global_trees[CTI_UNDERLYING_WCHAR_TYPE]
403 #define wint_type_node c_global_trees[CTI_WINT_TYPE]
404 #define signed_size_type_node c_global_trees[CTI_SIGNED_SIZE_TYPE]
405 #define unsigned_ptrdiff_type_node c_global_trees[CTI_UNSIGNED_PTRDIFF_TYPE]
406 #define intmax_type_node c_global_trees[CTI_INTMAX_TYPE]
407 #define uintmax_type_node c_global_trees[CTI_UINTMAX_TYPE]
408 #define widest_integer_literal_type_node c_global_trees[CTI_WIDEST_INT_LIT_TYPE]
409 #define widest_unsigned_literal_type_node \
410 c_global_trees[CTI_WIDEST_UINT_LIT_TYPE]
411
412 #define sig_atomic_type_node c_global_trees[CTI_SIG_ATOMIC_TYPE]
413 #define int8_type_node c_global_trees[CTI_INT8_TYPE]
414 #define int16_type_node c_global_trees[CTI_INT16_TYPE]
415 #define int32_type_node c_global_trees[CTI_INT32_TYPE]
416 #define int64_type_node c_global_trees[CTI_INT64_TYPE]
417 #define uint8_type_node c_global_trees[CTI_UINT8_TYPE]
418 #define c_uint16_type_node c_global_trees[CTI_UINT16_TYPE]
419 #define c_uint32_type_node c_global_trees[CTI_UINT32_TYPE]
420 #define c_uint64_type_node c_global_trees[CTI_UINT64_TYPE]
421 #define int_least8_type_node c_global_trees[CTI_INT_LEAST8_TYPE]
422 #define int_least16_type_node c_global_trees[CTI_INT_LEAST16_TYPE]
423 #define int_least32_type_node c_global_trees[CTI_INT_LEAST32_TYPE]
424 #define int_least64_type_node c_global_trees[CTI_INT_LEAST64_TYPE]
425 #define uint_least8_type_node c_global_trees[CTI_UINT_LEAST8_TYPE]
426 #define uint_least16_type_node c_global_trees[CTI_UINT_LEAST16_TYPE]
427 #define uint_least32_type_node c_global_trees[CTI_UINT_LEAST32_TYPE]
428 #define uint_least64_type_node c_global_trees[CTI_UINT_LEAST64_TYPE]
429 #define int_fast8_type_node c_global_trees[CTI_INT_FAST8_TYPE]
430 #define int_fast16_type_node c_global_trees[CTI_INT_FAST16_TYPE]
431 #define int_fast32_type_node c_global_trees[CTI_INT_FAST32_TYPE]
432 #define int_fast64_type_node c_global_trees[CTI_INT_FAST64_TYPE]
433 #define uint_fast8_type_node c_global_trees[CTI_UINT_FAST8_TYPE]
434 #define uint_fast16_type_node c_global_trees[CTI_UINT_FAST16_TYPE]
435 #define uint_fast32_type_node c_global_trees[CTI_UINT_FAST32_TYPE]
436 #define uint_fast64_type_node c_global_trees[CTI_UINT_FAST64_TYPE]
437 #define intptr_type_node c_global_trees[CTI_INTPTR_TYPE]
438 #define uintptr_type_node c_global_trees[CTI_UINTPTR_TYPE]
439
440 #define truthvalue_type_node c_global_trees[CTI_TRUTHVALUE_TYPE]
441 #define truthvalue_true_node c_global_trees[CTI_TRUTHVALUE_TRUE]
442 #define truthvalue_false_node c_global_trees[CTI_TRUTHVALUE_FALSE]
443
444 #define char_array_type_node c_global_trees[CTI_CHAR_ARRAY_TYPE]
445 #define char8_array_type_node c_global_trees[CTI_CHAR8_ARRAY_TYPE]
446 #define char16_array_type_node c_global_trees[CTI_CHAR16_ARRAY_TYPE]
447 #define char32_array_type_node c_global_trees[CTI_CHAR32_ARRAY_TYPE]
448 #define wchar_array_type_node c_global_trees[CTI_WCHAR_ARRAY_TYPE]
449 #define string_type_node c_global_trees[CTI_STRING_TYPE]
450 #define const_string_type_node c_global_trees[CTI_CONST_STRING_TYPE]
451
452 #define default_function_type c_global_trees[CTI_DEFAULT_FUNCTION_TYPE]
453
454 #define function_name_decl_node c_global_trees[CTI_FUNCTION_NAME_DECL]
455 #define pretty_function_name_decl_node \
456 c_global_trees[CTI_PRETTY_FUNCTION_NAME_DECL]
457 #define c99_function_name_decl_node c_global_trees[CTI_C99_FUNCTION_NAME_DECL]
458 #define saved_function_name_decls c_global_trees[CTI_SAVED_FUNCTION_NAME_DECLS]
459
460 /* The node for C++ `__null'. */
461 #define null_node c_global_trees[CTI_NULL]
462
463 /* We cache these tree nodes so as to call get_identifier less frequently.
464 For identifiers for functions, including special member functions such
465 as ctors and assignment operators, the nodes can be used (among other
466 things) to iterate over their overloads defined by/for a type. For
467 example:
468
469 tree ovlid = assign_op_identifier;
470 tree overloads = get_class_binding (type, ovlid);
471 for (ovl_iterator it (overloads); it; ++it) { ... }
472
473 iterates over the set of implicitly and explicitly defined overloads
474 of the assignment operator for type (including the copy and move
475 assignment operators, whether deleted or not). */
476
477 /* The name of a constructor that takes an in-charge parameter to
478 decide whether or not to construct virtual base classes. */
479 #define ctor_identifier cp_global_trees[CPTI_CTOR_IDENTIFIER]
480 /* The name of a constructor that constructs virtual base classes. */
481 #define complete_ctor_identifier cp_global_trees[CPTI_COMPLETE_CTOR_IDENTIFIER]
482 /* The name of a constructor that does not construct virtual base classes. */
483 #define base_ctor_identifier cp_global_trees[CPTI_BASE_CTOR_IDENTIFIER]
484 /* The name of a destructor that takes an in-charge parameter to
485 decide whether or not to destroy virtual base classes and whether
486 or not to delete the object. */
487 #define dtor_identifier cp_global_trees[CPTI_DTOR_IDENTIFIER]
488 /* The name of a destructor that destroys virtual base classes. */
489 #define complete_dtor_identifier cp_global_trees[CPTI_COMPLETE_DTOR_IDENTIFIER]
490 /* The name of a destructor that does not destroy virtual base
491 classes. */
492 #define base_dtor_identifier cp_global_trees[CPTI_BASE_DTOR_IDENTIFIER]
493 /* The name of a destructor that destroys virtual base classes, and
494 then deletes the entire object. */
495 #define deleting_dtor_identifier cp_global_trees[CPTI_DELETING_DTOR_IDENTIFIER]
496
497 /* The name used for conversion operators -- but note that actual
498 conversion functions use special identifiers outside the identifier
499 table. */
500 #define conv_op_identifier cp_global_trees[CPTI_CONV_OP_IDENTIFIER]
501
502 #define delta_identifier cp_global_trees[CPTI_DELTA_IDENTIFIER]
503 #define in_charge_identifier cp_global_trees[CPTI_IN_CHARGE_IDENTIFIER]
504 /* The name of the parameter that contains a pointer to the VTT to use
505 for this subobject constructor or destructor. */
506 #define vtt_parm_identifier cp_global_trees[CPTI_VTT_PARM_IDENTIFIER]
507 #define as_base_identifier cp_global_trees[CPTI_AS_BASE_IDENTIFIER]
508 #define this_identifier cp_global_trees[CPTI_THIS_IDENTIFIER]
509 #define pfn_identifier cp_global_trees[CPTI_PFN_IDENTIFIER]
510 #define vptr_identifier cp_global_trees[CPTI_VPTR_IDENTIFIER]
511 /* The name of the ::, std & anon namespaces. */
512 #define global_identifier cp_global_trees[CPTI_GLOBAL_IDENTIFIER]
513 #define anon_identifier cp_global_trees[CPTI_ANON_IDENTIFIER]
514 /* auto and declspec(auto) identifiers. */
515 #define auto_identifier cp_global_trees[CPTI_AUTO_IDENTIFIER]
516 #define decltype_auto_identifier cp_global_trees[CPTI_DECLTYPE_AUTO_IDENTIFIER]
517 #define init_list_identifier cp_global_trees[CPTI_INIT_LIST_IDENTIFIER]
518 #define for_range__identifier cp_global_trees[CPTI_FOR_RANGE__IDENTIFIER]
519 #define for_begin__identifier cp_global_trees[CPTI_FOR_BEGIN__IDENTIFIER]
520 #define for_end__identifier cp_global_trees[CPTI_FOR_END__IDENTIFIER]
521 #define for_range_identifier cp_global_trees[CPTI_FOR_RANGE_IDENTIFIER]
522 #define for_begin_identifier cp_global_trees[CPTI_FOR_BEGIN_IDENTIFIER]
523 #define for_end_identifier cp_global_trees[CPTI_FOR_END_IDENTIFIER]
524 #define abi_tag_identifier cp_global_trees[CPTI_ABI_TAG_IDENTIFIER]
525 #define aligned_identifier cp_global_trees[CPTI_ALIGNED_IDENTIFIER]
526 #define begin_identifier cp_global_trees[CPTI_BEGIN_IDENTIFIER]
527 #define end_identifier cp_global_trees[CPTI_END_IDENTIFIER]
528 #define get__identifier cp_global_trees[CPTI_GET_IDENTIFIER]
529 #define gnu_identifier cp_global_trees[CPTI_GNU_IDENTIFIER]
530 #define tuple_element_identifier cp_global_trees[CPTI_TUPLE_ELEMENT_IDENTIFIER]
531 #define tuple_size_identifier cp_global_trees[CPTI_TUPLE_SIZE_IDENTIFIER]
532 #define type_identifier cp_global_trees[CPTI_TYPE_IDENTIFIER]
533 #define value_identifier cp_global_trees[CPTI_VALUE_IDENTIFIER]
534 #define fun_identifier cp_global_trees[CPTI_FUN_IDENTIFIER]
535 #define closure_identifier cp_global_trees[CPTI_CLOSURE_IDENTIFIER]
536 #define heap_uninit_identifier cp_global_trees[CPTI_HEAP_UNINIT_IDENTIFIER]
537 #define heap_identifier cp_global_trees[CPTI_HEAP_IDENTIFIER]
538 #define heap_deleted_identifier cp_global_trees[CPTI_HEAP_DELETED_IDENTIFIER]
539 #define heap_vec_uninit_identifier \
540 cp_global_trees[CPTI_HEAP_VEC_UNINIT_IDENTIFIER]
541 #define heap_vec_identifier cp_global_trees[CPTI_HEAP_VEC_IDENTIFIER]
542 #define omp_identifier cp_global_trees[CPTI_OMP_IDENTIFIER]
543 #define lang_name_c cp_global_trees[CPTI_LANG_NAME_C]
544 #define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS]
545
546 /* Exception specifiers used for throw(), noexcept(true),
547 noexcept(false) and deferred noexcept. We rely on these being
548 uncloned. */
549 #define empty_except_spec cp_global_trees[CPTI_EMPTY_EXCEPT_SPEC]
550 #define noexcept_true_spec cp_global_trees[CPTI_NOEXCEPT_TRUE_SPEC]
551 #define noexcept_false_spec cp_global_trees[CPTI_NOEXCEPT_FALSE_SPEC]
552 #define noexcept_deferred_spec cp_global_trees[CPTI_NOEXCEPT_DEFERRED_SPEC]
553
554 /* Exception handling function declarations. */
555 #define terminate_fn cp_global_trees[CPTI_TERMINATE_FN]
556 #define call_unexpected_fn cp_global_trees[CPTI_CALL_UNEXPECTED_FN]
557 #define get_exception_ptr_fn cp_global_trees[CPTI_GET_EXCEPTION_PTR_FN]
558 #define begin_catch_fn cp_global_trees[CPTI_BEGIN_CATCH_FN]
559 #define end_catch_fn cp_global_trees[CPTI_END_CATCH_FN]
560 #define allocate_exception_fn cp_global_trees[CPTI_ALLOCATE_EXCEPTION_FN]
561 #define free_exception_fn cp_global_trees[CPTI_FREE_EXCEPTION_FN]
562 #define throw_fn cp_global_trees[CPTI_THROW_FN]
563 #define rethrow_fn cp_global_trees[CPTI_RETHROW_FN]
564
565 /* The type of the function-pointer argument to "__cxa_atexit" (or
566 "std::atexit", if "__cxa_atexit" is not being used). */
567 #define atexit_fn_ptr_type_node cp_global_trees[CPTI_ATEXIT_FN_PTR_TYPE]
568
569 /* A pointer to `std::atexit'. */
570 #define atexit_node cp_global_trees[CPTI_ATEXIT]
571
572 /* A pointer to `__dso_handle'. */
573 #define dso_handle_node cp_global_trees[CPTI_DSO_HANDLE]
574
575 /* The declaration of the dynamic_cast runtime. */
576 #define dynamic_cast_node cp_global_trees[CPTI_DCAST]
577
578 /* The type of a destructor. */
579 #define cleanup_type cp_global_trees[CPTI_CLEANUP_TYPE]
580
581 /* The type of the vtt parameter passed to subobject constructors and
582 destructors. */
583 #define vtt_parm_type cp_global_trees[CPTI_VTT_PARM_TYPE]
584
585 /* A node which matches any template argument. */
586 #define any_targ_node cp_global_trees[CPTI_ANY_TARG]
587
588 /* std::source_location::__impl class. */
589 #define source_location_impl cp_global_trees[CPTI_SOURCE_LOCATION_IMPL]
590
591 /* These two accessors should only be used by OVL manipulators.
592 Other users should use iterators and convenience functions. */
593 #define OVL_FUNCTION(NODE) \
594 (((struct tree_overload *) OVERLOAD_CHECK (NODE))->function)
595 #define OVL_CHAIN(NODE) \
596 (((struct tree_overload *) OVERLOAD_CHECK (NODE))->common.chain)
597
598 /* If set, this or a subsequent overload contains decls that need deduping. */
599 #define OVL_DEDUP_P(NODE) TREE_LANG_FLAG_0 (OVERLOAD_CHECK (NODE))
600 /* If set, this was imported in a using declaration. */
601 #define OVL_USING_P(NODE) TREE_LANG_FLAG_1 (OVERLOAD_CHECK (NODE))
602 /* If set, this overload is a hidden decl. */
603 #define OVL_HIDDEN_P(NODE) TREE_LANG_FLAG_2 (OVERLOAD_CHECK (NODE))
604 /* If set, this overload contains a nested overload. */
605 #define OVL_NESTED_P(NODE) TREE_LANG_FLAG_3 (OVERLOAD_CHECK (NODE))
606 /* If set, this overload was constructed during lookup. */
607 #define OVL_LOOKUP_P(NODE) TREE_LANG_FLAG_4 (OVERLOAD_CHECK (NODE))
608 /* If set, this OVL_USING_P overload is exported. */
609 #define OVL_EXPORT_P(NODE) TREE_LANG_FLAG_5 (OVERLOAD_CHECK (NODE))
610
611 /* The first decl of an overload. */
612 #define OVL_FIRST(NODE) ovl_first (NODE)
613 /* The name of the overload set. */
614 #define OVL_NAME(NODE) DECL_NAME (OVL_FIRST (NODE))
615
616 /* Whether this is a set of overloaded functions. TEMPLATE_DECLS are
617 always wrapped in an OVERLOAD, so we don't need to check them
618 here. */
619 #define OVL_P(NODE) \
620 (TREE_CODE (NODE) == FUNCTION_DECL || TREE_CODE (NODE) == OVERLOAD)
621 /* Whether this is a single member overload. */
622 #define OVL_SINGLE_P(NODE) (TREE_CODE (NODE) != OVERLOAD || !OVL_CHAIN (NODE))
623
624 /* Nonzero means that this type has an X() constructor. */
625 #define TYPE_HAS_DEFAULT_CONSTRUCTOR(NODE) \
626 (LANG_TYPE_CLASS_CHECK (NODE)->has_default_ctor)
627
628 /* Nonzero means that NODE (a class type) has a default constructor --
629 but that it has not yet been declared. */
630 #define CLASSTYPE_LAZY_DEFAULT_CTOR(NODE) \
631 (LANG_TYPE_CLASS_CHECK (NODE)->lazy_default_ctor)
632
633 /* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These
634 are the constructors that take an in-charge parameter. */
635 #define CLASSTYPE_CONSTRUCTORS(NODE) \
636 (get_class_binding_direct (NODE, ctor_identifier))
637
638 /* In a TREE_LIST in an attribute list, indicates that the attribute
639 must be applied at instantiation time. */
640 #define ATTR_IS_DEPENDENT(NODE) TREE_LANG_FLAG_0 (TREE_LIST_CHECK (NODE))
641
642 /* In a TREE_LIST in the argument of attribute abi_tag, indicates that the tag
643 was inherited from a template parameter, not explicitly indicated. */
644 #define ABI_TAG_IMPLICIT(NODE) TREE_LANG_FLAG_0 (TREE_LIST_CHECK (NODE))
645
646 /* In a TREE_LIST for a parameter-declaration-list, indicates that all the
647 parameters in the list have declarators enclosed in (). */
648 #define PARENTHESIZED_LIST_P(NODE) TREE_LANG_FLAG_0 (TREE_LIST_CHECK (NODE))
649
650 /* Non zero if this is a using decl for a dependent scope. */
651 #define DECL_DEPENDENT_P(NODE) DECL_LANG_FLAG_0 (USING_DECL_CHECK (NODE))
652
653 /* The scope named in a using decl. */
654 #define USING_DECL_SCOPE(NODE) DECL_RESULT_FLD (USING_DECL_CHECK (NODE))
655
656 /* The decls named by a using decl. */
657 #define USING_DECL_DECLS(NODE) DECL_INITIAL (USING_DECL_CHECK (NODE))
658
659 /* Non zero if the using decl refers to a dependent type. */
660 #define USING_DECL_TYPENAME_P(NODE) DECL_LANG_FLAG_1 (USING_DECL_CHECK (NODE))
661
662 /* True if member using decl NODE refers to a non-inherited NODE. */
663 #define USING_DECL_UNRELATED_P(NODE) DECL_LANG_FLAG_2 (USING_DECL_CHECK (NODE))
664
665 /* Nonzero if NODE declares a function. */
666 #define DECL_DECLARES_FUNCTION_P(NODE) (TREE_CODE (NODE) == FUNCTION_DECL)
667
668 /* Nonzero for a NODE which declares a type. */
669 #define DECL_DECLARES_TYPE_P(NODE) (TREE_CODE (NODE) == TYPE_DECL)
670
671 /* Kind bits. */
672 #define IDENTIFIER_KIND_BIT_0(NODE) \
673 TREE_LANG_FLAG_0 (IDENTIFIER_NODE_CHECK (NODE))
674 #define IDENTIFIER_KIND_BIT_1(NODE) \
675 TREE_LANG_FLAG_1 (IDENTIFIER_NODE_CHECK (NODE))
676 #define IDENTIFIER_KIND_BIT_2(NODE) \
677 TREE_LANG_FLAG_2 (IDENTIFIER_NODE_CHECK (NODE))
678
679 /* Used by various search routines. */
680 #define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_4 (IDENTIFIER_NODE_CHECK (NODE))
681
682 /* Nonzero if this identifier is used as a virtual function name somewhere
683 (optimizes searches). */
684 #define IDENTIFIER_VIRTUAL_P(NODE) \
685 TREE_LANG_FLAG_5 (IDENTIFIER_NODE_CHECK (NODE))
686
687 /* True if this identifier is a reserved word. C_RID_CODE (node) is
688 then the RID_* value of the keyword. Value 1. */
689 #define IDENTIFIER_KEYWORD_P(NODE) \
690 ((!IDENTIFIER_KIND_BIT_2 (NODE)) & (!IDENTIFIER_KIND_BIT_1 (NODE)) \
691 & IDENTIFIER_KIND_BIT_0 (NODE))
692
693 /* True if this identifier is the name of a constructor or
694 destructor. Value 2 or 3. */
695 #define IDENTIFIER_CDTOR_P(NODE) \
696 ((!IDENTIFIER_KIND_BIT_2 (NODE)) & IDENTIFIER_KIND_BIT_1 (NODE))
697
698 /* True if this identifier is the name of a constructor. Value 2. */
699 #define IDENTIFIER_CTOR_P(NODE) \
700 (IDENTIFIER_CDTOR_P (NODE) & (!IDENTIFIER_KIND_BIT_0 (NODE)))
701
702 /* True if this identifier is the name of a destructor. Value 3. */
703 #define IDENTIFIER_DTOR_P(NODE) \
704 (IDENTIFIER_CDTOR_P (NODE) & IDENTIFIER_KIND_BIT_0 (NODE))
705
706 /* True if this identifier is for any operator name (including
707 conversions). Value 4, 5, 6 or 7. */
708 #define IDENTIFIER_ANY_OP_P(NODE) (IDENTIFIER_KIND_BIT_2 (NODE))
709
710 /* True if this identifier is for an overloaded operator. Values 4, 5. */
711 #define IDENTIFIER_OVL_OP_P(NODE) \
712 (IDENTIFIER_ANY_OP_P (NODE) & (!IDENTIFIER_KIND_BIT_1 (NODE)))
713
714 /* True if this identifier is for any assignment. Values 5. */
715 #define IDENTIFIER_ASSIGN_OP_P(NODE) \
716 (IDENTIFIER_OVL_OP_P (NODE) & IDENTIFIER_KIND_BIT_0 (NODE))
717
718 /* True if this identifier is the name of a type-conversion
719 operator. Value 7. */
720 #define IDENTIFIER_CONV_OP_P(NODE) \
721 (IDENTIFIER_ANY_OP_P (NODE) & IDENTIFIER_KIND_BIT_1 (NODE) \
722 & (!IDENTIFIER_KIND_BIT_0 (NODE)))
723
724 /* True if this identifier is a new or delete operator. */
725 #define IDENTIFIER_NEWDEL_OP_P(NODE) \
726 (IDENTIFIER_OVL_OP_P (NODE) \
727 && IDENTIFIER_OVL_OP_FLAGS (NODE) & OVL_OP_FLAG_ALLOC)
728
729 /* True if this identifier is a new operator. */
730 #define IDENTIFIER_NEW_OP_P(NODE) \
731 (IDENTIFIER_OVL_OP_P (NODE) \
732 && (IDENTIFIER_OVL_OP_FLAGS (NODE) \
733 & (OVL_OP_FLAG_ALLOC | OVL_OP_FLAG_DELETE)) \
734 == OVL_OP_FLAG_ALLOC)
735
736 /* Nonzero if the class NODE has multiple paths to the same (virtual)
737 base object. */
738 #define CLASSTYPE_DIAMOND_SHAPED_P(NODE) \
739 (LANG_TYPE_CLASS_CHECK (NODE)->diamond_shaped)
740
741 /* Nonzero if the class NODE has multiple instances of the same base
742 type. */
743 #define CLASSTYPE_REPEATED_BASE_P(NODE) \
744 (LANG_TYPE_CLASS_CHECK (NODE)->repeated_base)
745
746 /* The member function with which the vtable will be emitted:
747 the first noninline non-pure-virtual member function. NULL_TREE
748 if there is no key function or if this is a class template */
749 #define CLASSTYPE_KEY_METHOD(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->key_method)
750
751 /* Vector of members. During definition, it is unordered and only
752 member functions are present. After completion it is sorted and
753 contains both member functions and non-functions. STAT_HACK is
754 involved to preserve oneslot per name invariant. */
755 #define CLASSTYPE_MEMBER_VEC(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->members)
756
757 /* For class templates, this is a TREE_LIST of all member data,
758 functions, types, and friends in the order of declaration.
759 The TREE_PURPOSE of each TREE_LIST is NULL_TREE for a friend,
760 and the RECORD_TYPE for the class template otherwise. */
761 #define CLASSTYPE_DECL_LIST(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->decl_list)
762
763 /* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These
764 are the constructors that take an in-charge parameter. */
765 #define CLASSTYPE_CONSTRUCTORS(NODE) \
766 (get_class_binding_direct (NODE, ctor_identifier))
767
768 /* A FUNCTION_DECL for the destructor for NODE. This is the
769 destructors that take an in-charge parameter. If
770 CLASSTYPE_LAZY_DESTRUCTOR is true, then this entry will be NULL
771 until the destructor is created with lazily_declare_fn. */
772 #define CLASSTYPE_DESTRUCTOR(NODE) \
773 (get_class_binding_direct (NODE, dtor_identifier))
774
775 /* Nonzero if NODE has a primary base class, i.e., a base class with
776 which it shares the virtual function table pointer. */
777 #define CLASSTYPE_HAS_PRIMARY_BASE_P(NODE) \
778 (CLASSTYPE_PRIMARY_BINFO (NODE) != NULL_TREE)
779
780 /* If non-NULL, this is the binfo for the primary base class, i.e.,
781 the base class which contains the virtual function table pointer
782 for this class. */
783 #define CLASSTYPE_PRIMARY_BINFO(NODE) \
784 (LANG_TYPE_CLASS_CHECK (NODE)->primary_base)
785
786 /* A vector of BINFOs for the direct and indirect virtual base classes
787 that this type uses in a post-order depth-first left-to-right
788 order. (In other words, these bases appear in the order that they
789 should be initialized.) */
790 #define CLASSTYPE_VBASECLASSES(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->vbases)
791
792 /* The type corresponding to NODE when NODE is used as a base class,
793 i.e., NODE without virtual base classes or tail padding. */
794 #define CLASSTYPE_AS_BASE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->as_base)
795
796 /* Nonzero if NODE is a user-defined conversion operator. */
797 #define DECL_CONV_FN_P(NODE) IDENTIFIER_CONV_OP_P (DECL_NAME (NODE))
798
799 /* The type to which conversion operator FN converts to. */
800 #define DECL_CONV_FN_TYPE(FN) \
801 TREE_TYPE ((gcc_checking_assert (DECL_CONV_FN_P (FN)), DECL_NAME (FN)))
802
803 /* Returns nonzero iff TYPE1 and TYPE2 are the same type, in the usual
804 sense of `same'. */
805 #define same_type_p(TYPE1, TYPE2) comptypes ((TYPE1), (TYPE2), COMPARE_STRICT)
806
807 /* Nonzero if T is a type that could resolve to any kind of concrete type
808 at instantiation time. */
809 #define WILDCARD_TYPE_P(T) \
810 (TREE_CODE (T) == TEMPLATE_TYPE_PARM || TREE_CODE (T) == TYPENAME_TYPE \
811 || TREE_CODE (T) == TYPEOF_TYPE \
812 || TREE_CODE (T) == BOUND_TEMPLATE_TEMPLATE_PARM \
813 || TREE_CODE (T) == DECLTYPE_TYPE \
814 || TREE_CODE (T) == DEPENDENT_OPERATOR_TYPE)
815
816 /* Nonzero if T is a class (or struct or union) type. Also nonzero
817 for template type parameters, typename types, and instantiated
818 template template parameters. Keep these checks in ascending code
819 order. */
820 #define MAYBE_CLASS_TYPE_P(T) (WILDCARD_TYPE_P (T) || CLASS_TYPE_P (T))
821
822 /* 1 iff FUNCTION_TYPE or METHOD_TYPE has a ref-qualifier (either & or &&). */
823 #define FUNCTION_REF_QUALIFIED(NODE) \
824 TREE_LANG_FLAG_4 (FUNC_OR_METHOD_CHECK (NODE))
825
826 /* 1 iff FUNCTION_TYPE or METHOD_TYPE has &&-ref-qualifier. */
827 #define FUNCTION_RVALUE_QUALIFIED(NODE) \
828 TREE_LANG_FLAG_5 (FUNC_OR_METHOD_CHECK (NODE))
829
830 /* Get the POINTER_TYPE to the METHOD_TYPE associated with this
831 pointer to member function. TYPE_PTRMEMFUNC_P _must_ be true,
832 before using this macro. */
833 #define TYPE_PTRMEMFUNC_FN_TYPE(NODE) \
834 (rs_build_qualified_type (TREE_TYPE (TYPE_FIELDS (NODE)), \
835 rs_type_quals (NODE)))
836
837 /* As above, but can be used in places that want an lvalue at the expense
838 of not necessarily having the correct cv-qualifiers. */
839 #define TYPE_PTRMEMFUNC_FN_TYPE_RAW(NODE) (TREE_TYPE (TYPE_FIELDS (NODE)))
840
841 /* True if this type is dependent. This predicate is only valid if
842 TYPE_DEPENDENT_P_VALID is true. */
843 #define TYPE_DEPENDENT_P(NODE) TYPE_LANG_FLAG_0 (NODE)
844
845 /* True if dependent_type_p has been called for this type, with the
846 result that TYPE_DEPENDENT_P is valid. */
847 #define TYPE_DEPENDENT_P_VALID(NODE) TYPE_LANG_FLAG_6 (NODE)
848
849 /* Nonzero for _TYPE node means that this type does not have a trivial
850 destructor. Therefore, destroying an object of this type will
851 involve a call to a destructor. This can apply to objects of
852 ARRAY_TYPE if the type of the elements needs a destructor. */
853 #define TYPE_HAS_NONTRIVIAL_DESTRUCTOR(NODE) (TYPE_LANG_FLAG_4 (NODE))
854
855 /* For FUNCTION_TYPE or METHOD_TYPE, a list of the exceptions that
856 this type can raise. Each TREE_VALUE is a _TYPE. The TREE_VALUE
857 will be NULL_TREE to indicate a throw specification of `()', or
858 no exceptions allowed. For a noexcept specification, TREE_VALUE
859 is NULL_TREE and TREE_PURPOSE is the constant-expression. For
860 a deferred noexcept-specification, TREE_PURPOSE is a DEFERRED_NOEXCEPT
861 (for templates) or an OVERLOAD list of functions (for implicitly
862 declared functions). */
863 #define TYPE_RAISES_EXCEPTIONS(NODE) \
864 TYPE_LANG_SLOT_1 (FUNC_OR_METHOD_CHECK (NODE))
865
866 /* Identifiers map directly to block or class-scope bindings.
867 Namespace-scope bindings are held in hash tables on the respective
868 namespaces. The identifier bindings are the innermost active
869 binding, from whence you can get the decl and/or implicit-typedef
870 of an elaborated type. When not bound to a local entity the
871 values are NULL. */
872 #define IDENTIFIER_BINDING(NODE) (LANG_IDENTIFIER_CAST (NODE)->bindings)
873
874 #define LANG_IDENTIFIER_CAST(NODE) \
875 ((struct lang_identifier *) IDENTIFIER_NODE_CHECK (NODE))
876
877 /* IF_STMT accessors. These give access to the condition of the if
878 statement, the then block of the if statement, and the else block
879 of the if statement if it exists. */
880 #define IF_COND(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 0)
881 #define THEN_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 1)
882 #define ELSE_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 2)
883 #define IF_SCOPE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 3)
884 #define IF_STMT_CONSTEXPR_P(NODE) TREE_LANG_FLAG_0 (IF_STMT_CHECK (NODE))
885 #define IF_STMT_CONSTEVAL_P(NODE) TREE_LANG_FLAG_2 (IF_STMT_CHECK (NODE))
886
887 /* The expression in question for a DECLTYPE_TYPE. */
888 #define DECLTYPE_TYPE_EXPR(NODE) (TYPE_VALUES_RAW (DECLTYPE_TYPE_CHECK (NODE)))
889
890 #define SET_CLASSTYPE_INTERFACE_UNKNOWN_X(NODE, X) \
891 (LANG_TYPE_CLASS_CHECK (NODE)->interface_unknown = !!(X))
892
893 /* Nonzero if this class is included from a header file which employs
894 `#pragma interface', and it is not included in its implementation file. */
895 #define CLASSTYPE_INTERFACE_ONLY(NODE) \
896 (LANG_TYPE_CLASS_CHECK (NODE)->interface_only)
897
898 #define TYPE_NAME_STRING(NODE) (IDENTIFIER_POINTER (TYPE_IDENTIFIER (NODE)))
899 #define TYPE_NAME_LENGTH(NODE) (IDENTIFIER_LENGTH (TYPE_IDENTIFIER (NODE)))
900
901 /* Whether a PARM_DECL represents a local parameter in a
902 requires-expression. */
903 #define CONSTRAINT_VAR_P(NODE) DECL_LANG_FLAG_2 (TREE_CHECK (NODE, PARM_DECL))
904
905 /* In a CALL_EXPR appearing in a template, true if Koenig lookup
906 should be performed at instantiation time. */
907 #define KOENIG_LOOKUP_P(NODE) TREE_LANG_FLAG_0 (CALL_EXPR_CHECK (NODE))
908
909 /* The index of a user-declared parameter in its function, starting at 1.
910 All artificial parameters will have index 0. */
911 #define DECL_PARM_INDEX(NODE) (LANG_DECL_PARM_CHECK (NODE)->index)
912
913 /* The level of a user-declared parameter in its function, starting at 1.
914 A parameter of the function will have level 1; a parameter of the first
915 nested function declarator (i.e. t in void f (void (*p)(T t))) will have
916 level 2. */
917 #define DECL_PARM_LEVEL(NODE) (LANG_DECL_PARM_CHECK (NODE)->level)
918
919 /* These flags are used by the conversion code.
920 CONV_IMPLICIT : Perform implicit conversions (standard and user-defined).
921 CONV_STATIC : Perform the explicit conversions for static_cast.
922 CONV_CONST : Perform the explicit conversions for const_cast.
923 CONV_REINTERPRET: Perform the explicit conversions for reinterpret_cast.
924 CONV_PRIVATE : Perform upcasts to private bases.
925 CONV_FORCE_TEMP : Require a new temporary when converting to the same
926 aggregate type. */
927
928 #define CONV_IMPLICIT 1
929 #define CONV_STATIC 2
930 #define CONV_CONST 4
931 #define CONV_REINTERPRET 8
932 #define CONV_PRIVATE 16
933 #define CONV_FORCE_TEMP 32
934 #define CONV_FOLD 64
935 #define CONV_OLD_CONVERT \
936 (CONV_IMPLICIT | CONV_STATIC | CONV_CONST | CONV_REINTERPRET)
937 #define CONV_C_CAST \
938 (CONV_IMPLICIT | CONV_STATIC | CONV_CONST | CONV_REINTERPRET | CONV_PRIVATE \
939 | CONV_FORCE_TEMP)
940 #define CONV_BACKEND_CONVERT (CONV_OLD_CONVERT | CONV_FOLD)
941
942 /* Used by build_expr_type_conversion to indicate which types are
943 acceptable as arguments to the expression under consideration. */
944
945 #define WANT_INT 1 /* integer types, including bool */
946 #define WANT_FLOAT 2 /* floating point types */
947 #define WANT_ENUM 4 /* enumerated types */
948 #define WANT_POINTER 8 /* pointer types */
949 #define WANT_NULL 16 /* null pointer constant */
950 #define WANT_VECTOR_OR_COMPLEX 32 /* vector or complex types */
951 #define WANT_ARITH (WANT_INT | WANT_FLOAT | WANT_VECTOR_OR_COMPLEX)
952
953 /* Used with comptypes, and related functions, to guide type
954 comparison. */
955
956 #define COMPARE_STRICT \
957 0 /* Just check if the types are the \
958 same. */
959 #define COMPARE_BASE \
960 1 /* Check to see if the second type is \
961 derived from the first. */
962 #define COMPARE_DERIVED \
963 2 /* Like COMPARE_BASE, but in \
964 reverse. */
965 #define COMPARE_REDECLARATION \
966 4 /* The comparison is being done when \
967 another declaration of an existing \
968 entity is seen. */
969 #define COMPARE_STRUCTURAL \
970 8 /* The comparison is intended to be \
971 structural. The actual comparison \
972 will be identical to \
973 COMPARE_STRICT. */
974
975 /* Used with start function. */
976 #define SF_DEFAULT 0 /* No flags. */
977 #define SF_PRE_PARSED \
978 1 /* The function declaration has \
979 already been parsed. */
980 #define SF_INCLASS_INLINE \
981 2 /* The function is an inline, defined \
982 in the class body. */
983
984 /* Used with start_decl's initialized parameter. */
985 #define SD_UNINITIALIZED 0
986 #define SD_INITIALIZED 1
987 /* Like SD_INITIALIZED, but also mark the new decl as DECL_DECOMPOSITION_P. */
988 #define SD_DECOMPOSITION 2
989 #define SD_DEFAULTED 3
990 #define SD_DELETED 4
991
992 /* Returns nonzero iff TYPE1 and TYPE2 are the same type, in the usual
993 sense of `same'. */
994 #define same_type_p(TYPE1, TYPE2) comptypes ((TYPE1), (TYPE2), COMPARE_STRICT)
995
996 /* Returns true if NODE is a pointer-to-data-member. */
997 #define TYPE_PTRDATAMEM_P(NODE) (TREE_CODE (NODE) == OFFSET_TYPE)
998
999 /* Nonzero if this type is const-qualified. */
1000 #define RS_TYPE_CONST_P(NODE) ((rs_type_quals (NODE) & TYPE_QUAL_CONST) != 0)
1001
1002 /* The _DECL for this _TYPE. */
1003 #define TYPE_MAIN_DECL(NODE) (TYPE_STUB_DECL (TYPE_MAIN_VARIANT (NODE)))
1004
1005 /* Nonzero for a VAR_DECL iff an explicit initializer was provided
1006 or a non-trivial constructor is called. */
1007 #define DECL_NONTRIVIALLY_INITIALIZED_P(NODE) \
1008 (TREE_LANG_FLAG_6 (VAR_DECL_CHECK (NODE)))
1009
1010 /* Nonzero if DECL was declared with '= default' (maybe implicitly). */
1011 #define DECL_DEFAULTED_FN(DECL) (LANG_DECL_FN_CHECK (DECL)->defaulted_p)
1012
1013 /* Nonzero for a class type means that the class type has a
1014 user-declared constructor. */
1015 #define TYPE_HAS_USER_CONSTRUCTOR(NODE) (TYPE_LANG_FLAG_1 (NODE))
1016
1017 /* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These
1018 are the constructors that take an in-charge parameter. */
1019 #define CLASSTYPE_CONSTRUCTORS(NODE) \
1020 (get_class_binding_direct (NODE, ctor_identifier))
1021
1022 /* Nonzero if the DECL was initialized in the class definition itself,
1023 rather than outside the class. This is used for both static member
1024 VAR_DECLS, and FUNCTION_DECLS that are defined in the class. */
1025 #define DECL_INITIALIZED_IN_CLASS_P(DECL) \
1026 (DECL_LANG_SPECIFIC (VAR_OR_FUNCTION_DECL_CHECK (DECL)) \
1027 ->u.base.initialized_in_class)
1028
1029 /* Nonzero if DECL is explicitly defaulted in the class body. */
1030 #define DECL_DEFAULTED_IN_CLASS_P(DECL) \
1031 (DECL_DEFAULTED_FN (DECL) && DECL_INITIALIZED_IN_CLASS_P (DECL))
1032
1033 /* Nonzero for FUNCTION_DECL means that this decl is a non-static
1034 member function. */
1035 #define DECL_NONSTATIC_MEMBER_FUNCTION_P(NODE) \
1036 (TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE)
1037
1038 /* For FUNCTION_DECLs: nonzero means that this function is a
1039 constructor or a destructor with an extra in-charge parameter to
1040 control whether or not virtual bases are constructed. */
1041 #define DECL_HAS_IN_CHARGE_PARM_P(NODE) \
1042 (LANG_DECL_FN_CHECK (NODE)->has_in_charge_parm_p)
1043
1044 /* Nonzero if the VTT parm has been added to NODE. */
1045 #define DECL_HAS_VTT_PARM_P(NODE) (LANG_DECL_FN_CHECK (NODE)->has_vtt_parm_p)
1046
1047 /* Given a FUNCTION_DECL, returns the first TREE_LIST out of TYPE_ARG_TYPES
1048 which refers to a user-written parameter. */
1049 #define FUNCTION_FIRST_USER_PARMTYPE(NODE) \
1050 skip_artificial_parms_for ((NODE), TYPE_ARG_TYPES (TREE_TYPE (NODE)))
1051
1052 /* Similarly, but for DECL_ARGUMENTS. */
1053 #define FUNCTION_FIRST_USER_PARM(NODE) \
1054 skip_artificial_parms_for ((NODE), DECL_ARGUMENTS (NODE))
1055
1056 /* For FUNCTION_DECLs and TEMPLATE_DECLs: nonzero means that this function
1057 is a constructor. */
1058 #define DECL_CONSTRUCTOR_P(NODE) DECL_CXX_CONSTRUCTOR_P (NODE)
1059
1060 /* Nonzero if DECL was declared with '= delete'. */
1061 #define DECL_DELETED_FN(DECL) \
1062 (LANG_DECL_FN_CHECK (DECL)->min.base.threadprivate_or_deleted_p)
1063
1064 /* Nonzero if DECL was declared with '= default' (maybe implicitly). */
1065 #define DECL_DEFAULTED_FN(DECL) (LANG_DECL_FN_CHECK (DECL)->defaulted_p)
1066
1067 /* True if NODE is a brace-enclosed initializer. */
1068 #define BRACE_ENCLOSED_INITIALIZER_P(NODE) \
1069 (TREE_CODE (NODE) == CONSTRUCTOR && TREE_TYPE (NODE) == init_list_type_node)
1070
1071 /* True if FNDECL is an immediate function. */
1072 #define DECL_IMMEDIATE_FUNCTION_P(NODE) \
1073 (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE)) \
1074 ? LANG_DECL_FN_CHECK (NODE)->immediate_fn_p \
1075 : false)
1076 #define SET_DECL_IMMEDIATE_FUNCTION_P(NODE) \
1077 (retrofit_lang_decl (FUNCTION_DECL_CHECK (NODE)), \
1078 LANG_DECL_FN_CHECK (NODE)->immediate_fn_p = true)
1079
1080 /* True if this CONSTRUCTOR should not be used as a variable initializer
1081 because it was loaded from a constexpr variable with mutable fields. */
1082 #define CONSTRUCTOR_MUTABLE_POISON(NODE) \
1083 (TREE_LANG_FLAG_2 (CONSTRUCTOR_CHECK (NODE)))
1084
1085 /* For a pointer-to-member constant `X::Y' this is the _DECL for
1086 `Y'. */
1087 #define PTRMEM_CST_MEMBER(NODE) \
1088 (((ptrmem_cst_t) PTRMEM_CST_CHECK (NODE))->member)
1089
1090 /* Indicates whether a COMPONENT_REF or a SCOPE_REF has been parenthesized, an
1091 INDIRECT_REF comes from parenthesizing a _DECL, or a PAREN_EXPR identifies a
1092 parenthesized initializer relevant for decltype(auto). Currently only set
1093 some of the time in C++14 mode. */
1094
1095 #define REF_PARENTHESIZED_P(NODE) \
1096 TREE_LANG_FLAG_2 (TREE_CHECK5 ((NODE), COMPONENT_REF, INDIRECT_REF, \
1097 SCOPE_REF, VIEW_CONVERT_EXPR, PAREN_EXPR))
1098
1099 /* Returns true if NODE is a pointer-to-member. */
1100 #define TYPE_PTRMEM_P(NODE) \
1101 (TYPE_PTRDATAMEM_P (NODE) || TYPE_PTRMEMFUNC_P (NODE))
1102
1103 /* Returns true if NODE is a pointer or a pointer-to-member. */
1104 #define TYPE_PTR_OR_PTRMEM_P(NODE) (TYPE_PTR_P (NODE) || TYPE_PTRMEM_P (NODE))
1105
1106 /* Nonzero if NODE is an artificial VAR_DECL for a C++17 structured binding
1107 declaration or one of VAR_DECLs for the user identifiers in it. */
1108 #define DECL_DECOMPOSITION_P(NODE) \
1109 (VAR_P (NODE) && DECL_LANG_SPECIFIC (NODE) \
1110 ? DECL_LANG_SPECIFIC (NODE)->u.base.selector == lds_decomp \
1111 : false)
1112
1113 /* The underlying artificial VAR_DECL for structured binding. */
1114 #define DECL_DECOMP_BASE(NODE) (LANG_DECL_DECOMP_CHECK (NODE)->base)
1115
1116 /* Nonzero if either DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P or
1117 DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P is true of NODE. */
1118 #define DECL_MAYBE_IN_CHARGE_CDTOR_P(NODE) \
1119 (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (NODE) \
1120 || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (NODE))
1121
1122 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor, but not the
1123 specialized in-charge constructor, in-charge deleting constructor,
1124 or the base destructor. */
1125 #define DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P(NODE) \
1126 (DECL_NAME (NODE) == dtor_identifier)
1127
1128 /* Nonzero if NODE (a _DECL) is a cloned constructor or
1129 destructor. */
1130 #define DECL_CLONED_FUNCTION_P(NODE) \
1131 (DECL_NAME (NODE) && IDENTIFIER_CDTOR_P (DECL_NAME (NODE)) \
1132 && !DECL_MAYBE_IN_CHARGE_CDTOR_P (NODE))
1133
1134 /* If DECL_CLONED_FUNCTION_P holds, this is the function that was
1135 cloned. */
1136 #define DECL_CLONED_FUNCTION(NODE) \
1137 (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE))->u.fn.u5.cloned_function)
1138
1139 /* Nonzero if NODE (a _DECL) is a cloned constructor or
1140 destructor. */
1141 #define DECL_CLONED_FUNCTION_P(NODE) \
1142 (DECL_NAME (NODE) && IDENTIFIER_CDTOR_P (DECL_NAME (NODE)) \
1143 && !DECL_MAYBE_IN_CHARGE_CDTOR_P (NODE))
1144
1145 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor, but not either the
1146 specialized in-charge constructor or the specialized not-in-charge
1147 constructor. */
1148 #define DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P(NODE) \
1149 (DECL_NAME (NODE) == ctor_identifier)
1150
1151 /* The current C++-specific per-function global variables. */
1152
1153 #define cp_function_chain (cfun->language)
1154
1155 /* In a constructor destructor, the point at which all derived class
1156 destroying/construction has been done. I.e., just before a
1157 constructor returns, or before any base class destroying will be done
1158 in a destructor. */
1159
1160 #define cdtor_label cp_function_chain->x_cdtor_label
1161
1162 /* When we're processing a member function, current_class_ptr is the
1163 PARM_DECL for the `this' pointer. The current_class_ref is an
1164 expression for `*this'. */
1165
1166 #define current_class_ptr \
1167 (*(cfun && cp_function_chain ? &cp_function_chain->x_current_class_ptr \
1168 : &scope_chain->x_current_class_ptr))
1169 #define current_class_ref \
1170 (*(cfun && cp_function_chain ? &cp_function_chain->x_current_class_ref \
1171 : &scope_chain->x_current_class_ref))
1172
1173 /* The EH_SPEC_BLOCK for the exception-specifiers for the current
1174 function, if any. */
1175
1176 #define current_eh_spec_block cp_function_chain->x_eh_spec_block
1177
1178 /* The `__in_chrg' parameter for the current function. Only used for
1179 constructors and destructors. */
1180
1181 #define current_in_charge_parm cp_function_chain->x_in_charge_parm
1182
1183 /* The `__vtt_parm' parameter for the current function. Only used for
1184 constructors and destructors. */
1185
1186 #define current_vtt_parm cp_function_chain->x_vtt_parm
1187
1188 /* A boolean flag to control whether we need to clean up the return value if a
1189 local destructor throws. Only used in functions that return by value a
1190 class with a destructor. Which 'tors don't, so we can use the same
1191 field as current_vtt_parm. */
1192
1193 #define current_retval_sentinel current_vtt_parm
1194
1195 /* Set to 0 at beginning of a function definition, set to 1 if
1196 a return statement that specifies a return value is seen. */
1197
1198 #define current_function_returns_value cp_function_chain->returns_value
1199
1200 /* Set to 0 at beginning of a function definition, set to 1 if
1201 a return statement with no argument is seen. */
1202
1203 #define current_function_returns_null cp_function_chain->returns_null
1204
1205 /* Set to 0 at beginning of a function definition, set to 1 if
1206 a call to a noreturn function is seen. */
1207
1208 #define current_function_returns_abnormally \
1209 cp_function_chain->returns_abnormally
1210
1211 /* Set to 0 at beginning of a function definition, set to 1 if we see an
1212 obvious infinite loop. This can have false positives and false
1213 negatives, so it should only be used as a heuristic. */
1214
1215 #define current_function_infinite_loop cp_function_chain->infinite_loop
1216
1217 /* Nonzero if we are processing a base initializer. Zero elsewhere. */
1218 #define in_base_initializer cp_function_chain->x_in_base_initializer
1219
1220 #define in_function_try_handler cp_function_chain->x_in_function_try_handler
1221
1222 /* Expression always returned from function, or error_mark_node
1223 otherwise, for use by the automatic named return value optimization. */
1224
1225 #define current_function_return_value (cp_function_chain->x_return_value)
1226
1227 #define current_class_type scope_chain->class_type
1228
1229 #define in_discarded_stmt scope_chain->discarded_stmt
1230 #define in_consteval_if_p scope_chain->consteval_if_p
1231
1232 /* Nonzero means that this type is being defined. I.e., the left brace
1233 starting the definition of this type has been seen. */
1234 #define TYPE_BEING_DEFINED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->being_defined)
1235
1236 /* Nonzero for FUNCTION_DECL means that this decl is a static
1237 member function. */
1238 #define DECL_STATIC_FUNCTION_P(NODE) \
1239 (LANG_DECL_FN_CHECK (NODE)->static_function)
1240
1241 /* Nonzero for FUNCTION_DECL means that this decl is a non-static
1242 member function. */
1243 #define DECL_NONSTATIC_MEMBER_FUNCTION_P(NODE) \
1244 (TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE)
1245
1246 /* Nonzero for FUNCTION_DECL means that this decl is a member function
1247 (static or non-static). */
1248 #define DECL_FUNCTION_MEMBER_P(NODE) \
1249 (DECL_NONSTATIC_MEMBER_FUNCTION_P (NODE) || DECL_STATIC_FUNCTION_P (NODE))
1250
1251 /* Nonzero if NODE is the target for genericization of 'return' stmts
1252 in constructors/destructors of targetm.cxx.cdtor_returns_this targets. */
1253 #define LABEL_DECL_CDTOR(NODE) DECL_LANG_FLAG_2 (LABEL_DECL_CHECK (NODE))
1254
1255 /* Nonzero if this NOP_EXPR is a reinterpret_cast. Such conversions
1256 are not constexprs. Other NOP_EXPRs are. */
1257 #define REINTERPRET_CAST_P(NODE) TREE_LANG_FLAG_0 (NOP_EXPR_CHECK (NODE))
1258
1259 /* Returns true if NODE is an object type:
1260
1261 [basic.types]
1262
1263 An object type is a (possibly cv-qualified) type that is not a
1264 function type, not a reference type, and not a void type.
1265
1266 Keep these checks in ascending order, for speed. */
1267 #define TYPE_OBJ_P(NODE) \
1268 (!TYPE_REF_P (NODE) && !VOID_TYPE_P (NODE) && !FUNC_OR_METHOD_TYPE_P (NODE))
1269
1270 /* Returns true if NODE is a pointer to an object. Keep these checks
1271 in ascending tree code order. */
1272 #define TYPE_PTROB_P(NODE) (TYPE_PTR_P (NODE) && TYPE_OBJ_P (TREE_TYPE (NODE)))
1273
1274 /* True if this CONSTRUCTOR contains PLACEHOLDER_EXPRs referencing the
1275 CONSTRUCTOR's type not nested inside another CONSTRUCTOR marked with
1276 CONSTRUCTOR_PLACEHOLDER_BOUNDARY. */
1277 #define CONSTRUCTOR_PLACEHOLDER_BOUNDARY(NODE) \
1278 (TREE_LANG_FLAG_5 (CONSTRUCTOR_CHECK (NODE)))
1279
1280 #define AGGR_INIT_EXPR_SLOT(NODE) TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 2)
1281
1282 /* True if this TARGET_EXPR expresses direct-initialization of an object
1283 to be named later. */
1284 #define TARGET_EXPR_DIRECT_INIT_P(NODE) \
1285 TREE_LANG_FLAG_2 (TARGET_EXPR_CHECK (NODE))
1286
1287 /* Nonzero if DECL is a declaration of __builtin_constant_p. */
1288 #define DECL_IS_BUILTIN_CONSTANT_P(NODE) \
1289 (TREE_CODE (NODE) == FUNCTION_DECL \
1290 && DECL_BUILT_IN_CLASS (NODE) == BUILT_IN_NORMAL \
1291 && DECL_FUNCTION_CODE (NODE) == BUILT_IN_CONSTANT_P)
1292
1293 /* True iff this represents an lvalue being treated as an rvalue during return
1294 or throw as per [class.copy.elision]. */
1295 #define IMPLICIT_RVALUE_P(NODE) \
1296 TREE_LANG_FLAG_3 (TREE_CHECK2 ((NODE), NON_LVALUE_EXPR, STATIC_CAST_EXPR))
1297
1298 /* Nonzero for _DECL means that this decl appears in (or will appear
1299 in) as a member in a RECORD_TYPE or UNION_TYPE node. It is also for
1300 detecting circularity in case members are multiply defined. In the
1301 case of a VAR_DECL, it means that no definition has been seen, even
1302 if an initializer has been. */
1303 #define DECL_IN_AGGR_P(NODE) (DECL_LANG_FLAG_3 (NODE))
1304
1305 /* Nonzero means that this class type is a non-standard-layout class. */
1306 #define CLASSTYPE_NON_STD_LAYOUT(NODE) \
1307 (LANG_TYPE_CLASS_CHECK (NODE)->non_std_layout)
1308
1309 /* Nonzero for FIELD_DECL node means that this field is a base class
1310 of the parent object, as opposed to a member field. */
1311 #define DECL_FIELD_IS_BASE(NODE) DECL_LANG_FLAG_6 (FIELD_DECL_CHECK (NODE))
1312
1313 /* Nonzero if TYPE is an anonymous union type. */
1314 #define ANON_UNION_TYPE_P(NODE) \
1315 (TREE_CODE (NODE) == UNION_TYPE && ANON_AGGR_TYPE_P (NODE))
1316
1317 /* For an ANON_AGGR_TYPE_P the single FIELD_DECL it is used with. */
1318 #define ANON_AGGR_TYPE_FIELD(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->typeinfo_var)
1319
1320 /* Nonzero if TYPE is an anonymous union or struct type. We have to use a
1321 flag for this because "A union for which objects or pointers are
1322 declared is not an anonymous union" [class.union]. */
1323 #define ANON_AGGR_TYPE_P(NODE) \
1324 (CLASS_TYPE_P (NODE) && LANG_TYPE_CLASS_CHECK (NODE)->anon_aggr)
1325 #define SET_ANON_AGGR_TYPE_P(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->anon_aggr = 1)
1326
1327 /* Nonzero if T is a class type but not a union. */
1328 #define NON_UNION_CLASS_TYPE_P(T) \
1329 (TREE_CODE (T) == RECORD_TYPE && TYPE_LANG_FLAG_5 (T))
1330
1331 /* Determines whether an ENUMERAL_TYPE has an explicit
1332 underlying type. */
1333 #define ENUM_FIXED_UNDERLYING_TYPE_P(NODE) (TYPE_LANG_FLAG_5 (NODE))
1334
1335 /* Returns the underlying type of the given enumeration type. The
1336 underlying type is determined in different ways, depending on the
1337 properties of the enum:
1338
1339 - In C++0x, the underlying type can be explicitly specified, e.g.,
1340
1341 enum E1 : char { ... } // underlying type is char
1342
1343 - In a C++0x scoped enumeration, the underlying type is int
1344 unless otherwises specified:
1345
1346 enum class E2 { ... } // underlying type is int
1347
1348 - Otherwise, the underlying type is determined based on the
1349 values of the enumerators. In this case, the
1350 ENUM_UNDERLYING_TYPE will not be set until after the definition
1351 of the enumeration is completed by finish_enum. */
1352 #define ENUM_UNDERLYING_TYPE(TYPE) TREE_TYPE (ENUMERAL_TYPE_CHECK (TYPE))
1353
1354 /* Nonzero if this type is volatile-qualified. */
1355 #define RS_TYPE_VOLATILE_P(NODE) \
1356 ((rs_type_quals (NODE) & TYPE_QUAL_VOLATILE) != 0)
1357
1358 /* Nonzero means that this type is either complete or being defined, so we
1359 can do lookup in it. */
1360 #define COMPLETE_OR_OPEN_TYPE_P(NODE) \
1361 (COMPLETE_TYPE_P (NODE) || (CLASS_TYPE_P (NODE) && TYPE_BEING_DEFINED (NODE)))
1362
1363 /* Indicates when overload resolution may resolve to a pointer to
1364 member function. [expr.unary.op]/3 */
1365 #define PTRMEM_OK_P(NODE) \
1366 TREE_LANG_FLAG_0 (TREE_CHECK3 ((NODE), ADDR_EXPR, OFFSET_REF, SCOPE_REF))
1367
1368 /* Returns nonzero iff NODE is a declaration for the global function
1369 `main'. */
1370 #define DECL_MAIN_P(NODE) \
1371 (DECL_NAME (NODE) != NULL_TREE && MAIN_NAME_P (DECL_NAME (NODE)) \
1372 && flag_hosted)
1373
1374 /* Nonzero if the variable was declared to be thread-local.
1375 We need a special C++ version of this test because the middle-end
1376 DECL_THREAD_LOCAL_P uses the symtab, so we can't use it for
1377 templates. */
1378 #define RS_DECL_THREAD_LOCAL_P(NODE) (TREE_LANG_FLAG_0 (VAR_DECL_CHECK (NODE)))
1379
1380 #define COND_EXPR_IS_VEC_DELETE(NODE) TREE_LANG_FLAG_0 (COND_EXPR_CHECK (NODE))
1381
1382 /* RANGE_FOR_STMT accessors. These give access to the declarator,
1383 expression, body, and scope of the statement, respectively. */
1384 #define RANGE_FOR_DECL(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 0)
1385 #define RANGE_FOR_EXPR(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 1)
1386 #define RANGE_FOR_BODY(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 2)
1387 #define RANGE_FOR_SCOPE(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 3)
1388 #define RANGE_FOR_UNROLL(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 4)
1389 #define RANGE_FOR_INIT_STMT(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 5)
1390 #define RANGE_FOR_IVDEP(NODE) TREE_LANG_FLAG_6 (RANGE_FOR_STMT_CHECK (NODE))
1391
1392 #define CP_DECL_CONTEXT(NODE) \
1393 (!DECL_FILE_SCOPE_P (NODE) ? DECL_CONTEXT (NODE) : global_namespace)
1394 #define CP_TYPE_CONTEXT(NODE) \
1395 (!TYPE_FILE_SCOPE_P (NODE) ? TYPE_CONTEXT (NODE) : global_namespace)
1396 #define FROB_CONTEXT(NODE) \
1397 ((NODE) == global_namespace ? DECL_CONTEXT (NODE) : (NODE))
1398
1399 /* Nonzero if NODE is the std namespace. */
1400 #define DECL_NAMESPACE_STD_P(NODE) ((NODE) == std_node)
1401
1402 /* Whether the namepace is an inline namespace. */
1403 #define DECL_NAMESPACE_INLINE_P(NODE) \
1404 TREE_LANG_FLAG_0 (NAMESPACE_DECL_CHECK (NODE))
1405
1406 #define CP_DECL_CONTEXT(NODE) \
1407 (!DECL_FILE_SCOPE_P (NODE) ? DECL_CONTEXT (NODE) : global_namespace)
1408
1409 /* Based off of TYPE_UNNAMED_P. */
1410 #define LAMBDA_TYPE_P(NODE) \
1411 (TREE_CODE (NODE) == RECORD_TYPE && TYPE_LINKAGE_IDENTIFIER (NODE) \
1412 && IDENTIFIER_LAMBDA_P (TYPE_LINKAGE_IDENTIFIER (NODE)))
1413
1414 /* Macros to make error reporting functions' lives easier. */
1415 #define TYPE_LINKAGE_IDENTIFIER(NODE) \
1416 (TYPE_IDENTIFIER (TYPE_MAIN_VARIANT (NODE)))
1417
1418 /* Identifiers used for lambda types are almost anonymous. Use this
1419 spare flag to distinguish them (they also have the anonymous flag). */
1420 #define IDENTIFIER_LAMBDA_P(NODE) \
1421 (IDENTIFIER_NODE_CHECK (NODE)->base.protected_flag)
1422
1423 /* If NODE, a FUNCTION_DECL, is a C++11 inheriting constructor, then this
1424 is the constructor it inherits from. */
1425 #define DECL_INHERITED_CTOR(NODE) \
1426 (DECL_DECLARES_FUNCTION_P (NODE) && DECL_CONSTRUCTOR_P (NODE) \
1427 ? LANG_DECL_FN_CHECK (NODE)->context \
1428 : NULL_TREE)
1429
1430 /* True if the class type TYPE is a literal type. */
1431 #define CLASSTYPE_LITERAL_P(TYPE) (LANG_TYPE_CLASS_CHECK (TYPE)->is_literal)
1432
1433 /* Nonzero if NODE (a FUNCTION_DECL or TEMPLATE_DECL)
1434 is a destructor. */
1435 #define DECL_DESTRUCTOR_P(NODE) DECL_CXX_DESTRUCTOR_P (NODE)
1436
1437 /* Nonzero if TYPE has a trivial destructor. From [class.dtor]:
1438
1439 A destructor is trivial if it is an implicitly declared
1440 destructor and if:
1441
1442 - all of the direct base classes of its class have trivial
1443 destructors,
1444
1445 - for all of the non-static data members of its class that are
1446 of class type (or array thereof), each such class has a
1447 trivial destructor. */
1448 #define TYPE_HAS_TRIVIAL_DESTRUCTOR(NODE) \
1449 (!TYPE_HAS_NONTRIVIAL_DESTRUCTOR (NODE))
1450
1451 /* Nonzero means that NODE (a class type) has a destructor -- but that
1452 it has not yet been declared. */
1453 #define CLASSTYPE_LAZY_DESTRUCTOR(NODE) \
1454 (LANG_TYPE_CLASS_CHECK (NODE)->lazy_destructor)
1455
1456 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a complete
1457 object. */
1458 #define DECL_COMPLETE_CONSTRUCTOR_P(NODE) \
1459 (DECL_NAME (NODE) == complete_ctor_identifier)
1460
1461 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a base
1462 object. */
1463 #define DECL_BASE_CONSTRUCTOR_P(NODE) (DECL_NAME (NODE) == base_ctor_identifier)
1464
1465 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor, but not either the
1466 specialized in-charge constructor or the specialized not-in-charge
1467 constructor. */
1468 #define DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P(NODE) \
1469 (DECL_NAME (NODE) == ctor_identifier)
1470
1471 /* Nonzero if NODE (a FUNCTION_DECL) is a copy constructor. */
1472 #define DECL_COPY_CONSTRUCTOR_P(NODE) \
1473 (DECL_CONSTRUCTOR_P (NODE) && copy_fn_p (NODE) > 0)
1474
1475 /* Nonzero if NODE (a FUNCTION_DECL) is a move constructor. */
1476 #define DECL_MOVE_CONSTRUCTOR_P(NODE) \
1477 (DECL_CONSTRUCTOR_P (NODE) && move_fn_p (NODE))
1478
1479 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor, but not the
1480 specialized in-charge constructor, in-charge deleting constructor,
1481 or the base destructor. */
1482 #define DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P(NODE) \
1483 (DECL_NAME (NODE) == dtor_identifier)
1484
1485 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete
1486 object. */
1487 #define DECL_COMPLETE_DESTRUCTOR_P(NODE) \
1488 (DECL_NAME (NODE) == complete_dtor_identifier)
1489
1490 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a base
1491 object. */
1492 #define DECL_BASE_DESTRUCTOR_P(NODE) (DECL_NAME (NODE) == base_dtor_identifier)
1493
1494 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete
1495 object that deletes the object after it has been destroyed. */
1496 #define DECL_DELETING_DESTRUCTOR_P(NODE) \
1497 (DECL_NAME (NODE) == deleting_dtor_identifier)
1498
1499 /* Nonzero if either DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P or
1500 DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P is true of NODE. */
1501 #define DECL_MAYBE_IN_CHARGE_CDTOR_P(NODE) \
1502 (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (NODE) \
1503 || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (NODE))
1504
1505 /* Nonzero if NODE (a _DECL) is a cloned constructor or
1506 destructor. */
1507 #define DECL_CLONED_FUNCTION_P(NODE) \
1508 (DECL_NAME (NODE) && IDENTIFIER_CDTOR_P (DECL_NAME (NODE)) \
1509 && !DECL_MAYBE_IN_CHARGE_CDTOR_P (NODE))
1510
1511 /* If DECL_CLONED_FUNCTION_P holds, this is the function that was
1512 cloned. */
1513 #define DECL_CLONED_FUNCTION(NODE) \
1514 (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE))->u.fn.u5.cloned_function)
1515
1516 /* Nonzero means that an object of this type cannot be initialized using
1517 an initializer list. */
1518 #define CLASSTYPE_NON_AGGREGATE(NODE) \
1519 (LANG_TYPE_CLASS_CHECK (NODE)->non_aggregate)
1520 #define TYPE_NON_AGGREGATE_CLASS(NODE) \
1521 (CLASS_TYPE_P (NODE) && CLASSTYPE_NON_AGGREGATE (NODE))
1522
1523 /* Nonzero for class type means that the default constructor is trivial. */
1524 #define TYPE_HAS_TRIVIAL_DFLT(NODE) \
1525 (TYPE_HAS_DEFAULT_CONSTRUCTOR (NODE) && !TYPE_HAS_COMPLEX_DFLT (NODE))
1526
1527 /* Nonzero if this class has a constexpr constructor other than a copy/move
1528 constructor. Note that a class can have constexpr constructors for
1529 static initialization even if it isn't a literal class. */
1530 #define TYPE_HAS_CONSTEXPR_CTOR(NODE) \
1531 (LANG_TYPE_CLASS_CHECK (NODE)->has_constexpr_ctor)
1532
1533 /* Nonzero if there is no trivial default constructor for this class. */
1534 #define TYPE_HAS_COMPLEX_DFLT(NODE) \
1535 (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_dflt)
1536
1537 /* [dcl.init.aggr]
1538
1539 An aggregate is an array or a class with no user-provided
1540 constructors, no brace-or-equal-initializers for non-static data
1541 members, no private or protected non-static data members, no
1542 base classes, and no virtual functions.
1543
1544 As an extension, we also treat vectors as aggregates. Keep these
1545 checks in ascending code order. */
1546 #define CP_AGGREGATE_TYPE_P(TYPE) \
1547 (gnu_vector_type_p (TYPE) || TREE_CODE (TYPE) == ARRAY_TYPE \
1548 || (CLASS_TYPE_P (TYPE) && COMPLETE_TYPE_P (TYPE) \
1549 && !CLASSTYPE_NON_AGGREGATE (TYPE)))
1550
1551 /* Nonzero for a FIELD_DECL means that this member object type
1552 is mutable. */
1553 #define DECL_MUTABLE_P(NODE) (DECL_LANG_FLAG_0 (FIELD_DECL_CHECK (NODE)))
1554
1555 #if defined ENABLE_TREE_CHECKING
1556
1557 #define LANG_DECL_MIN_CHECK(NODE) \
1558 __extension__({ \
1559 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1560 if (!LANG_DECL_HAS_MIN (NODE)) \
1561 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1562 &lt->u.min; \
1563 })
1564
1565 /* We want to be able to check DECL_CONSTRUCTOR_P and such on a function
1566 template, not just on a FUNCTION_DECL. So when looking for things in
1567 lang_decl_fn, look down through a TEMPLATE_DECL into its result. */
1568 #define LANG_DECL_FN_CHECK(NODE) \
1569 __extension__({ \
1570 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1571 if (!DECL_DECLARES_FUNCTION_P (NODE) || lt->u.base.selector != lds_fn) \
1572 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1573 &lt->u.fn; \
1574 })
1575
1576 #define LANG_DECL_NS_CHECK(NODE) \
1577 __extension__({ \
1578 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1579 if (TREE_CODE (NODE) != NAMESPACE_DECL || lt->u.base.selector != lds_ns) \
1580 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1581 &lt->u.ns; \
1582 })
1583
1584 #define LANG_DECL_PARM_CHECK(NODE) \
1585 __extension__({ \
1586 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1587 if (TREE_CODE (NODE) != PARM_DECL || lt->u.base.selector != lds_parm) \
1588 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1589 &lt->u.parm; \
1590 })
1591
1592 #define LANG_DECL_DECOMP_CHECK(NODE) \
1593 __extension__({ \
1594 struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
1595 if (!VAR_P (NODE) || lt->u.base.selector != lds_decomp) \
1596 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
1597 &lt->u.decomp; \
1598 })
1599
1600 #else
1601
1602 #define LANG_DECL_MIN_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.min)
1603
1604 #define LANG_DECL_FN_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.fn)
1605
1606 #define LANG_DECL_NS_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.ns)
1607
1608 #define LANG_DECL_PARM_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.parm)
1609
1610 #define LANG_DECL_DECOMP_CHECK(NODE) (&DECL_LANG_SPECIFIC (NODE)->u.decomp)
1611
1612 #endif /* ENABLE_TREE_CHECKING */
1613
1614 // Below macros are copied from gcc/c-family/c-common.h
1615
1616 /* In a FIELD_DECL, nonzero if the decl was originally a bitfield. */
1617 #define DECL_C_BIT_FIELD(NODE) (DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) == 1)
1618 #define SET_DECL_C_BIT_FIELD(NODE) \
1619 (DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) = 1)
1620 #define CLEAR_DECL_C_BIT_FIELD(NODE) \
1621 (DECL_LANG_FLAG_4 (FIELD_DECL_CHECK (NODE)) = 0)
1622
1623 /* True if the decl was an unnamed bitfield. */
1624 #define DECL_UNNAMED_BIT_FIELD(NODE) \
1625 (DECL_C_BIT_FIELD (NODE) && !DECL_NAME (NODE))
1626
1627 /* 1 iff NODE is function-local. */
1628 #define DECL_FUNCTION_SCOPE_P(NODE) \
1629 (DECL_CONTEXT (NODE) && TREE_CODE (DECL_CONTEXT (NODE)) == FUNCTION_DECL)
1630
1631 /* Nonzero if this type is const-qualified, but not
1632 volatile-qualified. Other qualifiers are ignored. This macro is
1633 used to test whether or not it is OK to bind an rvalue to a
1634 reference. */
1635 #define RS_TYPE_CONST_NON_VOLATILE_P(NODE) \
1636 ((rs_type_quals (NODE) & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)) \
1637 == TYPE_QUAL_CONST)
1638
1639 /* Returns true if TYPE is an integral or enumeration name. Keep
1640 these checks in ascending code order. */
1641 #define INTEGRAL_OR_ENUMERATION_TYPE_P(TYPE) \
1642 (TREE_CODE (TYPE) == ENUMERAL_TYPE || RS_INTEGRAL_TYPE_P (TYPE))
1643
1644 /* Nonzero for a VAR_DECL that was initialized with a
1645 constant-expression. */
1646 #define DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P(NODE) \
1647 (TREE_LANG_FLAG_2 (VAR_DECL_CHECK (NODE)))
1648
1649 /* WHILE_STMT accessors. These give access to the condition of the
1650 while statement and the body of the while statement, respectively. */
1651 #define WHILE_COND(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 0)
1652 #define WHILE_BODY(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 1)
1653
1654 /* FOR_STMT accessors. These give access to the init statement,
1655 condition, update expression, and body of the for statement,
1656 respectively. */
1657 #define FOR_INIT_STMT(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 0)
1658 #define FOR_COND(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 1)
1659 #define FOR_EXPR(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 2)
1660 #define FOR_BODY(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 3)
1661 #define FOR_SCOPE(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 4)
1662
1663 #define SWITCH_STMT_COND(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 0)
1664 #define SWITCH_STMT_BODY(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 1)
1665 #define SWITCH_STMT_TYPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 2)
1666 #define SWITCH_STMT_SCOPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 3)
1667
1668 /* Nonzero if NODE is the target for genericization of 'break' stmts. */
1669 #define LABEL_DECL_BREAK(NODE) DECL_LANG_FLAG_0 (LABEL_DECL_CHECK (NODE))
1670
1671 /* Nonzero if NODE is the target for genericization of 'continue' stmts. */
1672 #define LABEL_DECL_CONTINUE(NODE) DECL_LANG_FLAG_1 (LABEL_DECL_CHECK (NODE))
1673
1674 // Above macros are copied from gcc/c-family/c-common.h
1675
1676 // Below macros are copied from gcc/cp/name-lookup.h
1677
1678 /* Lookup walker marking. */
1679 #define LOOKUP_SEEN_P(NODE) TREE_VISITED (NODE)
1680 #define LOOKUP_FOUND_P(NODE) \
1681 TREE_LANG_FLAG_4 (TREE_CHECK4 (NODE, RECORD_TYPE, UNION_TYPE, ENUMERAL_TYPE, \
1682 NAMESPACE_DECL))
1683
1684 // Above macros are copied from gcc/cp/name-lookup.h
1685
1686 // Below macros are copied from gcc/cp/name-lookup.cc
1687
1688 /* Create an overload suitable for recording an artificial TYPE_DECL
1689 and another decl. We use this machanism to implement the struct
1690 stat hack. */
1691
1692 #define STAT_HACK_P(N) ((N) && TREE_CODE (N) == OVERLOAD && OVL_LOOKUP_P (N))
1693 #define STAT_TYPE_VISIBLE_P(N) TREE_USED (OVERLOAD_CHECK (N))
1694 #define STAT_TYPE(N) TREE_TYPE (N)
1695 #define STAT_DECL(N) OVL_FUNCTION (N)
1696 #define STAT_VISIBLE(N) OVL_CHAIN (N)
1697 #define MAYBE_STAT_DECL(N) (STAT_HACK_P (N) ? STAT_DECL (N) : N)
1698 #define MAYBE_STAT_TYPE(N) (STAT_HACK_P (N) ? STAT_TYPE (N) : NULL_TREE)
1699
1700 /* When a STAT_HACK_P is true, OVL_USING_P and OVL_EXPORT_P are valid
1701 and apply to the hacked type. */
1702
1703 /* For regular (maybe) overloaded functions, we have OVL_HIDDEN_P.
1704 But we also need to indicate hiddenness on implicit type decls
1705 (injected friend classes), and (coming soon) decls injected from
1706 block-scope externs. It is too awkward to press the existing
1707 overload marking for that. If we have a hidden non-function, we
1708 always create a STAT_HACK, and use these two markers as needed. */
1709 #define STAT_TYPE_HIDDEN_P(N) OVL_HIDDEN_P (N)
1710 #define STAT_DECL_HIDDEN_P(N) OVL_DEDUP_P (N)
1711
1712 /* The binding level currently in effect. */
1713
1714 #define current_binding_level \
1715 (*(cfun && cp_function_chain && cp_function_chain->bindings \
1716 ? &cp_function_chain->bindings \
1717 : &scope_chain->bindings))
1718
1719 // Above macros are copied from gcc/cp/name-lookup.cc
1720
1721 /* The various kinds of special functions. If you add to this list,
1722 you should update special_function_p as well. */
1723 enum special_function_kind
1724 {
1725 sfk_none = 0, /* Not a special function. This enumeral
1726 must have value zero; see
1727 special_function_p. */
1728 /* The following are ordered, for use by member synthesis fns. */
1729 sfk_destructor, /* A destructor. */
1730 sfk_constructor, /* A constructor. */
1731 sfk_inheriting_constructor, /* An inheriting constructor */
1732 sfk_copy_constructor, /* A copy constructor. */
1733 sfk_move_constructor, /* A move constructor. */
1734 sfk_copy_assignment, /* A copy assignment operator. */
1735 sfk_move_assignment, /* A move assignment operator. */
1736 /* The following are unordered. */
1737 sfk_complete_destructor, /* A destructor for complete objects. */
1738 sfk_base_destructor, /* A destructor for base subobjects. */
1739 sfk_deleting_destructor, /* A destructor for complete objects that
1740 deletes the object after it has been
1741 destroyed. */
1742 sfk_conversion, /* A conversion operator. */
1743 sfk_deduction_guide, /* A class template deduction guide. */
1744 sfk_comparison, /* A comparison operator (e.g. ==, <, <=>). */
1745 sfk_virtual_destructor /* Used by member synthesis fns. */
1746 };
1747
1748 /* Places where an lvalue, or modifiable lvalue, may be required.
1749 Used to select diagnostic messages in lvalue_error and
1750 readonly_error. */
1751 enum lvalue_use
1752 {
1753 lv_assign,
1754 lv_increment,
1755 lv_decrement,
1756 lv_addressof,
1757 lv_asm
1758 };
1759
1760 /* A class for recording information about access failures (e.g. private
1761 fields), so that we can potentially supply a fix-it hint about
1762 an accessor (from a context in which the constness of the object
1763 is known). */
1764
1765 class access_failure_info
1766 {
1767 public:
1768 access_failure_info ()
1769 : m_was_inaccessible (false), m_basetype_path (NULL_TREE),
1770 m_decl (NULL_TREE), m_diag_decl (NULL_TREE)
1771 {}
1772
1773 void record_access_failure (tree basetype_path, tree decl, tree diag_decl);
1774
1775 bool was_inaccessible_p () const { return m_was_inaccessible; }
1776 tree get_decl () const { return m_decl; }
1777 tree get_diag_decl () const { return m_diag_decl; }
1778 tree get_any_accessor (bool const_p) const;
1779 void maybe_suggest_accessor (bool const_p) const;
1780 static void add_fixit_hint (rich_location *richloc, tree accessor);
1781
1782 private:
1783 bool m_was_inaccessible;
1784 tree m_basetype_path;
1785 tree m_decl;
1786 tree m_diag_decl;
1787 };
1788
1789 /* The various kinds of access check during parsing. */
1790 enum deferring_kind
1791 {
1792 dk_no_deferred = 0, /* Check access immediately */
1793 dk_deferred = 1, /* Deferred check */
1794 dk_no_check = 2 /* No access check */
1795 };
1796
1797 /* The representation of a deferred access check. */
1798
1799 struct GTY (()) deferred_access_check
1800 {
1801 /* The base class in which the declaration is referenced. */
1802 tree binfo;
1803 /* The declaration whose access must be checked. */
1804 tree decl;
1805 /* The declaration that should be used in the error message. */
1806 tree diag_decl;
1807 /* The location of this access. */
1808 location_t loc;
1809 };
1810
1811 struct GTY (()) tree_template_info
1812 {
1813 struct tree_base base;
1814 tree tmpl;
1815 tree args;
1816 vec<deferred_access_check, va_gc> *deferred_access_checks;
1817 };
1818
1819 /* The various kinds of lvalues we distinguish. */
1820 enum cp_lvalue_kind_flags
1821 {
1822 clk_none = 0, /* Things that are not an lvalue. */
1823 clk_ordinary = 1, /* An ordinary lvalue. */
1824 clk_rvalueref = 2, /* An xvalue (rvalue formed using an rvalue reference) */
1825 clk_class = 4, /* A prvalue of class or array type. */
1826 clk_bitfield = 8, /* An lvalue for a bit-field. */
1827 clk_packed = 16, /* An lvalue for a packed field. */
1828 clk_implicit_rval = 1 << 5 /* An lvalue being treated as an xvalue. */
1829 };
1830
1831 /* This type is used for parameters and variables which hold
1832 combinations of the flags in enum cp_lvalue_kind_flags. */
1833 typedef int cp_lvalue_kind;
1834
1835 // forked from gcc/cp/name_lookup.h scope_kind
1836
1837 /* The kinds of scopes we recognize. */
1838 enum scope_kind
1839 {
1840 sk_block = 0, /* An ordinary block scope. This enumerator must
1841 have the value zero because "cp_binding_level"
1842 is initialized by using "memset" to set the
1843 contents to zero, and the default scope kind
1844 is "sk_block". */
1845 sk_cleanup, /* A scope for (pseudo-)scope for cleanup. It is
1846 pseudo in that it is transparent to name lookup
1847 activities. */
1848 sk_try, /* A try-block. */
1849 sk_catch, /* A catch-block. */
1850 sk_for, /* The scope of the variable declared in a
1851 init-statement. */
1852 sk_cond, /* The scope of the variable declared in the condition
1853 of an if or switch statement. */
1854 sk_function_parms, /* The scope containing function parameters. */
1855 sk_class, /* The scope containing the members of a class. */
1856 sk_scoped_enum, /* The scope containing the enumerators of a C++11
1857 scoped enumeration. */
1858 sk_namespace, /* The scope containing the members of a
1859 namespace, including the global scope. */
1860 sk_template_parms, /* A scope for template parameters. */
1861 sk_template_spec, /* Like sk_template_parms, but for an explicit
1862 specialization. Since, by definition, an
1863 explicit specialization is introduced by
1864 "template <>", this scope is always empty. */
1865 sk_transaction, /* A synchronized or atomic statement. */
1866 sk_omp /* An OpenMP structured block. */
1867 };
1868
1869 // forked from gcc/cp/cp-tree.h cp_built_in_function
1870
1871 /* BUILT_IN_FRONTEND function codes. */
1872 enum cp_built_in_function
1873 {
1874 CP_BUILT_IN_IS_CONSTANT_EVALUATED,
1875 CP_BUILT_IN_INTEGER_PACK,
1876 CP_BUILT_IN_IS_CORRESPONDING_MEMBER,
1877 CP_BUILT_IN_IS_POINTER_INTERCONVERTIBLE_WITH_CLASS,
1878 CP_BUILT_IN_SOURCE_LOCATION,
1879 CP_BUILT_IN_LAST
1880 };
1881
1882 // forked from gcc/cp/cp-tree.h warning_sentinel
1883
1884 /* RAII sentinel to disable certain warnings during template substitution
1885 and elsewhere. */
1886
1887 class warning_sentinel
1888 {
1889 public:
1890 int &flag;
1891 int val;
1892 warning_sentinel (int &flag, bool suppress = true) : flag (flag), val (flag)
1893 {
1894 if (suppress)
1895 flag = 0;
1896 }
1897 ~warning_sentinel () { flag = val; }
1898 };
1899
1900 // forked from gcc/cp/cp-tree.h uid_sensitive_constexpr_evaluation_checker
1901
1902 /* Used to determine whether uid_sensitive_constexpr_evaluation_p was
1903 called and returned true, indicating that we've restricted constexpr
1904 evaluation in order to avoid UID generation. We use this to control
1905 updates to the fold_cache and cv_cache. */
1906
1907 struct uid_sensitive_constexpr_evaluation_checker
1908 {
1909 const unsigned saved_counter;
1910 uid_sensitive_constexpr_evaluation_checker ();
1911 bool evaluation_restricted_p () const;
1912 };
1913
1914 // forked from gcc/cp/cp-tree.h iloc_sentinel
1915
1916 /* RAII sentinel to temporarily override input_location. This will not set
1917 input_location to UNKNOWN_LOCATION or BUILTINS_LOCATION. */
1918
1919 class iloc_sentinel
1920 {
1921 location_t saved_loc;
1922
1923 public:
1924 iloc_sentinel (location_t loc) : saved_loc (input_location)
1925 {
1926 if (loc >= RESERVED_LOCATION_COUNT)
1927 input_location = loc;
1928 }
1929 ~iloc_sentinel () { input_location = saved_loc; }
1930 };
1931
1932 // forked from gcc/cp/cp-tree.h ptrmem_cst
1933
1934 struct GTY (()) ptrmem_cst
1935 {
1936 struct tree_common common;
1937 tree member;
1938 location_t locus;
1939 };
1940 typedef struct ptrmem_cst *ptrmem_cst_t;
1941
1942 // forked from gcc/cp/cp-tree.h named_decl_hash
1943
1944 /* hash traits for declarations. Hashes potential overload sets via
1945 DECL_NAME. */
1946
1947 struct named_decl_hash : ggc_remove<tree>
1948 {
1949 typedef tree value_type; /* A DECL or OVERLOAD */
1950 typedef tree compare_type; /* An identifier. */
1951
1952 inline static hashval_t hash (const value_type decl);
1953 inline static bool equal (const value_type existing, compare_type candidate);
1954
1955 static const bool empty_zero_p = true;
1956 static inline void mark_empty (value_type &p) { p = NULL_TREE; }
1957 static inline bool is_empty (value_type p) { return !p; }
1958
1959 /* Nothing is deletable. Everything is insertable. */
1960 static bool is_deleted (value_type) { return false; }
1961 static void mark_deleted (value_type) { gcc_unreachable (); }
1962 };
1963
1964 // forked from gcc/cp/cp-tree.h lang_decl_selector
1965
1966 /* Discriminator values for lang_decl. */
1967
1968 enum lang_decl_selector
1969 {
1970 lds_min,
1971 lds_fn,
1972 lds_ns,
1973 lds_parm,
1974 lds_decomp
1975 };
1976
1977 // forked from gcc/cp/cp-tree.h lang_decl_base
1978
1979 /* Flags shared by all forms of DECL_LANG_SPECIFIC.
1980
1981 Some of the flags live here only to make lang_decl_min/fn smaller. Do
1982 not make this struct larger than 32 bits. */
1983
1984 struct GTY (()) lang_decl_base
1985 {
1986 ENUM_BITFIELD (lang_decl_selector) selector : 3;
1987 unsigned use_template : 2;
1988 unsigned not_really_extern : 1; /* var or fn */
1989 unsigned initialized_in_class : 1; /* var or fn */
1990
1991 unsigned threadprivate_or_deleted_p : 1; /* var or fn */
1992 /* anticipated_p is no longer used for anticipated_decls (fn, type
1993 or template). It is used as DECL_OMP_PRIVATIZED_MEMBER in
1994 var. */
1995 unsigned anticipated_p : 1;
1996 unsigned friend_or_tls : 1; /* var, fn, type or template */
1997 unsigned unknown_bound_p : 1; /* var */
1998 unsigned odr_used : 1; /* var or fn */
1999 unsigned concept_p : 1; /* applies to vars and functions */
2000 unsigned var_declared_inline_p : 1; /* var */
2001 unsigned dependent_init_p : 1; /* var */
2002
2003 /* The following apply to VAR, FUNCTION, TYPE, CONCEPT, & NAMESPACE
2004 decls. */
2005 unsigned module_purview_p : 1; /* in module purview (not GMF) */
2006 unsigned module_import_p : 1; /* from an import */
2007 unsigned module_entity_p : 1; /* is in the entitity ary &
2008 hash. */
2009 /* VAR_DECL or FUNCTION_DECL has attached decls. */
2010 unsigned module_attached_p : 1;
2011
2012 /* 12 spare bits. */
2013 };
2014
2015 /* True for DECL codes which have template info and access. */
2016 #define LANG_DECL_HAS_MIN(NODE) \
2017 (VAR_OR_FUNCTION_DECL_P (NODE) || TREE_CODE (NODE) == FIELD_DECL \
2018 || TREE_CODE (NODE) == CONST_DECL || TREE_CODE (NODE) == TYPE_DECL \
2019 || TREE_CODE (NODE) == TEMPLATE_DECL || TREE_CODE (NODE) == USING_DECL \
2020 || TREE_CODE (NODE) == CONCEPT_DECL)
2021
2022 // forked from gcc/c-family-common.h stmt_tree_s
2023
2024 /* Information about a statement tree. */
2025
2026 struct GTY (()) stmt_tree_s
2027 {
2028 /* A stack of statement lists being collected. */
2029 vec<tree, va_gc> *x_cur_stmt_list;
2030
2031 /* In C++, Nonzero if we should treat statements as full
2032 expressions. In particular, this variable is non-zero if at the
2033 end of a statement we should destroy any temporaries created
2034 during that statement. Similarly, if, at the end of a block, we
2035 should destroy any local variables in this block. Normally, this
2036 variable is nonzero, since those are the normal semantics of
2037 C++.
2038
2039 This flag has no effect in C. */
2040 int stmts_are_full_exprs_p;
2041 };
2042
2043 // forked from gcc/c-family-common.h stmt_tree_s
2044
2045 typedef struct stmt_tree_s *stmt_tree;
2046
2047 // forked from gcc/c-family-common.h c_language_function
2048
2049 /* Global state pertinent to the current function. Some C dialects
2050 extend this structure with additional fields. */
2051
2052 struct GTY (()) c_language_function
2053 {
2054 /* While we are parsing the function, this contains information
2055 about the statement-tree that we are building. */
2056 struct stmt_tree_s x_stmt_tree;
2057
2058 /* Vector of locally defined typedefs, for
2059 -Wunused-local-typedefs. */
2060 vec<tree, va_gc> *local_typedefs;
2061 };
2062
2063 // forked from gcc/cp/cp-tree.h omp_declare_target_attr
2064
2065 struct GTY (()) omp_declare_target_attr
2066 {
2067 bool attr_syntax;
2068 };
2069
2070 // forked from gcc/cp/name-lookup.h cxx_binding
2071
2072 /* Datatype that represents binding established by a declaration between
2073 a name and a C++ entity. */
2074 struct GTY (()) cxx_binding
2075 {
2076 /* Link to chain together various bindings for this name. */
2077 cxx_binding *previous;
2078 /* The non-type entity this name is bound to. */
2079 tree value;
2080 /* The type entity this name is bound to. */
2081 tree type;
2082
2083 bool value_is_inherited : 1;
2084 bool is_local : 1;
2085 bool type_is_hidden : 1;
2086 };
2087
2088 // forked from gcc/cp/name-lookup.h cxx_saved_binding
2089
2090 /* Datatype used to temporarily save C++ bindings (for implicit
2091 instantiations purposes and like). Implemented in decl.cc. */
2092 struct GTY (()) cxx_saved_binding
2093 {
2094 /* The name of the current binding. */
2095 tree identifier;
2096 /* The binding we're saving. */
2097 cxx_binding *binding;
2098 tree real_type_value;
2099 };
2100
2101 // forked from gcc/cp/cp-tree.h saved_scope
2102
2103 /* Global state. */
2104
2105 struct GTY (()) saved_scope
2106 {
2107 vec<cxx_saved_binding, va_gc> *old_bindings;
2108 tree old_namespace;
2109 vec<tree, va_gc> *decl_ns_list;
2110 tree class_name;
2111 tree class_type;
2112 tree access_specifier;
2113 tree function_decl;
2114 vec<tree, va_gc> *lang_base;
2115 tree lang_name;
2116 tree template_parms;
2117 tree x_saved_tree;
2118
2119 /* Only used for uses of this in trailing return type. */
2120 tree x_current_class_ptr;
2121 tree x_current_class_ref;
2122
2123 int x_processing_template_decl;
2124 int x_processing_specialization;
2125 int x_processing_constraint;
2126 int suppress_location_wrappers;
2127 BOOL_BITFIELD x_processing_explicit_instantiation : 1;
2128 BOOL_BITFIELD need_pop_function_context : 1;
2129
2130 /* Nonzero if we are parsing the discarded statement of a constexpr
2131 if-statement. */
2132 BOOL_BITFIELD discarded_stmt : 1;
2133 /* Nonzero if we are parsing or instantiating the compound-statement
2134 of consteval if statement. Also set while processing an immediate
2135 invocation. */
2136 BOOL_BITFIELD consteval_if_p : 1;
2137
2138 int unevaluated_operand;
2139 int inhibit_evaluation_warnings;
2140 int noexcept_operand;
2141 int ref_temp_count;
2142
2143 struct stmt_tree_s x_stmt_tree;
2144
2145 hash_map<tree, tree> *GTY ((skip)) x_local_specializations;
2146 vec<omp_declare_target_attr, va_gc> *omp_declare_target_attribute;
2147
2148 struct saved_scope *prev;
2149 };
2150
2151 extern GTY (()) struct saved_scope *scope_chain;
2152
2153 // forked from gcc/cp/cp-tree.h named_label_hash
2154
2155 struct named_label_entry; /* Defined in decl.cc. */
2156
2157 struct named_label_hash : ggc_remove<named_label_entry *>
2158 {
2159 typedef named_label_entry *value_type;
2160 typedef tree compare_type; /* An identifier. */
2161
2162 inline static hashval_t hash (value_type);
2163 inline static bool equal (const value_type, compare_type);
2164
2165 static const bool empty_zero_p = true;
2166 inline static void mark_empty (value_type &p) { p = NULL; }
2167 inline static bool is_empty (value_type p) { return !p; }
2168
2169 /* Nothing is deletable. Everything is insertable. */
2170 inline static bool is_deleted (value_type) { return false; }
2171 inline static void mark_deleted (value_type) { gcc_unreachable (); }
2172 };
2173
2174 // forked from gcc/cp/cp-tree.h
2175
2176 /* Global state pertinent to the current function. */
2177
2178 struct GTY (()) language_function
2179 {
2180 struct c_language_function base;
2181
2182 tree x_cdtor_label;
2183 tree x_current_class_ptr;
2184 tree x_current_class_ref;
2185 tree x_eh_spec_block;
2186 tree x_in_charge_parm;
2187 tree x_vtt_parm;
2188 tree x_return_value;
2189
2190 BOOL_BITFIELD returns_value : 1;
2191 BOOL_BITFIELD returns_null : 1;
2192 BOOL_BITFIELD returns_abnormally : 1;
2193 BOOL_BITFIELD infinite_loop : 1;
2194 BOOL_BITFIELD x_in_function_try_handler : 1;
2195 BOOL_BITFIELD x_in_base_initializer : 1;
2196
2197 /* True if this function can throw an exception. */
2198 BOOL_BITFIELD can_throw : 1;
2199
2200 BOOL_BITFIELD invalid_constexpr : 1;
2201 BOOL_BITFIELD throwing_cleanup : 1;
2202
2203 hash_table<named_label_hash> *x_named_labels;
2204
2205 /* Tracking possibly infinite loops. This is a vec<tree> only because
2206 vec<bool> doesn't work with gtype. */
2207 vec<tree, va_gc> *infinite_loops;
2208 };
2209
2210 // forked from gcc/c-family/c-common.h ref_operator
2211
2212 /* The various name of operator that appears in error messages. */
2213 enum ref_operator
2214 {
2215 /* NULL */
2216 RO_NULL,
2217 /* array indexing */
2218 RO_ARRAY_INDEXING,
2219 /* unary * */
2220 RO_UNARY_STAR,
2221 /* -> */
2222 RO_ARROW,
2223 /* implicit conversion */
2224 RO_IMPLICIT_CONVERSION,
2225 /* ->* */
2226 RO_ARROW_STAR
2227 };
2228
2229 // forked from gcc/cp/cp-tree.h lang_decl_min
2230
2231 /* DECL_LANG_SPECIFIC for the above codes. */
2232
2233 struct GTY (()) lang_decl_min
2234 {
2235 struct lang_decl_base base; /* 32-bits. */
2236
2237 /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
2238 THUNK_ALIAS.
2239 In a FUNCTION_DECL for which DECL_THUNK_P does not hold,
2240 VAR_DECL, TYPE_DECL, or TEMPLATE_DECL, this is
2241 DECL_TEMPLATE_INFO. */
2242 tree template_info;
2243
2244 /* In a DECL_THUNK_P FUNCTION_DECL, this is THUNK_VIRTUAL_OFFSET.
2245 In a lambda-capture proxy VAR_DECL, this is DECL_CAPTURED_VARIABLE.
2246 In a function-scope TREE_STATIC VAR_DECL or IMPLICIT_TYPEDEF_P TYPE_DECL,
2247 this is DECL_DISCRIMINATOR.
2248 In a DECL_LOCAL_DECL_P decl, this is the namespace decl it aliases.
2249 Otherwise, in a class-scope DECL, this is DECL_ACCESS. */
2250 tree access;
2251 };
2252
2253 // forked from gcc/cp/cp-tree.h lang_decl_fn
2254
2255 /* Additional DECL_LANG_SPECIFIC information for functions. */
2256
2257 struct GTY (()) lang_decl_fn
2258 {
2259 struct lang_decl_min min;
2260
2261 /* In a overloaded operator, this is the compressed operator code. */
2262 unsigned ovl_op_code : 6;
2263 unsigned global_ctor_p : 1;
2264 unsigned global_dtor_p : 1;
2265
2266 unsigned static_function : 1;
2267 unsigned pure_virtual : 1;
2268 unsigned defaulted_p : 1;
2269 unsigned has_in_charge_parm_p : 1;
2270 unsigned has_vtt_parm_p : 1;
2271 unsigned pending_inline_p : 1;
2272 unsigned nonconverting : 1;
2273 unsigned thunk_p : 1;
2274
2275 unsigned this_thunk_p : 1;
2276 unsigned omp_declare_reduction_p : 1;
2277 unsigned has_dependent_explicit_spec_p : 1;
2278 unsigned immediate_fn_p : 1;
2279 unsigned maybe_deleted : 1;
2280 unsigned coroutine_p : 1;
2281 unsigned implicit_constexpr : 1;
2282
2283 unsigned spare : 9;
2284
2285 /* 32-bits padding on 64-bit host. */
2286
2287 /* For a non-thunk function decl, this is a tree list of
2288 friendly classes. For a thunk function decl, it is the
2289 thunked to function decl. */
2290 tree befriending_classes;
2291
2292 /* For a virtual FUNCTION_DECL for which
2293 DECL_THIS_THUNK_P does not hold, this is DECL_THUNKS. Both
2294 this pointer and result pointer adjusting thunks are
2295 chained here. This pointer thunks to return pointer thunks
2296 will be chained on the return pointer thunk.
2297 For a DECL_CONSTUCTOR_P FUNCTION_DECL, this is the base from
2298 whence we inherit. Otherwise, it is the class in which a
2299 (namespace-scope) friend is defined (if any). */
2300 tree context;
2301
2302 union lang_decl_u5
2303 {
2304 /* In a non-thunk FUNCTION_DECL, this is DECL_CLONED_FUNCTION. */
2305 tree GTY ((tag ("0"))) cloned_function;
2306
2307 /* In a FUNCTION_DECL for which THUNK_P holds this is the
2308 THUNK_FIXED_OFFSET. */
2309 HOST_WIDE_INT GTY ((tag ("1"))) fixed_offset;
2310 } GTY ((desc ("%1.thunk_p"))) u5;
2311
2312 union lang_decl_u3
2313 {
2314 struct cp_token_cache *GTY ((tag ("1"))) pending_inline_info;
2315 tree GTY ((tag ("0"))) saved_auto_return_type;
2316 } GTY ((desc ("%1.pending_inline_p"))) u;
2317 };
2318
2319 // forked from gcc/cp/cp-tree.h lang_decl_ns
2320
2321 /* DECL_LANG_SPECIFIC for namespaces. */
2322
2323 struct GTY (()) lang_decl_ns
2324 {
2325 struct lang_decl_base base; /* 32 bits. */
2326
2327 /* Inline children. Needs to be va_gc, because of PCH. */
2328 vec<tree, va_gc> *inlinees;
2329
2330 /* Hash table of bound decls. It'd be nice to have this inline, but
2331 as the hash_map has a dtor, we can't then put this struct into a
2332 union (until moving to c++11). */
2333 hash_table<named_decl_hash> *bindings;
2334 };
2335
2336 // forked from gcc/cp/cp-tree.h lang_decl_parm
2337
2338 /* DECL_LANG_SPECIFIC for parameters. */
2339
2340 struct GTY (()) lang_decl_parm
2341 {
2342 struct lang_decl_base base; /* 32 bits. */
2343 int level;
2344 int index;
2345 };
2346
2347 // forked from gcc/cp/cp-tree.h lang_decl_decomp
2348
2349 /* Additional DECL_LANG_SPECIFIC information for structured bindings. */
2350
2351 struct GTY (()) lang_decl_decomp
2352 {
2353 struct lang_decl_min min;
2354 /* The artificial underlying "e" variable of the structured binding
2355 variable. */
2356 tree base;
2357 };
2358
2359 // forked from gcc/cp/cp-tree.h lang_decl
2360
2361 /* DECL_LANG_SPECIFIC for all types. It would be nice to just make this a
2362 union rather than a struct containing a union as its only field, but
2363 tree.h declares it as a struct. */
2364
2365 struct GTY (()) lang_decl
2366 {
2367 union GTY ((desc ("%h.base.selector"))) lang_decl_u
2368 {
2369 /* Nothing of only the base type exists. */
2370 struct lang_decl_base GTY ((default)) base;
2371 struct lang_decl_min GTY ((tag ("lds_min"))) min;
2372 struct lang_decl_fn GTY ((tag ("lds_fn"))) fn;
2373 struct lang_decl_ns GTY ((tag ("lds_ns"))) ns;
2374 struct lang_decl_parm GTY ((tag ("lds_parm"))) parm;
2375 struct lang_decl_decomp GTY ((tag ("lds_decomp"))) decomp;
2376 } u;
2377 };
2378
2379 // forked from gcc/c-family/c-common.h c_fileinfo
2380
2381 /* Information recorded about each file examined during compilation. */
2382
2383 struct c_fileinfo
2384 {
2385 int time; /* Time spent in the file. */
2386
2387 /* Flags used only by C++.
2388 INTERFACE_ONLY nonzero means that we are in an "interface" section
2389 of the compiler. INTERFACE_UNKNOWN nonzero means we cannot trust
2390 the value of INTERFACE_ONLY. If INTERFACE_UNKNOWN is zero and
2391 INTERFACE_ONLY is zero, it means that we are responsible for
2392 exporting definitions that others might need. */
2393 short interface_only;
2394 short interface_unknown;
2395 };
2396
2397 // forked from gcc/c-family/c-common.h c_common_identifier
2398
2399 /* Identifier part common to the C front ends. Inherits from
2400 tree_identifier, despite appearances. */
2401 struct GTY (()) c_common_identifier
2402 {
2403 struct tree_common common;
2404 struct cpp_hashnode node; // from cpplib.h
2405 };
2406
2407 // forked from gcc/cp/cp-tree.h lang_identifier
2408
2409 /* Language-dependent contents of an identifier. */
2410
2411 struct GTY (()) lang_identifier
2412 {
2413 struct c_common_identifier c_common;
2414 cxx_binding *bindings;
2415 };
2416
2417 // forked from gcc/cp/cp-tree.h tree_overload
2418
2419 /* OVL_HIDDEN_P nodes come before other nodes. */
2420
2421 struct GTY (()) tree_overload
2422 {
2423 struct tree_common common;
2424 tree function;
2425 };
2426
2427 // forked from gcc/cp/cp-tree.h ovl_iterator
2428
2429 class ovl_iterator
2430 {
2431 tree ovl;
2432 const bool allow_inner; /* Only used when checking. */
2433
2434 public:
2435 explicit ovl_iterator (tree o, bool allow = false)
2436 : ovl (o), allow_inner (allow)
2437 {}
2438
2439 public:
2440 operator bool () const { return ovl; }
2441 ovl_iterator &operator++ ()
2442 {
2443 ovl = TREE_CODE (ovl) != OVERLOAD ? NULL_TREE : OVL_CHAIN (ovl);
2444 return *this;
2445 }
2446 tree operator* () const
2447 {
2448 tree fn = TREE_CODE (ovl) != OVERLOAD ? ovl : OVL_FUNCTION (ovl);
2449
2450 /* Check this is not an unexpected 2-dimensional overload. */
2451 gcc_checking_assert (allow_inner || TREE_CODE (fn) != OVERLOAD);
2452
2453 return fn;
2454 }
2455 bool operator== (const ovl_iterator &o) const { return ovl == o.ovl; }
2456 tree get_using () const
2457 {
2458 gcc_checking_assert (using_p ());
2459 return ovl;
2460 }
2461
2462 public:
2463 /* Whether this overload was introduced by a using decl. */
2464 bool using_p () const
2465 {
2466 return (TREE_CODE (ovl) == USING_DECL
2467 || (TREE_CODE (ovl) == OVERLOAD && OVL_USING_P (ovl)));
2468 }
2469 /* Whether this using is being exported. */
2470 bool exporting_p () const { return OVL_EXPORT_P (get_using ()); }
2471
2472 bool hidden_p () const
2473 {
2474 return TREE_CODE (ovl) == OVERLOAD && OVL_HIDDEN_P (ovl);
2475 }
2476
2477 public:
2478 tree remove_node (tree head) { return remove_node (head, ovl); }
2479 tree reveal_node (tree head) { return reveal_node (head, ovl); }
2480
2481 protected:
2482 /* If we have a nested overload, point at the inner overload and
2483 return the next link on the outer one. */
2484 tree maybe_push ()
2485 {
2486 tree r = NULL_TREE;
2487
2488 if (ovl && TREE_CODE (ovl) == OVERLOAD && OVL_NESTED_P (ovl))
2489 {
2490 r = OVL_CHAIN (ovl);
2491 ovl = OVL_FUNCTION (ovl);
2492 }
2493 return r;
2494 }
2495 /* Restore an outer nested overload. */
2496 void pop (tree outer)
2497 {
2498 gcc_checking_assert (!ovl);
2499 ovl = outer;
2500 }
2501
2502 private:
2503 /* We make these static functions to avoid the address of the
2504 iterator escaping the local context. */
2505 static tree remove_node (tree head, tree node);
2506 static tree reveal_node (tree ovl, tree node);
2507 };
2508
2509 // forked from gcc/cp/cp-tree.h lkp_iterator
2510
2511 /* Iterator over a (potentially) 2 dimensional overload, which is
2512 produced by name lookup. */
2513
2514 class lkp_iterator : public ovl_iterator
2515 {
2516 typedef ovl_iterator parent;
2517
2518 tree outer;
2519
2520 public:
2521 explicit lkp_iterator (tree o) : parent (o, true), outer (maybe_push ()) {}
2522
2523 public:
2524 lkp_iterator &operator++ ()
2525 {
2526 bool repush = !outer;
2527
2528 if (!parent::operator++ () && !repush)
2529 {
2530 pop (outer);
2531 repush = true;
2532 }
2533
2534 if (repush)
2535 outer = maybe_push ();
2536
2537 return *this;
2538 }
2539 };
2540
2541 // forked from gcc/cp/cp-tree.h treee_pair_s
2542
2543 struct GTY (()) tree_pair_s
2544 {
2545 tree purpose;
2546 tree value;
2547 };
2548
2549 // forked from gcc/cp/cp-tree.h tree_pair_p
2550
2551 typedef tree_pair_s *tree_pair_p;
2552
2553 // forked from gcc/cp/cp-tree.h lang_type
2554
2555 /* This structure provides additional information above and beyond
2556 what is provide in the ordinary tree_type. In the past, we used it
2557 for the types of class types, template parameters types, typename
2558 types, and so forth. However, there can be many (tens to hundreds
2559 of thousands) of template parameter types in a compilation, and
2560 there's no need for this additional information in that case.
2561 Therefore, we now use this data structure only for class types.
2562
2563 In the past, it was thought that there would be relatively few
2564 class types. However, in the presence of heavy use of templates,
2565 many (i.e., thousands) of classes can easily be generated.
2566 Therefore, we should endeavor to keep the size of this structure to
2567 a minimum. */
2568 struct GTY (()) lang_type
2569 {
2570 unsigned char align;
2571
2572 unsigned has_type_conversion : 1;
2573 unsigned has_copy_ctor : 1;
2574 unsigned has_default_ctor : 1;
2575 unsigned const_needs_init : 1;
2576 unsigned ref_needs_init : 1;
2577 unsigned has_const_copy_assign : 1;
2578 unsigned use_template : 2;
2579
2580 unsigned has_mutable : 1;
2581 unsigned com_interface : 1;
2582 unsigned non_pod_class : 1;
2583 unsigned nearly_empty_p : 1;
2584 unsigned user_align : 1;
2585 unsigned has_copy_assign : 1;
2586 unsigned has_new : 1;
2587 unsigned has_array_new : 1;
2588
2589 unsigned gets_delete : 2;
2590 unsigned interface_only : 1;
2591 unsigned interface_unknown : 1;
2592 unsigned contains_empty_class_p : 1;
2593 unsigned anon_aggr : 1;
2594 unsigned non_zero_init : 1;
2595 unsigned empty_p : 1;
2596 /* 32 bits allocated. */
2597
2598 unsigned vec_new_uses_cookie : 1;
2599 unsigned declared_class : 1;
2600 unsigned diamond_shaped : 1;
2601 unsigned repeated_base : 1;
2602 unsigned being_defined : 1;
2603 unsigned debug_requested : 1;
2604 unsigned fields_readonly : 1;
2605 unsigned ptrmemfunc_flag : 1;
2606
2607 unsigned lazy_default_ctor : 1;
2608 unsigned lazy_copy_ctor : 1;
2609 unsigned lazy_copy_assign : 1;
2610 unsigned lazy_destructor : 1;
2611 unsigned has_const_copy_ctor : 1;
2612 unsigned has_complex_copy_ctor : 1;
2613 unsigned has_complex_copy_assign : 1;
2614 unsigned non_aggregate : 1;
2615
2616 unsigned has_complex_dflt : 1;
2617 unsigned has_list_ctor : 1;
2618 unsigned non_std_layout : 1;
2619 unsigned is_literal : 1;
2620 unsigned lazy_move_ctor : 1;
2621 unsigned lazy_move_assign : 1;
2622 unsigned has_complex_move_ctor : 1;
2623 unsigned has_complex_move_assign : 1;
2624
2625 unsigned has_constexpr_ctor : 1;
2626 unsigned unique_obj_representations : 1;
2627 unsigned unique_obj_representations_set : 1;
2628 bool erroneous : 1;
2629 bool non_pod_aggregate : 1;
2630
2631 /* When adding a flag here, consider whether or not it ought to
2632 apply to a template instance if it applies to the template. If
2633 so, make sure to copy it in instantiate_class_template! */
2634
2635 /* There are some bits left to fill out a 32-bit word. Keep track
2636 of this by updating the size of this bitfield whenever you add or
2637 remove a flag. */
2638 unsigned dummy : 3;
2639
2640 tree primary_base;
2641 vec<tree_pair_s, va_gc> *vcall_indices;
2642 tree vtables;
2643 tree typeinfo_var;
2644 vec<tree, va_gc> *vbases;
2645 tree as_base;
2646 vec<tree, va_gc> *pure_virtuals;
2647 tree friend_classes;
2648 vec<tree, va_gc> *GTY ((reorder ("resort_type_member_vec"))) members;
2649 tree key_method;
2650 tree decl_list;
2651 tree befriending_classes;
2652 /* In a RECORD_TYPE, information specific to Objective-C++, such
2653 as a list of adopted protocols or a pointer to a corresponding
2654 @interface. See objc/objc-act.h for details. */
2655 tree objc_info;
2656 /* FIXME reuse another field? */
2657 tree lambda_expr;
2658 };
2659
2660 namespace Rust {
2661
2662 // forked from gcc/cp/cp-tree.h cp_ref_qualifier
2663
2664 enum rs_ref_qualifier
2665 {
2666 REF_QUAL_NONE = 0,
2667 REF_QUAL_LVALUE = 1,
2668 REF_QUAL_RVALUE = 2
2669 };
2670
2671 // forked from gcc/cp/cp-tree.h tsubst_flags
2672
2673 /* Bitmask flags to control type substitution. */
2674 enum tsubst_flags
2675 {
2676 tf_none = 0, /* nothing special */
2677 tf_error = 1 << 0, /* give error messages */
2678 tf_warning = 1 << 1, /* give warnings too */
2679 tf_ignore_bad_quals = 1 << 2, /* ignore bad cvr qualifiers */
2680 tf_keep_type_decl = 1 << 3, /* retain typedef type decls
2681 (make_typename_type use) */
2682 tf_ptrmem_ok = 1 << 4, /* pointers to member ok (internal
2683 instantiate_type use) */
2684 tf_user = 1 << 5, /* found template must be a user template
2685 (lookup_template_class use) */
2686 tf_conv = 1 << 6, /* We are determining what kind of
2687 conversion might be permissible,
2688 not actually performing the
2689 conversion. */
2690 tf_decltype = 1 << 7, /* We are the operand of decltype.
2691 Used to implement the special rules
2692 for calls in decltype (5.2.2/11). */
2693 tf_partial = 1 << 8, /* Doing initial explicit argument
2694 substitution in fn_type_unification. */
2695 tf_fndecl_type = 1 << 9, /* Substituting the type of a function
2696 declaration. */
2697 tf_no_cleanup = 1 << 10, /* Do not build a cleanup
2698 (build_target_expr and friends) */
2699 tf_norm = 1 << 11, /* Build diagnostic information during
2700 constraint normalization. */
2701 /* Convenient substitution flags combinations. */
2702 tf_warning_or_error = tf_warning | tf_error
2703 };
2704
2705 // forked from gcc/cp/cp-tree.h cp_identifier_kind
2706
2707 /* Kinds of identifiers. Values are carefully chosen. */
2708 enum cp_identifier_kind
2709 {
2710 cik_normal = 0, /* Not a special identifier. */
2711 cik_keyword = 1, /* A keyword. */
2712 cik_ctor = 2, /* Constructor (in-chg, complete or base). */
2713 cik_dtor = 3, /* Destructor (in-chg, deleting, complete or
2714 base). */
2715 cik_simple_op = 4, /* Non-assignment operator name. */
2716 cik_assign_op = 5, /* An assignment operator name. */
2717 cik_conv_op = 6, /* Conversion operator name. */
2718 cik_reserved_for_udlit = 7, /* Not yet in use */
2719 cik_max
2720 };
2721
2722 // forked from gcc/cp/cp-tree.h tag_types
2723
2724 /* An enumeration of the kind of tags that C++ accepts. */
2725 enum tag_types
2726 {
2727 none_type = 0, /* Not a tag type. */
2728 record_type, /* "struct" types. */
2729 class_type, /* "class" types. */
2730 union_type, /* "union" types. */
2731 enum_type, /* "enum" types. */
2732 typename_type, /* "typename" types. */
2733 scope_type /* namespace or tagged type name followed by :: */
2734 };
2735
2736 // forked from gcc/cp/cp-tree.h tsubst_flags_t
2737
2738 /* This type is used for parameters and variables which hold
2739 combinations of the flags in enum tsubst_flags. */
2740 typedef int tsubst_flags_t;
2741
2742 // forked from gcc/cp/cvt.cc convert_to_void
2743 //
2744 // When an expression is used in a void context, its value is discarded and
2745 // no lvalue-rvalue and similar conversions happen [expr.static.cast/4,
2746 // stmt.expr/1, expr.comma/1]. This permits dereferencing an incomplete type
2747 // in a void context. The C++ standard does not define what an `access' to an
2748 // object is, but there is reason to believe that it is the lvalue to rvalue
2749 // conversion -- if it were not, `*&*p = 1' would violate [expr]/4 in that it
2750 // accesses `*p' not to calculate the value to be stored. But, dcl.type.cv/8
2751 // indicates that volatile semantics should be the same between C and C++
2752 // where ever possible. C leaves it implementation defined as to what
2753 // constitutes an access to a volatile. So, we interpret `*vp' as a read of
2754 // the volatile object `vp' points to, unless that is an incomplete type. For
2755 // volatile references we do not do this interpretation, because that would
2756 // make it impossible to ignore the reference return value from functions. We
2757 // issue warnings in the confusing cases.
2758 //
2759 // The IMPLICIT is ICV_CAST when the user is explicitly converting an
2760 // expression to void via a cast. If an expression is being implicitly
2761 // converted, IMPLICIT indicates the context of the implicit conversion.
2762
2763 /* Possible cases of implicit or explicit bad conversions to void. */
2764 enum impl_conv_void
2765 {
2766 ICV_CAST, /* (explicit) conversion to void */
2767 ICV_SECOND_OF_COND, /* second operand of conditional expression */
2768 ICV_THIRD_OF_COND, /* third operand of conditional expression */
2769 ICV_RIGHT_OF_COMMA, /* right operand of comma operator */
2770 ICV_LEFT_OF_COMMA, /* left operand of comma operator */
2771 ICV_STATEMENT, /* statement */
2772 ICV_THIRD_IN_FOR /* for increment expression */
2773 };
2774
2775 /* BUILT_IN_FRONTEND function codes. */
2776 enum rs_built_in_function
2777 {
2778 RS_BUILT_IN_IS_CONSTANT_EVALUATED,
2779 RS_BUILT_IN_INTEGER_PACK,
2780 RS_BUILT_IN_IS_CORRESPONDING_MEMBER,
2781 RS_BUILT_IN_IS_POINTER_INTERCONVERTIBLE_WITH_CLASS,
2782 RS_BUILT_IN_SOURCE_LOCATION,
2783 RS_BUILT_IN_LAST
2784 };
2785
2786 // forked from gcc/cp/cp-tree.h compare_bounds_t
2787
2788 /* in typeck.cc */
2789 /* Says how we should behave when comparing two arrays one of which
2790 has unknown bounds. */
2791 enum compare_bounds_t
2792 {
2793 bounds_none,
2794 bounds_either,
2795 bounds_first
2796 };
2797
2798 extern tree
2799 convert_to_void (tree expr, impl_conv_void implicit);
2800
2801 // The lvalue-to-rvalue conversion (7.1) is applied if and only if the
2802 // expression is a glvalue of volatile-qualified type and it is one of the
2803 // following:
2804 // * ( expression ), where expression is one of these expressions,
2805 // * id-expression (8.1.4),
2806 // * subscripting (8.2.1),
2807 // * class member access (8.2.5),
2808 // * indirection (8.3.1),
2809 // * pointer-to-member operation (8.5),
2810 // * conditional expression (8.16) where both the second and the third
2811 // operands are one of these expressions, or
2812 // * comma expression (8.19) where the right operand is one of these
2813 // expressions.
2814 extern tree
2815 mark_discarded_use (tree expr);
2816
2817 // Mark EXP as read, not just set, for set but not used -Wunused warning
2818 // purposes.
2819 extern void
2820 mark_exp_read (tree exp);
2821
2822 // We've seen an actual use of EXPR. Possibly replace an outer variable
2823 // reference inside with its constant value or a lambda capture.
2824 extern tree
2825 mark_use (tree expr, bool rvalue_p, bool read_p, location_t loc,
2826 bool reject_builtin);
2827
2828 // Called whenever the expression EXPR is used in an rvalue context.
2829 // When REJECT_BUILTIN is true the expression is checked to make sure
2830 // it doesn't make it possible to obtain the address of a GCC built-in
2831 // function with no library fallback (or any of its bits, such as in
2832 // a conversion to bool).
2833 extern tree
2834 mark_rvalue_use (tree, location_t = UNKNOWN_LOCATION,
2835 bool reject_builtin = true);
2836
2837 // Called whenever an expression is used in an lvalue context.
2838 extern tree
2839 mark_lvalue_use (tree expr);
2840
2841 // As above, but don't consider this use a read.
2842 extern tree
2843 mark_lvalue_use_nonread (tree expr);
2844
2845 // We are using a reference VAL for its value. Bash that reference all the way
2846 // down to its lowest form.
2847 extern tree
2848 convert_from_reference (tree val);
2849
2850 // Subroutine of convert_to_void. Warn if we're discarding something with
2851 // attribute [[nodiscard]].
2852 extern void
2853 maybe_warn_nodiscard (tree expr, impl_conv_void implicit);
2854
2855 extern location_t
2856 expr_loc_or_loc (const_tree t, location_t or_loc);
2857
2858 extern location_t
2859 expr_loc_or_input_loc (const_tree t);
2860
2861 // FN is the callee of a CALL_EXPR or AGGR_INIT_EXPR; return the FUNCTION_DECL
2862 // if we can.
2863 extern tree
2864 get_fndecl_from_callee (tree fn);
2865
2866 // FIXME some helpers from HIRCompileBase could probably be moved here over time
2867
2868 // Return an expression for the address of BASE[INDEX], used in offset intrinsic
2869 extern tree
2870 pointer_offset_expression (tree base_tree, tree index_tree, location_t locus);
2871
2872 /* A tree node, together with a location, so that we can track locations
2873 (and ranges) during parsing.
2874
2875 The location is redundant for node kinds that have locations,
2876 but not all node kinds do (e.g. constants, and references to
2877 params, locals, etc), so we stash a copy here. */
2878
2879 extern location_t rs_expr_location (const_tree);
2880
2881 extern int
2882 is_empty_class (tree type);
2883
2884 extern tree array_type_nelts_top (tree);
2885
2886 extern bool
2887 is_really_empty_class (tree, bool);
2888
2889 extern bool builtin_valid_in_constant_expr_p (const_tree);
2890
2891 extern bool maybe_constexpr_fn (tree);
2892
2893 extern bool var_in_maybe_constexpr_fn (tree);
2894
2895 extern int
2896 rs_type_quals (const_tree type);
2897
2898 inline bool type_unknown_p (const_tree);
2899
2900 extern bool decl_maybe_constant_var_p (tree);
2901
2902 extern void
2903 init_modules ();
2904
2905 extern bool var_in_constexpr_fn (tree);
2906
2907 inline tree ovl_first (tree) ATTRIBUTE_PURE;
2908
2909 inline bool type_unknown_p (const_tree);
2910
2911 extern tree
2912 lookup_add (tree fns, tree lookup);
2913
2914 extern tree
2915 ovl_make (tree fn, tree next = NULL_TREE);
2916
2917 extern int is_overloaded_fn (tree) ATTRIBUTE_PURE;
2918
2919 extern bool maybe_add_lang_type_raw (tree);
2920
2921 extern rs_ref_qualifier type_memfn_rqual (const_tree);
2922
2923 extern bool builtin_pack_fn_p (tree);
2924
2925 extern tree make_conv_op_name (tree);
2926
2927 extern int type_memfn_quals (const_tree);
2928
2929 struct c_fileinfo *
2930 get_fileinfo (const char *);
2931
2932 extern tree
2933 cxx_make_type (enum tree_code CXX_MEM_STAT_INFO);
2934
2935 extern tree
2936 build_cplus_array_type (tree, tree, int is_dep = -1);
2937
2938 extern bool is_byte_access_type (tree);
2939
2940 extern bool
2941 comptypes (tree, tree, int);
2942
2943 extern tree canonical_eh_spec (tree);
2944
2945 extern int cp_tree_operand_length (const_tree);
2946
2947 extern bool rs_tree_equal (tree, tree);
2948
2949 extern bool compparms (const_tree, const_tree);
2950
2951 extern tree
2952 rs_build_qualified_type_real (tree, int, tsubst_flags_t);
2953 #define rs_build_qualified_type(TYPE, QUALS) \
2954 rs_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error)
2955 extern bool cv_qualified_p (const_tree);
2956
2957 extern bool similar_type_p (tree, tree);
2958
2959 extern bool rs_tree_equal (tree, tree);
2960
2961 extern bool
2962 vector_targets_convertible_p (const_tree t1, const_tree t2);
2963
2964 extern bool same_type_ignoring_top_level_qualifiers_p (tree, tree);
2965
2966 extern bool comp_ptr_ttypes_const (tree, tree, compare_bounds_t);
2967
2968 extern tree
2969 get_class_binding_direct (tree, tree, bool want_type = false);
2970
2971 extern tree skip_artificial_parms_for (const_tree, tree);
2972
2973 extern void
2974 lang_check_failed (const char *, int,
2975 const char *) ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
2976
2977 extern tree default_init_uninitialized_part (tree);
2978
2979 extern bool type_has_non_user_provided_default_constructor (tree);
2980
2981 extern bool default_ctor_p (const_tree);
2982
2983 extern bool user_provided_p (tree);
2984
2985 extern bool sufficient_parms_p (const_tree);
2986
2987 extern tree next_initializable_field (tree);
2988
2989 extern tree in_class_defaulted_default_constructor (tree);
2990
2991 extern bool is_instantiation_of_constexpr (tree);
2992
2993 extern bool
2994 check_for_uninitialized_const_var (tree, bool, tsubst_flags_t);
2995
2996 extern bool reduced_constant_expression_p (tree);
2997
2998 extern tree cv_unqualified (tree);
2999
3000 extern tree cp_get_callee (tree);
3001 extern tree rs_get_callee_fndecl_nofold (tree);
3002
3003 extern bool is_nondependent_static_init_expression (tree);
3004
3005 extern tree build_nop (tree, tree);
3006
3007 extern bool scalarish_type_p (const_tree);
3008
3009 extern tree is_bitfield_expr_with_lowered_type (const_tree);
3010
3011 extern tree convert_bitfield_to_declared_type (tree);
3012
3013 extern tree
3014 cp_fold_maybe_rvalue (tree, bool);
3015
3016 extern tree maybe_undo_parenthesized_ref (tree);
3017
3018 extern tree
3019 fold_offsetof (tree, tree = size_type_node, tree_code ctx = ERROR_MARK);
3020
3021 extern tree cp_truthvalue_conversion (tree, tsubst_flags_t);
3022
3023 extern tree
3024 fold_non_dependent_expr (tree, tsubst_flags_t = tf_warning_or_error,
3025 bool = false, tree = NULL_TREE);
3026
3027 extern int char_type_p (tree);
3028
3029 extern bool instantiation_dependent_expression_p (tree);
3030
3031 extern bool type_has_nontrivial_copy_init (const_tree);
3032
3033 extern tree build_local_temp (tree);
3034
3035 extern bool is_normal_capture_proxy (tree);
3036
3037 extern bool reject_gcc_builtin (const_tree, location_t = UNKNOWN_LOCATION);
3038
3039 extern tree resolve_nondeduced_context (tree, tsubst_flags_t);
3040
3041 extern void cxx_incomplete_type_diagnostic (location_t, const_tree, const_tree,
3042 diagnostic_t);
3043
3044 extern void cxx_incomplete_type_error (location_t, const_tree, const_tree);
3045
3046 extern bool invalid_nonstatic_memfn_p (location_t, tree, tsubst_flags_t);
3047
3048 extern bool really_overloaded_fn (tree) ATTRIBUTE_PURE;
3049
3050 extern tree resolve_nondeduced_context_or_error (tree, tsubst_flags_t);
3051
3052 extern tree instantiate_non_dependent_or_null (tree);
3053
3054 extern void cxx_incomplete_type_inform (const_tree);
3055
3056 extern tree strip_top_quals (tree);
3057
3058 extern bool undeduced_auto_decl (tree);
3059
3060 extern bool require_deduced_type (tree, tsubst_flags_t = tf_warning_or_error);
3061
3062 extern bool decl_constant_var_p (tree);
3063
3064 extern tree build_new_constexpr_heap_type (tree, tree, tree);
3065
3066 extern bool is_empty_field (tree);
3067
3068 extern bool
3069 in_immediate_context ();
3070
3071 extern tree cp_get_callee_fndecl_nofold (tree);
3072
3073 extern bool
3074 cxx_mark_addressable (tree, bool = false);
3075
3076 extern tree fold_builtin_source_location (location_t);
3077
3078 extern tree build_address (tree);
3079
3080 extern bool bitfield_p (const_tree);
3081
3082 extern tree rvalue (tree);
3083
3084 extern bool glvalue_p (const_tree);
3085
3086 extern cp_lvalue_kind lvalue_kind (const_tree);
3087
3088 extern tree
3089 decl_constant_value (tree, bool);
3090
3091 extern tree lookup_enumerator (tree, tree);
3092
3093 extern int
3094 is_class_type (tree, int);
3095
3096 extern tree braced_lists_to_strings (tree, tree);
3097
3098 extern tree
3099 fold_builtin_is_pointer_inverconvertible_with_class (location_t, int, tree *);
3100
3101 extern bool layout_compatible_type_p (tree, tree);
3102
3103 extern tree finish_underlying_type (tree);
3104
3105 extern tree
3106 c_common_type_for_mode (machine_mode, int);
3107
3108 extern bool std_layout_type_p (const_tree);
3109
3110 extern tree complete_type (tree);
3111
3112 extern tree complete_type_or_else (tree, tree);
3113
3114 extern void note_failed_type_completion_for_satisfaction (tree);
3115
3116 extern tree complete_type_or_maybe_complain (tree, tree, tsubst_flags_t);
3117
3118 extern bool
3119 next_common_initial_seqence (tree &, tree &);
3120
3121 extern bool null_member_pointer_value_p (tree);
3122
3123 extern tree
3124 fold_builtin_is_corresponding_member (location_t, int, tree *);
3125
3126 extern tree cp_fold_rvalue (tree);
3127
3128 extern tree
3129 maybe_constant_value (tree, tree = NULL_TREE, bool = false);
3130
3131 extern tree lvalue_type (tree);
3132
3133 extern void lvalue_error (location_t, enum lvalue_use);
3134
3135 extern tree
3136 cp_fold_maybe_rvalue (tree, bool);
3137
3138 extern tree get_first_fn (tree) ATTRIBUTE_PURE;
3139
3140 extern void explain_non_literal_class (tree);
3141
3142 extern bool reference_related_p (tree, tree);
3143
3144 extern bool ordinary_char_type_p (tree);
3145
3146 extern bool array_string_literal_compatible_p (tree, tree);
3147
3148 // forked from gcc/cp/cp-tree.h
3149
3150 enum
3151 {
3152 ce_derived,
3153 ce_type,
3154 ce_normal,
3155 ce_exact
3156 };
3157
3158 extern tree
3159 rs_build_qualified_type_real (tree, int, tsubst_flags_t);
3160 #define rs_build_qualified_type(TYPE, QUALS) \
3161 rs_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error)
3162
3163 extern tree
3164 rs_walk_subtrees (tree *, int *, walk_tree_fn, void *, hash_set<tree> *);
3165 #define rs_walk_tree(tp, func, data, pset) \
3166 walk_tree_1 (tp, func, data, pset, rs_walk_subtrees)
3167 #define rs_walk_tree_without_duplicates(tp, func, data) \
3168 walk_tree_without_duplicates_1 (tp, func, data, rs_walk_subtrees)
3169
3170 // forked from gcc/cp/cp-tree.h cp_expr_loc_or_loc
3171
3172 inline location_t
3173 rs_expr_loc_or_loc (const_tree t, location_t or_loc)
3174 {
3175 location_t loc = rs_expr_location (t);
3176 if (loc == UNKNOWN_LOCATION)
3177 loc = or_loc;
3178 return loc;
3179 }
3180
3181 // forked from gcc/cp/cp-tree.h cp_expr_loc_or_input_loc
3182
3183 inline location_t
3184 rs_expr_loc_or_input_loc (const_tree t)
3185 {
3186 return rs_expr_loc_or_loc (t, input_location);
3187 }
3188
3189 // forked from gcc/cp/cp-tree.h type_unknown_p
3190
3191 inline bool
3192 type_unknown_p (const_tree expr)
3193 {
3194 return TREE_TYPE (expr) == unknown_type_node;
3195 }
3196
3197 // forked from gcc/cp/cp-tree.h ovl_first
3198
3199 /* Inline bodies. */
3200
3201 inline tree
3202 ovl_first (tree node)
3203 {
3204 while (TREE_CODE (node) == OVERLOAD)
3205 node = OVL_FUNCTION (node);
3206 return node;
3207 }
3208
3209 // forked from gcc/cp/cp-tree.h type_of_this_parm
3210
3211 /* Return the type of the `this' parameter of FNTYPE. */
3212
3213 inline tree
3214 type_of_this_parm (const_tree fntype)
3215 {
3216 function_args_iterator iter;
3217 gcc_assert (TREE_CODE (fntype) == METHOD_TYPE);
3218 function_args_iter_init (&iter, fntype);
3219 return function_args_iter_cond (&iter);
3220 }
3221
3222 // forked from gcc/cp/cp-tree.h class_of_this_parm
3223
3224 /* Return the class of the `this' parameter of FNTYPE. */
3225
3226 inline tree
3227 class_of_this_parm (const_tree fntype)
3228 {
3229 return TREE_TYPE (type_of_this_parm (fntype));
3230 }
3231
3232 // forked from gcc/cp/cp-tree.h identifier_p
3233
3234 /* Return a typed pointer version of T if it designates a
3235 C++ front-end identifier. */
3236 inline lang_identifier *
3237 identifier_p (tree t)
3238 {
3239 if (TREE_CODE (t) == IDENTIFIER_NODE)
3240 return (lang_identifier *) t;
3241 return NULL;
3242 }
3243
3244 // forked from gcc/c-family/c-common.h gnu_vector_type_p
3245
3246 /* Return true if TYPE is a vector type that should be subject to the GNU
3247 vector extensions (as opposed to a vector type that is used only for
3248 the purposes of defining target-specific built-in functions). */
3249
3250 inline bool
3251 gnu_vector_type_p (const_tree type)
3252 {
3253 return TREE_CODE (type) == VECTOR_TYPE && !TYPE_INDIVISIBLE_P (type);
3254 }
3255
3256 extern vec<tree, va_gc> *
3257 make_tree_vector (void);
3258
3259 extern void
3260 release_tree_vector (vec<tree, va_gc> *);
3261
3262 /* Simplified unique_ptr clone to release a tree vec on exit. */
3263
3264 class releasing_vec
3265 {
3266 public:
3267 typedef vec<tree, va_gc> vec_t;
3268
3269 releasing_vec (vec_t *v) : v (v) {}
3270 releasing_vec () : v (make_tree_vector ()) {}
3271
3272 /* Copy ops are deliberately declared but not defined,
3273 copies must always be elided. */
3274 releasing_vec (const releasing_vec &);
3275 releasing_vec &operator= (const releasing_vec &);
3276
3277 vec_t &operator* () const { return *v; }
3278 vec_t *operator-> () const { return v; }
3279 vec_t *get () const { return v; }
3280 operator vec_t * () const { return v; }
3281 vec_t **operator& () { return &v; }
3282
3283 /* Breaks pointer/value consistency for convenience. This takes ptrdiff_t
3284 rather than unsigned to avoid ambiguity with the built-in operator[]
3285 (bootstrap/91828). */
3286 tree &operator[] (ptrdiff_t i) const { return (*v)[i]; }
3287
3288 tree *begin () { return ::begin (v); }
3289 tree *end () { return ::end (v); }
3290
3291 void release ()
3292 {
3293 release_tree_vector (v);
3294 v = NULL;
3295 }
3296
3297 ~releasing_vec () { release_tree_vector (v); }
3298
3299 private:
3300 vec_t *v;
3301 };
3302
3303 inline tree *
3304 vec_safe_push (releasing_vec &r, const tree &t CXX_MEM_STAT_INFO)
3305 {
3306 return vec_safe_push (*&r, t PASS_MEM_STAT);
3307 }
3308
3309 inline bool
3310 vec_safe_reserve (releasing_vec &r, unsigned n,
3311 bool e = false CXX_MEM_STAT_INFO)
3312 {
3313 return vec_safe_reserve (*&r, n, e PASS_MEM_STAT);
3314 }
3315 inline unsigned
3316 vec_safe_length (releasing_vec &r)
3317 {
3318 return r->length ();
3319 }
3320 inline void
3321 vec_safe_splice (releasing_vec &r, vec<tree, va_gc> *p CXX_MEM_STAT_INFO)
3322 {
3323 vec_safe_splice (*&r, p PASS_MEM_STAT);
3324 }
3325
3326 inline bool
3327 null_node_p (const_tree expr)
3328 {
3329 STRIP_ANY_LOCATION_WRAPPER (expr);
3330 return expr == null_node;
3331 }
3332
3333 inline void
3334 cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
3335 diagnostic_t diag_kind)
3336 {
3337 cxx_incomplete_type_diagnostic (rs_expr_loc_or_input_loc (value), value, type,
3338 diag_kind);
3339 }
3340
3341 inline void
3342 cxx_incomplete_type_error (const_tree value, const_tree type)
3343 {
3344 cxx_incomplete_type_diagnostic (value, type, DK_ERROR);
3345 }
3346
3347 extern location_t
3348 location_of (tree t);
3349
3350 /* Helpers for IMPLICIT_RVALUE_P to look through automatic dereference. */
3351
3352 inline bool
3353 implicit_rvalue_p (const_tree t)
3354 {
3355 if (REFERENCE_REF_P (t))
3356 t = TREE_OPERAND (t, 0);
3357 return ((TREE_CODE (t) == NON_LVALUE_EXPR) && IMPLICIT_RVALUE_P (t));
3358 }
3359 inline tree
3360 set_implicit_rvalue_p (tree ot)
3361 {
3362 tree t = ot;
3363 if (REFERENCE_REF_P (t))
3364 t = TREE_OPERAND (t, 0);
3365 IMPLICIT_RVALUE_P (t) = 1;
3366 return ot;
3367 }
3368
3369 namespace Compile {
3370 extern tree
3371 maybe_constant_init (tree, tree = NULL_TREE, bool = false);
3372
3373 extern void
3374 explain_invalid_constexpr_fn (tree fun);
3375
3376 extern bool potential_constant_expression (tree);
3377
3378 extern bool
3379 literal_type_p (tree t);
3380
3381 extern bool
3382 maybe_constexpr_fn (tree t);
3383
3384 extern tree
3385 fold_non_dependent_init (tree, tsubst_flags_t = tf_warning_or_error,
3386 bool = false, tree = NULL_TREE);
3387 } // namespace Compile
3388
3389 } // namespace Rust
3390
3391 #endif // RUST_TREE