]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/rust/backend/rust-tree.h
Match: Support form 2 for vector signed integer .SAT_ADD
[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 RS_DST_FLAG TREE_LANG_FLAG_0
82 #define RS_DST_FLAG_P(TYPE) \
83 (TREE_CODE (TYPE) == RECORD_TYPE && TREE_LANG_FLAG_0 (TYPE))
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) Rust::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 rust_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) { rust_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 c_language_function
2023
2024 /* Global state pertinent to the current function. Some C dialects
2025 extend this structure with additional fields. */
2026
2027 struct GTY (()) c_language_function
2028 {
2029 /* Vector of locally defined typedefs, for
2030 -Wunused-local-typedefs. */
2031 vec<tree, va_gc> *local_typedefs;
2032 };
2033
2034 // forked from gcc/cp/cp-tree.h omp_declare_target_attr
2035
2036 struct GTY (()) omp_declare_target_attr
2037 {
2038 bool attr_syntax;
2039 };
2040
2041 // forked from gcc/cp/name-lookup.h cxx_binding
2042
2043 /* Datatype that represents binding established by a declaration between
2044 a name and a C++ entity. */
2045 struct GTY (()) cxx_binding
2046 {
2047 /* Link to chain together various bindings for this name. */
2048 cxx_binding *previous;
2049 /* The non-type entity this name is bound to. */
2050 tree value;
2051 /* The type entity this name is bound to. */
2052 tree type;
2053
2054 bool value_is_inherited : 1;
2055 bool is_local : 1;
2056 bool type_is_hidden : 1;
2057 };
2058
2059 // forked from gcc/cp/name-lookup.h cxx_saved_binding
2060
2061 /* Datatype used to temporarily save C++ bindings (for implicit
2062 instantiations purposes and like). Implemented in decl.cc. */
2063 struct GTY (()) rust_cxx_saved_binding
2064 {
2065 /* The name of the current binding. */
2066 tree identifier;
2067 /* The binding we're saving. */
2068 cxx_binding *binding;
2069 tree real_type_value;
2070 };
2071
2072 // forked from gcc/cp/name-lookup.h resort_type_member_vec
2073
2074 /* needed for GTY annotation */
2075 extern void
2076 resort_type_member_vec (void *, void *, gt_pointer_operator, void *);
2077
2078 // forked from gcc/cp/cp-tree.h saved_scope
2079
2080 /* Global state. */
2081
2082 struct GTY (()) saved_scope
2083 {
2084 vec<rust_cxx_saved_binding, va_gc> *old_bindings;
2085 tree old_namespace;
2086 vec<tree, va_gc> *decl_ns_list;
2087 tree class_name;
2088 tree class_type;
2089 tree access_specifier;
2090 tree function_decl;
2091 vec<tree, va_gc> *lang_base;
2092 tree lang_name;
2093 tree template_parms;
2094 tree x_saved_tree;
2095
2096 /* Only used for uses of this in trailing return type. */
2097 tree x_current_class_ptr;
2098 tree x_current_class_ref;
2099
2100 int x_processing_template_decl;
2101 int x_processing_specialization;
2102 int x_processing_constraint;
2103 int suppress_location_wrappers;
2104 BOOL_BITFIELD x_processing_explicit_instantiation : 1;
2105 BOOL_BITFIELD need_pop_function_context : 1;
2106
2107 /* Nonzero if we are parsing the discarded statement of a constexpr
2108 if-statement. */
2109 BOOL_BITFIELD discarded_stmt : 1;
2110 /* Nonzero if we are parsing or instantiating the compound-statement
2111 of consteval if statement. Also set while processing an immediate
2112 invocation. */
2113 BOOL_BITFIELD consteval_if_p : 1;
2114
2115 int unevaluated_operand;
2116 int inhibit_evaluation_warnings;
2117 int noexcept_operand;
2118 int ref_temp_count;
2119
2120 hash_map<tree, tree> *GTY ((skip)) x_local_specializations;
2121 vec<omp_declare_target_attr, va_gc> *omp_declare_target_attribute;
2122
2123 struct saved_scope *prev;
2124 };
2125
2126 extern GTY (()) struct saved_scope *scope_chain;
2127
2128 // forked from gcc/cp/name_lookup.h cp_class_binding
2129
2130 struct GTY (()) rust_cp_class_binding
2131 {
2132 cxx_binding *base;
2133 /* The bound name. */
2134 tree identifier;
2135 };
2136
2137 // forked from gcc/cp/name_lookup.h cp_binding_level
2138
2139 /* For each binding contour we allocate a binding_level structure
2140 which records the names defined in that contour.
2141 Contours include:
2142 0) the global one
2143 1) one for each function definition,
2144 where internal declarations of the parameters appear.
2145 2) one for each compound statement,
2146 to record its declarations.
2147
2148 The current meaning of a name can be found by searching the levels
2149 from the current one out to the global one.
2150
2151 Off to the side, may be the class_binding_level. This exists only
2152 to catch class-local declarations. It is otherwise nonexistent.
2153
2154 Also there may be binding levels that catch cleanups that must be
2155 run when exceptions occur. Thus, to see whether a name is bound in
2156 the current scope, it is not enough to look in the
2157 CURRENT_BINDING_LEVEL. You should use lookup_name_current_level
2158 instead. */
2159
2160 struct GTY (()) rust_cp_binding_level
2161 {
2162 /* A chain of _DECL nodes for all variables, constants, functions,
2163 and typedef types. These are in the reverse of the order
2164 supplied. There may be OVERLOADs on this list, too, but they
2165 are wrapped in TREE_LISTs; the TREE_VALUE is the OVERLOAD. */
2166 tree names;
2167
2168 /* Using directives. */
2169 vec<tree, va_gc> *using_directives;
2170
2171 /* For the binding level corresponding to a class, the entities
2172 declared in the class or its base classes. */
2173 vec<rust_cp_class_binding, va_gc> *class_shadowed;
2174
2175 /* Similar to class_shadowed, but for IDENTIFIER_TYPE_VALUE, and
2176 is used for all binding levels. The TREE_PURPOSE is the name of
2177 the entity, the TREE_TYPE is the associated type. In addition
2178 the TREE_VALUE is the IDENTIFIER_TYPE_VALUE before we entered
2179 the class. */
2180 tree type_shadowed;
2181
2182 /* For each level (except not the global one),
2183 a chain of BLOCK nodes for all the levels
2184 that were entered and exited one level down. */
2185 tree blocks;
2186
2187 /* The entity (namespace, class, function) the scope of which this
2188 binding contour corresponds to. Otherwise NULL. */
2189 tree this_entity;
2190
2191 /* The binding level which this one is contained in (inherits from). */
2192 rust_cp_binding_level *level_chain;
2193
2194 /* STATEMENT_LIST for statements in this binding contour.
2195 Only used at present for SK_CLEANUP temporary bindings. */
2196 tree statement_list;
2197
2198 /* Binding depth at which this level began. */
2199 int binding_depth;
2200
2201 /* The kind of scope that this object represents. However, a
2202 SK_TEMPLATE_SPEC scope is represented with KIND set to
2203 SK_TEMPLATE_PARMS and EXPLICIT_SPEC_P set to true. */
2204 ENUM_BITFIELD (scope_kind) kind : 4;
2205
2206 /* True if this scope is an SK_TEMPLATE_SPEC scope. This field is
2207 only valid if KIND == SK_TEMPLATE_PARMS. */
2208 BOOL_BITFIELD explicit_spec_p : 1;
2209
2210 /* true means make a BLOCK for this level regardless of all else. */
2211 unsigned keep : 1;
2212
2213 /* Nonzero if this level can safely have additional
2214 cleanup-needing variables added to it. */
2215 unsigned more_cleanups_ok : 1;
2216 unsigned have_cleanups : 1;
2217
2218 /* Transient state set if this scope is of sk_class kind
2219 and is in the process of defining 'this_entity'. Reset
2220 on leaving the class definition to allow for the scope
2221 to be subsequently re-used as a non-defining scope for
2222 'this_entity'. */
2223 unsigned defining_class_p : 1;
2224
2225 /* True for SK_FUNCTION_PARMS of a requires-expression. */
2226 unsigned requires_expression : 1;
2227
2228 /* 22 bits left to fill a 32-bit word. */
2229 };
2230
2231 // forked from gcc/cp/decl.cc named_label_entry
2232
2233 /* A list of all LABEL_DECLs in the function that have names. Here so
2234 we can clear out their names' definitions at the end of the
2235 function, and so we can check the validity of jumps to these labels. */
2236
2237 struct GTY ((for_user)) rust_named_label_entry
2238 {
2239 tree name; /* Name of decl. */
2240
2241 tree label_decl; /* LABEL_DECL, unless deleted local label. */
2242
2243 rust_named_label_entry *outer; /* Outer shadowed chain. */
2244
2245 /* The binding level to which the label is *currently* attached.
2246 This is initially set to the binding level in which the label
2247 is defined, but is modified as scopes are closed. */
2248 rust_cp_binding_level *binding_level;
2249
2250 /* The head of the names list that was current when the label was
2251 defined, or the inner scope popped. These are the decls that will
2252 be skipped when jumping to the label. */
2253 tree names_in_scope;
2254
2255 /* A vector of all decls from all binding levels that would be
2256 crossed by a backward branch to the label. */
2257 vec<tree, va_gc> *bad_decls;
2258
2259 /* The following bits are set after the label is defined, and are
2260 updated as scopes are popped. They indicate that a jump to the
2261 label will illegally enter a scope of the given flavor. */
2262 bool in_try_scope;
2263 bool in_catch_scope;
2264 bool in_omp_scope;
2265 bool in_transaction_scope;
2266 bool in_constexpr_if;
2267 bool in_consteval_if;
2268 bool in_stmt_expr;
2269 };
2270
2271 // forked from gcc/cp/cp-tree.h named_label_hash
2272
2273 struct rust_named_label_hash : ggc_remove<rust_named_label_entry *>
2274 {
2275 typedef rust_named_label_entry *value_type;
2276 typedef tree compare_type; /* An identifier. */
2277
2278 inline static hashval_t hash (value_type);
2279 inline static bool equal (const value_type, compare_type);
2280
2281 static const bool empty_zero_p = true;
2282 inline static void mark_empty (value_type &p) { p = NULL; }
2283 inline static bool is_empty (value_type p) { return !p; }
2284
2285 /* Nothing is deletable. Everything is insertable. */
2286 inline static bool is_deleted (value_type) { return false; }
2287 inline static void mark_deleted (value_type) { rust_unreachable (); }
2288 };
2289
2290 // forked from gcc/cp/cp-tree.h
2291
2292 /* Global state pertinent to the current function.
2293 TODO: remove vestigial fields */
2294
2295 struct GTY (()) language_function
2296 {
2297 struct c_language_function base;
2298
2299 tree x_cdtor_label;
2300 tree x_current_class_ptr;
2301 tree x_current_class_ref;
2302 tree x_eh_spec_block;
2303 tree x_in_charge_parm;
2304 tree x_vtt_parm;
2305 tree x_return_value;
2306
2307 BOOL_BITFIELD returns_value : 1;
2308 BOOL_BITFIELD returns_null : 1;
2309 BOOL_BITFIELD returns_abnormally : 1;
2310 BOOL_BITFIELD infinite_loop : 1;
2311 BOOL_BITFIELD x_in_function_try_handler : 1;
2312 BOOL_BITFIELD x_in_base_initializer : 1;
2313
2314 /* True if this function can throw an exception. */
2315 BOOL_BITFIELD can_throw : 1;
2316
2317 BOOL_BITFIELD invalid_constexpr : 1;
2318 BOOL_BITFIELD throwing_cleanup : 1;
2319
2320 hash_table<rust_named_label_hash> *x_named_labels;
2321
2322 /* Tracking possibly infinite loops. This is a vec<tree> only because
2323 vec<bool> doesn't work with gtype. */
2324 vec<tree, va_gc> *infinite_loops;
2325 };
2326
2327 // forked from gcc/c-family/c-common.h ref_operator
2328
2329 /* The various name of operator that appears in error messages. */
2330 enum ref_operator
2331 {
2332 /* NULL */
2333 RO_NULL,
2334 /* array indexing */
2335 RO_ARRAY_INDEXING,
2336 /* unary * */
2337 RO_UNARY_STAR,
2338 /* -> */
2339 RO_ARROW,
2340 /* implicit conversion */
2341 RO_IMPLICIT_CONVERSION,
2342 /* ->* */
2343 RO_ARROW_STAR
2344 };
2345
2346 // forked from gcc/cp/cp-tree.h lang_decl_min
2347
2348 /* DECL_LANG_SPECIFIC for the above codes. */
2349
2350 struct GTY (()) lang_decl_min
2351 {
2352 struct lang_decl_base base; /* 32-bits. */
2353
2354 /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
2355 THUNK_ALIAS.
2356 In a FUNCTION_DECL for which DECL_THUNK_P does not hold,
2357 VAR_DECL, TYPE_DECL, or TEMPLATE_DECL, this is
2358 DECL_TEMPLATE_INFO. */
2359 tree template_info;
2360
2361 /* In a DECL_THUNK_P FUNCTION_DECL, this is THUNK_VIRTUAL_OFFSET.
2362 In a lambda-capture proxy VAR_DECL, this is DECL_CAPTURED_VARIABLE.
2363 In a function-scope TREE_STATIC VAR_DECL or IMPLICIT_TYPEDEF_P TYPE_DECL,
2364 this is DECL_DISCRIMINATOR.
2365 In a DECL_LOCAL_DECL_P decl, this is the namespace decl it aliases.
2366 Otherwise, in a class-scope DECL, this is DECL_ACCESS. */
2367 tree access;
2368 };
2369
2370 // forked from gcc/cp/cp-tree.h lang_decl_fn
2371
2372 /* Additional DECL_LANG_SPECIFIC information for functions. */
2373
2374 struct GTY (()) lang_decl_fn
2375 {
2376 struct lang_decl_min min;
2377
2378 /* In a overloaded operator, this is the compressed operator code. */
2379 unsigned ovl_op_code : 6;
2380 unsigned global_ctor_p : 1;
2381 unsigned global_dtor_p : 1;
2382
2383 unsigned static_function : 1;
2384 unsigned pure_virtual : 1;
2385 unsigned defaulted_p : 1;
2386 unsigned has_in_charge_parm_p : 1;
2387 unsigned has_vtt_parm_p : 1;
2388 unsigned nonconverting : 1;
2389 unsigned thunk_p : 1;
2390
2391 unsigned this_thunk_p : 1;
2392 unsigned omp_declare_reduction_p : 1;
2393 unsigned has_dependent_explicit_spec_p : 1;
2394 unsigned immediate_fn_p : 1;
2395 unsigned maybe_deleted : 1;
2396 unsigned coroutine_p : 1;
2397 unsigned implicit_constexpr : 1;
2398
2399 unsigned spare : 10;
2400
2401 /* 32-bits padding on 64-bit host. */
2402
2403 /* For a non-thunk function decl, this is a tree list of
2404 friendly classes. For a thunk function decl, it is the
2405 thunked to function decl. */
2406 tree befriending_classes;
2407
2408 /* For a virtual FUNCTION_DECL for which
2409 DECL_THIS_THUNK_P does not hold, this is DECL_THUNKS. Both
2410 this pointer and result pointer adjusting thunks are
2411 chained here. This pointer thunks to return pointer thunks
2412 will be chained on the return pointer thunk.
2413 For a DECL_CONSTUCTOR_P FUNCTION_DECL, this is the base from
2414 whence we inherit. Otherwise, it is the class in which a
2415 (namespace-scope) friend is defined (if any). */
2416 tree context;
2417
2418 union lang_decl_u5
2419 {
2420 /* In a non-thunk FUNCTION_DECL, this is DECL_CLONED_FUNCTION. */
2421 tree GTY ((tag ("0"))) cloned_function;
2422
2423 /* In a FUNCTION_DECL for which THUNK_P holds this is the
2424 THUNK_FIXED_OFFSET. */
2425 HOST_WIDE_INT GTY ((tag ("1"))) fixed_offset;
2426 } GTY ((desc ("%1.thunk_p"))) u5;
2427
2428 tree GTY (()) saved_auto_return_type;
2429 };
2430
2431 // forked from gcc/cp/cp-tree.h lang_decl_ns
2432
2433 /* DECL_LANG_SPECIFIC for namespaces. */
2434
2435 struct GTY (()) lang_decl_ns
2436 {
2437 struct lang_decl_base base; /* 32 bits. */
2438
2439 /* Inline children. Needs to be va_gc, because of PCH. */
2440 vec<tree, va_gc> *inlinees;
2441
2442 /* Hash table of bound decls. It'd be nice to have this inline, but
2443 as the hash_map has a dtor, we can't then put this struct into a
2444 union (until moving to c++11). */
2445 hash_table<rust_named_decl_hash> *bindings;
2446 };
2447
2448 // forked from gcc/cp/cp-tree.h lang_decl_parm
2449
2450 /* DECL_LANG_SPECIFIC for parameters. */
2451
2452 struct GTY (()) lang_decl_parm
2453 {
2454 struct lang_decl_base base; /* 32 bits. */
2455 int level;
2456 int index;
2457 };
2458
2459 // forked from gcc/cp/cp-tree.h lang_decl_decomp
2460
2461 /* Additional DECL_LANG_SPECIFIC information for structured bindings. */
2462
2463 struct GTY (()) lang_decl_decomp
2464 {
2465 struct lang_decl_min min;
2466 /* The artificial underlying "e" variable of the structured binding
2467 variable. */
2468 tree base;
2469 };
2470
2471 // forked from gcc/cp/cp-tree.h lang_decl
2472
2473 /* DECL_LANG_SPECIFIC for all types. It would be nice to just make this a
2474 union rather than a struct containing a union as its only field, but
2475 tree.h declares it as a struct. */
2476
2477 struct GTY (()) lang_decl
2478 {
2479 union GTY ((desc ("%h.base.selector"))) lang_decl_u
2480 {
2481 /* Nothing of only the base type exists. */
2482 struct lang_decl_base GTY ((default)) base;
2483 struct lang_decl_min GTY ((tag ("lds_min"))) min;
2484 struct lang_decl_fn GTY ((tag ("lds_fn"))) fn;
2485 struct lang_decl_ns GTY ((tag ("lds_ns"))) ns;
2486 struct lang_decl_parm GTY ((tag ("lds_parm"))) parm;
2487 struct lang_decl_decomp GTY ((tag ("lds_decomp"))) decomp;
2488 } u;
2489 };
2490
2491 // forked from gcc/c-family/c-common.h c_fileinfo
2492
2493 /* Information recorded about each file examined during compilation. */
2494
2495 struct c_fileinfo
2496 {
2497 int time; /* Time spent in the file. */
2498
2499 /* Flags used only by C++.
2500 INTERFACE_ONLY nonzero means that we are in an "interface" section
2501 of the compiler. INTERFACE_UNKNOWN nonzero means we cannot trust
2502 the value of INTERFACE_ONLY. If INTERFACE_UNKNOWN is zero and
2503 INTERFACE_ONLY is zero, it means that we are responsible for
2504 exporting definitions that others might need. */
2505 short interface_only;
2506 short interface_unknown;
2507 };
2508
2509 // forked from gcc/c-family/c-common.h c_common_identifier
2510
2511 /* Identifier part common to the C front ends. Inherits from
2512 tree_identifier, despite appearances. */
2513 struct GTY (()) c_common_identifier
2514 {
2515 struct tree_common common;
2516 struct cpp_hashnode node; // from cpplib.h
2517 };
2518
2519 // forked from gcc/cp/cp-tree.h lang_identifier
2520
2521 /* Language-dependent contents of an identifier. */
2522
2523 struct GTY (()) lang_identifier
2524 {
2525 struct c_common_identifier c_common;
2526 cxx_binding *bindings;
2527 };
2528
2529 // forked from gcc/cp/cp-tree.h tree_overload
2530
2531 /* OVL_HIDDEN_P nodes come before other nodes. */
2532
2533 struct GTY (()) tree_overload
2534 {
2535 struct tree_common common;
2536 tree function;
2537 };
2538
2539 // forked from gcc/cp/cp-tree.h ovl_iterator
2540
2541 class ovl_iterator
2542 {
2543 tree ovl;
2544 const bool allow_inner; /* Only used when checking. */
2545
2546 public:
2547 explicit ovl_iterator (tree o, bool allow = false)
2548 : ovl (o), allow_inner (allow)
2549 {}
2550
2551 public:
2552 operator bool () const { return ovl; }
2553 ovl_iterator &operator++ ()
2554 {
2555 ovl = TREE_CODE (ovl) != OVERLOAD ? NULL_TREE : OVL_CHAIN (ovl);
2556 return *this;
2557 }
2558 tree operator* () const
2559 {
2560 tree fn = TREE_CODE (ovl) != OVERLOAD ? ovl : OVL_FUNCTION (ovl);
2561
2562 /* Check this is not an unexpected 2-dimensional overload. */
2563 gcc_checking_assert (allow_inner || TREE_CODE (fn) != OVERLOAD);
2564
2565 return fn;
2566 }
2567 bool operator== (const ovl_iterator &o) const { return ovl == o.ovl; }
2568 tree get_using () const
2569 {
2570 gcc_checking_assert (using_p ());
2571 return ovl;
2572 }
2573
2574 public:
2575 /* Whether this overload was introduced by a using decl. */
2576 bool using_p () const
2577 {
2578 return (TREE_CODE (ovl) == USING_DECL
2579 || (TREE_CODE (ovl) == OVERLOAD && OVL_USING_P (ovl)));
2580 }
2581 /* Whether this using is being exported. */
2582 bool exporting_p () const { return OVL_EXPORT_P (get_using ()); }
2583
2584 bool hidden_p () const
2585 {
2586 return TREE_CODE (ovl) == OVERLOAD && OVL_HIDDEN_P (ovl);
2587 }
2588
2589 public:
2590 tree remove_node (tree head) { return remove_node (head, ovl); }
2591 tree reveal_node (tree head) { return reveal_node (head, ovl); }
2592
2593 protected:
2594 /* If we have a nested overload, point at the inner overload and
2595 return the next link on the outer one. */
2596 tree maybe_push ()
2597 {
2598 tree r = NULL_TREE;
2599
2600 if (ovl && TREE_CODE (ovl) == OVERLOAD && OVL_NESTED_P (ovl))
2601 {
2602 r = OVL_CHAIN (ovl);
2603 ovl = OVL_FUNCTION (ovl);
2604 }
2605 return r;
2606 }
2607 /* Restore an outer nested overload. */
2608 void pop (tree outer)
2609 {
2610 gcc_checking_assert (!ovl);
2611 ovl = outer;
2612 }
2613
2614 private:
2615 /* We make these static functions to avoid the address of the
2616 iterator escaping the local context. */
2617 static tree remove_node (tree head, tree node);
2618 static tree reveal_node (tree ovl, tree node);
2619 };
2620
2621 // forked from gcc/cp/cp-tree.h lkp_iterator
2622
2623 /* Iterator over a (potentially) 2 dimensional overload, which is
2624 produced by name lookup. */
2625
2626 class lkp_iterator : public ovl_iterator
2627 {
2628 typedef ovl_iterator parent;
2629
2630 tree outer;
2631
2632 public:
2633 explicit lkp_iterator (tree o) : parent (o, true), outer (maybe_push ()) {}
2634
2635 public:
2636 lkp_iterator &operator++ ()
2637 {
2638 bool repush = !outer;
2639
2640 if (!parent::operator++ () && !repush)
2641 {
2642 pop (outer);
2643 repush = true;
2644 }
2645
2646 if (repush)
2647 outer = maybe_push ();
2648
2649 return *this;
2650 }
2651 };
2652
2653 // forked from gcc/cp/cp-tree.h treee_pair_s
2654
2655 struct GTY (()) rust_tree_pair_s
2656 {
2657 tree purpose;
2658 tree value;
2659 };
2660
2661 // forked from gcc/cp/cp-tree.h tree_pair_p
2662
2663 typedef rust_tree_pair_s *rust_tree_pair_p;
2664
2665 // forked from gcc/cp/cp-tree.h lang_type
2666
2667 /* This structure provides additional information above and beyond
2668 what is provide in the ordinary tree_type. In the past, we used it
2669 for the types of class types, template parameters types, typename
2670 types, and so forth. However, there can be many (tens to hundreds
2671 of thousands) of template parameter types in a compilation, and
2672 there's no need for this additional information in that case.
2673 Therefore, we now use this data structure only for class types.
2674
2675 In the past, it was thought that there would be relatively few
2676 class types. However, in the presence of heavy use of templates,
2677 many (i.e., thousands) of classes can easily be generated.
2678 Therefore, we should endeavor to keep the size of this structure to
2679 a minimum. */
2680 struct GTY (()) lang_type
2681 {
2682 unsigned char align;
2683
2684 unsigned has_type_conversion : 1;
2685 unsigned has_copy_ctor : 1;
2686 unsigned has_default_ctor : 1;
2687 unsigned const_needs_init : 1;
2688 unsigned ref_needs_init : 1;
2689 unsigned has_const_copy_assign : 1;
2690 unsigned use_template : 2;
2691
2692 unsigned has_mutable : 1;
2693 unsigned com_interface : 1;
2694 unsigned non_pod_class : 1;
2695 unsigned nearly_empty_p : 1;
2696 unsigned user_align : 1;
2697 unsigned has_copy_assign : 1;
2698 unsigned has_new : 1;
2699 unsigned has_array_new : 1;
2700
2701 unsigned gets_delete : 2;
2702 unsigned interface_only : 1;
2703 unsigned interface_unknown : 1;
2704 unsigned contains_empty_class_p : 1;
2705 unsigned anon_aggr : 1;
2706 unsigned non_zero_init : 1;
2707 unsigned empty_p : 1;
2708 /* 32 bits allocated. */
2709
2710 unsigned vec_new_uses_cookie : 1;
2711 unsigned declared_class : 1;
2712 unsigned diamond_shaped : 1;
2713 unsigned repeated_base : 1;
2714 unsigned being_defined : 1;
2715 unsigned debug_requested : 1;
2716 unsigned fields_readonly : 1;
2717 unsigned ptrmemfunc_flag : 1;
2718
2719 unsigned lazy_default_ctor : 1;
2720 unsigned lazy_copy_ctor : 1;
2721 unsigned lazy_copy_assign : 1;
2722 unsigned lazy_destructor : 1;
2723 unsigned has_const_copy_ctor : 1;
2724 unsigned has_complex_copy_ctor : 1;
2725 unsigned has_complex_copy_assign : 1;
2726 unsigned non_aggregate : 1;
2727
2728 unsigned has_complex_dflt : 1;
2729 unsigned has_list_ctor : 1;
2730 unsigned non_std_layout : 1;
2731 unsigned is_literal : 1;
2732 unsigned lazy_move_ctor : 1;
2733 unsigned lazy_move_assign : 1;
2734 unsigned has_complex_move_ctor : 1;
2735 unsigned has_complex_move_assign : 1;
2736
2737 unsigned has_constexpr_ctor : 1;
2738 unsigned unique_obj_representations : 1;
2739 unsigned unique_obj_representations_set : 1;
2740 bool erroneous : 1;
2741 bool non_pod_aggregate : 1;
2742
2743 /* When adding a flag here, consider whether or not it ought to
2744 apply to a template instance if it applies to the template. If
2745 so, make sure to copy it in instantiate_class_template! */
2746
2747 /* There are some bits left to fill out a 32-bit word. Keep track
2748 of this by updating the size of this bitfield whenever you add or
2749 remove a flag. */
2750 unsigned dummy : 3;
2751
2752 tree primary_base;
2753 vec<rust_tree_pair_s, va_gc> *vcall_indices;
2754 tree vtables;
2755 tree typeinfo_var;
2756 vec<tree, va_gc> *vbases;
2757 tree as_base;
2758 vec<tree, va_gc> *pure_virtuals;
2759 tree friend_classes;
2760 vec<tree, va_gc> *GTY ((reorder ("resort_type_member_vec"))) members;
2761 tree key_method;
2762 tree decl_list;
2763 tree befriending_classes;
2764 /* In a RECORD_TYPE, information specific to Objective-C++, such
2765 as a list of adopted protocols or a pointer to a corresponding
2766 @interface. See objc/objc-act.h for details. */
2767 tree objc_info;
2768 /* FIXME reuse another field? */
2769 tree lambda_expr;
2770 };
2771
2772 namespace Rust {
2773
2774 // forked from gcc/cp/cp-tree.h cp_ref_qualifier
2775
2776 enum rs_ref_qualifier
2777 {
2778 REF_QUAL_NONE = 0,
2779 REF_QUAL_LVALUE = 1,
2780 REF_QUAL_RVALUE = 2
2781 };
2782
2783 // forked from gcc/cp/cp-tree.h tsubst_flags
2784
2785 /* Bitmask flags to control type substitution. */
2786 enum tsubst_flags
2787 {
2788 tf_none = 0, /* nothing special */
2789 tf_error = 1 << 0, /* give error messages */
2790 tf_warning = 1 << 1, /* give warnings too */
2791 tf_ignore_bad_quals = 1 << 2, /* ignore bad cvr qualifiers */
2792 tf_keep_type_decl = 1 << 3, /* retain typedef type decls
2793 (make_typename_type use) */
2794 tf_ptrmem_ok = 1 << 4, /* pointers to member ok (internal
2795 instantiate_type use) */
2796 tf_user = 1 << 5, /* found template must be a user template
2797 (lookup_template_class use) */
2798 tf_conv = 1 << 6, /* We are determining what kind of
2799 conversion might be permissible,
2800 not actually performing the
2801 conversion. */
2802 tf_decltype = 1 << 7, /* We are the operand of decltype.
2803 Used to implement the special rules
2804 for calls in decltype (5.2.2/11). */
2805 tf_partial = 1 << 8, /* Doing initial explicit argument
2806 substitution in fn_type_unification. */
2807 tf_fndecl_type = 1 << 9, /* Substituting the type of a function
2808 declaration. */
2809 tf_no_cleanup = 1 << 10, /* Do not build a cleanup
2810 (build_target_expr and friends) */
2811 tf_norm = 1 << 11, /* Build diagnostic information during
2812 constraint normalization. */
2813 /* Convenient substitution flags combinations. */
2814 tf_warning_or_error = tf_warning | tf_error
2815 };
2816
2817 // forked from gcc/cp/cp-tree.h cp_identifier_kind
2818
2819 /* Kinds of identifiers. Values are carefully chosen. */
2820 enum cp_identifier_kind
2821 {
2822 cik_normal = 0, /* Not a special identifier. */
2823 cik_keyword = 1, /* A keyword. */
2824 cik_ctor = 2, /* Constructor (in-chg, complete or base). */
2825 cik_dtor = 3, /* Destructor (in-chg, deleting, complete or
2826 base). */
2827 cik_simple_op = 4, /* Non-assignment operator name. */
2828 cik_assign_op = 5, /* An assignment operator name. */
2829 cik_conv_op = 6, /* Conversion operator name. */
2830 cik_reserved_for_udlit = 7, /* Not yet in use */
2831 cik_max
2832 };
2833
2834 // forked from gcc/cp/cp-tree.h tag_types
2835
2836 /* An enumeration of the kind of tags that C++ accepts. */
2837 enum tag_types
2838 {
2839 none_type = 0, /* Not a tag type. */
2840 record_type, /* "struct" types. */
2841 class_type, /* "class" types. */
2842 union_type, /* "union" types. */
2843 enum_type, /* "enum" types. */
2844 typename_type, /* "typename" types. */
2845 scope_type /* namespace or tagged type name followed by :: */
2846 };
2847
2848 // forked from gcc/cp/cp-tree.h tsubst_flags_t
2849
2850 /* This type is used for parameters and variables which hold
2851 combinations of the flags in enum tsubst_flags. */
2852 typedef int tsubst_flags_t;
2853
2854 // forked from gcc/cp/cvt.cc convert_to_void
2855 //
2856 // When an expression is used in a void context, its value is discarded and
2857 // no lvalue-rvalue and similar conversions happen [expr.static.cast/4,
2858 // stmt.expr/1, expr.comma/1]. This permits dereferencing an incomplete type
2859 // in a void context. The C++ standard does not define what an `access' to an
2860 // object is, but there is reason to believe that it is the lvalue to rvalue
2861 // conversion -- if it were not, `*&*p = 1' would violate [expr]/4 in that it
2862 // accesses `*p' not to calculate the value to be stored. But, dcl.type.cv/8
2863 // indicates that volatile semantics should be the same between C and C++
2864 // where ever possible. C leaves it implementation defined as to what
2865 // constitutes an access to a volatile. So, we interpret `*vp' as a read of
2866 // the volatile object `vp' points to, unless that is an incomplete type. For
2867 // volatile references we do not do this interpretation, because that would
2868 // make it impossible to ignore the reference return value from functions. We
2869 // issue warnings in the confusing cases.
2870 //
2871 // The IMPLICIT is ICV_CAST when the user is explicitly converting an
2872 // expression to void via a cast. If an expression is being implicitly
2873 // converted, IMPLICIT indicates the context of the implicit conversion.
2874
2875 /* Possible cases of implicit or explicit bad conversions to void. */
2876 enum impl_conv_void
2877 {
2878 ICV_CAST, /* (explicit) conversion to void */
2879 ICV_SECOND_OF_COND, /* second operand of conditional expression */
2880 ICV_THIRD_OF_COND, /* third operand of conditional expression */
2881 ICV_RIGHT_OF_COMMA, /* right operand of comma operator */
2882 ICV_LEFT_OF_COMMA, /* left operand of comma operator */
2883 ICV_STATEMENT, /* statement */
2884 ICV_THIRD_IN_FOR /* for increment expression */
2885 };
2886
2887 /* BUILT_IN_FRONTEND function codes. */
2888 enum rs_built_in_function
2889 {
2890 RS_BUILT_IN_IS_CONSTANT_EVALUATED,
2891 RS_BUILT_IN_INTEGER_PACK,
2892 RS_BUILT_IN_IS_CORRESPONDING_MEMBER,
2893 RS_BUILT_IN_IS_POINTER_INTERCONVERTIBLE_WITH_CLASS,
2894 RS_BUILT_IN_SOURCE_LOCATION,
2895 RS_BUILT_IN_LAST
2896 };
2897
2898 // forked from gcc/cp/cp-tree.h compare_bounds_t
2899
2900 /* in typeck.cc */
2901 /* Says how we should behave when comparing two arrays one of which
2902 has unknown bounds. */
2903 enum compare_bounds_t
2904 {
2905 bounds_none,
2906 bounds_either,
2907 bounds_first
2908 };
2909
2910 extern tree
2911 convert_to_void (tree expr, impl_conv_void implicit);
2912
2913 // The lvalue-to-rvalue conversion (7.1) is applied if and only if the
2914 // expression is a glvalue of volatile-qualified type and it is one of the
2915 // following:
2916 // * ( expression ), where expression is one of these expressions,
2917 // * id-expression (8.1.4),
2918 // * subscripting (8.2.1),
2919 // * class member access (8.2.5),
2920 // * indirection (8.3.1),
2921 // * pointer-to-member operation (8.5),
2922 // * conditional expression (8.16) where both the second and the third
2923 // operands are one of these expressions, or
2924 // * comma expression (8.19) where the right operand is one of these
2925 // expressions.
2926 extern tree
2927 mark_discarded_use (tree expr);
2928
2929 // Mark EXP as read, not just set, for set but not used -Wunused warning
2930 // purposes.
2931 extern void
2932 mark_exp_read (tree exp);
2933
2934 // We've seen an actual use of EXPR. Possibly replace an outer variable
2935 // reference inside with its constant value or a lambda capture.
2936 extern tree
2937 mark_use (tree expr, bool rvalue_p, bool read_p, location_t loc,
2938 bool reject_builtin);
2939
2940 // Called whenever the expression EXPR is used in an rvalue context.
2941 // When REJECT_BUILTIN is true the expression is checked to make sure
2942 // it doesn't make it possible to obtain the address of a GCC built-in
2943 // function with no library fallback (or any of its bits, such as in
2944 // a conversion to bool).
2945 extern tree
2946 mark_rvalue_use (tree, location_t = UNKNOWN_LOCATION,
2947 bool reject_builtin = true);
2948
2949 // Called whenever an expression is used in an lvalue context.
2950 extern tree
2951 mark_lvalue_use (tree expr);
2952
2953 // As above, but don't consider this use a read.
2954 extern tree
2955 mark_lvalue_use_nonread (tree expr);
2956
2957 // We are using a reference VAL for its value. Bash that reference all the way
2958 // down to its lowest form.
2959 extern tree
2960 convert_from_reference (tree val);
2961
2962 // Subroutine of convert_to_void. Warn if we're discarding something with
2963 // attribute [[nodiscard]].
2964 extern void
2965 maybe_warn_nodiscard (tree expr, impl_conv_void implicit);
2966
2967 extern location_t
2968 expr_loc_or_loc (const_tree t, location_t or_loc);
2969
2970 extern location_t
2971 expr_loc_or_input_loc (const_tree t);
2972
2973 // FN is the callee of a CALL_EXPR or AGGR_INIT_EXPR; return the FUNCTION_DECL
2974 // if we can.
2975 extern tree
2976 get_fndecl_from_callee (tree fn);
2977
2978 // FIXME some helpers from HIRCompileBase could probably be moved here over time
2979
2980 // Return an expression for the address of BASE[INDEX], used in offset intrinsic
2981 extern tree
2982 pointer_offset_expression (tree base_tree, tree index_tree, location_t locus);
2983
2984 /* A tree node, together with a location, so that we can track locations
2985 (and ranges) during parsing.
2986
2987 The location is redundant for node kinds that have locations,
2988 but not all node kinds do (e.g. constants, and references to
2989 params, locals, etc), so we stash a copy here. */
2990
2991 extern location_t rs_expr_location (const_tree);
2992
2993 extern int
2994 is_empty_class (tree type);
2995
2996 extern tree array_type_nelts_top (tree);
2997
2998 extern bool
2999 is_really_empty_class (tree, bool);
3000
3001 extern bool builtin_valid_in_constant_expr_p (const_tree);
3002
3003 extern bool maybe_constexpr_fn (tree);
3004
3005 extern bool var_in_maybe_constexpr_fn (tree);
3006
3007 extern int
3008 rs_type_quals (const_tree type);
3009
3010 inline bool type_unknown_p (const_tree);
3011
3012 extern bool decl_maybe_constant_var_p (tree);
3013
3014 extern void
3015 init_modules ();
3016
3017 extern bool var_in_constexpr_fn (tree);
3018
3019 inline tree ovl_first (tree) ATTRIBUTE_PURE;
3020
3021 inline bool type_unknown_p (const_tree);
3022
3023 extern tree
3024 lookup_add (tree fns, tree lookup);
3025
3026 extern tree
3027 ovl_make (tree fn, tree next = NULL_TREE);
3028
3029 extern int is_overloaded_fn (tree) ATTRIBUTE_PURE;
3030
3031 extern bool maybe_add_lang_type_raw (tree);
3032
3033 extern rs_ref_qualifier type_memfn_rqual (const_tree);
3034
3035 extern bool builtin_pack_fn_p (tree);
3036
3037 extern tree make_conv_op_name (tree);
3038
3039 extern int type_memfn_quals (const_tree);
3040
3041 struct c_fileinfo *
3042 get_fileinfo (const char *);
3043
3044 extern tree
3045 cxx_make_type (enum tree_code CXX_MEM_STAT_INFO);
3046
3047 extern tree
3048 build_cplus_array_type (tree, tree, int is_dep = -1);
3049
3050 extern bool is_byte_access_type (tree);
3051
3052 extern bool
3053 comptypes (tree, tree, int);
3054
3055 extern tree canonical_eh_spec (tree);
3056
3057 extern int cp_tree_operand_length (const_tree);
3058
3059 extern bool rs_tree_equal (tree, tree);
3060
3061 extern bool compparms (const_tree, const_tree);
3062
3063 extern tree
3064 rs_build_qualified_type_real (tree, int, tsubst_flags_t);
3065 #define rs_build_qualified_type(TYPE, QUALS) \
3066 rs_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error)
3067 extern bool cv_qualified_p (const_tree);
3068
3069 extern bool similar_type_p (tree, tree);
3070
3071 extern bool rs_tree_equal (tree, tree);
3072
3073 extern bool
3074 vector_targets_convertible_p (const_tree t1, const_tree t2);
3075
3076 extern bool same_type_ignoring_top_level_qualifiers_p (tree, tree);
3077
3078 extern bool comp_ptr_ttypes_const (tree, tree, compare_bounds_t);
3079
3080 extern tree
3081 get_class_binding_direct (tree, tree, bool want_type = false);
3082
3083 extern tree skip_artificial_parms_for (const_tree, tree);
3084
3085 extern void
3086 lang_check_failed (const char *, int,
3087 const char *) ATTRIBUTE_NORETURN ATTRIBUTE_COLD;
3088
3089 extern tree default_init_uninitialized_part (tree);
3090
3091 extern bool type_has_non_user_provided_default_constructor (tree);
3092
3093 extern bool default_ctor_p (const_tree);
3094
3095 extern bool user_provided_p (tree);
3096
3097 extern bool sufficient_parms_p (const_tree);
3098
3099 extern tree next_initializable_field (tree);
3100
3101 extern tree in_class_defaulted_default_constructor (tree);
3102
3103 extern bool is_instantiation_of_constexpr (tree);
3104
3105 extern bool
3106 check_for_uninitialized_const_var (tree, bool, tsubst_flags_t);
3107
3108 extern bool reduced_constant_expression_p (tree);
3109
3110 extern tree cv_unqualified (tree);
3111
3112 extern tree cp_get_callee (tree);
3113 extern tree rs_get_callee_fndecl_nofold (tree);
3114
3115 extern bool is_nondependent_static_init_expression (tree);
3116
3117 extern tree build_nop (tree, tree);
3118
3119 extern bool scalarish_type_p (const_tree);
3120
3121 extern tree is_bitfield_expr_with_lowered_type (const_tree);
3122
3123 extern tree convert_bitfield_to_declared_type (tree);
3124
3125 extern tree
3126 cp_fold_maybe_rvalue (tree, bool);
3127
3128 extern tree maybe_undo_parenthesized_ref (tree);
3129
3130 extern tree
3131 fold_offsetof (tree, tree = size_type_node, tree_code ctx = ERROR_MARK);
3132
3133 extern tree cp_truthvalue_conversion (tree, tsubst_flags_t);
3134
3135 extern tree
3136 fold_non_dependent_expr (tree, tsubst_flags_t = tf_warning_or_error,
3137 bool = false, tree = NULL_TREE);
3138
3139 extern int char_type_p (tree);
3140
3141 extern bool instantiation_dependent_expression_p (tree);
3142
3143 extern bool type_has_nontrivial_copy_init (const_tree);
3144
3145 extern tree build_local_temp (tree);
3146
3147 extern bool is_normal_capture_proxy (tree);
3148
3149 extern bool reject_gcc_builtin (const_tree, location_t = UNKNOWN_LOCATION);
3150
3151 extern tree resolve_nondeduced_context (tree, tsubst_flags_t);
3152
3153 extern void cxx_incomplete_type_diagnostic (location_t, const_tree, const_tree,
3154 diagnostic_t);
3155
3156 extern void cxx_incomplete_type_error (location_t, const_tree, const_tree);
3157
3158 extern bool invalid_nonstatic_memfn_p (location_t, tree, tsubst_flags_t);
3159
3160 extern bool really_overloaded_fn (tree) ATTRIBUTE_PURE;
3161
3162 extern tree resolve_nondeduced_context_or_error (tree, tsubst_flags_t);
3163
3164 extern tree instantiate_non_dependent_or_null (tree);
3165
3166 extern void cxx_incomplete_type_inform (const_tree);
3167
3168 extern tree strip_top_quals (tree);
3169
3170 extern bool undeduced_auto_decl (tree);
3171
3172 extern bool require_deduced_type (tree, tsubst_flags_t = tf_warning_or_error);
3173
3174 extern bool decl_constant_var_p (tree);
3175
3176 extern tree build_new_constexpr_heap_type (tree, tree, tree);
3177
3178 extern bool is_empty_field (tree);
3179
3180 extern bool
3181 in_immediate_context ();
3182
3183 extern tree cp_get_callee_fndecl_nofold (tree);
3184
3185 extern bool
3186 cxx_mark_addressable (tree, bool = false);
3187
3188 extern tree fold_builtin_source_location (location_t);
3189
3190 extern tree build_address (tree);
3191
3192 extern bool bitfield_p (const_tree);
3193
3194 extern tree rvalue (tree);
3195
3196 extern bool glvalue_p (const_tree);
3197
3198 extern cp_lvalue_kind lvalue_kind (const_tree);
3199
3200 extern tree
3201 decl_constant_value (tree, bool);
3202
3203 extern tree lookup_enumerator (tree, tree);
3204
3205 extern int
3206 is_class_type (tree, int);
3207
3208 extern tree braced_lists_to_strings (tree, tree);
3209
3210 extern tree
3211 fold_builtin_is_pointer_inverconvertible_with_class (location_t, int, tree *);
3212
3213 extern bool layout_compatible_type_p (tree, tree);
3214
3215 extern tree finish_underlying_type (tree);
3216
3217 extern tree
3218 c_common_type_for_mode (machine_mode, int);
3219
3220 extern bool std_layout_type_p (const_tree);
3221
3222 extern tree complete_type (tree);
3223
3224 extern tree complete_type_or_else (tree, tree);
3225
3226 extern void note_failed_type_completion_for_satisfaction (tree);
3227
3228 extern tree complete_type_or_maybe_complain (tree, tree, tsubst_flags_t);
3229
3230 extern bool
3231 next_common_initial_seqence (tree &, tree &);
3232
3233 extern bool null_member_pointer_value_p (tree);
3234
3235 extern tree
3236 fold_builtin_is_corresponding_member (location_t, int, tree *);
3237
3238 extern tree cp_fold_rvalue (tree);
3239
3240 extern tree
3241 maybe_constant_value (tree, tree = NULL_TREE, bool = false);
3242
3243 extern tree lvalue_type (tree);
3244
3245 extern void lvalue_error (location_t, enum lvalue_use);
3246
3247 extern tree
3248 cp_fold_maybe_rvalue (tree, bool);
3249
3250 extern tree get_first_fn (tree) ATTRIBUTE_PURE;
3251
3252 extern void explain_non_literal_class (tree);
3253
3254 extern bool reference_related_p (tree, tree);
3255
3256 extern bool ordinary_char_type_p (tree);
3257
3258 extern bool array_string_literal_compatible_p (tree, tree);
3259
3260 // forked from gcc/cp/cp-tree.h
3261
3262 enum
3263 {
3264 ce_derived,
3265 ce_type,
3266 ce_normal,
3267 ce_exact
3268 };
3269
3270 extern tree
3271 rs_build_qualified_type_real (tree, int, tsubst_flags_t);
3272 #define rs_build_qualified_type(TYPE, QUALS) \
3273 rs_build_qualified_type_real ((TYPE), (QUALS), tf_warning_or_error)
3274
3275 extern tree
3276 rs_walk_subtrees (tree *, int *, walk_tree_fn, void *, hash_set<tree> *);
3277 #define rs_walk_tree(tp, func, data, pset) \
3278 walk_tree_1 (tp, func, data, pset, rs_walk_subtrees)
3279 #define rs_walk_tree_without_duplicates(tp, func, data) \
3280 walk_tree_without_duplicates_1 (tp, func, data, rs_walk_subtrees)
3281
3282 // forked from gcc/cp/cp-tree.h cp_expr_loc_or_loc
3283
3284 inline location_t
3285 rs_expr_loc_or_loc (const_tree t, location_t or_loc)
3286 {
3287 location_t loc = rs_expr_location (t);
3288 if (loc == UNKNOWN_LOCATION)
3289 loc = or_loc;
3290 return loc;
3291 }
3292
3293 // forked from gcc/cp/cp-tree.h cp_expr_loc_or_input_loc
3294
3295 inline location_t
3296 rs_expr_loc_or_input_loc (const_tree t)
3297 {
3298 return rs_expr_loc_or_loc (t, input_location);
3299 }
3300
3301 // forked from gcc/cp/cp-tree.h type_unknown_p
3302
3303 inline bool
3304 type_unknown_p (const_tree expr)
3305 {
3306 return TREE_TYPE (expr) == unknown_type_node;
3307 }
3308
3309 // forked from gcc/cp/cp-tree.h ovl_first
3310
3311 /* Inline bodies. */
3312
3313 inline tree
3314 ovl_first (tree node)
3315 {
3316 while (TREE_CODE (node) == OVERLOAD)
3317 node = OVL_FUNCTION (node);
3318 return node;
3319 }
3320
3321 // forked from gcc/cp/cp-tree.h type_of_this_parm
3322
3323 /* Return the type of the `this' parameter of FNTYPE. */
3324
3325 inline tree
3326 type_of_this_parm (const_tree fntype)
3327 {
3328 function_args_iterator iter;
3329 gcc_assert (TREE_CODE (fntype) == METHOD_TYPE);
3330 function_args_iter_init (&iter, fntype);
3331 return function_args_iter_cond (&iter);
3332 }
3333
3334 // forked from gcc/cp/cp-tree.h class_of_this_parm
3335
3336 /* Return the class of the `this' parameter of FNTYPE. */
3337
3338 inline tree
3339 class_of_this_parm (const_tree fntype)
3340 {
3341 return TREE_TYPE (type_of_this_parm (fntype));
3342 }
3343
3344 // forked from gcc/cp/cp-tree.h identifier_p
3345
3346 /* Return a typed pointer version of T if it designates a
3347 C++ front-end identifier. */
3348 inline lang_identifier *
3349 identifier_p (tree t)
3350 {
3351 if (TREE_CODE (t) == IDENTIFIER_NODE)
3352 return (lang_identifier *) t;
3353 return NULL;
3354 }
3355
3356 // forked from gcc/c-family/c-common.h gnu_vector_type_p
3357
3358 /* Return true if TYPE is a vector type that should be subject to the GNU
3359 vector extensions (as opposed to a vector type that is used only for
3360 the purposes of defining target-specific built-in functions). */
3361
3362 inline bool
3363 gnu_vector_type_p (const_tree type)
3364 {
3365 return TREE_CODE (type) == VECTOR_TYPE && !TYPE_INDIVISIBLE_P (type);
3366 }
3367
3368 extern vec<tree, va_gc> *
3369 make_tree_vector (void);
3370
3371 extern void
3372 release_tree_vector (vec<tree, va_gc> *);
3373
3374 /* Simplified unique_ptr clone to release a tree vec on exit. */
3375
3376 class releasing_vec
3377 {
3378 public:
3379 typedef vec<tree, va_gc> vec_t;
3380
3381 releasing_vec (vec_t *v) : v (v) {}
3382 releasing_vec () : v (make_tree_vector ()) {}
3383
3384 /* Copy ops are deliberately declared but not defined,
3385 copies must always be elided. */
3386 releasing_vec (const releasing_vec &);
3387 releasing_vec &operator= (const releasing_vec &);
3388
3389 vec_t &operator* () const { return *v; }
3390 vec_t *operator-> () const { return v; }
3391 vec_t *get () const { return v; }
3392 operator vec_t * () const { return v; }
3393 vec_t **operator& () { return &v; }
3394
3395 /* Breaks pointer/value consistency for convenience. This takes ptrdiff_t
3396 rather than unsigned to avoid ambiguity with the built-in operator[]
3397 (bootstrap/91828). */
3398 tree &operator[] (ptrdiff_t i) const { return (*v)[i]; }
3399
3400 tree *begin () { return ::begin (v); }
3401 tree *end () { return ::end (v); }
3402
3403 void release ()
3404 {
3405 release_tree_vector (v);
3406 v = NULL;
3407 }
3408
3409 ~releasing_vec () { release_tree_vector (v); }
3410
3411 private:
3412 vec_t *v;
3413 };
3414
3415 inline tree *
3416 vec_safe_push (releasing_vec &r, const tree &t CXX_MEM_STAT_INFO)
3417 {
3418 return vec_safe_push (*&r, t PASS_MEM_STAT);
3419 }
3420
3421 inline bool
3422 vec_safe_reserve (releasing_vec &r, unsigned n,
3423 bool e = false CXX_MEM_STAT_INFO)
3424 {
3425 return vec_safe_reserve (*&r, n, e PASS_MEM_STAT);
3426 }
3427 inline unsigned
3428 vec_safe_length (releasing_vec &r)
3429 {
3430 return r->length ();
3431 }
3432 inline void
3433 vec_safe_splice (releasing_vec &r, vec<tree, va_gc> *p CXX_MEM_STAT_INFO)
3434 {
3435 vec_safe_splice (*&r, p PASS_MEM_STAT);
3436 }
3437
3438 inline bool
3439 null_node_p (const_tree expr)
3440 {
3441 STRIP_ANY_LOCATION_WRAPPER (expr);
3442 return expr == null_node;
3443 }
3444
3445 inline void
3446 cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
3447 diagnostic_t diag_kind)
3448 {
3449 cxx_incomplete_type_diagnostic (rs_expr_loc_or_input_loc (value), value, type,
3450 diag_kind);
3451 }
3452
3453 inline void
3454 cxx_incomplete_type_error (const_tree value, const_tree type)
3455 {
3456 cxx_incomplete_type_diagnostic (value, type, DK_ERROR);
3457 }
3458
3459 extern location_t
3460 location_of (tree t);
3461
3462 /* Helpers for IMPLICIT_RVALUE_P to look through automatic dereference. */
3463
3464 inline bool
3465 implicit_rvalue_p (const_tree t)
3466 {
3467 if (REFERENCE_REF_P (t))
3468 t = TREE_OPERAND (t, 0);
3469 return ((TREE_CODE (t) == NON_LVALUE_EXPR) && IMPLICIT_RVALUE_P (t));
3470 }
3471 inline tree
3472 set_implicit_rvalue_p (tree ot)
3473 {
3474 tree t = ot;
3475 if (REFERENCE_REF_P (t))
3476 t = TREE_OPERAND (t, 0);
3477 IMPLICIT_RVALUE_P (t) = 1;
3478 return ot;
3479 }
3480
3481 namespace Compile {
3482 extern tree
3483 maybe_constant_init (tree, tree = NULL_TREE, bool = false);
3484
3485 extern void
3486 explain_invalid_constexpr_fn (tree fun);
3487
3488 extern bool potential_constant_expression (tree);
3489
3490 extern bool
3491 literal_type_p (tree t);
3492
3493 extern bool
3494 maybe_constexpr_fn (tree t);
3495
3496 extern tree
3497 fold_non_dependent_init (tree, tsubst_flags_t = tf_warning_or_error,
3498 bool = false, tree = NULL_TREE);
3499 } // namespace Compile
3500
3501 } // namespace Rust
3502
3503 #endif // RUST_TREE