1/* Definitions for C++ parsing and type checking.
2 Copyright (C) 1987-2017 Free Software Foundation, Inc.
3 Contributed by Michael Tiemann (tiemann@cygnus.com)
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_CP_TREE_H
22#define GCC_CP_TREE_H
23
24#include "tm.h"
25#include "hard-reg-set.h"
26#include "function.h"
27
28/* In order for the format checking to accept the C++ front end
29 diagnostic framework extensions, you must include this file before
30 diagnostic-core.h, not after. We override the definition of GCC_DIAG_STYLE
31 in c-common.h. */
32#undef GCC_DIAG_STYLE
33#define GCC_DIAG_STYLE __gcc_cxxdiag__
34#if defined(GCC_DIAGNOSTIC_CORE_H) || defined (GCC_C_COMMON_H)
35#error \
36In order for the format checking to accept the C++ front end diagnostic \
37framework extensions, you must include this file before diagnostic-core.h and \
38c-common.h, not after.
39#endif
40#include "c-family/c-common.h"
41#include "diagnostic.h"
42
43/* A tree node, together with a location, so that we can track locations
44 (and ranges) during parsing.
45
46 The location is redundant for node kinds that have locations,
47 but not all node kinds do (e.g. constants, and references to
48 params, locals, etc), so we stash a copy here. */
49
50class cp_expr
51{
52public:
53 cp_expr () :
54 m_value (NULL), m_loc (UNKNOWN_LOCATION) {}
55
56 cp_expr (tree value) :
57 m_value (value), m_loc (EXPR_LOCATION (m_value)) {}
58
59 cp_expr (tree value, location_t loc):
60 m_value (value), m_loc (loc) {}
61
62 cp_expr (const cp_expr &other) :
63 m_value (other.m_value), m_loc (other.m_loc) {}
64
65 /* Implicit conversions to tree. */
66 operator tree () const { return m_value; }
67 tree & operator* () { return m_value; }
68 tree operator* () const { return m_value; }
69 tree & operator-> () { return m_value; }
70 tree operator-> () const { return m_value; }
71
72 tree get_value () const { return m_value; }
73 location_t get_location () const { return m_loc; }
74 location_t get_start () const
75 {
76 source_range src_range = get_range_from_loc (line_table, m_loc);
77 return src_range.m_start;
78 }
79 location_t get_finish () const
80 {
81 source_range src_range = get_range_from_loc (line_table, m_loc);
82 return src_range.m_finish;
83 }
84
85 void set_location (location_t loc)
86 {
87 protected_set_expr_location (m_value, loc);
88 m_loc = loc;
89 }
90
91 void set_range (location_t start, location_t finish)
92 {
93 set_location (make_location (m_loc, start, finish));
94 }
95
96 private:
97 tree m_value;
98 location_t m_loc;
99};
100
101inline bool
102operator == (const cp_expr &lhs, tree rhs)
103{
104 return lhs.get_value () == rhs;
105}
106
107
108enum cp_tree_index
109{
110 CPTI_WCHAR_DECL,
111 CPTI_VTABLE_ENTRY_TYPE,
112 CPTI_DELTA_TYPE,
113 CPTI_VTABLE_INDEX_TYPE,
114 CPTI_CLEANUP_TYPE,
115 CPTI_VTT_PARM_TYPE,
116
117 CPTI_CLASS_TYPE,
118 CPTI_UNKNOWN_TYPE,
119 CPTI_INIT_LIST_TYPE,
120 CPTI_VTBL_TYPE,
121 CPTI_VTBL_PTR_TYPE,
122 CPTI_STD,
123 CPTI_ABI,
124 CPTI_GLOBAL,
125 CPTI_GLOBAL_TYPE,
126 CPTI_CONST_TYPE_INFO_TYPE,
127 CPTI_TYPE_INFO_PTR_TYPE,
128 CPTI_ABORT_FNDECL,
129 CPTI_AGGR_TAG,
130 CPTI_CONV_OP_MARKER,
131
132 CPTI_CTOR_IDENTIFIER,
133 CPTI_COMPLETE_CTOR_IDENTIFIER,
134 CPTI_BASE_CTOR_IDENTIFIER,
135 CPTI_DTOR_IDENTIFIER,
136 CPTI_COMPLETE_DTOR_IDENTIFIER,
137 CPTI_BASE_DTOR_IDENTIFIER,
138 CPTI_DELETING_DTOR_IDENTIFIER,
139 CPTI_CONV_OP_IDENTIFIER,
140 CPTI_DELTA_IDENTIFIER,
141 CPTI_IN_CHARGE_IDENTIFIER,
142 CPTI_VTT_PARM_IDENTIFIER,
143 CPTI_THIS_IDENTIFIER,
144 CPTI_PFN_IDENTIFIER,
145 CPTI_VPTR_IDENTIFIER,
146 CPTI_GLOBAL_IDENTIFIER,
147 CPTI_STD_IDENTIFIER,
148 CPTI_ANON_IDENTIFIER,
149 CPTI_AUTO_IDENTIFIER,
150 CPTI_DECLTYPE_AUTO_IDENTIFIER,
151 CPTI_INIT_LIST_IDENTIFIER,
152
153 CPTI_LANG_NAME_C,
154 CPTI_LANG_NAME_CPLUSPLUS,
155
156 CPTI_EMPTY_EXCEPT_SPEC,
157 CPTI_NOEXCEPT_TRUE_SPEC,
158 CPTI_NOEXCEPT_FALSE_SPEC,
159 CPTI_NOEXCEPT_DEFERRED_SPEC,
160
161 CPTI_TERMINATE_FN,
162 CPTI_CALL_UNEXPECTED_FN,
163 CPTI_GET_EXCEPTION_PTR_FN,
164 CPTI_BEGIN_CATCH_FN,
165 CPTI_END_CATCH_FN,
166 CPTI_ALLOCATE_EXCEPTION_FN,
167 CPTI_FREE_EXCEPTION_FN,
168 CPTI_THROW_FN,
169 CPTI_RETHROW_FN,
170 CPTI_ATEXIT_FN_PTR_TYPE,
171 CPTI_ATEXIT,
172 CPTI_DSO_HANDLE,
173 CPTI_DCAST,
174
175 CPTI_NULLPTR,
176 CPTI_NULLPTR_TYPE,
177
178 CPTI_ALIGN_TYPE,
179
180 CPTI_ANY_TARG,
181
182 CPTI_MAX
183};
184
185extern GTY(()) tree cp_global_trees[CPTI_MAX];
186
187#define wchar_decl_node cp_global_trees[CPTI_WCHAR_DECL]
188#define vtable_entry_type cp_global_trees[CPTI_VTABLE_ENTRY_TYPE]
189/* The type used to represent an offset by which to adjust the `this'
190 pointer in pointer-to-member types. */
191#define delta_type_node cp_global_trees[CPTI_DELTA_TYPE]
192/* The type used to represent an index into the vtable. */
193#define vtable_index_type cp_global_trees[CPTI_VTABLE_INDEX_TYPE]
194
195#define class_type_node cp_global_trees[CPTI_CLASS_TYPE]
196#define unknown_type_node cp_global_trees[CPTI_UNKNOWN_TYPE]
197#define init_list_type_node cp_global_trees[CPTI_INIT_LIST_TYPE]
198#define vtbl_type_node cp_global_trees[CPTI_VTBL_TYPE]
199#define vtbl_ptr_type_node cp_global_trees[CPTI_VTBL_PTR_TYPE]
200#define std_node cp_global_trees[CPTI_STD]
201#define abi_node cp_global_trees[CPTI_ABI]
202#define global_namespace cp_global_trees[CPTI_GLOBAL]
203#define global_type_node cp_global_trees[CPTI_GLOBAL_TYPE]
204#define const_type_info_type_node cp_global_trees[CPTI_CONST_TYPE_INFO_TYPE]
205#define type_info_ptr_type cp_global_trees[CPTI_TYPE_INFO_PTR_TYPE]
206#define conv_op_marker cp_global_trees[CPTI_CONV_OP_MARKER]
207#define abort_fndecl cp_global_trees[CPTI_ABORT_FNDECL]
208#define current_aggr cp_global_trees[CPTI_AGGR_TAG]
209#define nullptr_node cp_global_trees[CPTI_NULLPTR]
210#define nullptr_type_node cp_global_trees[CPTI_NULLPTR_TYPE]
211/* std::align_val_t */
212#define align_type_node cp_global_trees[CPTI_ALIGN_TYPE]
213
214/* We cache these tree nodes so as to call get_identifier less frequently.
215 For identifiers for functions, including special member functions such
216 as ctors and assignment operators, the nodes can be used (among other
217 things) to iterate over their overloads defined by/for a type. For
218 example:
219
220 tree ovlid = assign_op_identifier;
221 tree overloads = get_class_binding (type, ovlid);
222 for (ovl_iterator it (overloads); it; ++it) { ... }
223
224 iterates over the set of implicitly and explicitly defined overloads
225 of the assignment operator for type (including the copy and move
226 assignment operators, whether deleted or not). */
227
228/* The name of a constructor that takes an in-charge parameter to
229 decide whether or not to construct virtual base classes. */
230#define ctor_identifier cp_global_trees[CPTI_CTOR_IDENTIFIER]
231/* The name of a constructor that constructs virtual base classes. */
232#define complete_ctor_identifier cp_global_trees[CPTI_COMPLETE_CTOR_IDENTIFIER]
233/* The name of a constructor that does not construct virtual base classes. */
234#define base_ctor_identifier cp_global_trees[CPTI_BASE_CTOR_IDENTIFIER]
235/* The name of a destructor that takes an in-charge parameter to
236 decide whether or not to destroy virtual base classes and whether
237 or not to delete the object. */
238#define dtor_identifier cp_global_trees[CPTI_DTOR_IDENTIFIER]
239/* The name of a destructor that destroys virtual base classes. */
240#define complete_dtor_identifier cp_global_trees[CPTI_COMPLETE_DTOR_IDENTIFIER]
241/* The name of a destructor that does not destroy virtual base
242 classes. */
243#define base_dtor_identifier cp_global_trees[CPTI_BASE_DTOR_IDENTIFIER]
244/* The name of a destructor that destroys virtual base classes, and
245 then deletes the entire object. */
246#define deleting_dtor_identifier cp_global_trees[CPTI_DELETING_DTOR_IDENTIFIER]
247
248#define ovl_op_identifier(ISASS, CODE) (OVL_OP_INFO(ISASS, CODE)->identifier)
249#define assign_op_identifier (ovl_op_info[true][OVL_OP_NOP_EXPR].identifier)
250#define call_op_identifier (ovl_op_info[false][OVL_OP_CALL_EXPR].identifier)
251/* The name used for conversion operators -- but note that actual
252 conversion functions use special identifiers outside the identifier
253 table. */
254#define conv_op_identifier cp_global_trees[CPTI_CONV_OP_IDENTIFIER]
255
256#define delta_identifier cp_global_trees[CPTI_DELTA_IDENTIFIER]
257#define in_charge_identifier cp_global_trees[CPTI_IN_CHARGE_IDENTIFIER]
258/* The name of the parameter that contains a pointer to the VTT to use
259 for this subobject constructor or destructor. */
260#define vtt_parm_identifier cp_global_trees[CPTI_VTT_PARM_IDENTIFIER]
261#define this_identifier cp_global_trees[CPTI_THIS_IDENTIFIER]
262#define pfn_identifier cp_global_trees[CPTI_PFN_IDENTIFIER]
263#define vptr_identifier cp_global_trees[CPTI_VPTR_IDENTIFIER]
264/* The name of the ::, std & anon namespaces. */
265#define global_identifier cp_global_trees[CPTI_GLOBAL_IDENTIFIER]
266#define std_identifier cp_global_trees[CPTI_STD_IDENTIFIER]
267#define anon_identifier cp_global_trees[CPTI_ANON_IDENTIFIER]
268/* auto and declspec(auto) identifiers. */
269#define auto_identifier cp_global_trees[CPTI_AUTO_IDENTIFIER]
270#define decltype_auto_identifier cp_global_trees[CPTI_DECLTYPE_AUTO_IDENTIFIER]
271#define init_list_identifier cp_global_trees[CPTI_INIT_LIST_IDENTIFIER]
272#define lang_name_c cp_global_trees[CPTI_LANG_NAME_C]
273#define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS]
274
275/* Exception specifiers used for throw(), noexcept(true),
276 noexcept(false) and deferred noexcept. We rely on these being
277 uncloned. */
278#define empty_except_spec cp_global_trees[CPTI_EMPTY_EXCEPT_SPEC]
279#define noexcept_true_spec cp_global_trees[CPTI_NOEXCEPT_TRUE_SPEC]
280#define noexcept_false_spec cp_global_trees[CPTI_NOEXCEPT_FALSE_SPEC]
281#define noexcept_deferred_spec cp_global_trees[CPTI_NOEXCEPT_DEFERRED_SPEC]
282
283/* Exception handling function declarations. */
284#define terminate_fn cp_global_trees[CPTI_TERMINATE_FN]
285#define call_unexpected_fn cp_global_trees[CPTI_CALL_UNEXPECTED_FN]
286#define get_exception_ptr_fn cp_global_trees[CPTI_GET_EXCEPTION_PTR_FN]
287#define begin_catch_fn cp_global_trees[CPTI_BEGIN_CATCH_FN]
288#define end_catch_fn cp_global_trees[CPTI_END_CATCH_FN]
289#define allocate_exception_fn cp_global_trees[CPTI_ALLOCATE_EXCEPTION_FN]
290#define free_exception_fn cp_global_trees[CPTI_FREE_EXCEPTION_FN]
291#define throw_fn cp_global_trees[CPTI_THROW_FN]
292#define rethrow_fn cp_global_trees[CPTI_RETHROW_FN]
293
294/* The type of the function-pointer argument to "__cxa_atexit" (or
295 "std::atexit", if "__cxa_atexit" is not being used). */
296#define atexit_fn_ptr_type_node cp_global_trees[CPTI_ATEXIT_FN_PTR_TYPE]
297
298/* A pointer to `std::atexit'. */
299#define atexit_node cp_global_trees[CPTI_ATEXIT]
300
301/* A pointer to `__dso_handle'. */
302#define dso_handle_node cp_global_trees[CPTI_DSO_HANDLE]
303
304/* The declaration of the dynamic_cast runtime. */
305#define dynamic_cast_node cp_global_trees[CPTI_DCAST]
306
307/* The type of a destructor. */
308#define cleanup_type cp_global_trees[CPTI_CLEANUP_TYPE]
309
310/* The type of the vtt parameter passed to subobject constructors and
311 destructors. */
312#define vtt_parm_type cp_global_trees[CPTI_VTT_PARM_TYPE]
313
314/* A node which matches any template argument. */
315#define any_targ_node cp_global_trees[CPTI_ANY_TARG]
316
317/* Node to indicate default access. This must be distinct from the
318 access nodes in tree.h. */
319
320#define access_default_node null_node
321
322
323#include "name-lookup.h"
324
325/* Usage of TREE_LANG_FLAG_?:
326 0: IDENTIFIER_KIND_BIT_0 (in IDENTIFIER_NODE)
327 NEW_EXPR_USE_GLOBAL (in NEW_EXPR).
328 COND_EXPR_IS_VEC_DELETE (in COND_EXPR).
329 DELETE_EXPR_USE_GLOBAL (in DELETE_EXPR).
330 COMPOUND_EXPR_OVERLOADED (in COMPOUND_EXPR).
331 CLEANUP_P (in TRY_BLOCK)
332 AGGR_INIT_VIA_CTOR_P (in AGGR_INIT_EXPR)
333 PTRMEM_OK_P (in ADDR_EXPR, OFFSET_REF, SCOPE_REF)
334 PAREN_STRING_LITERAL (in STRING_CST)
335 CP_DECL_THREAD_LOCAL_P (in VAR_DECL)
336 KOENIG_LOOKUP_P (in CALL_EXPR)
337 STATEMENT_LIST_NO_SCOPE (in STATEMENT_LIST).
338 EXPR_STMT_STMT_EXPR_RESULT (in EXPR_STMT)
339 STMT_EXPR_NO_SCOPE (in STMT_EXPR)
340 BIND_EXPR_TRY_BLOCK (in BIND_EXPR)
341 TYPENAME_IS_ENUM_P (in TYPENAME_TYPE)
342 OMP_FOR_GIMPLIFYING_P (in OMP_FOR, OMP_SIMD, OMP_DISTRIBUTE,
343 and OMP_TASKLOOP)
344 BASELINK_QUALIFIED_P (in BASELINK)
345 TARGET_EXPR_IMPLICIT_P (in TARGET_EXPR)
346 TEMPLATE_PARM_PARAMETER_PACK (in TEMPLATE_PARM_INDEX)
347 ATTR_IS_DEPENDENT (in the TREE_LIST for an attribute)
348 ABI_TAG_IMPLICIT (in the TREE_LIST for the argument of abi_tag)
349 CONSTRUCTOR_IS_DIRECT_INIT (in CONSTRUCTOR)
350 LAMBDA_EXPR_CAPTURES_THIS_P (in LAMBDA_EXPR)
351 DECLTYPE_FOR_LAMBDA_CAPTURE (in DECLTYPE_TYPE)
352 VEC_INIT_EXPR_IS_CONSTEXPR (in VEC_INIT_EXPR)
353 DECL_OVERRIDE_P (in FUNCTION_DECL)
354 IMPLICIT_CONV_EXPR_DIRECT_INIT (in IMPLICIT_CONV_EXPR)
355 TRANSACTION_EXPR_IS_STMT (in TRANSACTION_EXPR)
356 CONVERT_EXPR_VBASE_PATH (in CONVERT_EXPR)
357 PACK_EXPANSION_LOCAL_P (in *_PACK_EXPANSION)
358 TINFO_HAS_ACCESS_ERRORS (in TEMPLATE_INFO)
359 SIZEOF_EXPR_TYPE_P (in SIZEOF_EXPR)
360 COMPOUND_REQ_NOEXCEPT_P (in COMPOUND_REQ)
361 WILDCARD_PACK_P (in WILDCARD_DECL)
362 BLOCK_OUTER_CURLY_BRACE_P (in BLOCK)
363 FOLD_EXPR_MODOP_P (*_FOLD_EXPR)
364 IF_STMT_CONSTEXPR_P (IF_STMT)
365 TEMPLATE_TYPE_PARM_FOR_CLASS (TEMPLATE_TYPE_PARM)
366 DECL_NAMESPACE_INLINE_P (in NAMESPACE_DECL)
367 SWITCH_STMT_ALL_CASES_P (in SWITCH_STMT)
368 1: IDENTIFIER_KIND_BIT_1 (in IDENTIFIER_NODE)
369 TI_PENDING_TEMPLATE_FLAG.
370 TEMPLATE_PARMS_FOR_INLINE.
371 DELETE_EXPR_USE_VEC (in DELETE_EXPR).
372 (TREE_CALLS_NEW) (in _EXPR or _REF) (commented-out).
373 ICS_ELLIPSIS_FLAG (in _CONV)
374 DECL_INITIALIZED_P (in VAR_DECL)
375 TYPENAME_IS_CLASS_P (in TYPENAME_TYPE)
376 STMT_IS_FULL_EXPR_P (in _STMT)
377 TARGET_EXPR_LIST_INIT_P (in TARGET_EXPR)
378 LAMBDA_EXPR_MUTABLE_P (in LAMBDA_EXPR)
379 DECL_FINAL_P (in FUNCTION_DECL)
380 QUALIFIED_NAME_IS_TEMPLATE (in SCOPE_REF)
381 DECLTYPE_FOR_INIT_CAPTURE (in DECLTYPE_TYPE)
382 CONSTRUCTOR_NO_IMPLICIT_ZERO (in CONSTRUCTOR)
383 TINFO_USED_TEMPLATE_ID (in TEMPLATE_INFO)
384 PACK_EXPANSION_SIZEOF_P (in *_PACK_EXPANSION)
385 OVL_USING_P (in OVERLOAD)
386 IMPLICIT_CONV_EXPR_NONTYPE_ARG (in IMPLICIT_CONV_EXPR)
387 2: IDENTIFIER_KIND_BIT_2 (in IDENTIFIER_NODE)
388 ICS_THIS_FLAG (in _CONV)
389 DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (in VAR_DECL)
390 STATEMENT_LIST_TRY_BLOCK (in STATEMENT_LIST)
391 TYPENAME_IS_RESOLVING_P (in TYPE_NAME_TYPE)
392 TARGET_EXPR_DIRECT_INIT_P (in TARGET_EXPR)
393 FNDECL_USED_AUTO (in FUNCTION_DECL)
394 DECLTYPE_FOR_LAMBDA_PROXY (in DECLTYPE_TYPE)
395 REF_PARENTHESIZED_P (in COMPONENT_REF, INDIRECT_REF, SCOPE_REF)
396 AGGR_INIT_ZERO_FIRST (in AGGR_INIT_EXPR)
397 CONSTRUCTOR_MUTABLE_POISON (in CONSTRUCTOR)
398 OVL_HIDDEN_P (in OVERLOAD)
399 SWITCH_STMT_NO_BREAK_P (in SWITCH_STMT)
400 3: (TREE_REFERENCE_EXPR) (in NON_LVALUE_EXPR) (commented-out).
401 ICS_BAD_FLAG (in _CONV)
402 FN_TRY_BLOCK_P (in TRY_BLOCK)
403 BIND_EXPR_BODY_BLOCK (in BIND_EXPR)
404 DECL_NON_TRIVIALLY_INITIALIZED_P (in VAR_DECL)
405 CALL_EXPR_ORDERED_ARGS (in CALL_EXPR, AGGR_INIT_EXPR)
406 DECLTYPE_FOR_REF_CAPTURE (in DECLTYPE_TYPE)
407 CONSTUCTOR_C99_COMPOUND_LITERAL (in CONSTRUCTOR)
408 OVL_NESTED_P (in OVERLOAD)
409 4: IDENTIFIER_MARKED (IDENTIFIER_NODEs)
410 TREE_HAS_CONSTRUCTOR (in INDIRECT_REF, SAVE_EXPR, CONSTRUCTOR,
411 CALL_EXPR, or FIELD_DECL).
412 DECL_TINFO_P (in VAR_DECL)
413 FUNCTION_REF_QUALIFIED (in FUNCTION_TYPE, METHOD_TYPE)
414 OVL_LOOKUP_P (in OVERLOAD)
415 LOOKUP_FOUND_P (in RECORD_TYPE, UNION_TYPE, NAMESPACE_DECL)
416 5: IDENTIFIER_VIRTUAL_P (in IDENTIFIER_NODE)
417 DECL_VTABLE_OR_VTT_P (in VAR_DECL)
418 FUNCTION_RVALUE_QUALIFIED (in FUNCTION_TYPE, METHOD_TYPE)
419 CALL_EXPR_REVERSE_ARGS (in CALL_EXPR, AGGR_INIT_EXPR)
420 6: IDENTIFIER_REPO_CHOSEN (in IDENTIFIER_NODE)
421 DECL_CONSTRUCTION_VTABLE_P (in VAR_DECL)
422 TYPE_MARKED_P (in _TYPE)
423 RANGE_FOR_IVDEP (in RANGE_FOR_STMT)
424 CALL_EXPR_OPERATOR_SYNTAX (in CALL_EXPR, AGGR_INIT_EXPR)
425
426 Usage of TYPE_LANG_FLAG_?:
427 0: TYPE_DEPENDENT_P
428 1: TYPE_HAS_USER_CONSTRUCTOR.
429 2: TYPE_HAS_LATE_RETURN_TYPE (in FUNCTION_TYPE, METHOD_TYPE)
430 TYPE_PTRMEMFUNC_FLAG (in RECORD_TYPE)
431 4: TYPE_HAS_NONTRIVIAL_DESTRUCTOR
432 5: CLASS_TYPE_P (in RECORD_TYPE and UNION_TYPE)
433 ENUM_FIXED_UNDERLYING_TYPE_P (in ENUMERAL_TYPE)
434 AUTO_IS_DECLTYPE (in TEMPLATE_TYPE_PARM)
435 REFERENCE_VLA_OK (in REFERENCE_TYPE)
436 6: TYPE_DEPENDENT_P_VALID
437
438 Usage of DECL_LANG_FLAG_?:
439 0: DECL_ERROR_REPORTED (in VAR_DECL).
440 DECL_TEMPLATE_PARM_P (in PARM_DECL, CONST_DECL, TYPE_DECL, or TEMPLATE_DECL)
441 DECL_LOCAL_FUNCTION_P (in FUNCTION_DECL)
442 DECL_MUTABLE_P (in FIELD_DECL)
443 DECL_DEPENDENT_P (in USING_DECL)
444 LABEL_DECL_BREAK (in LABEL_DECL)
445 1: C_TYPEDEF_EXPLICITLY_SIGNED (in TYPE_DECL).
446 DECL_TEMPLATE_INSTANTIATED (in a VAR_DECL or a FUNCTION_DECL)
447 DECL_MEMBER_TEMPLATE_P (in TEMPLATE_DECL)
448 USING_DECL_TYPENAME_P (in USING_DECL)
449 DECL_VLA_CAPTURE_P (in FIELD_DECL)
450 DECL_ARRAY_PARAMETER_P (in PARM_DECL)
451 LABEL_DECL_CONTINUE (in LABEL_DECL)
452 2: DECL_THIS_EXTERN (in VAR_DECL or FUNCTION_DECL).
453 DECL_IMPLICIT_TYPEDEF_P (in a TYPE_DECL)
454 DECL_CONSTRAINT_VAR_P (in a PARM_DECL)
455 TEMPLATE_DECL_COMPLEX_ALIAS_P (in TEMPLATE_DECL)
456 DECL_INSTANTIATING_NSDMI_P (in a FIELD_DECL)
457 LABEL_DECL_CDTOR (in LABEL_DECL)
458 3: DECL_IN_AGGR_P.
459 4: DECL_C_BIT_FIELD (in a FIELD_DECL)
460 DECL_ANON_UNION_VAR_P (in a VAR_DECL)
461 DECL_SELF_REFERENCE_P (in a TYPE_DECL)
462 DECL_INVALID_OVERRIDER_P (in a FUNCTION_DECL)
463 5: DECL_INTERFACE_KNOWN.
464 6: DECL_THIS_STATIC (in VAR_DECL or FUNCTION_DECL).
465 DECL_FIELD_IS_BASE (in FIELD_DECL)
466 TYPE_DECL_ALIAS_P (in TYPE_DECL)
467 7: DECL_DEAD_FOR_LOCAL (in VAR_DECL).
468 DECL_THUNK_P (in a member FUNCTION_DECL)
469 DECL_NORMAL_CAPTURE_P (in FIELD_DECL)
470 8: DECL_DECLARED_CONSTEXPR_P (in VAR_DECL, FUNCTION_DECL)
471
472 Usage of language-independent fields in a language-dependent manner:
473
474 TYPE_ALIAS_SET
475 This field is used by TYPENAME_TYPEs, TEMPLATE_TYPE_PARMs, and so
476 forth as a substitute for the mark bits provided in `lang_type'.
477 At present, only the six low-order bits are used.
478
479 TYPE_LANG_SLOT_1
480 For a FUNCTION_TYPE or METHOD_TYPE, this is TYPE_RAISES_EXCEPTIONS.
481 For a POINTER_TYPE (to a METHOD_TYPE), this is TYPE_PTRMEMFUNC_TYPE.
482 For an ENUMERAL_TYPE, BOUND_TEMPLATE_TEMPLATE_PARM_TYPE,
483 RECORD_TYPE or UNION_TYPE this is TYPE_TEMPLATE_INFO,
484
485 BINFO_VIRTUALS
486 For a binfo, this is a TREE_LIST. There is an entry for each
487 virtual function declared either in BINFO or its direct and
488 indirect primary bases.
489
490 The BV_DELTA of each node gives the amount by which to adjust the
491 `this' pointer when calling the function. If the method is an
492 overridden version of a base class method, then it is assumed
493 that, prior to adjustment, the this pointer points to an object
494 of the base class.
495
496 The BV_VCALL_INDEX of each node, if non-NULL, gives the vtable
497 index of the vcall offset for this entry.
498
499 The BV_FN is the declaration for the virtual function itself.
500
501 If BV_LOST_PRIMARY is set, it means that this entry is for a lost
502 primary virtual base and can be left null in the vtable.
503
504 BINFO_VTABLE
505 This is an expression with POINTER_TYPE that gives the value
506 to which the vptr should be initialized. Use get_vtbl_decl_for_binfo
507 to extract the VAR_DECL for the complete vtable.
508
509 DECL_VINDEX
510 This field is NULL for a non-virtual function. For a virtual
511 function, it is eventually set to an INTEGER_CST indicating the
512 index in the vtable at which this function can be found. When
513 a virtual function is declared, but before it is known what
514 function is overridden, this field is the error_mark_node.
515
516 Temporarily, it may be set to a TREE_LIST whose TREE_VALUE is
517 the virtual function this one overrides, and whose TREE_CHAIN is
518 the old DECL_VINDEX. */
519
520/* Language-specific tree checkers. */
521
522#define VAR_OR_FUNCTION_DECL_CHECK(NODE) \
523 TREE_CHECK2(NODE,VAR_DECL,FUNCTION_DECL)
524
525#define TYPE_FUNCTION_OR_TEMPLATE_DECL_CHECK(NODE) \
526 TREE_CHECK3(NODE,TYPE_DECL,TEMPLATE_DECL,FUNCTION_DECL)
527
528#define TYPE_FUNCTION_OR_TEMPLATE_DECL_P(NODE) \
529 (TREE_CODE (NODE) == TYPE_DECL || TREE_CODE (NODE) == TEMPLATE_DECL \
530 || TREE_CODE (NODE) == FUNCTION_DECL)
531
532#define VAR_FUNCTION_OR_PARM_DECL_CHECK(NODE) \
533 TREE_CHECK3(NODE,VAR_DECL,FUNCTION_DECL,PARM_DECL)
534
535#define VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK(NODE) \
536 TREE_CHECK4(NODE,VAR_DECL,FUNCTION_DECL,TYPE_DECL,TEMPLATE_DECL)
537
538#define VAR_TEMPL_TYPE_FIELD_OR_FUNCTION_DECL_CHECK(NODE) \
539 TREE_CHECK5(NODE,VAR_DECL,FIELD_DECL,FUNCTION_DECL,TYPE_DECL,TEMPLATE_DECL)
540
541#define BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK(NODE) \
542 TREE_CHECK(NODE,BOUND_TEMPLATE_TEMPLATE_PARM)
543
544#if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
545#define THUNK_FUNCTION_CHECK(NODE) __extension__ \
546({ __typeof (NODE) const __t = (NODE); \
547 if (TREE_CODE (__t) != FUNCTION_DECL || !__t->decl_common.lang_specific \
548 || !__t->decl_common.lang_specific->u.fn.thunk_p) \
549 tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, 0); \
550 __t; })
551#else
552#define THUNK_FUNCTION_CHECK(NODE) (NODE)
553#endif
554
555/* Language-dependent contents of an identifier. */
556
557struct GTY(()) lang_identifier {
558 struct c_common_identifier c_common;
559 cxx_binding *bindings;
560};
561
562/* Return a typed pointer version of T if it designates a
563 C++ front-end identifier. */
564inline lang_identifier*
565identifier_p (tree t)
566{
567 if (TREE_CODE (t) == IDENTIFIER_NODE)
568 return (lang_identifier*) t;
569 return NULL;
570}
571
572#define LANG_IDENTIFIER_CAST(NODE) \
573 ((struct lang_identifier*)IDENTIFIER_NODE_CHECK (NODE))
574
575struct GTY(()) template_parm_index {
576 struct tree_common common;
577 int index;
578 int level;
579 int orig_level;
580 tree decl;
581};
582
583struct GTY(()) ptrmem_cst {
584 struct tree_common common;
585 tree member;
586};
587typedef struct ptrmem_cst * ptrmem_cst_t;
588
589#define CLEANUP_P(NODE) TREE_LANG_FLAG_0 (TRY_BLOCK_CHECK (NODE))
590
591#define BIND_EXPR_TRY_BLOCK(NODE) \
592 TREE_LANG_FLAG_0 (BIND_EXPR_CHECK (NODE))
593
594/* Used to mark the block around the member initializers and cleanups. */
595#define BIND_EXPR_BODY_BLOCK(NODE) \
596 TREE_LANG_FLAG_3 (BIND_EXPR_CHECK (NODE))
597#define FUNCTION_NEEDS_BODY_BLOCK(NODE) \
598 (DECL_CONSTRUCTOR_P (NODE) || DECL_DESTRUCTOR_P (NODE) \
599 || LAMBDA_FUNCTION_P (NODE))
600
601#define STATEMENT_LIST_NO_SCOPE(NODE) \
602 TREE_LANG_FLAG_0 (STATEMENT_LIST_CHECK (NODE))
603#define STATEMENT_LIST_TRY_BLOCK(NODE) \
604 TREE_LANG_FLAG_2 (STATEMENT_LIST_CHECK (NODE))
605
606/* Mark the outer curly brace BLOCK. */
607#define BLOCK_OUTER_CURLY_BRACE_P(NODE) TREE_LANG_FLAG_0 (BLOCK_CHECK (NODE))
608
609/* Nonzero if this statement should be considered a full-expression,
610 i.e., if temporaries created during this statement should have
611 their destructors run at the end of this statement. */
612#define STMT_IS_FULL_EXPR_P(NODE) TREE_LANG_FLAG_1 ((NODE))
613
614/* Marks the result of a statement expression. */
615#define EXPR_STMT_STMT_EXPR_RESULT(NODE) \
616 TREE_LANG_FLAG_0 (EXPR_STMT_CHECK (NODE))
617
618/* Nonzero if this statement-expression does not have an associated scope. */
619#define STMT_EXPR_NO_SCOPE(NODE) \
620 TREE_LANG_FLAG_0 (STMT_EXPR_CHECK (NODE))
621
622#define COND_EXPR_IS_VEC_DELETE(NODE) \
623 TREE_LANG_FLAG_0 (COND_EXPR_CHECK (NODE))
624
625/* Returns nonzero iff TYPE1 and TYPE2 are the same type, in the usual
626 sense of `same'. */
627#define same_type_p(TYPE1, TYPE2) \
628 comptypes ((TYPE1), (TYPE2), COMPARE_STRICT)
629
630/* Returns nonzero iff NODE is a declaration for the global function
631 `main'. */
632#define DECL_MAIN_P(NODE) \
633 (DECL_EXTERN_C_FUNCTION_P (NODE) \
634 && DECL_NAME (NODE) != NULL_TREE \
635 && MAIN_NAME_P (DECL_NAME (NODE)) \
636 && flag_hosted)
637
638/* Lookup walker marking. */
639#define LOOKUP_SEEN_P(NODE) TREE_VISITED(NODE)
640#define LOOKUP_FOUND_P(NODE) \
641 TREE_LANG_FLAG_4 (TREE_CHECK3(NODE,RECORD_TYPE,UNION_TYPE,NAMESPACE_DECL))
642
643/* These two accessors should only be used by OVL manipulators.
644 Other users should use iterators and convenience functions. */
645#define OVL_FUNCTION(NODE) \
646 (((struct tree_overload*)OVERLOAD_CHECK (NODE))->function)
647#define OVL_CHAIN(NODE) \
648 (((struct tree_overload*)OVERLOAD_CHECK (NODE))->common.chain)
649
650/* If set, this was imported in a using declaration. */
651#define OVL_USING_P(NODE) TREE_LANG_FLAG_1 (OVERLOAD_CHECK (NODE))
652/* If set, this overload is a hidden decl. */
653#define OVL_HIDDEN_P(NODE) TREE_LANG_FLAG_2 (OVERLOAD_CHECK (NODE))
654/* If set, this overload contains a nested overload. */
655#define OVL_NESTED_P(NODE) TREE_LANG_FLAG_3 (OVERLOAD_CHECK (NODE))
656/* If set, this overload was constructed during lookup. */
657#define OVL_LOOKUP_P(NODE) TREE_LANG_FLAG_4 (OVERLOAD_CHECK (NODE))
658/* If set, this is a persistant lookup. */
659#define OVL_USED_P(NODE) TREE_USED (OVERLOAD_CHECK (NODE))
660
661/* The first decl of an overload. */
662#define OVL_FIRST(NODE) ovl_first (NODE)
663/* The name of the overload set. */
664#define OVL_NAME(NODE) DECL_NAME (OVL_FIRST (NODE))
665
666/* Whether this is a set of overloaded functions. TEMPLATE_DECLS are
667 always wrapped in an OVERLOAD, so we don't need to check them
668 here. */
669#define OVL_P(NODE) \
670 (TREE_CODE (NODE) == FUNCTION_DECL || TREE_CODE (NODE) == OVERLOAD)
671/* Whether this is a single member overload. */
672#define OVL_SINGLE_P(NODE) \
673 (TREE_CODE (NODE) != OVERLOAD || !OVL_CHAIN (NODE))
674
675/* OVL_HIDDEN_P nodes come first, then OVL_USING_P nodes, then regular
676 fns. */
677
678struct GTY(()) tree_overload {
679 struct tree_common common;
680 tree function;
681};
682
683/* Iterator for a 1 dimensional overload. Permits iterating over the
684 outer level of a 2-d overload when explicitly enabled. */
685
686class ovl_iterator
687{
688 tree ovl;
689 const bool allow_inner; /* Only used when checking. */
690
691 public:
692 explicit ovl_iterator (tree o, bool allow = false)
693 : ovl (o), allow_inner (allow)
694 {
695 }
696
697 private:
698 /* Do not duplicate. */
699 ovl_iterator &operator= (const ovl_iterator &);
700 ovl_iterator (const ovl_iterator &);
701
702 public:
703 operator bool () const
704 {
705 return ovl;
706 }
707 ovl_iterator &operator++ ()
708 {
709 ovl = TREE_CODE (ovl) != OVERLOAD ? NULL_TREE : OVL_CHAIN (ovl);
710 return *this;
711 }
712 tree operator* () const
713 {
714 tree fn = TREE_CODE (ovl) != OVERLOAD ? ovl : OVL_FUNCTION (ovl);
715
716 /* Check this is not an unexpected 2-dimensional overload. */
717 gcc_checking_assert (allow_inner || TREE_CODE (fn) != OVERLOAD);
718
719 return fn;
720 }
721
722 public:
723 /* Whether this overload was introduced by a using decl. */
724 bool using_p () const
725 {
726 return TREE_CODE (ovl) == OVERLOAD && OVL_USING_P (ovl);
727 }
728 bool hidden_p () const
729 {
730 return TREE_CODE (ovl) == OVERLOAD && OVL_HIDDEN_P (ovl);
731 }
732
733 public:
734 tree remove_node (tree head)
735 {
736 return remove_node (head, ovl);
737 }
738 tree reveal_node (tree head)
739 {
740 return reveal_node (head, ovl);
741 }
742
743 protected:
744 /* If we have a nested overload, point at the inner overload and
745 return the next link on the outer one. */
746 tree maybe_push ()
747 {
748 tree r = NULL_TREE;
749
750 if (ovl && TREE_CODE (ovl) == OVERLOAD && OVL_NESTED_P (ovl))
751 {
752 r = OVL_CHAIN (ovl);
753 ovl = OVL_FUNCTION (ovl);
754 }
755 return r;
756 }
757 /* Restore an outer nested overload. */
758 void pop (tree outer)
759 {
760 gcc_checking_assert (!ovl);
761 ovl = outer;
762 }
763
764 private:
765 /* We make these static functions to avoid the address of the
766 iterator escaping the local context. */
767 static tree remove_node (tree head, tree node);
768 static tree reveal_node (tree ovl, tree node);
769};
770
771/* Iterator over a (potentially) 2 dimensional overload, which is
772 produced by name lookup. */
773
774class lkp_iterator : public ovl_iterator
775{
776 typedef ovl_iterator parent;
777
778 tree outer;
779
780 public:
781 explicit lkp_iterator (tree o)
782 : parent (o, true), outer (maybe_push ())
783 {
784 }
785
786 public:
787 lkp_iterator &operator++ ()
788 {
789 bool repush = !outer;
790
791 if (!parent::operator++ () && !repush)
792 {
793 pop (outer);
794 repush = true;
795 }
796
797 if (repush)
798 outer = maybe_push ();
799
800 return *this;
801 }
802};
803
804/* hash traits for declarations. Hashes potential overload sets via
805 DECL_NAME. */
806
807struct named_decl_hash : ggc_remove <tree>
808{
809 typedef tree value_type; /* A DECL or OVERLOAD */
810 typedef tree compare_type; /* An identifier. */
811
812 inline static hashval_t hash (const value_type decl);
813 inline static bool equal (const value_type existing, compare_type candidate);
814
815 static inline void mark_empty (value_type &p) {p = NULL_TREE;}
816 static inline bool is_empty (value_type p) {return !p;}
817
818 /* Nothing is deletable. Everything is insertable. */
819 static bool is_deleted (value_type) { return false; }
820 static void mark_deleted (value_type) { gcc_unreachable (); }
821};
822
823struct GTY(()) tree_template_decl {
824 struct tree_decl_common common;
825 tree arguments;
826 tree result;
827};
828
829/* Returns true iff NODE is a BASELINK. */
830#define BASELINK_P(NODE) \
831 (TREE_CODE (NODE) == BASELINK)
832/* The BINFO indicating the base in which lookup found the
833 BASELINK_FUNCTIONS. */
834#define BASELINK_BINFO(NODE) \
835 (((struct tree_baselink*) BASELINK_CHECK (NODE))->binfo)
836/* The functions referred to by the BASELINK; either a FUNCTION_DECL,
837 a TEMPLATE_DECL, an OVERLOAD, or a TEMPLATE_ID_EXPR. */
838#define BASELINK_FUNCTIONS(NODE) \
839 (((struct tree_baselink*) BASELINK_CHECK (NODE))->functions)
840/* If T is a BASELINK, grab the functions, otherwise just T, which is
841 expected to already be a (list of) functions. */
842#define MAYBE_BASELINK_FUNCTIONS(T) \
843 (BASELINK_P (T) ? BASELINK_FUNCTIONS (T) : T)
844/* The BINFO in which the search for the functions indicated by this baselink
845 began. This base is used to determine the accessibility of functions
846 selected by overload resolution. */
847#define BASELINK_ACCESS_BINFO(NODE) \
848 (((struct tree_baselink*) BASELINK_CHECK (NODE))->access_binfo)
849/* For a type-conversion operator, the BASELINK_OPTYPE indicates the type
850 to which the conversion should occur. This value is important if
851 the BASELINK_FUNCTIONS include a template conversion operator --
852 the BASELINK_OPTYPE can be used to determine what type the user
853 requested. */
854#define BASELINK_OPTYPE(NODE) \
855 (TREE_CHAIN (BASELINK_CHECK (NODE)))
856/* Nonzero if this baselink was from a qualified lookup. */
857#define BASELINK_QUALIFIED_P(NODE) \
858 TREE_LANG_FLAG_0 (BASELINK_CHECK (NODE))
859
860struct GTY(()) tree_baselink {
861 struct tree_common common;
862 tree binfo;
863 tree functions;
864 tree access_binfo;
865};
866
867/* The different kinds of ids that we encounter. */
868
869enum cp_id_kind
870{
871 /* Not an id at all. */
872 CP_ID_KIND_NONE,
873 /* An unqualified-id that is not a template-id. */
874 CP_ID_KIND_UNQUALIFIED,
875 /* An unqualified-id that is a dependent name. */
876 CP_ID_KIND_UNQUALIFIED_DEPENDENT,
877 /* An unqualified template-id. */
878 CP_ID_KIND_TEMPLATE_ID,
879 /* A qualified-id. */
880 CP_ID_KIND_QUALIFIED
881};
882
883
884/* The various kinds of C++0x warnings we encounter. */
885
886enum cpp0x_warn_str
887{
888 /* extended initializer lists */
889 CPP0X_INITIALIZER_LISTS,
890 /* explicit conversion operators */
891 CPP0X_EXPLICIT_CONVERSION,
892 /* variadic templates */
893 CPP0X_VARIADIC_TEMPLATES,
894 /* lambda expressions */
895 CPP0X_LAMBDA_EXPR,
896 /* C++0x auto */
897 CPP0X_AUTO,
898 /* scoped enums */
899 CPP0X_SCOPED_ENUMS,
900 /* defaulted and deleted functions */
901 CPP0X_DEFAULTED_DELETED,
902 /* inline namespaces */
903 CPP0X_INLINE_NAMESPACES,
904 /* override controls, override/final */
905 CPP0X_OVERRIDE_CONTROLS,
906 /* non-static data member initializers */
907 CPP0X_NSDMI,
908 /* user defined literals */
909 CPP0X_USER_DEFINED_LITERALS,
910 /* delegating constructors */
911 CPP0X_DELEGATING_CTORS,
912 /* inheriting constructors */
913 CPP0X_INHERITING_CTORS,
914 /* C++11 attributes */
915 CPP0X_ATTRIBUTES,
916 /* ref-qualified member functions */
917 CPP0X_REF_QUALIFIER
918};
919
920/* The various kinds of operation used by composite_pointer_type. */
921
922enum composite_pointer_operation
923{
924 /* comparison */
925 CPO_COMPARISON,
926 /* conversion */
927 CPO_CONVERSION,
928 /* conditional expression */
929 CPO_CONDITIONAL_EXPR
930};
931
932/* Possible cases of expression list used by build_x_compound_expr_from_list. */
933enum expr_list_kind {
934 ELK_INIT, /* initializer */
935 ELK_MEM_INIT, /* member initializer */
936 ELK_FUNC_CAST /* functional cast */
937};
938
939/* Possible cases of implicit bad rhs conversions. */
940enum impl_conv_rhs {
941 ICR_DEFAULT_ARGUMENT, /* default argument */
942 ICR_CONVERTING, /* converting */
943 ICR_INIT, /* initialization */
944 ICR_ARGPASS, /* argument passing */
945 ICR_RETURN, /* return */
946 ICR_ASSIGN /* assignment */
947};
948
949/* Possible cases of implicit or explicit bad conversions to void. */
950enum impl_conv_void {
951 ICV_CAST, /* (explicit) conversion to void */
952 ICV_SECOND_OF_COND, /* second operand of conditional expression */
953 ICV_THIRD_OF_COND, /* third operand of conditional expression */
954 ICV_RIGHT_OF_COMMA, /* right operand of comma operator */
955 ICV_LEFT_OF_COMMA, /* left operand of comma operator */
956 ICV_STATEMENT, /* statement */
957 ICV_THIRD_IN_FOR /* for increment expression */
958};
959
960/* Possible invalid uses of an abstract class that might not have a
961 specific associated declaration. */
962enum GTY(()) abstract_class_use {
963 ACU_UNKNOWN, /* unknown or decl provided */
964 ACU_CAST, /* cast to abstract class */
965 ACU_NEW, /* new-expression of abstract class */
966 ACU_THROW, /* throw-expression of abstract class */
967 ACU_CATCH, /* catch-parameter of abstract class */
968 ACU_ARRAY, /* array of abstract class */
969 ACU_RETURN, /* return type of abstract class */
970 ACU_PARM /* parameter type of abstract class */
971};
972
973/* Macros for access to language-specific slots in an identifier. */
974
975/* The IDENTIFIER_BINDING is the innermost cxx_binding for the
976 identifier. Its PREVIOUS is the next outermost binding. Each
977 VALUE field is a DECL for the associated declaration. Thus,
978 name lookup consists simply of pulling off the node at the front
979 of the list (modulo oddities for looking up the names of types,
980 and such.) You can use SCOPE field to determine the scope
981 that bound the name. */
982#define IDENTIFIER_BINDING(NODE) \
983 (LANG_IDENTIFIER_CAST (NODE)->bindings)
984
985/* TREE_TYPE only indicates on local and class scope the current
986 type. For namespace scope, the presence of a type in any namespace
987 is indicated with global_type_node, and the real type behind must
988 be found through lookup. */
989#define IDENTIFIER_TYPE_VALUE(NODE) identifier_type_value (NODE)
990#define REAL_IDENTIFIER_TYPE_VALUE(NODE) TREE_TYPE (NODE)
991#define SET_IDENTIFIER_TYPE_VALUE(NODE,TYPE) (TREE_TYPE (NODE) = (TYPE))
992#define IDENTIFIER_HAS_TYPE_VALUE(NODE) (IDENTIFIER_TYPE_VALUE (NODE) ? 1 : 0)
993
994/* Kinds of identifiers. Values are carefully chosen. */
995enum cp_identifier_kind {
996 cik_normal = 0, /* Not a special identifier. */
997 cik_keyword = 1, /* A keyword. */
998 cik_ctor = 2, /* Constructor (in-chg, complete or base). */
999 cik_dtor = 3, /* Destructor (in-chg, deleting, complete or
1000 base). */
1001 cik_simple_op = 4, /* Non-assignment operator name. */
1002 cik_assign_op = 5, /* An assignment operator name. */
1003 cik_conv_op = 6, /* Conversion operator name. */
1004 cik_reserved_for_udlit = 7, /* Not yet in use */
1005 cik_max
1006};
1007
1008/* Kind bits. */
1009#define IDENTIFIER_KIND_BIT_0(NODE) \
1010 TREE_LANG_FLAG_0 (IDENTIFIER_NODE_CHECK (NODE))
1011#define IDENTIFIER_KIND_BIT_1(NODE) \
1012 TREE_LANG_FLAG_1 (IDENTIFIER_NODE_CHECK (NODE))
1013#define IDENTIFIER_KIND_BIT_2(NODE) \
1014 TREE_LANG_FLAG_2 (IDENTIFIER_NODE_CHECK (NODE))
1015
1016/* Used by various search routines. */
1017#define IDENTIFIER_MARKED(NODE) \
1018 TREE_LANG_FLAG_4 (IDENTIFIER_NODE_CHECK (NODE))
1019
1020/* Nonzero if this identifier is used as a virtual function name somewhere
1021 (optimizes searches). */
1022#define IDENTIFIER_VIRTUAL_P(NODE) \
1023 TREE_LANG_FLAG_5 (IDENTIFIER_NODE_CHECK (NODE))
1024
1025/* True iff NAME is the DECL_ASSEMBLER_NAME for an entity with vague
1026 linkage which the prelinker has assigned to this translation
1027 unit. */
1028#define IDENTIFIER_REPO_CHOSEN(NAME) \
1029 (TREE_LANG_FLAG_6 (IDENTIFIER_NODE_CHECK (NAME)))
1030
1031/* True if this identifier is a reserved word. C_RID_CODE (node) is
1032 then the RID_* value of the keyword. Value 1. */
1033#define IDENTIFIER_KEYWORD_P(NODE) \
1034 ((!IDENTIFIER_KIND_BIT_2 (NODE)) \
1035 & (!IDENTIFIER_KIND_BIT_1 (NODE)) \
1036 & IDENTIFIER_KIND_BIT_0 (NODE))
1037
1038/* True if this identifier is the name of a constructor or
1039 destructor. Value 2 or 3. */
1040#define IDENTIFIER_CDTOR_P(NODE) \
1041 ((!IDENTIFIER_KIND_BIT_2 (NODE)) \
1042 & IDENTIFIER_KIND_BIT_1 (NODE))
1043
1044/* True if this identifier is the name of a constructor. Value 2. */
1045#define IDENTIFIER_CTOR_P(NODE) \
1046 (IDENTIFIER_CDTOR_P(NODE) \
1047 & (!IDENTIFIER_KIND_BIT_0 (NODE)))
1048
1049/* True if this identifier is the name of a destructor. Value 3. */
1050#define IDENTIFIER_DTOR_P(NODE) \
1051 (IDENTIFIER_CDTOR_P(NODE) \
1052 & IDENTIFIER_KIND_BIT_0 (NODE))
1053
1054/* True if this identifier is for any operator name (including
1055 conversions). Value 4, 5, 6 or 7. */
1056#define IDENTIFIER_ANY_OP_P(NODE) \
1057 (IDENTIFIER_KIND_BIT_2 (NODE))
1058
1059/* True if this identifier is for an overloaded operator. Values 4, 5. */
1060#define IDENTIFIER_OVL_OP_P(NODE) \
1061 (IDENTIFIER_ANY_OP_P (NODE) \
1062 & (!IDENTIFIER_KIND_BIT_1 (NODE)))
1063
1064/* True if this identifier is for any assignment. Values 5. */
1065#define IDENTIFIER_ASSIGN_OP_P(NODE) \
1066 (IDENTIFIER_OVL_OP_P (NODE) \
1067 & IDENTIFIER_KIND_BIT_0 (NODE))
1068
1069/* True if this identifier is the name of a type-conversion
1070 operator. Value 7. */
1071#define IDENTIFIER_CONV_OP_P(NODE) \
1072 (IDENTIFIER_ANY_OP_P (NODE) \
1073 & IDENTIFIER_KIND_BIT_1 (NODE) \
1074 & (!IDENTIFIER_KIND_BIT_0 (NODE)))
1075
1076/* True if this identifier is a new or delete operator. */
1077#define IDENTIFIER_NEWDEL_OP_P(NODE) \
1078 (IDENTIFIER_OVL_OP_P (NODE) \
1079 && IDENTIFIER_OVL_OP_FLAGS (NODE) & OVL_OP_FLAG_ALLOC)
1080
1081/* True if this identifier is a new operator. */
1082#define IDENTIFIER_NEW_OP_P(NODE) \
1083 (IDENTIFIER_OVL_OP_P (NODE) \
1084 && (IDENTIFIER_OVL_OP_FLAGS (NODE) \
1085 & (OVL_OP_FLAG_ALLOC | OVL_OP_FLAG_DELETE)) == OVL_OP_FLAG_ALLOC)
1086
1087/* Access a C++-specific index for identifier NODE.
1088 Used to optimize operator mappings etc. */
1089#define IDENTIFIER_CP_INDEX(NODE) \
1090 (IDENTIFIER_NODE_CHECK(NODE)->base.u.bits.address_space)
1091
1092/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only. */
1093#define C_TYPE_FIELDS_READONLY(TYPE) \
1094 (LANG_TYPE_CLASS_CHECK (TYPE)->fields_readonly)
1095
1096/* The tokens stored in the default argument. */
1097
1098#define DEFARG_TOKENS(NODE) \
1099 (((struct tree_default_arg *)DEFAULT_ARG_CHECK (NODE))->tokens)
1100#define DEFARG_INSTANTIATIONS(NODE) \
1101 (((struct tree_default_arg *)DEFAULT_ARG_CHECK (NODE))->instantiations)
1102
1103struct GTY (()) tree_default_arg {
1104 struct tree_common common;
1105 struct cp_token_cache *tokens;
1106 vec<tree, va_gc> *instantiations;
1107};
1108
1109
1110#define DEFERRED_NOEXCEPT_PATTERN(NODE) \
1111 (((struct tree_deferred_noexcept *)DEFERRED_NOEXCEPT_CHECK (NODE))->pattern)
1112#define DEFERRED_NOEXCEPT_ARGS(NODE) \
1113 (((struct tree_deferred_noexcept *)DEFERRED_NOEXCEPT_CHECK (NODE))->args)
1114#define DEFERRED_NOEXCEPT_SPEC_P(NODE) \
1115 ((NODE) && (TREE_PURPOSE (NODE)) \
1116 && (TREE_CODE (TREE_PURPOSE (NODE)) == DEFERRED_NOEXCEPT))
1117#define UNEVALUATED_NOEXCEPT_SPEC_P(NODE) \
1118 (DEFERRED_NOEXCEPT_SPEC_P (NODE) \
1119 && DEFERRED_NOEXCEPT_PATTERN (TREE_PURPOSE (NODE)) == NULL_TREE)
1120
1121struct GTY (()) tree_deferred_noexcept {
1122 struct tree_base base;
1123 tree pattern;
1124 tree args;
1125};
1126
1127
1128/* The condition associated with the static assertion. This must be
1129 an integral constant expression. */
1130#define STATIC_ASSERT_CONDITION(NODE) \
1131 (((struct tree_static_assert *)STATIC_ASSERT_CHECK (NODE))->condition)
1132
1133/* The message associated with the static assertion. This must be a
1134 string constant, which will be emitted as an error message when the
1135 static assert condition is false. */
1136#define STATIC_ASSERT_MESSAGE(NODE) \
1137 (((struct tree_static_assert *)STATIC_ASSERT_CHECK (NODE))->message)
1138
1139/* Source location information for a static assertion. */
1140#define STATIC_ASSERT_SOURCE_LOCATION(NODE) \
1141 (((struct tree_static_assert *)STATIC_ASSERT_CHECK (NODE))->location)
1142
1143struct GTY (()) tree_static_assert {
1144 struct tree_common common;
1145 tree condition;
1146 tree message;
1147 location_t location;
1148};
1149
1150struct GTY (()) tree_argument_pack_select {
1151 struct tree_common common;
1152 tree argument_pack;
1153 int index;
1154};
1155
1156/* The different kinds of traits that we encounter. */
1157
1158enum cp_trait_kind
1159{
1160 CPTK_BASES,
1161 CPTK_DIRECT_BASES,
1162 CPTK_HAS_NOTHROW_ASSIGN,
1163 CPTK_HAS_NOTHROW_CONSTRUCTOR,
1164 CPTK_HAS_NOTHROW_COPY,
1165 CPTK_HAS_TRIVIAL_ASSIGN,
1166 CPTK_HAS_TRIVIAL_CONSTRUCTOR,
1167 CPTK_HAS_TRIVIAL_COPY,
1168 CPTK_HAS_TRIVIAL_DESTRUCTOR,
1169 CPTK_HAS_UNIQUE_OBJ_REPRESENTATIONS,
1170 CPTK_HAS_VIRTUAL_DESTRUCTOR,
1171 CPTK_IS_ABSTRACT,
1172 CPTK_IS_AGGREGATE,
1173 CPTK_IS_BASE_OF,
1174 CPTK_IS_CLASS,
1175 CPTK_IS_EMPTY,
1176 CPTK_IS_ENUM,
1177 CPTK_IS_FINAL,
1178 CPTK_IS_LITERAL_TYPE,
1179 CPTK_IS_POD,
1180 CPTK_IS_POLYMORPHIC,
1181 CPTK_IS_SAME_AS,
1182 CPTK_IS_STD_LAYOUT,
1183 CPTK_IS_TRIVIAL,
1184 CPTK_IS_TRIVIALLY_ASSIGNABLE,
1185 CPTK_IS_TRIVIALLY_CONSTRUCTIBLE,
1186 CPTK_IS_TRIVIALLY_COPYABLE,
1187 CPTK_IS_UNION,
1188 CPTK_UNDERLYING_TYPE,
1189 CPTK_IS_ASSIGNABLE,
1190 CPTK_IS_CONSTRUCTIBLE
1191};
1192
1193/* The types that we are processing. */
1194#define TRAIT_EXPR_TYPE1(NODE) \
1195 (((struct tree_trait_expr *)TRAIT_EXPR_CHECK (NODE))->type1)
1196
1197#define TRAIT_EXPR_TYPE2(NODE) \
1198 (((struct tree_trait_expr *)TRAIT_EXPR_CHECK (NODE))->type2)
1199
1200/* The specific trait that we are processing. */
1201#define TRAIT_EXPR_KIND(NODE) \
1202 (((struct tree_trait_expr *)TRAIT_EXPR_CHECK (NODE))->kind)
1203
1204struct GTY (()) tree_trait_expr {
1205 struct tree_common common;
1206 tree type1;
1207 tree type2;
1208 enum cp_trait_kind kind;
1209};
1210
1211/* Based off of TYPE_UNNAMED_P. */
1212#define LAMBDA_TYPE_P(NODE) \
1213 (CLASS_TYPE_P (NODE) && CLASSTYPE_LAMBDA_EXPR (NODE))
1214
1215/* Test if FUNCTION_DECL is a lambda function. */
1216#define LAMBDA_FUNCTION_P(FNDECL) \
1217 (DECL_DECLARES_FUNCTION_P (FNDECL) \
1218 && DECL_OVERLOADED_OPERATOR_P (FNDECL) \
1219 && DECL_OVERLOADED_OPERATOR_IS (FNDECL, CALL_EXPR) \
1220 && LAMBDA_TYPE_P (CP_DECL_CONTEXT (FNDECL)))
1221
1222enum cp_lambda_default_capture_mode_type {
1223 CPLD_NONE,
1224 CPLD_COPY,
1225 CPLD_REFERENCE
1226};
1227
1228/* The method of default capture, if any. */
1229#define LAMBDA_EXPR_DEFAULT_CAPTURE_MODE(NODE) \
1230 (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->default_capture_mode)
1231
1232/* The capture-list, including `this'. Each capture is stored as a FIELD_DECL
1233 * so that the name, type, and field are all together, whether or not it has
1234 * been added to the lambda's class type.
1235 TREE_LIST:
1236 TREE_PURPOSE: The FIELD_DECL for this capture.
1237 TREE_VALUE: The initializer. This is part of a GNU extension. */
1238#define LAMBDA_EXPR_CAPTURE_LIST(NODE) \
1239 (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->capture_list)
1240
1241/* During parsing of the lambda-introducer, the node in the capture-list
1242 that holds the 'this' capture. During parsing of the body, the
1243 capture proxy for that node. */
1244#define LAMBDA_EXPR_THIS_CAPTURE(NODE) \
1245 (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->this_capture)
1246
1247/* Predicate tracking whether `this' is in the effective capture set. */
1248#define LAMBDA_EXPR_CAPTURES_THIS_P(NODE) \
1249 LAMBDA_EXPR_THIS_CAPTURE(NODE)
1250
1251/* Predicate tracking whether the lambda was declared 'mutable'. */
1252#define LAMBDA_EXPR_MUTABLE_P(NODE) \
1253 TREE_LANG_FLAG_1 (LAMBDA_EXPR_CHECK (NODE))
1254
1255/* The source location of the lambda. */
1256#define LAMBDA_EXPR_LOCATION(NODE) \
1257 (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->locus)
1258
1259/* The mangling scope for the lambda: FUNCTION_DECL, PARM_DECL, VAR_DECL,
1260 FIELD_DECL or NULL_TREE. If this is NULL_TREE, we have no linkage. */
1261#define LAMBDA_EXPR_EXTRA_SCOPE(NODE) \
1262 (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->extra_scope)
1263
1264/* If EXTRA_SCOPE, this is the number of the lambda within that scope. */
1265#define LAMBDA_EXPR_DISCRIMINATOR(NODE) \
1266 (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->discriminator)
1267
1268/* During parsing of the lambda, a vector of capture proxies which need
1269 to be pushed once we're done processing a nested lambda. */
1270#define LAMBDA_EXPR_PENDING_PROXIES(NODE) \
1271 (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->pending_proxies)
1272
1273/* The closure type of the lambda, which is also the type of the
1274 LAMBDA_EXPR. */
1275#define LAMBDA_EXPR_CLOSURE(NODE) \
1276 (TREE_TYPE (LAMBDA_EXPR_CHECK (NODE)))
1277
1278struct GTY (()) tree_lambda_expr
1279{
1280 struct tree_typed typed;
1281 tree capture_list;
1282 tree this_capture;
1283 tree extra_scope;
1284 vec<tree, va_gc> *pending_proxies;
1285 location_t locus;
1286 enum cp_lambda_default_capture_mode_type default_capture_mode;
1287 int discriminator;
1288};
1289
1290/* A (typedef,context,usage location) triplet.
1291 It represents a typedef used through a
1292 context at a given source location.
1293 e.g.
1294 struct foo {
1295 typedef int myint;
1296 };
1297
1298 struct bar {
1299 foo::myint v; // #1<-- this location.
1300 };
1301
1302 In bar, the triplet will be (myint, foo, #1).
1303 */
1304struct GTY(()) qualified_typedef_usage_s {
1305 tree typedef_decl;
1306 tree context;
1307 location_t locus;
1308};
1309typedef struct qualified_typedef_usage_s qualified_typedef_usage_t;
1310
1311/* Non-zero if this template specialization has access violations that
1312 should be rechecked when the function is instantiated outside argument
1313 deduction. */
1314#define TINFO_HAS_ACCESS_ERRORS(NODE) \
1315 (TREE_LANG_FLAG_0 (TEMPLATE_INFO_CHECK (NODE)))
1316#define FNDECL_HAS_ACCESS_ERRORS(NODE) \
1317 (TINFO_HAS_ACCESS_ERRORS (DECL_TEMPLATE_INFO (NODE)))
1318
1319/* Non-zero if this variable template specialization was specified using a
1320 template-id, so it's a partial or full specialization and not a definition
1321 of the member template of a particular class specialization. */
1322#define TINFO_USED_TEMPLATE_ID(NODE) \
1323 (TREE_LANG_FLAG_1 (TEMPLATE_INFO_CHECK (NODE)))
1324
1325struct GTY(()) tree_template_info {
1326 struct tree_common common;
1327 vec<qualified_typedef_usage_t, va_gc> *typedefs_needing_access_checking;
1328};
1329
1330// Constraint information for a C++ declaration. Constraint information is
1331// comprised of:
1332//
1333// - a constraint expression introduced by the template header
1334// - a constraint expression introduced by a function declarator
1335// - the associated constraints, which are the conjunction of those,
1336// and used for declaration matching
1337//
1338// The template and declarator requirements are kept to support pretty
1339// printing constrained declarations.
1340struct GTY(()) tree_constraint_info {
1341 struct tree_base base;
1342 tree template_reqs;
1343 tree declarator_reqs;
1344 tree associated_constr;
1345};
1346
1347// Require that pointer P is non-null before returning.
1348template<typename T>
1349inline T*
1350check_nonnull (T* p)
1351{
1352 gcc_assert (p);
1353 return p;
1354}
1355
1356// Returns true iff T is non-null and represents constraint info.
1357inline tree_constraint_info *
1358check_constraint_info (tree t)
1359{
1360 if (t && TREE_CODE (t) == CONSTRAINT_INFO)
1361 return (tree_constraint_info *)t;
1362 return NULL;
1363}
1364
1365// Access the expression describing the template constraints. This may be
1366// null if no constraints were introduced in the template parameter list,
1367// a requirements clause after the template parameter list, or constraints
1368// through a constrained-type-specifier.
1369#define CI_TEMPLATE_REQS(NODE) \
1370 check_constraint_info (check_nonnull(NODE))->template_reqs
1371
1372// Access the expression describing the trailing constraints. This is non-null
1373// for any implicit instantiation of a constrained declaration. For a
1374// templated declaration it is non-null only when a trailing requires-clause
1375// was specified.
1376#define CI_DECLARATOR_REQS(NODE) \
1377 check_constraint_info (check_nonnull(NODE))->declarator_reqs
1378
1379// The computed associated constraint expression for a declaration.
1380#define CI_ASSOCIATED_CONSTRAINTS(NODE) \
1381 check_constraint_info (check_nonnull(NODE))->associated_constr
1382
1383// Access the logical constraints on the template parameters introduced
1384// at a given template parameter list level indicated by NODE.
1385#define TEMPLATE_PARMS_CONSTRAINTS(NODE) \
1386 TREE_TYPE (TREE_LIST_CHECK (NODE))
1387
1388// Access the logical constraints on the template parameter declaration
1389// indicated by NODE.
1390#define TEMPLATE_PARM_CONSTRAINTS(NODE) \
1391 TREE_TYPE (TREE_LIST_CHECK (NODE))
1392
1393/* Non-zero if the noexcept is present in a compound requirement. */
1394#define COMPOUND_REQ_NOEXCEPT_P(NODE) \
1395 TREE_LANG_FLAG_0 (TREE_CHECK (NODE, COMPOUND_REQ))
1396
1397/* The constraints on an 'auto' placeholder type, used in an argument deduction
1398 constraint. */
1399#define PLACEHOLDER_TYPE_CONSTRAINTS(NODE) \
1400 DECL_SIZE_UNIT (TYPE_NAME (NODE))
1401
1402/* The expression evaluated by the predicate constraint. */
1403#define PRED_CONSTR_EXPR(NODE) \
1404 TREE_OPERAND (TREE_CHECK (NODE, PRED_CONSTR), 0)
1405
1406/* The concept of a concept check. */
1407#define CHECK_CONSTR_CONCEPT(NODE) \
1408 TREE_OPERAND (TREE_CHECK (NODE, CHECK_CONSTR), 0)
1409
1410/* The template arguments of a concept check. */
1411#define CHECK_CONSTR_ARGS(NODE) \
1412 TREE_OPERAND (TREE_CHECK (NODE, CHECK_CONSTR), 1)
1413
1414/* The expression validated by the predicate constraint. */
1415#define EXPR_CONSTR_EXPR(NODE) \
1416 TREE_OPERAND (TREE_CHECK (NODE, EXPR_CONSTR), 0)
1417
1418/* The type validated by the predicate constraint. */
1419#define TYPE_CONSTR_TYPE(NODE) \
1420 TREE_OPERAND (TREE_CHECK (NODE, TYPE_CONSTR), 0)
1421
1422/* In an implicit conversion constraint, the source expression. */
1423#define ICONV_CONSTR_EXPR(NODE) \
1424 TREE_OPERAND (TREE_CHECK (NODE, ICONV_CONSTR), 0)
1425
1426/* In an implicit conversion constraint, the target type. */
1427#define ICONV_CONSTR_TYPE(NODE) \
1428 TREE_OPERAND (TREE_CHECK (NODE, ICONV_CONSTR), 1)
1429
1430/* In an argument deduction constraint, the source expression. */
1431#define DEDUCT_CONSTR_EXPR(NODE) \
1432 TREE_OPERAND (TREE_CHECK (NODE, DEDUCT_CONSTR), 0)
1433
1434/* In an argument deduction constraint, the target type pattern. */
1435#define DEDUCT_CONSTR_PATTERN(NODE) \
1436 TREE_OPERAND (TREE_CHECK (NODE, DEDUCT_CONSTR), 1)
1437
1438/* In an argument deduction constraint, the list of placeholder nodes. */
1439#define DEDUCT_CONSTR_PLACEHOLDER(NODE) \
1440 TREE_OPERAND (TREE_CHECK (NODE, DEDUCT_CONSTR), 2)
1441
1442/* The expression of an exception constraint. */
1443#define EXCEPT_CONSTR_EXPR(NODE) \
1444 TREE_OPERAND (TREE_CHECK (NODE, EXCEPT_CONSTR), 0)
1445
1446/* In a parameterized constraint, the local parameters. */
1447#define PARM_CONSTR_PARMS(NODE) \
1448 TREE_OPERAND (TREE_CHECK (NODE, PARM_CONSTR), 0)
1449
1450/* In a parameterized constraint, the operand. */
1451#define PARM_CONSTR_OPERAND(NODE) \
1452 TREE_OPERAND (TREE_CHECK (NODE, PARM_CONSTR), 1)
1453
1454/* Whether a PARM_DECL represents a local parameter in a
1455 requires-expression. */
1456#define CONSTRAINT_VAR_P(NODE) \
1457 DECL_LANG_FLAG_2 (TREE_CHECK (NODE, PARM_DECL))
1458
1459/* The concept constraining this constrained template-parameter. */
1460#define CONSTRAINED_PARM_CONCEPT(NODE) \
1461 DECL_SIZE_UNIT (TYPE_DECL_CHECK (NODE))
1462/* Any extra template arguments specified for a constrained
1463 template-parameter. */
1464#define CONSTRAINED_PARM_EXTRA_ARGS(NODE) \
1465 DECL_SIZE (TYPE_DECL_CHECK (NODE))
1466/* The first template parameter of CONSTRAINED_PARM_CONCEPT to be used as a
1467 prototype for the constrained parameter in finish_shorthand_constraint,
1468 attached for convenience. */
1469#define CONSTRAINED_PARM_PROTOTYPE(NODE) \
1470 DECL_INITIAL (TYPE_DECL_CHECK (NODE))
1471
1472enum cp_tree_node_structure_enum {
1473 TS_CP_GENERIC,
1474 TS_CP_IDENTIFIER,
1475 TS_CP_TPI,
1476 TS_CP_PTRMEM,
1477 TS_CP_OVERLOAD,
1478 TS_CP_BASELINK,
1479 TS_CP_TEMPLATE_DECL,
1480 TS_CP_DEFAULT_ARG,
1481 TS_CP_DEFERRED_NOEXCEPT,
1482 TS_CP_STATIC_ASSERT,
1483 TS_CP_ARGUMENT_PACK_SELECT,
1484 TS_CP_TRAIT_EXPR,
1485 TS_CP_LAMBDA_EXPR,
1486 TS_CP_TEMPLATE_INFO,
1487 TS_CP_CONSTRAINT_INFO,
1488 TS_CP_USERDEF_LITERAL
1489};
1490
1491/* The resulting tree type. */
1492union GTY((desc ("cp_tree_node_structure (&%h)"),
1493 chain_next ("(union lang_tree_node *) c_tree_chain_next (&%h.generic)"))) lang_tree_node {
1494 union tree_node GTY ((tag ("TS_CP_GENERIC"),
1495 desc ("tree_node_structure (&%h)"))) generic;
1496 struct template_parm_index GTY ((tag ("TS_CP_TPI"))) tpi;
1497 struct ptrmem_cst GTY ((tag ("TS_CP_PTRMEM"))) ptrmem;
1498 struct tree_overload GTY ((tag ("TS_CP_OVERLOAD"))) overload;
1499 struct tree_baselink GTY ((tag ("TS_CP_BASELINK"))) baselink;
1500 struct tree_template_decl GTY ((tag ("TS_CP_TEMPLATE_DECL"))) template_decl;
1501 struct tree_default_arg GTY ((tag ("TS_CP_DEFAULT_ARG"))) default_arg;
1502 struct tree_deferred_noexcept GTY ((tag ("TS_CP_DEFERRED_NOEXCEPT"))) deferred_noexcept;
1503 struct lang_identifier GTY ((tag ("TS_CP_IDENTIFIER"))) identifier;
1504 struct tree_static_assert GTY ((tag ("TS_CP_STATIC_ASSERT")))
1505 static_assertion;
1506 struct tree_argument_pack_select GTY ((tag ("TS_CP_ARGUMENT_PACK_SELECT")))
1507 argument_pack_select;
1508 struct tree_trait_expr GTY ((tag ("TS_CP_TRAIT_EXPR")))
1509 trait_expression;
1510 struct tree_lambda_expr GTY ((tag ("TS_CP_LAMBDA_EXPR")))
1511 lambda_expression;
1512 struct tree_template_info GTY ((tag ("TS_CP_TEMPLATE_INFO")))
1513 template_info;
1514 struct tree_constraint_info GTY ((tag ("TS_CP_CONSTRAINT_INFO")))
1515 constraint_info;
1516 struct tree_userdef_literal GTY ((tag ("TS_CP_USERDEF_LITERAL")))
1517 userdef_literal;
1518};
1519
1520
1521/* Global state. */
1522
1523struct GTY(()) saved_scope {
1524 vec<cxx_saved_binding, va_gc> *old_bindings;
1525 tree old_namespace;
1526 vec<tree, va_gc> *decl_ns_list;
1527 tree class_name;
1528 tree class_type;
1529 tree access_specifier;
1530 tree function_decl;
1531 vec<tree, va_gc> *lang_base;
1532 tree lang_name;
1533 tree template_parms;
1534 cp_binding_level *x_previous_class_level;
1535 tree x_saved_tree;
1536
1537 /* Only used for uses of this in trailing return type. */
1538 tree x_current_class_ptr;
1539 tree x_current_class_ref;
1540
1541 int x_processing_template_decl;
1542 int x_processing_specialization;
1543 BOOL_BITFIELD x_processing_explicit_instantiation : 1;
1544 BOOL_BITFIELD need_pop_function_context : 1;
1545
1546/* Nonzero if we are parsing the discarded statement of a constexpr
1547 if-statement. */
1548 BOOL_BITFIELD discarded_stmt : 1;
1549
1550 int unevaluated_operand;
1551 int inhibit_evaluation_warnings;
1552 int noexcept_operand;
1553 /* If non-zero, implicit "omp declare target" attribute is added into the
1554 attribute lists. */
1555 int omp_declare_target_attribute;
1556
1557 struct stmt_tree_s x_stmt_tree;
1558
1559 cp_binding_level *class_bindings;
1560 cp_binding_level *bindings;
1561
1562 hash_map<tree, tree> *GTY((skip)) x_local_specializations;
1563
1564 struct saved_scope *prev;
1565};
1566
1567extern GTY(()) struct saved_scope *scope_chain;
1568
1569/* The current open namespace. */
1570
1571#define current_namespace scope_chain->old_namespace
1572
1573/* The stack for namespaces of current declarations. */
1574
1575#define decl_namespace_list scope_chain->decl_ns_list
1576
1577/* IDENTIFIER_NODE: name of current class */
1578
1579#define current_class_name scope_chain->class_name
1580
1581/* _TYPE: the type of the current class */
1582
1583#define current_class_type scope_chain->class_type
1584
1585/* When parsing a class definition, the access specifier most recently
1586 given by the user, or, if no access specifier was given, the
1587 default value appropriate for the kind of class (i.e., struct,
1588 class, or union). */
1589
1590#define current_access_specifier scope_chain->access_specifier
1591
1592/* Pointer to the top of the language name stack. */
1593
1594#define current_lang_base scope_chain->lang_base
1595#define current_lang_name scope_chain->lang_name
1596
1597/* When parsing a template declaration, a TREE_LIST represents the
1598 active template parameters. Each node in the list represents one
1599 level of template parameters. The innermost level is first in the
1600 list. The depth of each level is stored as an INTEGER_CST in the
1601 TREE_PURPOSE of each node. The parameters for that level are
1602 stored in the TREE_VALUE. */
1603
1604#define current_template_parms scope_chain->template_parms
1605
1606#define processing_template_decl scope_chain->x_processing_template_decl
1607#define processing_specialization scope_chain->x_processing_specialization
1608#define processing_explicit_instantiation scope_chain->x_processing_explicit_instantiation
1609
1610#define in_discarded_stmt scope_chain->discarded_stmt
1611
1612/* RAII sentinel to handle clearing processing_template_decl and restoring
1613 it when done. */
1614
1615struct processing_template_decl_sentinel
1616{
1617 int saved;
1618 processing_template_decl_sentinel (bool reset = true)
1619 : saved (processing_template_decl)
1620 {
1621 if (reset)
1622 processing_template_decl = 0;
1623 }
1624 ~processing_template_decl_sentinel()
1625 {
1626 processing_template_decl = saved;
1627 }
1628};
1629
1630/* RAII sentinel to disable certain warnings during template substitution
1631 and elsewhere. */
1632
1633struct warning_sentinel
1634{
1635 int &flag;
1636 int val;
1637 warning_sentinel(int& flag, bool suppress=true)
1638 : flag(flag), val(flag) { if (suppress) flag = 0; }
1639 ~warning_sentinel() { flag = val; }
1640};
1641
1642/* The cached class binding level, from the most recently exited
1643 class, or NULL if none. */
1644
1645#define previous_class_level scope_chain->x_previous_class_level
1646
1647/* A map from local variable declarations in the body of the template
1648 presently being instantiated to the corresponding instantiated
1649 local variables. */
1650
1651#define local_specializations scope_chain->x_local_specializations
1652
1653/* Nonzero if we are parsing the operand of a noexcept operator. */
1654
1655#define cp_noexcept_operand scope_chain->noexcept_operand
1656
1657/* A list of private types mentioned, for deferred access checking. */
1658
1659struct GTY((for_user)) cxx_int_tree_map {
1660 unsigned int uid;
1661 tree to;
1662};
1663
1664struct cxx_int_tree_map_hasher : ggc_ptr_hash<cxx_int_tree_map>
1665{
1666 static hashval_t hash (cxx_int_tree_map *);
1667 static bool equal (cxx_int_tree_map *, cxx_int_tree_map *);
1668};
1669
1670struct named_label_entry; /* Defined in decl.c. */
1671
1672struct named_label_hash : ggc_remove <named_label_entry *>
1673{
1674 typedef named_label_entry *value_type;
1675 typedef tree compare_type; /* An identifier. */
1676
1677 inline static hashval_t hash (value_type);
1678 inline static bool equal (const value_type, compare_type);
1679
1680 inline static void mark_empty (value_type &p) {p = NULL;}
1681 inline static bool is_empty (value_type p) {return !p;}
1682
1683 /* Nothing is deletable. Everything is insertable. */
1684 inline static bool is_deleted (value_type) { return false; }
1685 inline static void mark_deleted (value_type) { gcc_unreachable (); }
1686};
1687
1688/* Global state pertinent to the current function. */
1689
1690struct GTY(()) language_function {
1691 struct c_language_function base;
1692
1693 tree x_cdtor_label;
1694 tree x_current_class_ptr;
1695 tree x_current_class_ref;
1696 tree x_eh_spec_block;
1697 tree x_in_charge_parm;
1698 tree x_vtt_parm;
1699 tree x_return_value;
1700 tree x_auto_return_pattern;
1701
1702 BOOL_BITFIELD returns_value : 1;
1703 BOOL_BITFIELD returns_null : 1;
1704 BOOL_BITFIELD returns_abnormally : 1;
1705 BOOL_BITFIELD infinite_loop: 1;
1706 BOOL_BITFIELD x_in_function_try_handler : 1;
1707 BOOL_BITFIELD x_in_base_initializer : 1;
1708
1709 /* True if this function can throw an exception. */
1710 BOOL_BITFIELD can_throw : 1;
1711
1712 BOOL_BITFIELD invalid_constexpr : 1;
1713
1714 hash_table<named_label_hash> *x_named_labels;
1715
1716 cp_binding_level *bindings;
1717 vec<tree, va_gc> *x_local_names;
1718 /* Tracking possibly infinite loops. This is a vec<tree> only because
1719 vec<bool> doesn't work with gtype. */
1720 vec<tree, va_gc> *infinite_loops;
1721 hash_table<cxx_int_tree_map_hasher> *extern_decl_map;
1722};
1723
1724/* The current C++-specific per-function global variables. */
1725
1726#define cp_function_chain (cfun->language)
1727
1728/* In a constructor destructor, the point at which all derived class
1729 destroying/construction has been done. I.e., just before a
1730 constructor returns, or before any base class destroying will be done
1731 in a destructor. */
1732
1733#define cdtor_label cp_function_chain->x_cdtor_label
1734
1735/* When we're processing a member function, current_class_ptr is the
1736 PARM_DECL for the `this' pointer. The current_class_ref is an
1737 expression for `*this'. */
1738
1739#define current_class_ptr \
1740 (*(cfun && cp_function_chain \
1741 ? &cp_function_chain->x_current_class_ptr \
1742 : &scope_chain->x_current_class_ptr))
1743#define current_class_ref \
1744 (*(cfun && cp_function_chain \
1745 ? &cp_function_chain->x_current_class_ref \
1746 : &scope_chain->x_current_class_ref))
1747
1748/* The EH_SPEC_BLOCK for the exception-specifiers for the current
1749 function, if any. */
1750
1751#define current_eh_spec_block cp_function_chain->x_eh_spec_block
1752
1753/* The `__in_chrg' parameter for the current function. Only used for
1754 constructors and destructors. */
1755
1756#define current_in_charge_parm cp_function_chain->x_in_charge_parm
1757
1758/* The `__vtt_parm' parameter for the current function. Only used for
1759 constructors and destructors. */
1760
1761#define current_vtt_parm cp_function_chain->x_vtt_parm
1762
1763/* Set to 0 at beginning of a function definition, set to 1 if
1764 a return statement that specifies a return value is seen. */
1765
1766#define current_function_returns_value cp_function_chain->returns_value
1767
1768/* Set to 0 at beginning of a function definition, set to 1 if
1769 a return statement with no argument is seen. */
1770
1771#define current_function_returns_null cp_function_chain->returns_null
1772
1773/* Set to 0 at beginning of a function definition, set to 1 if
1774 a call to a noreturn function is seen. */
1775
1776#define current_function_returns_abnormally \
1777 cp_function_chain->returns_abnormally
1778
1779/* Set to 0 at beginning of a function definition, set to 1 if we see an
1780 obvious infinite loop. This can have false positives and false
1781 negatives, so it should only be used as a heuristic. */
1782
1783#define current_function_infinite_loop cp_function_chain->infinite_loop
1784
1785/* Nonzero if we are processing a base initializer. Zero elsewhere. */
1786#define in_base_initializer cp_function_chain->x_in_base_initializer
1787
1788#define in_function_try_handler cp_function_chain->x_in_function_try_handler
1789
1790/* Expression always returned from function, or error_mark_node
1791 otherwise, for use by the automatic named return value optimization. */
1792
1793#define current_function_return_value \
1794 (cp_function_chain->x_return_value)
1795
1796/* A type involving 'auto' to be used for return type deduction. */
1797
1798#define current_function_auto_return_pattern \
1799 (cp_function_chain->x_auto_return_pattern)
1800
1801/* In parser.c. */
1802extern tree cp_literal_operator_id (const char *);
1803
1804/* TRUE if a tree code represents a statement. */
1805extern bool statement_code_p[MAX_TREE_CODES];
1806
1807#define STATEMENT_CODE_P(CODE) statement_code_p[(int) (CODE)]
1808
1809enum languages { lang_c, lang_cplusplus };
1810
1811/* Macros to make error reporting functions' lives easier. */
1812#define TYPE_LINKAGE_IDENTIFIER(NODE) \
1813 (TYPE_IDENTIFIER (TYPE_MAIN_VARIANT (NODE)))
1814#define TYPE_NAME_STRING(NODE) (IDENTIFIER_POINTER (TYPE_IDENTIFIER (NODE)))
1815#define TYPE_NAME_LENGTH(NODE) (IDENTIFIER_LENGTH (TYPE_IDENTIFIER (NODE)))
1816
1817/* Nonzero if NODE has no name for linkage purposes. */
1818#define TYPE_UNNAMED_P(NODE) \
1819 (OVERLOAD_TYPE_P (NODE) && anon_aggrname_p (TYPE_LINKAGE_IDENTIFIER (NODE)))
1820
1821/* The _DECL for this _TYPE. */
1822#define TYPE_MAIN_DECL(NODE) (TYPE_STUB_DECL (TYPE_MAIN_VARIANT (NODE)))
1823
1824/* Nonzero if T is a type that could resolve to any kind of concrete type
1825 at instantiation time. */
1826#define WILDCARD_TYPE_P(T) \
1827 (TREE_CODE (T) == TEMPLATE_TYPE_PARM \
1828 || TREE_CODE (T) == TYPENAME_TYPE \
1829 || TREE_CODE (T) == TYPEOF_TYPE \
1830 || TREE_CODE (T) == BOUND_TEMPLATE_TEMPLATE_PARM \
1831 || TREE_CODE (T) == DECLTYPE_TYPE)
1832
1833/* Nonzero if T is a class (or struct or union) type. Also nonzero
1834 for template type parameters, typename types, and instantiated
1835 template template parameters. Keep these checks in ascending code
1836 order. */
1837#define MAYBE_CLASS_TYPE_P(T) (WILDCARD_TYPE_P (T) || CLASS_TYPE_P (T))
1838
1839/* Set CLASS_TYPE_P for T to VAL. T must be a class, struct, or
1840 union type. */
1841#define SET_CLASS_TYPE_P(T, VAL) \
1842 (TYPE_LANG_FLAG_5 (RECORD_OR_UNION_CHECK (T)) = (VAL))
1843
1844/* Nonzero if T is a class type. Zero for template type parameters,
1845 typename types, and so forth. */
1846#define CLASS_TYPE_P(T) \
1847 (RECORD_OR_UNION_CODE_P (TREE_CODE (T)) && TYPE_LANG_FLAG_5 (T))
1848
1849/* Nonzero if T is a class type but not an union. */
1850#define NON_UNION_CLASS_TYPE_P(T) \
1851 (TREE_CODE (T) == RECORD_TYPE && TYPE_LANG_FLAG_5 (T))
1852
1853/* Keep these checks in ascending code order. */
1854#define RECORD_OR_UNION_CODE_P(T) \
1855 ((T) == RECORD_TYPE || (T) == UNION_TYPE)
1856#define OVERLOAD_TYPE_P(T) \
1857 (CLASS_TYPE_P (T) || TREE_CODE (T) == ENUMERAL_TYPE)
1858
1859/* True if this type is dependent. This predicate is only valid if
1860 TYPE_DEPENDENT_P_VALID is true. */
1861#define TYPE_DEPENDENT_P(NODE) TYPE_LANG_FLAG_0 (NODE)
1862
1863/* True if dependent_type_p has been called for this type, with the
1864 result that TYPE_DEPENDENT_P is valid. */
1865#define TYPE_DEPENDENT_P_VALID(NODE) TYPE_LANG_FLAG_6(NODE)
1866
1867/* Nonzero if this type is const-qualified. */
1868#define CP_TYPE_CONST_P(NODE) \
1869 ((cp_type_quals (NODE) & TYPE_QUAL_CONST) != 0)
1870
1871/* Nonzero if this type is volatile-qualified. */
1872#define CP_TYPE_VOLATILE_P(NODE) \
1873 ((cp_type_quals (NODE) & TYPE_QUAL_VOLATILE) != 0)
1874
1875/* Nonzero if this type is restrict-qualified. */
1876#define CP_TYPE_RESTRICT_P(NODE) \
1877 ((cp_type_quals (NODE) & TYPE_QUAL_RESTRICT) != 0)
1878
1879/* Nonzero if this type is const-qualified, but not
1880 volatile-qualified. Other qualifiers are ignored. This macro is
1881 used to test whether or not it is OK to bind an rvalue to a
1882 reference. */
1883#define CP_TYPE_CONST_NON_VOLATILE_P(NODE) \
1884 ((cp_type_quals (NODE) & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)) \
1885 == TYPE_QUAL_CONST)
1886
1887#define FUNCTION_ARG_CHAIN(NODE) \
1888 TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (NODE)))
1889
1890/* Given a FUNCTION_DECL, returns the first TREE_LIST out of TYPE_ARG_TYPES
1891 which refers to a user-written parameter. */
1892#define FUNCTION_FIRST_USER_PARMTYPE(NODE) \
1893 skip_artificial_parms_for ((NODE), TYPE_ARG_TYPES (TREE_TYPE (NODE)))
1894
1895/* Similarly, but for DECL_ARGUMENTS. */
1896#define FUNCTION_FIRST_USER_PARM(NODE) \
1897 skip_artificial_parms_for ((NODE), DECL_ARGUMENTS (NODE))
1898
1899/* Nonzero iff TYPE is derived from PARENT. Ignores accessibility and
1900 ambiguity issues. */
1901#define DERIVED_FROM_P(PARENT, TYPE) \
1902 (lookup_base ((TYPE), (PARENT), ba_any, NULL, tf_none) != NULL_TREE)
1903
1904/* Gives the visibility specification for a class type. */
1905#define CLASSTYPE_VISIBILITY(TYPE) \
1906 DECL_VISIBILITY (TYPE_MAIN_DECL (TYPE))
1907#define CLASSTYPE_VISIBILITY_SPECIFIED(TYPE) \
1908 DECL_VISIBILITY_SPECIFIED (TYPE_MAIN_DECL (TYPE))
1909
1910struct GTY (()) tree_pair_s {
1911 tree purpose;
1912 tree value;
1913};
1914typedef tree_pair_s *tree_pair_p;
1915
1916/* This structure provides additional information above and beyond
1917 what is provide in the ordinary tree_type. In the past, we used it
1918 for the types of class types, template parameters types, typename
1919 types, and so forth. However, there can be many (tens to hundreds
1920 of thousands) of template parameter types in a compilation, and
1921 there's no need for this additional information in that case.
1922 Therefore, we now use this data structure only for class types.
1923
1924 In the past, it was thought that there would be relatively few
1925 class types. However, in the presence of heavy use of templates,
1926 many (i.e., thousands) of classes can easily be generated.
1927 Therefore, we should endeavor to keep the size of this structure to
1928 a minimum. */
1929struct GTY(()) lang_type {
1930 unsigned char align;
1931
1932 unsigned has_type_conversion : 1;
1933 unsigned has_copy_ctor : 1;
1934 unsigned has_default_ctor : 1;
1935 unsigned const_needs_init : 1;
1936 unsigned ref_needs_init : 1;
1937 unsigned has_const_copy_assign : 1;
1938 unsigned use_template : 2;
1939
1940 unsigned has_mutable : 1;
1941 unsigned com_interface : 1;
1942 unsigned non_pod_class : 1;
1943 unsigned nearly_empty_p : 1;
1944 unsigned user_align : 1;
1945 unsigned has_copy_assign : 1;
1946 unsigned has_new : 1;
1947 unsigned has_array_new : 1;
1948
1949 unsigned gets_delete : 2;
1950 unsigned interface_only : 1;
1951 unsigned interface_unknown : 1;
1952 unsigned contains_empty_class_p : 1;
1953 unsigned anon_aggr : 1;
1954 unsigned non_zero_init : 1;
1955 unsigned empty_p : 1;
1956 /* 32 bits allocated. */
1957
1958 unsigned vec_new_uses_cookie : 1;
1959 unsigned declared_class : 1;
1960 unsigned diamond_shaped : 1;
1961 unsigned repeated_base : 1;
1962 unsigned being_defined : 1;
1963 unsigned debug_requested : 1;
1964 unsigned fields_readonly : 1;
1965 unsigned ptrmemfunc_flag : 1;
1966
1967 unsigned was_anonymous : 1;
1968 unsigned lazy_default_ctor : 1;
1969 unsigned lazy_copy_ctor : 1;
1970 unsigned lazy_copy_assign : 1;
1971 unsigned lazy_destructor : 1;
1972 unsigned has_const_copy_ctor : 1;
1973 unsigned has_complex_copy_ctor : 1;
1974 unsigned has_complex_copy_assign : 1;
1975
1976 unsigned non_aggregate : 1;
1977 unsigned has_complex_dflt : 1;
1978 unsigned has_list_ctor : 1;
1979 unsigned non_std_layout : 1;
1980 unsigned is_literal : 1;
1981 unsigned lazy_move_ctor : 1;
1982 unsigned lazy_move_assign : 1;
1983 unsigned has_complex_move_ctor : 1;
1984
1985 unsigned has_complex_move_assign : 1;
1986 unsigned has_constexpr_ctor : 1;
1987 unsigned unique_obj_representations : 1;
1988 unsigned unique_obj_representations_set : 1;
1989
1990 /* When adding a flag here, consider whether or not it ought to
1991 apply to a template instance if it applies to the template. If
1992 so, make sure to copy it in instantiate_class_template! */
1993
1994 /* There are some bits left to fill out a 32-bit word. Keep track
1995 of this by updating the size of this bitfield whenever you add or
1996 remove a flag. */
1997 unsigned dummy : 4;
1998
1999 tree primary_base;
2000 vec<tree_pair_s, va_gc> *vcall_indices;
2001 tree vtables;
2002 tree typeinfo_var;
2003 vec<tree, va_gc> *vbases;
2004 binding_table nested_udts;
2005 tree as_base;
2006 vec<tree, va_gc> *pure_virtuals;
2007 tree friend_classes;
2008 vec<tree, va_gc> * GTY((reorder ("resort_type_member_vec"))) members;
2009 tree key_method;
2010 tree decl_list;
2011 tree befriending_classes;
2012 /* In a RECORD_TYPE, information specific to Objective-C++, such
2013 as a list of adopted protocols or a pointer to a corresponding
2014 @interface. See objc/objc-act.h for details. */
2015 tree objc_info;
2016 /* FIXME reuse another field? */
2017 tree lambda_expr;
2018};
2019
2020/* We used to have a variant type for lang_type. Keep the name of the
2021 checking accessor for the sole survivor. */
2022#define LANG_TYPE_CLASS_CHECK(NODE) (TYPE_LANG_SPECIFIC (NODE))
2023
2024/* Nonzero for _CLASSTYPE means that operator delete is defined. */
2025#define TYPE_GETS_DELETE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->gets_delete)
2026#define TYPE_GETS_REG_DELETE(NODE) (TYPE_GETS_DELETE (NODE) & 1)
2027
2028/* Nonzero if `new NODE[x]' should cause the allocation of extra
2029 storage to indicate how many array elements are in use. */
2030#define TYPE_VEC_NEW_USES_COOKIE(NODE) \
2031 (CLASS_TYPE_P (NODE) \
2032 && LANG_TYPE_CLASS_CHECK (NODE)->vec_new_uses_cookie)
2033
2034/* Nonzero means that this _CLASSTYPE node defines ways of converting
2035 itself to other types. */
2036#define TYPE_HAS_CONVERSION(NODE) \
2037 (LANG_TYPE_CLASS_CHECK (NODE)->has_type_conversion)
2038
2039/* Nonzero means that NODE (a class type) has a default constructor --
2040 but that it has not yet been declared. */
2041#define CLASSTYPE_LAZY_DEFAULT_CTOR(NODE) \
2042 (LANG_TYPE_CLASS_CHECK (NODE)->lazy_default_ctor)
2043
2044/* Nonzero means that NODE (a class type) has a copy constructor --
2045 but that it has not yet been declared. */
2046#define CLASSTYPE_LAZY_COPY_CTOR(NODE) \
2047 (LANG_TYPE_CLASS_CHECK (NODE)->lazy_copy_ctor)
2048
2049/* Nonzero means that NODE (a class type) has a move constructor --
2050 but that it has not yet been declared. */
2051#define CLASSTYPE_LAZY_MOVE_CTOR(NODE) \
2052 (LANG_TYPE_CLASS_CHECK (NODE)->lazy_move_ctor)
2053
2054/* Nonzero means that NODE (a class type) has an assignment operator
2055 -- but that it has not yet been declared. */
2056#define CLASSTYPE_LAZY_COPY_ASSIGN(NODE) \
2057 (LANG_TYPE_CLASS_CHECK (NODE)->lazy_copy_assign)
2058
2059/* Nonzero means that NODE (a class type) has an assignment operator
2060 -- but that it has not yet been declared. */
2061#define CLASSTYPE_LAZY_MOVE_ASSIGN(NODE) \
2062 (LANG_TYPE_CLASS_CHECK (NODE)->lazy_move_assign)
2063
2064/* Nonzero means that NODE (a class type) has a destructor -- but that
2065 it has not yet been declared. */
2066#define CLASSTYPE_LAZY_DESTRUCTOR(NODE) \
2067 (LANG_TYPE_CLASS_CHECK (NODE)->lazy_destructor)
2068
2069/* Nonzero means that NODE (a class type) is final */
2070#define CLASSTYPE_FINAL(NODE) \
2071 TYPE_FINAL_P (NODE)
2072
2073
2074/* Nonzero means that this _CLASSTYPE node overloads operator=(X&). */
2075#define TYPE_HAS_COPY_ASSIGN(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_copy_assign)
2076
2077/* True iff the class type NODE has an "operator =" whose parameter
2078 has a parameter of type "const X&". */
2079#define TYPE_HAS_CONST_COPY_ASSIGN(NODE) \
2080 (LANG_TYPE_CLASS_CHECK (NODE)->has_const_copy_assign)
2081
2082/* Nonzero means that this _CLASSTYPE node has an X(X&) constructor. */
2083#define TYPE_HAS_COPY_CTOR(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_copy_ctor)
2084#define TYPE_HAS_CONST_COPY_CTOR(NODE) \
2085 (LANG_TYPE_CLASS_CHECK (NODE)->has_const_copy_ctor)
2086
2087/* Nonzero if this class has an X(initializer_list<T>) constructor. */
2088#define TYPE_HAS_LIST_CTOR(NODE) \
2089 (LANG_TYPE_CLASS_CHECK (NODE)->has_list_ctor)
2090
2091/* Nonzero if this class has a constexpr constructor other than a copy/move
2092 constructor. Note that a class can have constexpr constructors for
2093 static initialization even if it isn't a literal class. */
2094#define TYPE_HAS_CONSTEXPR_CTOR(NODE) \
2095 (LANG_TYPE_CLASS_CHECK (NODE)->has_constexpr_ctor)
2096
2097/* Nonzero if this class defines an overloaded operator new. (An
2098 operator new [] doesn't count.) */
2099#define TYPE_HAS_NEW_OPERATOR(NODE) \
2100 (LANG_TYPE_CLASS_CHECK (NODE)->has_new)
2101
2102/* Nonzero if this class defines an overloaded operator new[]. */
2103#define TYPE_HAS_ARRAY_NEW_OPERATOR(NODE) \
2104 (LANG_TYPE_CLASS_CHECK (NODE)->has_array_new)
2105
2106/* Nonzero means that this type is being defined. I.e., the left brace
2107 starting the definition of this type has been seen. */
2108#define TYPE_BEING_DEFINED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->being_defined)
2109
2110/* Nonzero means that this type is either complete or being defined, so we
2111 can do lookup in it. */
2112#define COMPLETE_OR_OPEN_TYPE_P(NODE) \
2113 (COMPLETE_TYPE_P (NODE) || (CLASS_TYPE_P (NODE) && TYPE_BEING_DEFINED (NODE)))
2114
2115/* Mark bits for repeated base checks. */
2116#define TYPE_MARKED_P(NODE) TREE_LANG_FLAG_6 (TYPE_CHECK (NODE))
2117
2118/* Nonzero if the class NODE has multiple paths to the same (virtual)
2119 base object. */
2120#define CLASSTYPE_DIAMOND_SHAPED_P(NODE) \
2121 (LANG_TYPE_CLASS_CHECK(NODE)->diamond_shaped)
2122
2123/* Nonzero if the class NODE has multiple instances of the same base
2124 type. */
2125#define CLASSTYPE_REPEATED_BASE_P(NODE) \
2126 (LANG_TYPE_CLASS_CHECK(NODE)->repeated_base)
2127
2128/* The member function with which the vtable will be emitted:
2129 the first noninline non-pure-virtual member function. NULL_TREE
2130 if there is no key function or if this is a class template */
2131#define CLASSTYPE_KEY_METHOD(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->key_method)
2132
2133/* Vector of members. During definition, it is unordered and only
2134 member functions are present. After completion it is sorted and
2135 contains both member functions and non-functions. STAT_HACK is
2136 involved to preserve oneslot per name invariant. */
2137#define CLASSTYPE_MEMBER_VEC(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->members)
2138
2139/* For class templates, this is a TREE_LIST of all member data,
2140 functions, types, and friends in the order of declaration.
2141 The TREE_PURPOSE of each TREE_LIST is NULL_TREE for a friend,
2142 and the RECORD_TYPE for the class template otherwise. */
2143#define CLASSTYPE_DECL_LIST(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->decl_list)
2144
2145/* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These
2146 are the constructors that take an in-charge parameter. */
2147#define CLASSTYPE_CONSTRUCTORS(NODE) \
2148 (get_class_binding_direct (NODE, ctor_identifier))
2149
2150/* A FUNCTION_DECL for the destructor for NODE. This is the
2151 destructors that take an in-charge parameter. If
2152 CLASSTYPE_LAZY_DESTRUCTOR is true, then this entry will be NULL
2153 until the destructor is created with lazily_declare_fn. */
2154#define CLASSTYPE_DESTRUCTOR(NODE) \
2155 (get_class_binding_direct (NODE, dtor_identifier))
2156
2157/* A dictionary of the nested user-defined-types (class-types, or enums)
2158 found within this class. This table includes nested member class
2159 templates. */
2160#define CLASSTYPE_NESTED_UTDS(NODE) \
2161 (LANG_TYPE_CLASS_CHECK (NODE)->nested_udts)
2162
2163/* Nonzero if NODE has a primary base class, i.e., a base class with
2164 which it shares the virtual function table pointer. */
2165#define CLASSTYPE_HAS_PRIMARY_BASE_P(NODE) \
2166 (CLASSTYPE_PRIMARY_BINFO (NODE) != NULL_TREE)
2167
2168/* If non-NULL, this is the binfo for the primary base class, i.e.,
2169 the base class which contains the virtual function table pointer
2170 for this class. */
2171#define CLASSTYPE_PRIMARY_BINFO(NODE) \
2172 (LANG_TYPE_CLASS_CHECK (NODE)->primary_base)
2173
2174/* A vector of BINFOs for the direct and indirect virtual base classes
2175 that this type uses in a post-order depth-first left-to-right
2176 order. (In other words, these bases appear in the order that they
2177 should be initialized.) */
2178#define CLASSTYPE_VBASECLASSES(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->vbases)
2179
2180/* The type corresponding to NODE when NODE is used as a base class,
2181 i.e., NODE without virtual base classes or tail padding. */
2182#define CLASSTYPE_AS_BASE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->as_base)
2183
2184/* True iff NODE is the CLASSTYPE_AS_BASE version of some type. */
2185#define IS_FAKE_BASE_TYPE(NODE) \
2186 (TREE_CODE (NODE) == RECORD_TYPE \
2187 && TYPE_CONTEXT (NODE) && CLASS_TYPE_P (TYPE_CONTEXT (NODE)) \
2188 && CLASSTYPE_AS_BASE (TYPE_CONTEXT (NODE)) == (NODE))
2189
2190/* These are the size and alignment of the type without its virtual
2191 base classes, for when we use this type as a base itself. */
2192#define CLASSTYPE_SIZE(NODE) TYPE_SIZE (CLASSTYPE_AS_BASE (NODE))
2193#define CLASSTYPE_SIZE_UNIT(NODE) TYPE_SIZE_UNIT (CLASSTYPE_AS_BASE (NODE))
2194#define CLASSTYPE_ALIGN(NODE) TYPE_ALIGN (CLASSTYPE_AS_BASE (NODE))
2195#define CLASSTYPE_USER_ALIGN(NODE) TYPE_USER_ALIGN (CLASSTYPE_AS_BASE (NODE))
2196
2197/* The alignment of NODE, without its virtual bases, in bytes. */
2198#define CLASSTYPE_ALIGN_UNIT(NODE) \
2199 (CLASSTYPE_ALIGN (NODE) / BITS_PER_UNIT)
2200
2201/* A vec<tree> of virtual functions which cannot be inherited by
2202 derived classes. When deriving from this type, the derived
2203 class must provide its own definition for each of these functions. */
2204#define CLASSTYPE_PURE_VIRTUALS(NODE) \
2205 (LANG_TYPE_CLASS_CHECK (NODE)->pure_virtuals)
2206
2207/* Nonzero means that this type is an abstract class type. */
2208#define ABSTRACT_CLASS_TYPE_P(NODE) \
2209 (CLASS_TYPE_P (NODE) && CLASSTYPE_PURE_VIRTUALS(NODE))
2210
2211/* Nonzero means that this type has an X() constructor. */
2212#define TYPE_HAS_DEFAULT_CONSTRUCTOR(NODE) \
2213 (LANG_TYPE_CLASS_CHECK (NODE)->has_default_ctor)
2214
2215/* Nonzero means that this type contains a mutable member. */
2216#define CLASSTYPE_HAS_MUTABLE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_mutable)
2217#define TYPE_HAS_MUTABLE_P(NODE) (cp_has_mutable_p (NODE))
2218
2219/* Nonzero means that this class type is not POD for the purpose of layout
2220 (as defined in the ABI). This is different from the language's POD. */
2221#define CLASSTYPE_NON_LAYOUT_POD_P(NODE) \
2222 (LANG_TYPE_CLASS_CHECK (NODE)->non_pod_class)
2223
2224/* Nonzero means that this class type is a non-standard-layout class. */
2225#define CLASSTYPE_NON_STD_LAYOUT(NODE) \
2226 (LANG_TYPE_CLASS_CHECK (NODE)->non_std_layout)
2227
2228/* Nonzero means that this class type does have unique object
2229 representations. */
2230#define CLASSTYPE_UNIQUE_OBJ_REPRESENTATIONS(NODE) \
2231 (LANG_TYPE_CLASS_CHECK (NODE)->unique_obj_representations)
2232
2233/* Nonzero means that this class type has
2234 CLASSTYPE_UNIQUE_OBJ_REPRESENTATIONS computed. */
2235#define CLASSTYPE_UNIQUE_OBJ_REPRESENTATIONS_SET(NODE) \
2236 (LANG_TYPE_CLASS_CHECK (NODE)->unique_obj_representations_set)
2237
2238/* Nonzero means that this class contains pod types whose default
2239 initialization is not a zero initialization (namely, pointers to
2240 data members). */
2241#define CLASSTYPE_NON_ZERO_INIT_P(NODE) \
2242 (LANG_TYPE_CLASS_CHECK (NODE)->non_zero_init)
2243
2244/* Nonzero if this class is "empty" in the sense of the C++ ABI. */
2245#define CLASSTYPE_EMPTY_P(NODE) \
2246 (LANG_TYPE_CLASS_CHECK (NODE)->empty_p)
2247
2248/* Nonzero if this class is "nearly empty", i.e., contains only a
2249 virtual function table pointer. */
2250#define CLASSTYPE_NEARLY_EMPTY_P(NODE) \
2251 (LANG_TYPE_CLASS_CHECK (NODE)->nearly_empty_p)
2252
2253/* Nonzero if this class contains an empty subobject. */
2254#define CLASSTYPE_CONTAINS_EMPTY_CLASS_P(NODE) \
2255 (LANG_TYPE_CLASS_CHECK (NODE)->contains_empty_class_p)
2256
2257/* A list of class types of which this type is a friend. The
2258 TREE_VALUE is normally a TYPE, but will be a TEMPLATE_DECL in the
2259 case of a template friend. */
2260#define CLASSTYPE_FRIEND_CLASSES(NODE) \
2261 (LANG_TYPE_CLASS_CHECK (NODE)->friend_classes)
2262
2263/* A list of the classes which grant friendship to this class. */
2264#define CLASSTYPE_BEFRIENDING_CLASSES(NODE) \
2265 (LANG_TYPE_CLASS_CHECK (NODE)->befriending_classes)
2266
2267/* The associated LAMBDA_EXPR that made this class. */
2268#define CLASSTYPE_LAMBDA_EXPR(NODE) \
2269 (LANG_TYPE_CLASS_CHECK (NODE)->lambda_expr)
2270/* The extra mangling scope for this closure type. */
2271#define LAMBDA_TYPE_EXTRA_SCOPE(NODE) \
2272 (LAMBDA_EXPR_EXTRA_SCOPE (CLASSTYPE_LAMBDA_EXPR (NODE)))
2273
2274/* Say whether this node was declared as a "class" or a "struct". */
2275#define CLASSTYPE_DECLARED_CLASS(NODE) \
2276 (LANG_TYPE_CLASS_CHECK (NODE)->declared_class)
2277
2278/* Nonzero if this class has const members
2279 which have no specified initialization. */
2280#define CLASSTYPE_READONLY_FIELDS_NEED_INIT(NODE) \
2281 (TYPE_LANG_SPECIFIC (NODE) \
2282 ? LANG_TYPE_CLASS_CHECK (NODE)->const_needs_init : 0)
2283#define SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT(NODE, VALUE) \
2284 (LANG_TYPE_CLASS_CHECK (NODE)->const_needs_init = (VALUE))
2285
2286/* Nonzero if this class has ref members
2287 which have no specified initialization. */
2288#define CLASSTYPE_REF_FIELDS_NEED_INIT(NODE) \
2289 (TYPE_LANG_SPECIFIC (NODE) \
2290 ? LANG_TYPE_CLASS_CHECK (NODE)->ref_needs_init : 0)
2291#define SET_CLASSTYPE_REF_FIELDS_NEED_INIT(NODE, VALUE) \
2292 (LANG_TYPE_CLASS_CHECK (NODE)->ref_needs_init = (VALUE))
2293
2294/* Nonzero if this class is included from a header file which employs
2295 `#pragma interface', and it is not included in its implementation file. */
2296#define CLASSTYPE_INTERFACE_ONLY(NODE) \
2297 (LANG_TYPE_CLASS_CHECK (NODE)->interface_only)
2298
2299/* True if we have already determined whether or not vtables, VTTs,
2300 typeinfo, and other similar per-class data should be emitted in
2301 this translation unit. This flag does not indicate whether or not
2302 these items should be emitted; it only indicates that we know one
2303 way or the other. */
2304#define CLASSTYPE_INTERFACE_KNOWN(NODE) \
2305 (LANG_TYPE_CLASS_CHECK (NODE)->interface_unknown == 0)
2306/* The opposite of CLASSTYPE_INTERFACE_KNOWN. */
2307#define CLASSTYPE_INTERFACE_UNKNOWN(NODE) \
2308 (LANG_TYPE_CLASS_CHECK (NODE)->interface_unknown)
2309
2310#define SET_CLASSTYPE_INTERFACE_UNKNOWN_X(NODE,X) \
2311 (LANG_TYPE_CLASS_CHECK (NODE)->interface_unknown = !!(X))
2312#define SET_CLASSTYPE_INTERFACE_UNKNOWN(NODE) \
2313 (LANG_TYPE_CLASS_CHECK (NODE)->interface_unknown = 1)
2314#define SET_CLASSTYPE_INTERFACE_KNOWN(NODE) \
2315 (LANG_TYPE_CLASS_CHECK (NODE)->interface_unknown = 0)
2316
2317/* Nonzero if a _DECL node requires us to output debug info for this class. */
2318#define CLASSTYPE_DEBUG_REQUESTED(NODE) \
2319 (LANG_TYPE_CLASS_CHECK (NODE)->debug_requested)
2320
2321/* Additional macros for inheritance information. */
2322
2323/* Nonzero means that this class is on a path leading to a new vtable. */
2324#define BINFO_VTABLE_PATH_MARKED(NODE) BINFO_FLAG_1 (NODE)
2325
2326/* Nonzero means B (a BINFO) has its own vtable. Any copies will not
2327 have this flag set. */
2328#define BINFO_NEW_VTABLE_MARKED(B) (BINFO_FLAG_2 (B))
2329
2330/* Compare a BINFO_TYPE with another type for equality. For a binfo,
2331 this is functionally equivalent to using same_type_p, but
2332 measurably faster. At least one of the arguments must be a
2333 BINFO_TYPE. The other can be a BINFO_TYPE or a regular type. If
2334 BINFO_TYPE(T) ever stops being the main variant of the class the
2335 binfo is for, this macro must change. */
2336#define SAME_BINFO_TYPE_P(A, B) ((A) == (B))
2337
2338/* Any subobject that needs a new vtable must have a vptr and must not
2339 be a non-virtual primary base (since it would then use the vtable from a
2340 derived class and never become non-primary.) */
2341#define SET_BINFO_NEW_VTABLE_MARKED(B) \
2342 (BINFO_NEW_VTABLE_MARKED (B) = 1, \
2343 gcc_assert (!BINFO_PRIMARY_P (B) || BINFO_VIRTUAL_P (B)), \
2344 gcc_assert (TYPE_VFIELD (BINFO_TYPE (B))))
2345
2346/* Nonzero if this binfo is for a dependent base - one that should not
2347 be searched. */
2348#define BINFO_DEPENDENT_BASE_P(NODE) BINFO_FLAG_3 (NODE)
2349
2350/* Nonzero if this binfo has lost its primary base binfo (because that
2351 is a nearly-empty virtual base that has been taken by some other
2352 base in the complete hierarchy. */
2353#define BINFO_LOST_PRIMARY_P(NODE) BINFO_FLAG_4 (NODE)
2354
2355/* Nonzero if this BINFO is a primary base class. */
2356#define BINFO_PRIMARY_P(NODE) BINFO_FLAG_5(NODE)
2357
2358/* A vec<tree_pair_s> of the vcall indices associated with the class
2359 NODE. The PURPOSE of each element is a FUNCTION_DECL for a virtual
2360 function. The VALUE is the index into the virtual table where the
2361 vcall offset for that function is stored, when NODE is a virtual
2362 base. */
2363#define CLASSTYPE_VCALL_INDICES(NODE) \
2364 (LANG_TYPE_CLASS_CHECK (NODE)->vcall_indices)
2365
2366/* The various vtables for the class NODE. The primary vtable will be
2367 first, followed by the construction vtables and VTT, if any. */
2368#define CLASSTYPE_VTABLES(NODE) \
2369 (LANG_TYPE_CLASS_CHECK (NODE)->vtables)
2370
2371/* The std::type_info variable representing this class, or NULL if no
2372 such variable has been created. This field is only set for the
2373 TYPE_MAIN_VARIANT of the class. */
2374#define CLASSTYPE_TYPEINFO_VAR(NODE) \
2375 (LANG_TYPE_CLASS_CHECK (NODE)->typeinfo_var)
2376
2377/* Accessor macros for the BINFO_VIRTUALS list. */
2378
2379/* The number of bytes by which to adjust the `this' pointer when
2380 calling this virtual function. Subtract this value from the this
2381 pointer. Always non-NULL, might be constant zero though. */
2382#define BV_DELTA(NODE) (TREE_PURPOSE (NODE))
2383
2384/* If non-NULL, the vtable index at which to find the vcall offset
2385 when calling this virtual function. Add the value at that vtable
2386 index to the this pointer. */
2387#define BV_VCALL_INDEX(NODE) (TREE_TYPE (NODE))
2388
2389/* The function to call. */
2390#define BV_FN(NODE) (TREE_VALUE (NODE))
2391
2392/* Whether or not this entry is for a lost primary virtual base. */
2393#define BV_LOST_PRIMARY(NODE) (TREE_LANG_FLAG_0 (NODE))
2394
2395/* For FUNCTION_TYPE or METHOD_TYPE, a list of the exceptions that
2396 this type can raise. Each TREE_VALUE is a _TYPE. The TREE_VALUE
2397 will be NULL_TREE to indicate a throw specification of `()', or
2398 no exceptions allowed. For a noexcept specification, TREE_VALUE
2399 is NULL_TREE and TREE_PURPOSE is the constant-expression. For
2400 a deferred noexcept-specification, TREE_PURPOSE is a DEFERRED_NOEXCEPT
2401 (for templates) or an OVERLOAD list of functions (for implicitly
2402 declared functions). */
2403#define TYPE_RAISES_EXCEPTIONS(NODE) \
2404 TYPE_LANG_SLOT_1 (FUNC_OR_METHOD_CHECK (NODE))
2405
2406/* For FUNCTION_TYPE or METHOD_TYPE, return 1 iff it is declared `throw()'
2407 or noexcept(true). */
2408#define TYPE_NOTHROW_P(NODE) nothrow_spec_p (TYPE_RAISES_EXCEPTIONS (NODE))
2409
2410/* For FUNCTION_TYPE or METHOD_TYPE, true if NODE is noexcept. This is the
2411 case for things declared noexcept(true) and, with -fnothrow-opt, for
2412 throw() functions. */
2413#define TYPE_NOEXCEPT_P(NODE) type_noexcept_p (NODE)
2414
2415/* The binding level associated with the namespace. */
2416#define NAMESPACE_LEVEL(NODE) \
2417 (LANG_DECL_NS_CHECK (NODE)->level)
2418
2419/* Discriminator values for lang_decl. */
2420
2421enum lang_decl_selector
2422{
2423 lds_min,
2424 lds_fn,
2425 lds_ns,
2426 lds_parm,
2427 lds_decomp
2428};
2429
2430/* Flags shared by all forms of DECL_LANG_SPECIFIC.
2431
2432 Some of the flags live here only to make lang_decl_min/fn smaller. Do
2433 not make this struct larger than 32 bits; instead, make sel smaller. */
2434
2435struct GTY(()) lang_decl_base {
2436 /* Larger than necessary for faster access. */
2437 ENUM_BITFIELD(lang_decl_selector) selector : 16;
2438 ENUM_BITFIELD(languages) language : 1;
2439 unsigned use_template : 2;
2440 unsigned not_really_extern : 1; /* var or fn */
2441 unsigned initialized_in_class : 1; /* var or fn */
2442 unsigned repo_available_p : 1; /* var or fn */
2443 unsigned threadprivate_or_deleted_p : 1; /* var or fn */
2444 unsigned anticipated_p : 1; /* fn, type or template */
2445 /* anticipated_p reused as DECL_OMP_PRIVATIZED_MEMBER in var */
2446 unsigned friend_or_tls : 1; /* var, fn, type or template */
2447 unsigned unknown_bound_p : 1; /* var */
2448 unsigned odr_used : 1; /* var or fn */
2449 unsigned u2sel : 1;
2450 unsigned concept_p : 1; /* applies to vars and functions */
2451 unsigned var_declared_inline_p : 1; /* var */
2452 unsigned dependent_init_p : 1; /* var */
2453 /* 1 spare bit */
2454};
2455
2456/* True for DECL codes which have template info and access. */
2457#define LANG_DECL_HAS_MIN(NODE) \
2458 (VAR_OR_FUNCTION_DECL_P (NODE) \
2459 || TREE_CODE (NODE) == FIELD_DECL \
2460 || TREE_CODE (NODE) == CONST_DECL \
2461 || TREE_CODE (NODE) == TYPE_DECL \
2462 || TREE_CODE (NODE) == TEMPLATE_DECL \
2463 || TREE_CODE (NODE) == USING_DECL)
2464
2465/* DECL_LANG_SPECIFIC for the above codes. */
2466
2467struct GTY(()) lang_decl_min {
2468 struct lang_decl_base base;
2469
2470 /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
2471 THUNK_ALIAS.
2472 In a FUNCTION_DECL for which DECL_THUNK_P does not hold,
2473 VAR_DECL, TYPE_DECL, or TEMPLATE_DECL, this is
2474 DECL_TEMPLATE_INFO. */
2475 tree template_info;
2476
2477 union lang_decl_u2 {
2478 /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
2479 THUNK_VIRTUAL_OFFSET.
2480 In a VAR_DECL for which DECL_HAS_VALUE_EXPR_P holds,
2481 this is DECL_CAPTURED_VARIABLE.
2482 Otherwise this is DECL_ACCESS. */
2483 tree GTY ((tag ("0"))) access;
2484
2485 /* For TREE_STATIC VAR_DECL in function, this is DECL_DISCRIMINATOR. */
2486 int GTY ((tag ("1"))) discriminator;
2487 } GTY ((desc ("%0.u.base.u2sel"))) u2;
2488};
2489
2490/* Additional DECL_LANG_SPECIFIC information for functions. */
2491
2492struct GTY(()) lang_decl_fn {
2493 struct lang_decl_min min;
2494
2495 /* In a overloaded operator, this is the compressed operator code. */
2496 unsigned ovl_op_code : 6;
2497 unsigned global_ctor_p : 1;
2498 unsigned global_dtor_p : 1;
2499
2500 unsigned static_function : 1;
2501 unsigned pure_virtual : 1;
2502 unsigned defaulted_p : 1;
2503 unsigned has_in_charge_parm_p : 1;
2504 unsigned has_vtt_parm_p : 1;
2505 unsigned pending_inline_p : 1;
2506 unsigned nonconverting : 1;
2507 unsigned thunk_p : 1;
2508
2509 unsigned this_thunk_p : 1;
2510 unsigned hidden_friend_p : 1;
2511 unsigned omp_declare_reduction_p : 1;
2512 unsigned spare : 13;
2513
2514 /* 32-bits padding on 64-bit host. */
2515
2516 /* For a non-thunk function decl, this is a tree list of
2517 friendly classes. For a thunk function decl, it is the
2518 thunked to function decl. */
2519 tree befriending_classes;
2520
2521 /* For a non-virtual FUNCTION_DECL, this is
2522 DECL_FRIEND_CONTEXT. For a virtual FUNCTION_DECL for which
2523 DECL_THIS_THUNK_P does not hold, this is DECL_THUNKS. Both
2524 this pointer and result pointer adjusting thunks are
2525 chained here. This pointer thunks to return pointer thunks
2526 will be chained on the return pointer thunk. */
2527 tree context;
2528
2529 union lang_decl_u5
2530 {
2531 /* In a non-thunk FUNCTION_DECL or TEMPLATE_DECL, this is
2532 DECL_CLONED_FUNCTION. */
2533 tree GTY ((tag ("0"))) cloned_function;
2534
2535 /* In a FUNCTION_DECL for which THUNK_P holds this is the
2536 THUNK_FIXED_OFFSET. */
2537 HOST_WIDE_INT GTY ((tag ("1"))) fixed_offset;
2538 } GTY ((desc ("%1.thunk_p"))) u5;
2539
2540 union lang_decl_u3
2541 {
2542 struct cp_token_cache * GTY ((tag ("1"))) pending_inline_info;
2543 struct language_function * GTY ((tag ("0")))
2544 saved_language_function;
2545 } GTY ((desc ("%1.pending_inline_p"))) u;
2546
2547};
2548
2549/* DECL_LANG_SPECIFIC for namespaces. */
2550
2551struct GTY(()) lang_decl_ns {
2552 struct lang_decl_base base;
2553 cp_binding_level *level;
2554
2555 /* using directives and inline children. These need to be va_gc,
2556 because of PCH. */
2557 vec<tree, va_gc> *usings;
2558 vec<tree, va_gc> *inlinees;
2559
2560 /* Hash table of bound decls. It'd be nice to have this inline, but
2561 as the hash_map has a dtor, we can't then put this struct into a
2562 union (until moving to c++11). */
2563 hash_table<named_decl_hash> *bindings;
2564};
2565
2566/* DECL_LANG_SPECIFIC for parameters. */
2567
2568struct GTY(()) lang_decl_parm {
2569 struct lang_decl_base base;
2570 int level;
2571 int index;
2572};
2573
2574/* Additional DECL_LANG_SPECIFIC information for structured bindings. */
2575
2576struct GTY(()) lang_decl_decomp {
2577 struct lang_decl_min min;
2578 /* The artificial underlying "e" variable of the structured binding
2579 variable. */
2580 tree base;
2581};
2582
2583/* DECL_LANG_SPECIFIC for all types. It would be nice to just make this a
2584 union rather than a struct containing a union as its only field, but
2585 tree.h declares it as a struct. */
2586
2587struct GTY(()) lang_decl {
2588 union GTY((desc ("%h.base.selector"))) lang_decl_u {
2589 /* Nothing of only the base type exists. */
2590 struct lang_decl_base GTY ((default)) base;
2591 struct lang_decl_min GTY((tag ("lds_min"))) min;
2592 struct lang_decl_fn GTY ((tag ("lds_fn"))) fn;
2593 struct lang_decl_ns GTY((tag ("lds_ns"))) ns;
2594 struct lang_decl_parm GTY((tag ("lds_parm"))) parm;
2595 struct lang_decl_decomp GTY((tag ("lds_decomp"))) decomp;
2596 } u;
2597};
2598
2599/* Looks through a template (if present) to find what it declares. */
2600#define STRIP_TEMPLATE(NODE) \
2601 (TREE_CODE (NODE) == TEMPLATE_DECL ? DECL_TEMPLATE_RESULT (NODE) : NODE)
2602
2603#if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
2604
2605#define LANG_DECL_MIN_CHECK(NODE) __extension__ \
2606({ struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
2607 if (!LANG_DECL_HAS_MIN (NODE)) \
2608 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
2609 &lt->u.min; })
2610
2611/* We want to be able to check DECL_CONSTRUCTOR_P and such on a function
2612 template, not just on a FUNCTION_DECL. So when looking for things in
2613 lang_decl_fn, look down through a TEMPLATE_DECL into its result. */
2614#define LANG_DECL_FN_CHECK(NODE) __extension__ \
2615({ struct lang_decl *lt = DECL_LANG_SPECIFIC (STRIP_TEMPLATE (NODE)); \
2616 if (!DECL_DECLARES_FUNCTION_P (NODE) \
2617 || lt->u.base.selector != lds_fn) \
2618 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
2619 &lt->u.fn; })
2620
2621#define LANG_DECL_NS_CHECK(NODE) __extension__ \
2622({ struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
2623 if (TREE_CODE (NODE) != NAMESPACE_DECL \
2624 || lt->u.base.selector != lds_ns) \
2625 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
2626 &lt->u.ns; })
2627
2628#define LANG_DECL_PARM_CHECK(NODE) __extension__ \
2629({ struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
2630 if (TREE_CODE (NODE) != PARM_DECL \
2631 || lt->u.base.selector != lds_parm) \
2632 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
2633 &lt->u.parm; })
2634
2635#define LANG_DECL_DECOMP_CHECK(NODE) __extension__ \
2636({ struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
2637 if (!VAR_P (NODE) \
2638 || lt->u.base.selector != lds_decomp) \
2639 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
2640 &lt->u.decomp; })
2641
2642#define LANG_DECL_U2_CHECK(NODE, TF) __extension__ \
2643({ struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE); \
2644 if (!LANG_DECL_HAS_MIN (NODE) || lt->u.base.u2sel != TF) \
2645 lang_check_failed (__FILE__, __LINE__, __FUNCTION__); \
2646 &lt->u.min.u2; })
2647
2648#else
2649
2650#define LANG_DECL_MIN_CHECK(NODE) \
2651 (&DECL_LANG_SPECIFIC (NODE)->u.min)
2652
2653#define LANG_DECL_FN_CHECK(NODE) \
2654 (&DECL_LANG_SPECIFIC (STRIP_TEMPLATE (NODE))->u.fn)
2655
2656#define LANG_DECL_NS_CHECK(NODE) \
2657 (&DECL_LANG_SPECIFIC (NODE)->u.ns)
2658
2659#define LANG_DECL_PARM_CHECK(NODE) \
2660 (&DECL_LANG_SPECIFIC (NODE)->u.parm)
2661
2662#define LANG_DECL_DECOMP_CHECK(NODE) \
2663 (&DECL_LANG_SPECIFIC (NODE)->u.decomp)
2664
2665#define LANG_DECL_U2_CHECK(NODE, TF) \
2666 (&DECL_LANG_SPECIFIC (NODE)->u.min.u2)
2667
2668#endif /* ENABLE_TREE_CHECKING */
2669
2670/* For a FUNCTION_DECL or a VAR_DECL, the language linkage for the
2671 declaration. Some entities (like a member function in a local
2672 class, or a local variable) do not have linkage at all, and this
2673 macro should not be used in those cases.
2674
2675 Implementation note: A FUNCTION_DECL without DECL_LANG_SPECIFIC was
2676 created by language-independent code, and has C linkage. Most
2677 VAR_DECLs have C++ linkage, and do not have DECL_LANG_SPECIFIC, but
2678 we do create DECL_LANG_SPECIFIC for variables with non-C++ linkage. */
2679#define DECL_LANGUAGE(NODE) \
2680 (DECL_LANG_SPECIFIC (NODE) \
2681 ? DECL_LANG_SPECIFIC (NODE)->u.base.language \
2682 : (TREE_CODE (NODE) == FUNCTION_DECL \
2683 ? lang_c : lang_cplusplus))
2684
2685/* Set the language linkage for NODE to LANGUAGE. */
2686#define SET_DECL_LANGUAGE(NODE, LANGUAGE) \
2687 (DECL_LANG_SPECIFIC (NODE)->u.base.language = (LANGUAGE))
2688
2689/* For FUNCTION_DECLs and TEMPLATE_DECLs: nonzero means that this function
2690 is a constructor. */
2691#define DECL_CONSTRUCTOR_P(NODE) \
2692 IDENTIFIER_CTOR_P (DECL_NAME (NODE))
2693
2694/* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a complete
2695 object. */
2696#define DECL_COMPLETE_CONSTRUCTOR_P(NODE) \
2697 (DECL_NAME (NODE) == complete_ctor_identifier)
2698
2699/* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a base
2700 object. */
2701#define DECL_BASE_CONSTRUCTOR_P(NODE) \
2702 (DECL_NAME (NODE) == base_ctor_identifier)
2703
2704/* Nonzero if NODE (a FUNCTION_DECL) is a constructor, but not either the
2705 specialized in-charge constructor or the specialized not-in-charge
2706 constructor. */
2707#define DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P(NODE) \
2708 (DECL_NAME (NODE) == ctor_identifier)
2709
2710/* Nonzero if NODE (a FUNCTION_DECL) is a copy constructor. */
2711#define DECL_COPY_CONSTRUCTOR_P(NODE) \
2712 (DECL_CONSTRUCTOR_P (NODE) && copy_fn_p (NODE) > 0)
2713
2714/* Nonzero if NODE (a FUNCTION_DECL) is a move constructor. */
2715#define DECL_MOVE_CONSTRUCTOR_P(NODE) \
2716 (DECL_CONSTRUCTOR_P (NODE) && move_fn_p (NODE))
2717
2718/* Nonzero if NODE (a FUNCTION_DECL or TEMPLATE_DECL)
2719 is a destructor. */
2720#define DECL_DESTRUCTOR_P(NODE) \
2721 IDENTIFIER_DTOR_P (DECL_NAME (NODE))
2722
2723/* Nonzero if NODE (a FUNCTION_DECL) is a destructor, but not the
2724 specialized in-charge constructor, in-charge deleting constructor,
2725 or the base destructor. */
2726#define DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P(NODE) \
2727 (DECL_NAME (NODE) == dtor_identifier)
2728
2729/* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete
2730 object. */
2731#define DECL_COMPLETE_DESTRUCTOR_P(NODE) \
2732 (DECL_NAME (NODE) == complete_dtor_identifier)
2733
2734/* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a base
2735 object. */
2736#define DECL_BASE_DESTRUCTOR_P(NODE) \
2737 (DECL_NAME (NODE) == base_dtor_identifier)
2738
2739/* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete
2740 object that deletes the object after it has been destroyed. */
2741#define DECL_DELETING_DESTRUCTOR_P(NODE) \
2742 (DECL_NAME (NODE) == deleting_dtor_identifier)
2743
2744/* Nonzero if NODE (a FUNCTION_DECL) is a cloned constructor or
2745 destructor. */
2746#define DECL_CLONED_FUNCTION_P(NODE) (!!decl_cloned_function_p (NODE, true))
2747
2748/* If DECL_CLONED_FUNCTION_P holds, this is the function that was
2749 cloned. */
2750#define DECL_CLONED_FUNCTION(NODE) (*decl_cloned_function_p (NODE, false))
2751
2752/* Perform an action for each clone of FN, if FN is a function with
2753 clones. This macro should be used like:
2754
2755 FOR_EACH_CLONE (clone, fn)
2756 { ... }
2757
2758 */
2759#define FOR_EACH_CLONE(CLONE, FN) \
2760 if (!(TREE_CODE (FN) == FUNCTION_DECL \
2761 && (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (FN) \
2762 || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (FN))))\
2763 ; \
2764 else \
2765 for (CLONE = DECL_CHAIN (FN); \
2766 CLONE && DECL_CLONED_FUNCTION_P (CLONE); \
2767 CLONE = DECL_CHAIN (CLONE))
2768
2769/* Nonzero if NODE has DECL_DISCRIMINATOR and not DECL_ACCESS. */
2770#define DECL_DISCRIMINATOR_P(NODE) \
2771 (VAR_P (NODE) && DECL_FUNCTION_SCOPE_P (NODE))
2772
2773/* Discriminator for name mangling. */
2774#define DECL_DISCRIMINATOR(NODE) (LANG_DECL_U2_CHECK (NODE, 1)->discriminator)
2775
2776/* True iff DECL_DISCRIMINATOR is set for a DECL_DISCRIMINATOR_P decl. */
2777#define DECL_DISCRIMINATOR_SET_P(NODE) \
2778 (DECL_LANG_SPECIFIC (NODE) && DECL_LANG_SPECIFIC (NODE)->u.base.u2sel == 1)
2779
2780/* The index of a user-declared parameter in its function, starting at 1.
2781 All artificial parameters will have index 0. */
2782#define DECL_PARM_INDEX(NODE) \
2783 (LANG_DECL_PARM_CHECK (NODE)->index)
2784
2785/* The level of a user-declared parameter in its function, starting at 1.
2786 A parameter of the function will have level 1; a parameter of the first
2787 nested function declarator (i.e. t in void f (void (*p)(T t))) will have
2788 level 2. */
2789#define DECL_PARM_LEVEL(NODE) \
2790 (LANG_DECL_PARM_CHECK (NODE)->level)
2791
2792/* Nonzero if the VTT parm has been added to NODE. */
2793#define DECL_HAS_VTT_PARM_P(NODE) \
2794 (LANG_DECL_FN_CHECK (NODE)->has_vtt_parm_p)
2795
2796/* Nonzero if NODE is a FUNCTION_DECL for which a VTT parameter is
2797 required. */
2798#define DECL_NEEDS_VTT_PARM_P(NODE) \
2799 (CLASSTYPE_VBASECLASSES (DECL_CONTEXT (NODE)) \
2800 && (DECL_BASE_CONSTRUCTOR_P (NODE) \
2801 || DECL_BASE_DESTRUCTOR_P (NODE)))
2802
2803/* Nonzero if NODE is a user-defined conversion operator. */
2804#define DECL_CONV_FN_P(NODE) IDENTIFIER_CONV_OP_P (DECL_NAME (NODE))
2805
2806/* The type to which conversion operator FN converts to. */
2807#define DECL_CONV_FN_TYPE(FN) \
2808 TREE_TYPE ((gcc_checking_assert (DECL_CONV_FN_P (FN)), DECL_NAME (FN)))
2809
2810/* Nonzero if NODE, a static data member, was declared in its class as an
2811 array of unknown bound. */
2812#define VAR_HAD_UNKNOWN_BOUND(NODE) \
2813 (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE)) \
2814 ? DECL_LANG_SPECIFIC (NODE)->u.base.unknown_bound_p \
2815 : false)
2816#define SET_VAR_HAD_UNKNOWN_BOUND(NODE) \
2817 (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE))->u.base.unknown_bound_p = true)
2818
2819/* True iff decl NODE is for an overloaded operator. */
2820#define DECL_OVERLOADED_OPERATOR_P(NODE) \
2821 IDENTIFIER_ANY_OP_P (DECL_NAME (NODE))
2822
2823/* Nonzero if NODE is an assignment operator (including += and such). */
2824#define DECL_ASSIGNMENT_OPERATOR_P(NODE) \
2825 IDENTIFIER_ASSIGN_OP_P (DECL_NAME (NODE))
2826
2827/* NODE is a function_decl for an overloaded operator. Return its
2828 compressed (raw) operator code. Note that this is not a TREE_CODE. */
2829#define DECL_OVERLOADED_OPERATOR_CODE_RAW(NODE) \
2830 (LANG_DECL_FN_CHECK (NODE)->ovl_op_code)
2831
2832/* DECL is an overloaded operator. Test whether it is for TREE_CODE
2833 (a literal constant). */
2834#define DECL_OVERLOADED_OPERATOR_IS(DECL, CODE) \
2835 (DECL_OVERLOADED_OPERATOR_CODE_RAW (DECL) == OVL_OP_##CODE)
2836
2837/* For FUNCTION_DECLs: nonzero means that this function is a
2838 constructor or a destructor with an extra in-charge parameter to
2839 control whether or not virtual bases are constructed. */
2840#define DECL_HAS_IN_CHARGE_PARM_P(NODE) \
2841 (LANG_DECL_FN_CHECK (NODE)->has_in_charge_parm_p)
2842
2843/* Nonzero if DECL is a declaration of __builtin_constant_p. */
2844#define DECL_IS_BUILTIN_CONSTANT_P(NODE) \
2845 (TREE_CODE (NODE) == FUNCTION_DECL \
2846 && DECL_BUILT_IN_CLASS (NODE) == BUILT_IN_NORMAL \
2847 && DECL_FUNCTION_CODE (NODE) == BUILT_IN_CONSTANT_P)
2848
2849/* Nonzero for _DECL means that this decl appears in (or will appear
2850 in) as a member in a RECORD_TYPE or UNION_TYPE node. It is also for
2851 detecting circularity in case members are multiply defined. In the
2852 case of a VAR_DECL, it is also used to determine how program storage
2853 should be allocated. */
2854#define DECL_IN_AGGR_P(NODE) (DECL_LANG_FLAG_3 (NODE))
2855
2856/* Nonzero for a VAR_DECL means that the variable's initialization (if
2857 any) has been processed. (In general, DECL_INITIALIZED_P is
2858 !DECL_EXTERNAL, but static data members may be initialized even if
2859 not defined.) */
2860#define DECL_INITIALIZED_P(NODE) \
2861 (TREE_LANG_FLAG_1 (VAR_DECL_CHECK (NODE)))
2862
2863/* Nonzero for a VAR_DECL iff an explicit initializer was provided
2864 or a non-trivial constructor is called. */
2865#define DECL_NONTRIVIALLY_INITIALIZED_P(NODE) \
2866 (TREE_LANG_FLAG_3 (VAR_DECL_CHECK (NODE)))
2867
2868/* Nonzero for a VAR_DECL that was initialized with a
2869 constant-expression. */
2870#define DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P(NODE) \
2871 (TREE_LANG_FLAG_2 (VAR_DECL_CHECK (NODE)))
2872
2873/* Nonzero if the DECL was initialized in the class definition itself,
2874 rather than outside the class. This is used for both static member
2875 VAR_DECLS, and FUNCTION_DECLS that are defined in the class. */
2876#define DECL_INITIALIZED_IN_CLASS_P(DECL) \
2877 (DECL_LANG_SPECIFIC (VAR_OR_FUNCTION_DECL_CHECK (DECL)) \
2878 ->u.base.initialized_in_class)
2879
2880/* Nonzero if the DECL is used in the sense of 3.2 [basic.def.odr].
2881 Only available for decls with DECL_LANG_SPECIFIC. */
2882#define DECL_ODR_USED(DECL) \
2883 (DECL_LANG_SPECIFIC (VAR_OR_FUNCTION_DECL_CHECK (DECL)) \
2884 ->u.base.odr_used)
2885
2886/* Nonzero for DECL means that this decl is just a friend declaration,
2887 and should not be added to the list of members for this class. */
2888#define DECL_FRIEND_P(NODE) \
2889 (DECL_LANG_SPECIFIC (TYPE_FUNCTION_OR_TEMPLATE_DECL_CHECK (NODE)) \
2890 ->u.base.friend_or_tls)
2891
2892/* Nonzero if the thread-local variable was declared with __thread as
2893 opposed to thread_local. */
2894#define DECL_GNU_TLS_P(NODE) \
2895 (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE)) \
2896 && DECL_LANG_SPECIFIC (NODE)->u.base.friend_or_tls)
2897#define SET_DECL_GNU_TLS_P(NODE) \
2898 (retrofit_lang_decl (VAR_DECL_CHECK (NODE)), \
2899 DECL_LANG_SPECIFIC (NODE)->u.base.friend_or_tls = true)
2900
2901/* A TREE_LIST of the types which have befriended this FUNCTION_DECL. */
2902#define DECL_BEFRIENDING_CLASSES(NODE) \
2903 (LANG_DECL_FN_CHECK (NODE)->befriending_classes)
2904
2905/* Nonzero for FUNCTION_DECL means that this decl is a static
2906 member function. */
2907#define DECL_STATIC_FUNCTION_P(NODE) \
2908 (LANG_DECL_FN_CHECK (NODE)->static_function)
2909
2910/* Nonzero for FUNCTION_DECL means that this decl is a non-static
2911 member function. */
2912#define DECL_NONSTATIC_MEMBER_FUNCTION_P(NODE) \
2913 (TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE)
2914
2915/* Nonzero for FUNCTION_DECL means that this decl is a member function
2916 (static or non-static). */
2917#define DECL_FUNCTION_MEMBER_P(NODE) \
2918 (DECL_NONSTATIC_MEMBER_FUNCTION_P (NODE) || DECL_STATIC_FUNCTION_P (NODE))
2919
2920/* Nonzero for FUNCTION_DECL means that this member function
2921 has `this' as const X *const. */
2922#define DECL_CONST_MEMFUNC_P(NODE) \
2923 (DECL_NONSTATIC_MEMBER_FUNCTION_P (NODE) \
2924 && CP_TYPE_CONST_P (TREE_TYPE (TREE_VALUE \
2925 (TYPE_ARG_TYPES (TREE_TYPE (NODE))))))
2926
2927/* Nonzero for FUNCTION_DECL means that this member function
2928 has `this' as volatile X *const. */
2929#define DECL_VOLATILE_MEMFUNC_P(NODE) \
2930 (DECL_NONSTATIC_MEMBER_FUNCTION_P (NODE) \
2931 && CP_TYPE_VOLATILE_P (TREE_TYPE (TREE_VALUE \
2932 (TYPE_ARG_TYPES (TREE_TYPE (NODE))))))
2933
2934/* Nonzero for a DECL means that this member is a non-static member. */
2935#define DECL_NONSTATIC_MEMBER_P(NODE) \
2936 (DECL_NONSTATIC_MEMBER_FUNCTION_P (NODE) \
2937 || TREE_CODE (NODE) == FIELD_DECL)
2938
2939/* Nonzero for _DECL means that this member object type
2940 is mutable. */
2941#define DECL_MUTABLE_P(NODE) (DECL_LANG_FLAG_0 (NODE))
2942
2943/* Nonzero for _DECL means that this constructor or conversion function is
2944 non-converting. */
2945#define DECL_NONCONVERTING_P(NODE) \
2946 (LANG_DECL_FN_CHECK (NODE)->nonconverting)
2947
2948/* Nonzero for FUNCTION_DECL means that this member function is a pure
2949 virtual function. */
2950#define DECL_PURE_VIRTUAL_P(NODE) \
2951 (LANG_DECL_FN_CHECK (NODE)->pure_virtual)
2952
2953/* True (in a FUNCTION_DECL) if NODE is a virtual function that is an
2954 invalid overrider for a function from a base class. Once we have
2955 complained about an invalid overrider we avoid complaining about it
2956 again. */
2957#define DECL_INVALID_OVERRIDER_P(NODE) \
2958 (DECL_LANG_FLAG_4 (NODE))
2959
2960/* True (in a FUNCTION_DECL) if NODE is a function declared with
2961 an override virt-specifier */
2962#define DECL_OVERRIDE_P(NODE) (TREE_LANG_FLAG_0 (NODE))
2963
2964/* The thunks associated with NODE, a FUNCTION_DECL. */
2965#define DECL_THUNKS(NODE) \
2966 (DECL_VIRTUAL_P (NODE) ? LANG_DECL_FN_CHECK (NODE)->context : NULL_TREE)
2967
2968/* Set DECL_THUNKS. */
2969#define SET_DECL_THUNKS(NODE,THUNKS) \
2970 (LANG_DECL_FN_CHECK (NODE)->context = (THUNKS))
2971
2972/* If NODE, a FUNCTION_DECL, is a C++11 inheriting constructor, then this
2973 is the constructor it inherits from. */
2974#define DECL_INHERITED_CTOR(NODE) \
2975 (DECL_DECLARES_FUNCTION_P (NODE) && DECL_CONSTRUCTOR_P (NODE) \
2976 ? LANG_DECL_FN_CHECK (NODE)->context : NULL_TREE)
2977
2978/* And this is the base that constructor comes from. */
2979#define DECL_INHERITED_CTOR_BASE(NODE) \
2980 (DECL_INHERITED_CTOR (NODE) \
2981 ? DECL_CONTEXT (flag_new_inheriting_ctors \
2982 ? strip_inheriting_ctors (NODE) \
2983 : DECL_INHERITED_CTOR (NODE)) \
2984 : NULL_TREE)
2985
2986/* Set the inherited base. */
2987#define SET_DECL_INHERITED_CTOR(NODE,INH) \
2988 (LANG_DECL_FN_CHECK (NODE)->context = (INH))
2989
2990/* Nonzero if NODE is a thunk, rather than an ordinary function. */
2991#define DECL_THUNK_P(NODE) \
2992 (TREE_CODE (NODE) == FUNCTION_DECL \
2993 && DECL_LANG_SPECIFIC (NODE) \
2994 && LANG_DECL_FN_CHECK (NODE)->thunk_p)
2995
2996/* Set DECL_THUNK_P for node. */
2997#define SET_DECL_THUNK_P(NODE, THIS_ADJUSTING) \
2998 (LANG_DECL_FN_CHECK (NODE)->thunk_p = 1, \
2999 LANG_DECL_FN_CHECK (NODE)->this_thunk_p = (THIS_ADJUSTING))
3000
3001/* Nonzero if NODE is a this pointer adjusting thunk. */
3002#define DECL_THIS_THUNK_P(NODE) \
3003 (DECL_THUNK_P (NODE) && LANG_DECL_FN_CHECK (NODE)->this_thunk_p)
3004
3005/* Nonzero if NODE is a result pointer adjusting thunk. */
3006#define DECL_RESULT_THUNK_P(NODE) \
3007 (DECL_THUNK_P (NODE) && !LANG_DECL_FN_CHECK (NODE)->this_thunk_p)
3008
3009/* Nonzero if NODE is a FUNCTION_DECL, but not a thunk. */
3010#define DECL_NON_THUNK_FUNCTION_P(NODE) \
3011 (TREE_CODE (NODE) == FUNCTION_DECL && !DECL_THUNK_P (NODE))
3012
3013/* Nonzero if NODE is `extern "C"'. */
3014#define DECL_EXTERN_C_P(NODE) \
3015 (DECL_LANGUAGE (NODE) == lang_c)
3016
3017/* Nonzero if NODE is an `extern "C"' function. */
3018#define DECL_EXTERN_C_FUNCTION_P(NODE) \
3019 (DECL_NON_THUNK_FUNCTION_P (NODE) && DECL_EXTERN_C_P (NODE))
3020
3021/* True iff DECL is an entity with vague linkage whose definition is
3022 available in this translation unit. */
3023#define DECL_REPO_AVAILABLE_P(NODE) \
3024 (DECL_LANG_SPECIFIC (NODE)->u.base.repo_available_p)
3025
3026/* True if DECL is declared 'constexpr'. */
3027#define DECL_DECLARED_CONSTEXPR_P(DECL) \
3028 DECL_LANG_FLAG_8 (VAR_OR_FUNCTION_DECL_CHECK (STRIP_TEMPLATE (DECL)))
3029
3030// True if NODE was declared as 'concept'. The flag implies that the
3031// declaration is constexpr, that the declaration cannot be specialized or
3032// refined, and that the result type must be convertible to bool.
3033#define DECL_DECLARED_CONCEPT_P(NODE) \
3034 (DECL_LANG_SPECIFIC (NODE)->u.base.concept_p)
3035
3036/* Nonzero if this DECL is the __PRETTY_FUNCTION__ variable in a
3037 template function. */
3038#define DECL_PRETTY_FUNCTION_P(NODE) \
3039 (DECL_NAME (NODE) \
3040 && id_equal (DECL_NAME (NODE), "__PRETTY_FUNCTION__"))
3041
3042/* Nonzero if the variable was declared to be thread-local.
3043 We need a special C++ version of this test because the middle-end
3044 DECL_THREAD_LOCAL_P uses the symtab, so we can't use it for
3045 templates. */
3046#define CP_DECL_THREAD_LOCAL_P(NODE) \
3047 (TREE_LANG_FLAG_0 (VAR_DECL_CHECK (NODE)))
3048
3049/* The _TYPE context in which this _DECL appears. This field holds the
3050 class where a virtual function instance is actually defined. */
3051#define DECL_CLASS_CONTEXT(NODE) \
3052 (DECL_CLASS_SCOPE_P (NODE) ? DECL_CONTEXT (NODE) : NULL_TREE)
3053
3054/* For a non-member friend function, the class (if any) in which this
3055 friend was defined. For example, given:
3056
3057 struct S { friend void f (); };
3058
3059 the DECL_FRIEND_CONTEXT for `f' will be `S'. */
3060#define DECL_FRIEND_CONTEXT(NODE) \
3061 ((DECL_DECLARES_FUNCTION_P (NODE) \
3062 && DECL_FRIEND_P (NODE) && !DECL_FUNCTION_MEMBER_P (NODE)) \
3063 ? LANG_DECL_FN_CHECK (NODE)->context \
3064 : NULL_TREE)
3065
3066/* Set the DECL_FRIEND_CONTEXT for NODE to CONTEXT. */
3067#define SET_DECL_FRIEND_CONTEXT(NODE, CONTEXT) \
3068 (LANG_DECL_FN_CHECK (NODE)->context = (CONTEXT))
3069
3070#define CP_DECL_CONTEXT(NODE) \
3071 (!DECL_FILE_SCOPE_P (NODE) ? DECL_CONTEXT (NODE) : global_namespace)
3072#define CP_TYPE_CONTEXT(NODE) \
3073 (!TYPE_FILE_SCOPE_P (NODE) ? TYPE_CONTEXT (NODE) : global_namespace)
3074#define FROB_CONTEXT(NODE) \
3075 ((NODE) == global_namespace ? DECL_CONTEXT (NODE) : (NODE))
3076
3077/* 1 iff NODE has namespace scope, including the global namespace. */
3078#define DECL_NAMESPACE_SCOPE_P(NODE) \
3079 (!DECL_TEMPLATE_PARM_P (NODE) \
3080 && TREE_CODE (CP_DECL_CONTEXT (NODE)) == NAMESPACE_DECL)
3081
3082#define TYPE_NAMESPACE_SCOPE_P(NODE) \
3083 (TREE_CODE (CP_TYPE_CONTEXT (NODE)) == NAMESPACE_DECL)
3084
3085#define NAMESPACE_SCOPE_P(NODE) \
3086 ((DECL_P (NODE) && DECL_NAMESPACE_SCOPE_P (NODE)) \
3087 || (TYPE_P (NODE) && TYPE_NAMESPACE_SCOPE_P (NODE)))
3088
3089/* 1 iff NODE is a class member. */
3090#define DECL_CLASS_SCOPE_P(NODE) \
3091 (DECL_CONTEXT (NODE) && TYPE_P (DECL_CONTEXT (NODE)))
3092
3093#define TYPE_CLASS_SCOPE_P(NODE) \
3094 (TYPE_CONTEXT (NODE) && TYPE_P (TYPE_CONTEXT (NODE)))
3095
3096/* 1 iff NODE is function-local. */
3097#define DECL_FUNCTION_SCOPE_P(NODE) \
3098 (DECL_CONTEXT (NODE) \
3099 && TREE_CODE (DECL_CONTEXT (NODE)) == FUNCTION_DECL)
3100
3101#define TYPE_FUNCTION_SCOPE_P(NODE) \
3102 (TYPE_CONTEXT (NODE) && TREE_CODE (TYPE_CONTEXT (NODE)) == FUNCTION_DECL)
3103
3104/* 1 iff VAR_DECL node NODE is a type-info decl. This flag is set for
3105 both the primary typeinfo object and the associated NTBS name. */
3106#define DECL_TINFO_P(NODE) TREE_LANG_FLAG_4 (VAR_DECL_CHECK (NODE))
3107
3108/* 1 iff VAR_DECL node NODE is virtual table or VTT. */
3109#define DECL_VTABLE_OR_VTT_P(NODE) TREE_LANG_FLAG_5 (VAR_DECL_CHECK (NODE))
3110
3111/* 1 iff FUNCTION_TYPE or METHOD_TYPE has a ref-qualifier (either & or &&). */
3112#define FUNCTION_REF_QUALIFIED(NODE) \
3113 TREE_LANG_FLAG_4 (FUNC_OR_METHOD_CHECK (NODE))
3114
3115/* 1 iff FUNCTION_TYPE or METHOD_TYPE has &&-ref-qualifier. */
3116#define FUNCTION_RVALUE_QUALIFIED(NODE) \
3117 TREE_LANG_FLAG_5 (FUNC_OR_METHOD_CHECK (NODE))
3118
3119/* Returns 1 iff VAR_DECL is a construction virtual table.
3120 DECL_VTABLE_OR_VTT_P will be true in this case and must be checked
3121 before using this macro. */
3122#define DECL_CONSTRUCTION_VTABLE_P(NODE) \
3123 TREE_LANG_FLAG_6 (VAR_DECL_CHECK (NODE))
3124
3125/* 1 iff NODE is function-local, but for types. */
3126#define LOCAL_CLASS_P(NODE) \
3127 (decl_function_context (TYPE_MAIN_DECL (NODE)) != NULL_TREE)
3128
3129/* The nesting depth of namespace, class or function. Makes is_ancestor much
3130 simpler. Only 8 bits available. */
3131#define SCOPE_DEPTH(NODE) \
3132 (NAMESPACE_DECL_CHECK (NODE)->base.u.bits.address_space)
3133
3134/* Whether the namepace is an inline namespace. */
3135#define DECL_NAMESPACE_INLINE_P(NODE) \
3136 TREE_LANG_FLAG_0 (NAMESPACE_DECL_CHECK (NODE))
3137
3138/* In a NAMESPACE_DECL, a vector of using directives. */
3139#define DECL_NAMESPACE_USING(NODE) \
3140 (LANG_DECL_NS_CHECK (NODE)->usings)
3141
3142/* In a NAMESPACE_DECL, a vector of inline namespaces. */
3143#define DECL_NAMESPACE_INLINEES(NODE) \
3144 (LANG_DECL_NS_CHECK (NODE)->inlinees)
3145
3146/* Pointer to hash_map from IDENTIFIERS to DECLS */
3147#define DECL_NAMESPACE_BINDINGS(NODE) \
3148 (LANG_DECL_NS_CHECK (NODE)->bindings)
3149
3150/* In a NAMESPACE_DECL, points to the original namespace if this is
3151 a namespace alias. */
3152#define DECL_NAMESPACE_ALIAS(NODE) \
3153 DECL_ABSTRACT_ORIGIN (NAMESPACE_DECL_CHECK (NODE))
3154#define ORIGINAL_NAMESPACE(NODE) \
3155 (DECL_NAMESPACE_ALIAS (NODE) ? DECL_NAMESPACE_ALIAS (NODE) : (NODE))
3156
3157/* Nonzero if NODE is the std namespace. */
3158#define DECL_NAMESPACE_STD_P(NODE) \
3159 (TREE_CODE (NODE) == NAMESPACE_DECL \
3160 && CP_DECL_CONTEXT (NODE) == global_namespace \
3161 && DECL_NAME (NODE) == std_identifier)
3162
3163/* In a TREE_LIST in an attribute list, indicates that the attribute
3164 must be applied at instantiation time. */
3165#define ATTR_IS_DEPENDENT(NODE) TREE_LANG_FLAG_0 (TREE_LIST_CHECK (NODE))
3166
3167/* In a TREE_LIST in the argument of attribute abi_tag, indicates that the tag
3168 was inherited from a template parameter, not explicitly indicated. */
3169#define ABI_TAG_IMPLICIT(NODE) TREE_LANG_FLAG_0 (TREE_LIST_CHECK (NODE))
3170
3171extern tree decl_shadowed_for_var_lookup (tree);
3172extern void decl_shadowed_for_var_insert (tree, tree);
3173
3174/* Non zero if this is a using decl for a dependent scope. */
3175#define DECL_DEPENDENT_P(NODE) DECL_LANG_FLAG_0 (USING_DECL_CHECK (NODE))
3176
3177/* The scope named in a using decl. */
3178#define USING_DECL_SCOPE(NODE) TREE_TYPE (USING_DECL_CHECK (NODE))
3179
3180/* The decls named by a using decl. */
3181#define USING_DECL_DECLS(NODE) DECL_INITIAL (USING_DECL_CHECK (NODE))
3182
3183/* Non zero if the using decl refers to a dependent type. */
3184#define USING_DECL_TYPENAME_P(NODE) DECL_LANG_FLAG_1 (USING_DECL_CHECK (NODE))
3185
3186/* In a VAR_DECL, true if we have a shadowed local variable
3187 in the shadowed var table for this VAR_DECL. */
3188#define DECL_HAS_SHADOWED_FOR_VAR_P(NODE) \
3189 (VAR_DECL_CHECK (NODE)->decl_with_vis.shadowed_for_var_p)
3190
3191/* In a VAR_DECL for a variable declared in a for statement,
3192 this is the shadowed (local) variable. */
3193#define DECL_SHADOWED_FOR_VAR(NODE) \
3194 (DECL_HAS_SHADOWED_FOR_VAR_P(NODE) ? decl_shadowed_for_var_lookup (NODE) : NULL)
3195
3196#define SET_DECL_SHADOWED_FOR_VAR(NODE, VAL) \
3197 (decl_shadowed_for_var_insert (NODE, VAL))
3198
3199/* In a FUNCTION_DECL, this is nonzero if this function was defined in
3200 the class definition. We have saved away the text of the function,
3201 but have not yet processed it. */
3202#define DECL_PENDING_INLINE_P(NODE) \
3203 (LANG_DECL_FN_CHECK (NODE)->pending_inline_p)
3204
3205/* If DECL_PENDING_INLINE_P holds, this is the saved text of the
3206 function. */
3207#define DECL_PENDING_INLINE_INFO(NODE) \
3208 (LANG_DECL_FN_CHECK (NODE)->u.pending_inline_info)
3209
3210/* Nonzero for TYPE_DECL means that it was written 'using name = type'. */
3211#define TYPE_DECL_ALIAS_P(NODE) \
3212 DECL_LANG_FLAG_6 (TYPE_DECL_CHECK (NODE))
3213
3214/* Nonzero for TEMPLATE_DECL means that it is a 'complex' alias template. */
3215#define TEMPLATE_DECL_COMPLEX_ALIAS_P(NODE) \
3216 DECL_LANG_FLAG_2 (TEMPLATE_DECL_CHECK (NODE))
3217
3218/* Nonzero for a type which is an alias for another type; i.e, a type
3219 which declaration was written 'using name-of-type =
3220 another-type'. */
3221#define TYPE_ALIAS_P(NODE) \
3222 (TYPE_P (NODE) \
3223 && TYPE_NAME (NODE) \
3224 && TREE_CODE (TYPE_NAME (NODE)) == TYPE_DECL \
3225 && TYPE_DECL_ALIAS_P (TYPE_NAME (NODE)))
3226
3227/* If non-NULL for a VAR_DECL, FUNCTION_DECL, TYPE_DECL or
3228 TEMPLATE_DECL, the entity is either a template specialization (if
3229 DECL_USE_TEMPLATE is nonzero) or the abstract instance of the
3230 template itself.
3231
3232 In either case, DECL_TEMPLATE_INFO is a TREE_LIST, whose
3233 TREE_PURPOSE is the TEMPLATE_DECL of which this entity is a
3234 specialization or abstract instance. The TREE_VALUE is the
3235 template arguments used to specialize the template.
3236
3237 Consider:
3238
3239 template <typename T> struct S { friend void f(T) {} };
3240
3241 In this case, S<int>::f is, from the point of view of the compiler,
3242 an instantiation of a template -- but, from the point of view of
3243 the language, each instantiation of S results in a wholly unrelated
3244 global function f. In this case, DECL_TEMPLATE_INFO for S<int>::f
3245 will be non-NULL, but DECL_USE_TEMPLATE will be zero. */
3246#define DECL_TEMPLATE_INFO(NODE) \
3247 (DECL_LANG_SPECIFIC (VAR_TEMPL_TYPE_FIELD_OR_FUNCTION_DECL_CHECK (NODE)) \
3248 ->u.min.template_info)
3249
3250/* For a lambda capture proxy, its captured variable. */
3251#define DECL_CAPTURED_VARIABLE(NODE) \
3252 (LANG_DECL_U2_CHECK (NODE, 0)->access)
3253
3254/* For a VAR_DECL, indicates that the variable is actually a
3255 non-static data member of anonymous union that has been promoted to
3256 variable status. */
3257#define DECL_ANON_UNION_VAR_P(NODE) \
3258 (DECL_LANG_FLAG_4 (VAR_DECL_CHECK (NODE)))
3259
3260/* Template information for a RECORD_TYPE or UNION_TYPE. */
3261#define CLASSTYPE_TEMPLATE_INFO(NODE) \
3262 (TYPE_LANG_SLOT_1 (RECORD_OR_UNION_CHECK (NODE)))
3263
3264/* Template information for a template template parameter. */
3265#define TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO(NODE) \
3266 (TYPE_LANG_SLOT_1 (BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK (NODE)))
3267
3268/* Template information for an ENUMERAL_, RECORD_, UNION_TYPE, or
3269 BOUND_TEMPLATE_TEMPLATE_PARM type. This ignores any alias
3270 templateness of NODE. It'd be nice if this could unconditionally
3271 access the slot, rather than return NULL if given a
3272 non-templatable type. */
3273#define TYPE_TEMPLATE_INFO(NODE) \
3274 (TREE_CODE (NODE) == ENUMERAL_TYPE \
3275 || TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM \
3276 || RECORD_OR_UNION_TYPE_P (NODE) \
3277 ? TYPE_LANG_SLOT_1 (NODE) : NULL_TREE)
3278
3279/* Template information (if any) for an alias type. */
3280#define TYPE_ALIAS_TEMPLATE_INFO(NODE) \
3281 (DECL_LANG_SPECIFIC (TYPE_NAME (NODE)) \
3282 ? DECL_TEMPLATE_INFO (TYPE_NAME (NODE)) \
3283 : NULL_TREE)
3284
3285/* If NODE is a type alias, this accessor returns the template info
3286 for the alias template (if any). Otherwise behave as
3287 TYPE_TEMPLATE_INFO. */
3288#define TYPE_TEMPLATE_INFO_MAYBE_ALIAS(NODE) \
3289 (TYPE_ALIAS_P (NODE) \
3290 ? TYPE_ALIAS_TEMPLATE_INFO (NODE) \
3291 : TYPE_TEMPLATE_INFO (NODE))
3292
3293/* Set the template information for an ENUMERAL_, RECORD_, or
3294 UNION_TYPE to VAL. */
3295#define SET_TYPE_TEMPLATE_INFO(NODE, VAL) \
3296 (TREE_CODE (NODE) == ENUMERAL_TYPE \
3297 || (CLASS_TYPE_P (NODE) && !TYPE_ALIAS_P (NODE)) \
3298 ? (TYPE_LANG_SLOT_1 (NODE) = (VAL)) \
3299 : (DECL_TEMPLATE_INFO (TYPE_NAME (NODE)) = (VAL)))
3300
3301#define TI_TEMPLATE(NODE) TREE_TYPE (TEMPLATE_INFO_CHECK (NODE))
3302#define TI_ARGS(NODE) TREE_CHAIN (TEMPLATE_INFO_CHECK (NODE))
3303#define TI_PENDING_TEMPLATE_FLAG(NODE) TREE_LANG_FLAG_1 (NODE)
3304/* For a given TREE_VEC containing a template argument list,
3305 this property contains the number of arguments that are not
3306 defaulted. */
3307#define NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) TREE_CHAIN (TREE_VEC_CHECK (NODE))
3308/* Below are the setter and getter of the NON_DEFAULT_TEMPLATE_ARGS_COUNT
3309 property. */
3310#define SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE, INT_VALUE) \
3311 NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) = build_int_cst (NULL_TREE, INT_VALUE)
3312#if CHECKING_P
3313#define GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) \
3314 int_cst_value (NON_DEFAULT_TEMPLATE_ARGS_COUNT (NODE))
3315#else
3316#define GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) \
3317 NON_DEFAULT_TEMPLATE_ARGS_COUNT (NODE) \
3318 ? int_cst_value (NON_DEFAULT_TEMPLATE_ARGS_COUNT (NODE)) \
3319 : TREE_VEC_LENGTH (INNERMOST_TEMPLATE_ARGS (NODE))
3320#endif
3321/* The list of typedefs - used in the template - that need
3322 access checking at template instantiation time.
3323
3324 FIXME this should be associated with the TEMPLATE_DECL, not the
3325 TEMPLATE_INFO. */
3326#define TI_TYPEDEFS_NEEDING_ACCESS_CHECKING(NODE) \
3327 ((struct tree_template_info*)TEMPLATE_INFO_CHECK \
3328 (NODE))->typedefs_needing_access_checking
3329
3330/* We use TREE_VECs to hold template arguments. If there is only one
3331 level of template arguments, then the TREE_VEC contains the
3332 arguments directly. If there is more than one level of template
3333 arguments, then each entry in the TREE_VEC is itself a TREE_VEC,
3334 containing the template arguments for a single level. The first
3335 entry in the outer TREE_VEC is the outermost level of template
3336 parameters; the last is the innermost.
3337
3338 It is incorrect to ever form a template argument vector containing
3339 only one level of arguments, but which is a TREE_VEC containing as
3340 its only entry the TREE_VEC for that level.
3341
3342 For each TREE_VEC containing the template arguments for a single
3343 level, it's possible to get or set the number of non defaulted
3344 template arguments by using the accessor macros
3345 GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT or
3346 SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT. */
3347
3348/* Nonzero if the template arguments is actually a vector of vectors,
3349 rather than just a vector. */
3350#define TMPL_ARGS_HAVE_MULTIPLE_LEVELS(NODE) \
3351 (NODE && TREE_VEC_LENGTH (NODE) && TREE_VEC_ELT (NODE, 0) \
3352 && TREE_CODE (TREE_VEC_ELT (NODE, 0)) == TREE_VEC)
3353
3354/* The depth of a template argument vector. When called directly by
3355 the parser, we use a TREE_LIST rather than a TREE_VEC to represent
3356 template arguments. In fact, we may even see NULL_TREE if there
3357 are no template arguments. In both of those cases, there is only
3358 one level of template arguments. */
3359#define TMPL_ARGS_DEPTH(NODE) \
3360 (TMPL_ARGS_HAVE_MULTIPLE_LEVELS (NODE) ? TREE_VEC_LENGTH (NODE) : 1)
3361
3362/* The LEVELth level of the template ARGS. The outermost level of
3363 args is level 1, not level 0. */
3364#define TMPL_ARGS_LEVEL(ARGS, LEVEL) \
3365 (TMPL_ARGS_HAVE_MULTIPLE_LEVELS (ARGS) \
3366 ? TREE_VEC_ELT (ARGS, (LEVEL) - 1) : (ARGS))
3367
3368/* Set the LEVELth level of the template ARGS to VAL. This macro does
3369 not work with single-level argument vectors. */
3370#define SET_TMPL_ARGS_LEVEL(ARGS, LEVEL, VAL) \
3371 (TREE_VEC_ELT (ARGS, (LEVEL) - 1) = (VAL))
3372
3373/* Accesses the IDXth parameter in the LEVELth level of the ARGS. */
3374#define TMPL_ARG(ARGS, LEVEL, IDX) \
3375 (TREE_VEC_ELT (TMPL_ARGS_LEVEL (ARGS, LEVEL), IDX))
3376
3377/* Given a single level of template arguments in NODE, return the
3378 number of arguments. */
3379#define NUM_TMPL_ARGS(NODE) \
3380 (TREE_VEC_LENGTH (NODE))
3381
3382/* Returns the innermost level of template arguments in ARGS. */
3383#define INNERMOST_TEMPLATE_ARGS(NODE) \
3384 (get_innermost_template_args ((NODE), 1))
3385
3386/* The number of levels of template parameters given by NODE. */
3387#define TMPL_PARMS_DEPTH(NODE) \
3388 ((HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_PURPOSE (NODE)))
3389
3390/* The TEMPLATE_DECL instantiated or specialized by NODE. This
3391 TEMPLATE_DECL will be the immediate parent, not the most general
3392 template. For example, in:
3393
3394 template <class T> struct S { template <class U> void f(U); }
3395
3396 the FUNCTION_DECL for S<int>::f<double> will have, as its
3397 DECL_TI_TEMPLATE, `template <class U> S<int>::f<U>'.
3398
3399 As a special case, for a member friend template of a template
3400 class, this value will not be a TEMPLATE_DECL, but rather an
3401 IDENTIFIER_NODE or OVERLOAD indicating the name of the template and
3402 any explicit template arguments provided. For example, in:
3403
3404 template <class T> struct S { friend void f<int>(int, double); }
3405
3406 the DECL_TI_TEMPLATE will be an IDENTIFIER_NODE for `f' and the
3407 DECL_TI_ARGS will be {int}.
3408
3409 For a FIELD_DECL with a non-static data member initializer, this value
3410 is the FIELD_DECL it was instantiated from. */
3411#define DECL_TI_TEMPLATE(NODE) TI_TEMPLATE (DECL_TEMPLATE_INFO (NODE))
3412
3413/* The template arguments used to obtain this decl from the most
3414 general form of DECL_TI_TEMPLATE. For the example given for
3415 DECL_TI_TEMPLATE, the DECL_TI_ARGS will be {int, double}. These
3416 are always the full set of arguments required to instantiate this
3417 declaration from the most general template specialized here. */
3418#define DECL_TI_ARGS(NODE) TI_ARGS (DECL_TEMPLATE_INFO (NODE))
3419
3420/* The TEMPLATE_DECL associated with NODE, a class type. Even if NODE
3421 will be generated from a partial specialization, the TEMPLATE_DECL
3422 referred to here will be the original template. For example,
3423 given:
3424
3425 template <typename T> struct S {};
3426 template <typename T> struct S<T*> {};
3427
3428 the CLASSTPYE_TI_TEMPLATE for S<int*> will be S, not the S<T*>. */
3429#define CLASSTYPE_TI_TEMPLATE(NODE) TI_TEMPLATE (CLASSTYPE_TEMPLATE_INFO (NODE))
3430#define CLASSTYPE_TI_ARGS(NODE) TI_ARGS (CLASSTYPE_TEMPLATE_INFO (NODE))
3431
3432/* For a template instantiation TYPE, returns the TYPE corresponding
3433 to the primary template. Otherwise returns TYPE itself. */
3434#define CLASSTYPE_PRIMARY_TEMPLATE_TYPE(TYPE) \
3435 ((CLASSTYPE_USE_TEMPLATE ((TYPE)) \
3436 && !CLASSTYPE_TEMPLATE_SPECIALIZATION ((TYPE))) \
3437 ? TREE_TYPE (DECL_TEMPLATE_RESULT (DECL_PRIMARY_TEMPLATE \
3438 (CLASSTYPE_TI_TEMPLATE ((TYPE))))) \
3439 : (TYPE))
3440
3441/* Like CLASS_TI_TEMPLATE, but also works for ENUMERAL_TYPEs. */
3442#define TYPE_TI_TEMPLATE(NODE) \
3443 (TI_TEMPLATE (TYPE_TEMPLATE_INFO (NODE)))
3444
3445/* Like DECL_TI_ARGS, but for an ENUMERAL_, RECORD_, or UNION_TYPE. */
3446#define TYPE_TI_ARGS(NODE) \
3447 (TI_ARGS (TYPE_TEMPLATE_INFO (NODE)))
3448
3449#define INNERMOST_TEMPLATE_PARMS(NODE) TREE_VALUE (NODE)
3450
3451/* Nonzero if NODE (a TEMPLATE_DECL) is a member template, in the
3452 sense of [temp.mem]. */
3453#define DECL_MEMBER_TEMPLATE_P(NODE) \
3454 (DECL_LANG_FLAG_1 (TEMPLATE_DECL_CHECK (NODE)))
3455
3456/* Nonzero if the NODE corresponds to the template parameters for a
3457 member template, whose inline definition is being processed after
3458 the class definition is complete. */
3459#define TEMPLATE_PARMS_FOR_INLINE(NODE) TREE_LANG_FLAG_1 (NODE)
3460
3461/* Determine if a declaration (PARM_DECL or FIELD_DECL) is a pack. */
3462#define DECL_PACK_P(NODE) \
3463 (DECL_P (NODE) && PACK_EXPANSION_P (TREE_TYPE (NODE)))
3464
3465/* Determines if NODE is an expansion of one or more parameter packs,
3466 e.g., a TYPE_PACK_EXPANSION or EXPR_PACK_EXPANSION. */
3467#define PACK_EXPANSION_P(NODE) \
3468 (TREE_CODE (NODE) == TYPE_PACK_EXPANSION \
3469 || TREE_CODE (NODE) == EXPR_PACK_EXPANSION)
3470
3471/* Extracts the type or expression pattern from a TYPE_PACK_EXPANSION or
3472 EXPR_PACK_EXPANSION. */
3473#define PACK_EXPANSION_PATTERN(NODE) \
3474 (TREE_CODE (NODE) == TYPE_PACK_EXPANSION ? TREE_TYPE (NODE) \
3475 : TREE_OPERAND (NODE, 0))
3476
3477/* Sets the type or expression pattern for a TYPE_PACK_EXPANSION or
3478 EXPR_PACK_EXPANSION. */
3479#define SET_PACK_EXPANSION_PATTERN(NODE,VALUE) \
3480 if (TREE_CODE (NODE) == TYPE_PACK_EXPANSION) \
3481 TREE_TYPE (NODE) = VALUE; \
3482 else \
3483 TREE_OPERAND (NODE, 0) = VALUE
3484
3485/* The list of parameter packs used in the PACK_EXPANSION_* node. The
3486 TREE_VALUE of each TREE_LIST contains the parameter packs. */
3487#define PACK_EXPANSION_PARAMETER_PACKS(NODE) \
3488 *(TREE_CODE (NODE) == EXPR_PACK_EXPANSION \
3489 ? &TREE_OPERAND (NODE, 1) \
3490 : &TYPE_MIN_VALUE_RAW (TYPE_PACK_EXPANSION_CHECK (NODE)))
3491
3492/* Any additional template args to be applied when substituting into
3493 the pattern, set by tsubst_pack_expansion for partial instantiations. */
3494#define PACK_EXPANSION_EXTRA_ARGS(NODE) \
3495 *(TREE_CODE (NODE) == TYPE_PACK_EXPANSION \
3496 ? &TYPE_MAX_VALUE_RAW (NODE) \
3497 : &TREE_OPERAND ((NODE), 2))
3498
3499/* True iff this pack expansion is within a function context. */
3500#define PACK_EXPANSION_LOCAL_P(NODE) TREE_LANG_FLAG_0 (NODE)
3501
3502/* True iff this pack expansion is for sizeof.... */
3503#define PACK_EXPANSION_SIZEOF_P(NODE) TREE_LANG_FLAG_1 (NODE)
3504
3505/* True iff the wildcard can match a template parameter pack. */
3506#define WILDCARD_PACK_P(NODE) TREE_LANG_FLAG_0 (NODE)
3507
3508/* Determine if this is an argument pack. */
3509#define ARGUMENT_PACK_P(NODE) \
3510 (TREE_CODE (NODE) == TYPE_ARGUMENT_PACK \
3511 || TREE_CODE (NODE) == NONTYPE_ARGUMENT_PACK)
3512
3513/* The arguments stored in an argument pack. Arguments are stored in a
3514 TREE_VEC, which may have length zero. */
3515#define ARGUMENT_PACK_ARGS(NODE) \
3516 (TREE_CODE (NODE) == TYPE_ARGUMENT_PACK? TREE_TYPE (NODE) \
3517 : TREE_OPERAND (NODE, 0))
3518
3519/* Set the arguments stored in an argument pack. VALUE must be a
3520 TREE_VEC. */
3521#define SET_ARGUMENT_PACK_ARGS(NODE,VALUE) \
3522 if (TREE_CODE (NODE) == TYPE_ARGUMENT_PACK) \
3523 TREE_TYPE (NODE) = VALUE; \
3524 else \
3525 TREE_OPERAND (NODE, 0) = VALUE
3526
3527/* Whether the argument pack is "incomplete", meaning that more
3528 arguments can still be deduced. Incomplete argument packs are only
3529 used when the user has provided an explicit template argument list
3530 for a variadic function template. Some of the explicit template
3531 arguments will be placed into the beginning of the argument pack,
3532 but additional arguments might still be deduced. */
3533#define ARGUMENT_PACK_INCOMPLETE_P(NODE) \
3534 TREE_ADDRESSABLE (ARGUMENT_PACK_ARGS (NODE))
3535
3536/* When ARGUMENT_PACK_INCOMPLETE_P, stores the explicit template
3537 arguments used to fill this pack. */
3538#define ARGUMENT_PACK_EXPLICIT_ARGS(NODE) \
3539 TREE_TYPE (ARGUMENT_PACK_ARGS (NODE))
3540
3541/* In an ARGUMENT_PACK_SELECT, the argument pack from which an
3542 argument will be selected. */
3543#define ARGUMENT_PACK_SELECT_FROM_PACK(NODE) \
3544 (((struct tree_argument_pack_select *)ARGUMENT_PACK_SELECT_CHECK (NODE))->argument_pack)
3545
3546/* In an ARGUMENT_PACK_SELECT, the index of the argument we want to
3547 select. */
3548#define ARGUMENT_PACK_SELECT_INDEX(NODE) \
3549 (((struct tree_argument_pack_select *)ARGUMENT_PACK_SELECT_CHECK (NODE))->index)
3550
3551/* In an ARGUMENT_PACK_SELECT, the actual underlying argument that the
3552 ARGUMENT_PACK_SELECT represents. */
3553#define ARGUMENT_PACK_SELECT_ARG(NODE) \
3554 TREE_VEC_ELT (ARGUMENT_PACK_ARGS (ARGUMENT_PACK_SELECT_FROM_PACK (NODE)), \
3555 ARGUMENT_PACK_SELECT_INDEX (NODE))
3556
3557#define FOLD_EXPR_CHECK(NODE) \
3558 TREE_CHECK4 (NODE, UNARY_LEFT_FOLD_EXPR, UNARY_RIGHT_FOLD_EXPR, \
3559 BINARY_LEFT_FOLD_EXPR, BINARY_RIGHT_FOLD_EXPR)
3560
3561#define BINARY_FOLD_EXPR_CHECK(NODE) \
3562 TREE_CHECK2 (NODE, BINARY_LEFT_FOLD_EXPR, BINARY_RIGHT_FOLD_EXPR)
3563
3564/* True if NODE is UNARY_FOLD_EXPR or a BINARY_FOLD_EXPR */
3565#define FOLD_EXPR_P(NODE) \
3566 (TREE_CODE (NODE) == UNARY_LEFT_FOLD_EXPR \
3567 || TREE_CODE (NODE) == UNARY_RIGHT_FOLD_EXPR \
3568 || TREE_CODE (NODE) == BINARY_LEFT_FOLD_EXPR \
3569 || TREE_CODE (NODE) == BINARY_RIGHT_FOLD_EXPR)
3570
3571/* True when NODE is a fold over a compound assignment operator. */
3572#define FOLD_EXPR_MODIFY_P(NODE) \
3573 TREE_LANG_FLAG_0 (FOLD_EXPR_CHECK (NODE))
3574
3575/* An INTEGER_CST containing the tree code of the folded operator. */
3576#define FOLD_EXPR_OP(NODE) \
3577 TREE_OPERAND (FOLD_EXPR_CHECK (NODE), 0)
3578
3579/* The expression containing an unexpanded parameter pack. */
3580#define FOLD_EXPR_PACK(NODE) \
3581 TREE_OPERAND (FOLD_EXPR_CHECK (NODE), 1)
3582
3583/* In a binary fold expression, the argument with no unexpanded
3584 parameter packs. */
3585#define FOLD_EXPR_INIT(NODE) \
3586 TREE_OPERAND (BINARY_FOLD_EXPR_CHECK (NODE), 2)
3587
3588/* In a FUNCTION_DECL, the saved language-specific per-function data. */
3589#define DECL_SAVED_FUNCTION_DATA(NODE) \
3590 (LANG_DECL_FN_CHECK (FUNCTION_DECL_CHECK (NODE)) \
3591 ->u.saved_language_function)
3592
3593/* True if NODE is an implicit INDIRECT_EXPR from convert_from_reference. */
3594#define REFERENCE_REF_P(NODE) \
3595 (INDIRECT_REF_P (NODE) \
3596 && TREE_TYPE (TREE_OPERAND (NODE, 0)) \
3597 && (TREE_CODE (TREE_TYPE (TREE_OPERAND ((NODE), 0))) \
3598 == REFERENCE_TYPE))
3599
3600/* True if NODE is a REFERENCE_TYPE which is OK to instantiate to be a
3601 reference to VLA type, because it's used for VLA capture. */
3602#define REFERENCE_VLA_OK(NODE) \
3603 (TYPE_LANG_FLAG_5 (REFERENCE_TYPE_CHECK (NODE)))
3604
3605#define NEW_EXPR_USE_GLOBAL(NODE) \
3606 TREE_LANG_FLAG_0 (NEW_EXPR_CHECK (NODE))
3607#define DELETE_EXPR_USE_GLOBAL(NODE) \
3608 TREE_LANG_FLAG_0 (DELETE_EXPR_CHECK (NODE))
3609#define DELETE_EXPR_USE_VEC(NODE) \
3610 TREE_LANG_FLAG_1 (DELETE_EXPR_CHECK (NODE))
3611
3612#define CALL_OR_AGGR_INIT_CHECK(NODE) \
3613 TREE_CHECK2 ((NODE), CALL_EXPR, AGGR_INIT_EXPR)
3614
3615/* Indicates that this is a non-dependent COMPOUND_EXPR which will
3616 resolve to a function call. */
3617#define COMPOUND_EXPR_OVERLOADED(NODE) \
3618 TREE_LANG_FLAG_0 (COMPOUND_EXPR_CHECK (NODE))
3619
3620/* In a CALL_EXPR appearing in a template, true if Koenig lookup
3621 should be performed at instantiation time. */
3622#define KOENIG_LOOKUP_P(NODE) TREE_LANG_FLAG_0 (CALL_EXPR_CHECK (NODE))
3623
3624/* True if the arguments to NODE should be evaluated in left-to-right
3625 order regardless of PUSH_ARGS_REVERSED. */
3626#define CALL_EXPR_ORDERED_ARGS(NODE) \
3627 TREE_LANG_FLAG_3 (CALL_OR_AGGR_INIT_CHECK (NODE))
3628
3629/* True if the arguments to NODE should be evaluated in right-to-left
3630 order regardless of PUSH_ARGS_REVERSED. */
3631#define CALL_EXPR_REVERSE_ARGS(NODE) \
3632 TREE_LANG_FLAG_5 (CALL_OR_AGGR_INIT_CHECK (NODE))
3633
3634/* True if CALL_EXPR was written as an operator expression, not a function
3635 call. */
3636#define CALL_EXPR_OPERATOR_SYNTAX(NODE) \
3637 TREE_LANG_FLAG_6 (CALL_OR_AGGR_INIT_CHECK (NODE))
3638
3639/* Indicates whether a string literal has been parenthesized. Such
3640 usages are disallowed in certain circumstances. */
3641
3642#define PAREN_STRING_LITERAL_P(NODE) \
3643 TREE_LANG_FLAG_0 (STRING_CST_CHECK (NODE))
3644
3645/* Indicates whether a COMPONENT_REF or a SCOPE_REF has been parenthesized, or
3646 an INDIRECT_REF comes from parenthesizing a _DECL. Currently only set some
3647 of the time in C++14 mode. */
3648
3649#define REF_PARENTHESIZED_P(NODE) \
3650 TREE_LANG_FLAG_2 (TREE_CHECK3 ((NODE), COMPONENT_REF, INDIRECT_REF, SCOPE_REF))
3651
3652/* Nonzero if this AGGR_INIT_EXPR provides for initialization via a
3653 constructor call, rather than an ordinary function call. */
3654#define AGGR_INIT_VIA_CTOR_P(NODE) \
3655 TREE_LANG_FLAG_0 (AGGR_INIT_EXPR_CHECK (NODE))
3656
3657/* Nonzero if expanding this AGGR_INIT_EXPR should first zero-initialize
3658 the object. */
3659#define AGGR_INIT_ZERO_FIRST(NODE) \
3660 TREE_LANG_FLAG_2 (AGGR_INIT_EXPR_CHECK (NODE))
3661
3662/* Nonzero means that the call is the jump from a thunk to the
3663 thunked-to function. */
3664#define AGGR_INIT_FROM_THUNK_P(NODE) \
3665 (AGGR_INIT_EXPR_CHECK (NODE)->base.protected_flag)
3666
3667/* AGGR_INIT_EXPR accessors. These are equivalent to the CALL_EXPR
3668 accessors, except for AGGR_INIT_EXPR_SLOT (which takes the place of
3669 CALL_EXPR_STATIC_CHAIN). */
3670
3671#define AGGR_INIT_EXPR_FN(NODE) TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 1)
3672#define AGGR_INIT_EXPR_SLOT(NODE) \
3673 TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 2)
3674#define AGGR_INIT_EXPR_ARG(NODE, I) \
3675 TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), (I) + 3)
3676#define aggr_init_expr_nargs(NODE) (VL_EXP_OPERAND_LENGTH(NODE) - 3)
3677
3678/* AGGR_INIT_EXPR_ARGP returns a pointer to the argument vector for NODE.
3679 We can't use &AGGR_INIT_EXPR_ARG (NODE, 0) because that will complain if
3680 the argument count is zero when checking is enabled. Instead, do
3681 the pointer arithmetic to advance past the 3 fixed operands in a
3682 AGGR_INIT_EXPR. That produces a valid pointer to just past the end of
3683 the operand array, even if it's not valid to dereference it. */
3684#define AGGR_INIT_EXPR_ARGP(NODE) \
3685 (&(TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 0)) + 3)
3686
3687/* Abstract iterators for AGGR_INIT_EXPRs. */
3688
3689/* Structure containing iterator state. */
3690struct aggr_init_expr_arg_iterator {
3691 tree t; /* the aggr_init_expr */
3692 int n; /* argument count */
3693 int i; /* next argument index */
3694};
3695
3696/* Initialize the abstract argument list iterator object ITER with the
3697 arguments from AGGR_INIT_EXPR node EXP. */
3698inline void
3699init_aggr_init_expr_arg_iterator (tree exp,
3700 aggr_init_expr_arg_iterator *iter)
3701{
3702 iter->t = exp;
3703 iter->n = aggr_init_expr_nargs (exp);
3704 iter->i = 0;
3705}
3706
3707/* Return the next argument from abstract argument list iterator object ITER,
3708 and advance its state. Return NULL_TREE if there are no more arguments. */
3709inline tree
3710next_aggr_init_expr_arg (aggr_init_expr_arg_iterator *iter)
3711{
3712 tree result;
3713 if (iter->i >= iter->n)
3714 return NULL_TREE;
3715 result = AGGR_INIT_EXPR_ARG (iter->t, iter->i);
3716 iter->i++;
3717 return result;
3718}
3719
3720/* Initialize the abstract argument list iterator object ITER, then advance
3721 past and return the first argument. Useful in for expressions, e.g.
3722 for (arg = first_aggr_init_expr_arg (exp, &iter); arg;
3723 arg = next_aggr_init_expr_arg (&iter)) */
3724inline tree
3725first_aggr_init_expr_arg (tree exp, aggr_init_expr_arg_iterator *iter)
3726{
3727 init_aggr_init_expr_arg_iterator (exp, iter);
3728 return next_aggr_init_expr_arg (iter);
3729}
3730
3731/* Test whether there are more arguments in abstract argument list iterator
3732 ITER, without changing its state. */
3733inline bool
3734more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
3735{
3736 return (iter->i < iter->n);
3737}
3738
3739/* Iterate through each argument ARG of AGGR_INIT_EXPR CALL, using variable
3740 ITER (of type aggr_init_expr_arg_iterator) to hold the iteration state. */
3741#define FOR_EACH_AGGR_INIT_EXPR_ARG(arg, iter, call) \
3742 for ((arg) = first_aggr_init_expr_arg ((call), &(iter)); (arg); \
3743 (arg) = next_aggr_init_expr_arg (&(iter)))
3744
3745/* VEC_INIT_EXPR accessors. */
3746#define VEC_INIT_EXPR_SLOT(NODE) TREE_OPERAND (VEC_INIT_EXPR_CHECK (NODE), 0)
3747#define VEC_INIT_EXPR_INIT(NODE) TREE_OPERAND (VEC_INIT_EXPR_CHECK (NODE), 1)
3748
3749/* Indicates that a VEC_INIT_EXPR is a potential constant expression.
3750 Only set when the current function is constexpr. */
3751#define VEC_INIT_EXPR_IS_CONSTEXPR(NODE) \
3752 TREE_LANG_FLAG_0 (VEC_INIT_EXPR_CHECK (NODE))
3753
3754/* Indicates that a VEC_INIT_EXPR is expressing value-initialization. */
3755#define VEC_INIT_EXPR_VALUE_INIT(NODE) \
3756 TREE_LANG_FLAG_1 (VEC_INIT_EXPR_CHECK (NODE))
3757
3758/* The condition under which this MUST_NOT_THROW_EXPR actually blocks
3759 exceptions. NULL_TREE means 'true'. */
3760#define MUST_NOT_THROW_COND(NODE) \
3761 TREE_OPERAND (MUST_NOT_THROW_EXPR_CHECK (NODE), 1)
3762
3763/* The TYPE_MAIN_DECL for a class template type is a TYPE_DECL, not a
3764 TEMPLATE_DECL. This macro determines whether or not a given class
3765 type is really a template type, as opposed to an instantiation or
3766 specialization of one. */
3767#define CLASSTYPE_IS_TEMPLATE(NODE) \
3768 (CLASSTYPE_TEMPLATE_INFO (NODE) \
3769 && !CLASSTYPE_USE_TEMPLATE (NODE) \
3770 && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (NODE)))
3771
3772/* The name used by the user to name the typename type. Typically,
3773 this is an IDENTIFIER_NODE, and the same as the DECL_NAME on the
3774 corresponding TYPE_DECL. However, this may also be a
3775 TEMPLATE_ID_EXPR if we had something like `typename X::Y<T>'. */
3776#define TYPENAME_TYPE_FULLNAME(NODE) \
3777 (TYPE_VALUES_RAW (TYPENAME_TYPE_CHECK (NODE)))
3778
3779/* True if a TYPENAME_TYPE was declared as an "enum". */
3780#define TYPENAME_IS_ENUM_P(NODE) \
3781 (TREE_LANG_FLAG_0 (TYPENAME_TYPE_CHECK (NODE)))
3782
3783/* True if a TYPENAME_TYPE was declared as a "class", "struct", or
3784 "union". */
3785#define TYPENAME_IS_CLASS_P(NODE) \
3786 (TREE_LANG_FLAG_1 (TYPENAME_TYPE_CHECK (NODE)))
3787
3788/* True if a TYPENAME_TYPE is in the process of being resolved. */
3789#define TYPENAME_IS_RESOLVING_P(NODE) \
3790 (TREE_LANG_FLAG_2 (TYPENAME_TYPE_CHECK (NODE)))
3791
3792/* [class.virtual]
3793
3794 A class that declares or inherits a virtual function is called a
3795 polymorphic class. */
3796#define TYPE_POLYMORPHIC_P(NODE) (TREE_LANG_FLAG_2 (NODE))
3797
3798/* Nonzero if this class has a virtual function table pointer. */
3799#define TYPE_CONTAINS_VPTR_P(NODE) \
3800 (TYPE_POLYMORPHIC_P (NODE) || CLASSTYPE_VBASECLASSES (NODE))
3801
3802/* This flag is true of a local VAR_DECL if it was declared in a for
3803 statement, but we are no longer in the scope of the for. */
3804#define DECL_DEAD_FOR_LOCAL(NODE) DECL_LANG_FLAG_7 (VAR_DECL_CHECK (NODE))
3805
3806/* This flag is set on a VAR_DECL that is a DECL_DEAD_FOR_LOCAL
3807 if we already emitted a warning about using it. */
3808#define DECL_ERROR_REPORTED(NODE) DECL_LANG_FLAG_0 (VAR_DECL_CHECK (NODE))
3809
3810/* Nonzero if NODE is a FUNCTION_DECL (for a function with global
3811 scope) declared in a local scope. */
3812#define DECL_LOCAL_FUNCTION_P(NODE) \
3813 DECL_LANG_FLAG_0 (FUNCTION_DECL_CHECK (NODE))
3814
3815/* Nonzero if NODE is the target for genericization of 'break' stmts. */
3816#define LABEL_DECL_BREAK(NODE) \
3817 DECL_LANG_FLAG_0 (LABEL_DECL_CHECK (NODE))
3818
3819/* Nonzero if NODE is the target for genericization of 'continue' stmts. */
3820#define LABEL_DECL_CONTINUE(NODE) \
3821 DECL_LANG_FLAG_1 (LABEL_DECL_CHECK (NODE))
3822
3823/* Nonzero if NODE is the target for genericization of 'return' stmts
3824 in constructors/destructors of targetm.cxx.cdtor_returns_this targets. */
3825#define LABEL_DECL_CDTOR(NODE) \
3826 DECL_LANG_FLAG_2 (LABEL_DECL_CHECK (NODE))
3827
3828/* True if NODE was declared with auto in its return type, but it has
3829 started compilation and so the return type might have been changed by
3830 return type deduction; its declared return type should be found in
3831 DECL_STRUCT_FUNCTION(NODE)->language->x_auto_return_pattern. */
3832#define FNDECL_USED_AUTO(NODE) \
3833 TREE_LANG_FLAG_2 (FUNCTION_DECL_CHECK (NODE))
3834
3835/* Nonzero if NODE is a DECL which we know about but which has not
3836 been explicitly declared, such as a built-in function or a friend
3837 declared inside a class. In the latter case DECL_HIDDEN_FRIEND_P
3838 will be set. */
3839#define DECL_ANTICIPATED(NODE) \
3840 (DECL_LANG_SPECIFIC (TYPE_FUNCTION_OR_TEMPLATE_DECL_CHECK (NODE)) \
3841 ->u.base.anticipated_p)
3842
3843/* Is DECL NODE a hidden name? */
3844#define DECL_HIDDEN_P(NODE) \
3845 (DECL_LANG_SPECIFIC (NODE) && TYPE_FUNCTION_OR_TEMPLATE_DECL_P (NODE) \
3846 && DECL_ANTICIPATED (NODE))
3847
3848/* True if this is a hidden class type. */
3849#define TYPE_HIDDEN_P(NODE) \
3850 (DECL_LANG_SPECIFIC (TYPE_NAME (NODE)) \
3851 && DECL_ANTICIPATED (TYPE_NAME (NODE)))
3852
3853/* True for artificial decls added for OpenMP privatized non-static
3854 data members. */
3855#define DECL_OMP_PRIVATIZED_MEMBER(NODE) \
3856 (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE))->u.base.anticipated_p)
3857
3858/* Nonzero if NODE is a FUNCTION_DECL which was declared as a friend
3859 within a class but has not been declared in the surrounding scope.
3860 The function is invisible except via argument dependent lookup. */
3861#define DECL_HIDDEN_FRIEND_P(NODE) \
3862 (LANG_DECL_FN_CHECK (DECL_COMMON_CHECK (NODE))->hidden_friend_p)
3863
3864/* Nonzero if NODE is an artificial FUNCTION_DECL for
3865 #pragma omp declare reduction. */
3866#define DECL_OMP_DECLARE_REDUCTION_P(NODE) \
3867 (LANG_DECL_FN_CHECK (DECL_COMMON_CHECK (NODE))->omp_declare_reduction_p)
3868
3869/* Nonzero if DECL has been declared threadprivate by
3870 #pragma omp threadprivate. */
3871#define CP_DECL_THREADPRIVATE_P(DECL) \
3872 (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (DECL))->u.base.threadprivate_or_deleted_p)
3873
3874/* Nonzero if NODE is a VAR_DECL which has been declared inline. */
3875#define DECL_VAR_DECLARED_INLINE_P(NODE) \
3876 (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE)) \
3877 ? DECL_LANG_SPECIFIC (NODE)->u.base.var_declared_inline_p \
3878 : false)
3879#define SET_DECL_VAR_DECLARED_INLINE_P(NODE) \
3880 (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE))->u.base.var_declared_inline_p \
3881 = true)
3882
3883/* True if NODE is a constant variable with a value-dependent initializer. */
3884#define DECL_DEPENDENT_INIT_P(NODE) \
3885 (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE)) \
3886 && DECL_LANG_SPECIFIC (NODE)->u.base.dependent_init_p)
3887#define SET_DECL_DEPENDENT_INIT_P(NODE, X) \
3888 (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE))->u.base.dependent_init_p = (X))
3889
3890/* Nonzero if NODE is an artificial VAR_DECL for a C++17 structured binding
3891 declaration or one of VAR_DECLs for the user identifiers in it. */
3892#define DECL_DECOMPOSITION_P(NODE) \
3893 (VAR_P (NODE) && DECL_LANG_SPECIFIC (NODE) \
3894 ? DECL_LANG_SPECIFIC (NODE)->u.base.selector == lds_decomp \
3895 : false)
3896
3897/* The underlying artificial VAR_DECL for structured binding. */
3898#define DECL_DECOMP_BASE(NODE) \
3899 (LANG_DECL_DECOMP_CHECK (NODE)->base)
3900
3901/* Nonzero if NODE is an inline VAR_DECL. In C++17, static data members
3902 declared with constexpr specifier are implicitly inline variables. */
3903#define DECL_INLINE_VAR_P(NODE) \
3904 (DECL_VAR_DECLARED_INLINE_P (NODE) \
3905 || (cxx_dialect >= cxx17 \
3906 && DECL_DECLARED_CONSTEXPR_P (NODE) \
3907 && DECL_CLASS_SCOPE_P (NODE)))
3908
3909/* Nonzero if DECL was declared with '= delete'. */
3910#define DECL_DELETED_FN(DECL) \
3911 (LANG_DECL_FN_CHECK (DECL)->min.base.threadprivate_or_deleted_p)
3912
3913/* Nonzero if DECL was declared with '= default' (maybe implicitly). */
3914#define DECL_DEFAULTED_FN(DECL) \
3915 (LANG_DECL_FN_CHECK (DECL)->defaulted_p)
3916
3917/* Nonzero if DECL is explicitly defaulted in the class body. */
3918#define DECL_DEFAULTED_IN_CLASS_P(DECL) \
3919 (DECL_DEFAULTED_FN (DECL) && DECL_INITIALIZED_IN_CLASS_P (DECL))
3920/* Nonzero if DECL was defaulted outside the class body. */
3921#define DECL_DEFAULTED_OUTSIDE_CLASS_P(DECL) \
3922 (DECL_DEFAULTED_FN (DECL) \
3923 && !(DECL_ARTIFICIAL (DECL) || DECL_INITIALIZED_IN_CLASS_P (DECL)))
3924
3925/* Record whether a typedef for type `int' was actually `signed int'. */
3926#define C_TYPEDEF_EXPLICITLY_SIGNED(EXP) DECL_LANG_FLAG_1 (EXP)
3927
3928/* Returns nonzero if DECL has external linkage, as specified by the
3929 language standard. (This predicate may hold even when the
3930 corresponding entity is not actually given external linkage in the
3931 object file; see decl_linkage for details.) */
3932#define DECL_EXTERNAL_LINKAGE_P(DECL) \
3933 (decl_linkage (DECL) == lk_external)
3934
3935/* Keep these codes in ascending code order. */
3936
3937#define INTEGRAL_CODE_P(CODE) \
3938 ((CODE) == ENUMERAL_TYPE \
3939 || (CODE) == BOOLEAN_TYPE \
3940 || (CODE) == INTEGER_TYPE)
3941
3942/* [basic.fundamental]
3943
3944 Types bool, char, wchar_t, and the signed and unsigned integer types
3945 are collectively called integral types.
3946
3947 Note that INTEGRAL_TYPE_P, as defined in tree.h, allows enumeration
3948 types as well, which is incorrect in C++. Keep these checks in
3949 ascending code order. */
3950#define CP_INTEGRAL_TYPE_P(TYPE) \
3951 (TREE_CODE (TYPE) == BOOLEAN_TYPE \
3952 || TREE_CODE (TYPE) == INTEGER_TYPE)
3953
3954/* Returns true if TYPE is an integral or enumeration name. Keep
3955 these checks in ascending code order. */
3956#define INTEGRAL_OR_ENUMERATION_TYPE_P(TYPE) \
3957 (TREE_CODE (TYPE) == ENUMERAL_TYPE || CP_INTEGRAL_TYPE_P (TYPE))
3958
3959/* Returns true if TYPE is an integral or unscoped enumeration type. */
3960#define INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P(TYPE) \
3961 (UNSCOPED_ENUM_P (TYPE) || CP_INTEGRAL_TYPE_P (TYPE))
3962
3963/* True if the class type TYPE is a literal type. */
3964#define CLASSTYPE_LITERAL_P(TYPE) \
3965 (LANG_TYPE_CLASS_CHECK (TYPE)->is_literal)
3966
3967/* [basic.fundamental]
3968
3969 Integral and floating types are collectively called arithmetic
3970 types.
3971
3972 As a GNU extension, we also accept complex types.
3973
3974 Keep these checks in ascending code order. */
3975#define ARITHMETIC_TYPE_P(TYPE) \
3976 (CP_INTEGRAL_TYPE_P (TYPE) \
3977 || TREE_CODE (TYPE) == REAL_TYPE \
3978 || TREE_CODE (TYPE) == COMPLEX_TYPE)
3979
3980/* True iff TYPE is cv decltype(nullptr). */
3981#define NULLPTR_TYPE_P(TYPE) (TREE_CODE (TYPE) == NULLPTR_TYPE)
3982
3983/* [basic.types]
3984
3985 Arithmetic types, enumeration types, pointer types,
3986 pointer-to-member types, and std::nullptr_t are collectively called
3987 scalar types.
3988
3989 Keep these checks in ascending code order. */
3990#define SCALAR_TYPE_P(TYPE) \
3991 (TYPE_PTRDATAMEM_P (TYPE) \
3992 || TREE_CODE (TYPE) == ENUMERAL_TYPE \
3993 || ARITHMETIC_TYPE_P (TYPE) \
3994 || TYPE_PTR_P (TYPE) \
3995 || TYPE_PTRMEMFUNC_P (TYPE) \
3996 || NULLPTR_TYPE_P (TYPE))
3997
3998/* Determines whether this type is a C++0x scoped enumeration
3999 type. Scoped enumerations types are introduced via "enum class" or
4000 "enum struct", e.g.,
4001
4002 enum class Color {
4003 Red, Green, Blue
4004 };
4005
4006 Scoped enumeration types are different from normal (unscoped)
4007 enumeration types in several ways:
4008
4009 - The enumerators of a scoped enumeration type are only available
4010 within the scope of the enumeration type and not in the
4011 enclosing scope. For example, the Red color can be referred to
4012 with "Color::Red" but not "Red".
4013
4014 - Scoped enumerators and enumerations do not implicitly convert
4015 to integers or 'bool'.
4016
4017 - The underlying type of the enum is well-defined. */
4018#define SCOPED_ENUM_P(TYPE) \
4019 (TREE_CODE (TYPE) == ENUMERAL_TYPE && ENUM_IS_SCOPED (TYPE))
4020
4021/* Determine whether this is an unscoped enumeration type. */
4022#define UNSCOPED_ENUM_P(TYPE) \
4023 (TREE_CODE (TYPE) == ENUMERAL_TYPE && !ENUM_IS_SCOPED (TYPE))
4024
4025/* Set the flag indicating whether an ENUMERAL_TYPE is a C++0x scoped
4026 enumeration type (1) or a normal (unscoped) enumeration type
4027 (0). */
4028#define SET_SCOPED_ENUM_P(TYPE, VAL) \
4029 (ENUM_IS_SCOPED (TYPE) = (VAL))
4030
4031#define SET_OPAQUE_ENUM_P(TYPE, VAL) \
4032 (ENUM_IS_OPAQUE (TYPE) = (VAL))
4033
4034#define OPAQUE_ENUM_P(TYPE) \
4035 (TREE_CODE (TYPE) == ENUMERAL_TYPE && ENUM_IS_OPAQUE (TYPE))
4036
4037/* Determines whether an ENUMERAL_TYPE has an explicit
4038 underlying type. */
4039#define ENUM_FIXED_UNDERLYING_TYPE_P(NODE) (TYPE_LANG_FLAG_5 (NODE))
4040
4041/* Returns the underlying type of the given enumeration type. The
4042 underlying type is determined in different ways, depending on the
4043 properties of the enum:
4044
4045 - In C++0x, the underlying type can be explicitly specified, e.g.,
4046
4047 enum E1 : char { ... } // underlying type is char
4048
4049 - In a C++0x scoped enumeration, the underlying type is int
4050 unless otherwises specified:
4051
4052 enum class E2 { ... } // underlying type is int
4053
4054 - Otherwise, the underlying type is determined based on the
4055 values of the enumerators. In this case, the
4056 ENUM_UNDERLYING_TYPE will not be set until after the definition
4057 of the enumeration is completed by finish_enum. */
4058#define ENUM_UNDERLYING_TYPE(TYPE) \
4059 TREE_TYPE (ENUMERAL_TYPE_CHECK (TYPE))
4060
4061/* [dcl.init.aggr]
4062
4063 An aggregate is an array or a class with no user-provided
4064 constructors, no brace-or-equal-initializers for non-static data
4065 members, no private or protected non-static data members, no
4066 base classes, and no virtual functions.
4067
4068 As an extension, we also treat vectors as aggregates. Keep these
4069 checks in ascending code order. */
4070#define CP_AGGREGATE_TYPE_P(TYPE) \
4071 (TREE_CODE (TYPE) == VECTOR_TYPE \
4072 ||TREE_CODE (TYPE) == ARRAY_TYPE \
4073 || (CLASS_TYPE_P (TYPE) && !CLASSTYPE_NON_AGGREGATE (TYPE)))
4074
4075/* Nonzero for a class type means that the class type has a
4076 user-declared constructor. */
4077#define TYPE_HAS_USER_CONSTRUCTOR(NODE) (TYPE_LANG_FLAG_1 (NODE))
4078
4079/* Nonzero means that the FUNCTION_TYPE or METHOD_TYPE has a
4080 late-specified return type. */
4081#define TYPE_HAS_LATE_RETURN_TYPE(NODE) \
4082 (TYPE_LANG_FLAG_2 (FUNC_OR_METHOD_CHECK (NODE)))
4083
4084/* When appearing in an INDIRECT_REF, it means that the tree structure
4085 underneath is actually a call to a constructor. This is needed
4086 when the constructor must initialize local storage (which can
4087 be automatically destroyed), rather than allowing it to allocate
4088 space from the heap.
4089
4090 When appearing in a SAVE_EXPR, it means that underneath
4091 is a call to a constructor.
4092
4093 When appearing in a CONSTRUCTOR, the expression is a
4094 compound literal.
4095
4096 When appearing in a FIELD_DECL, it means that this field
4097 has been duly initialized in its constructor. */
4098#define TREE_HAS_CONSTRUCTOR(NODE) (TREE_LANG_FLAG_4 (NODE))
4099
4100/* True if NODE is a brace-enclosed initializer. */
4101#define BRACE_ENCLOSED_INITIALIZER_P(NODE) \
4102 (TREE_CODE (NODE) == CONSTRUCTOR && TREE_TYPE (NODE) == init_list_type_node)
4103
4104/* True if NODE is a compound-literal, i.e., a brace-enclosed
4105 initializer cast to a particular type. */
4106#define COMPOUND_LITERAL_P(NODE) \
4107 (TREE_CODE (NODE) == CONSTRUCTOR && TREE_HAS_CONSTRUCTOR (NODE))
4108
4109#define EMPTY_CONSTRUCTOR_P(NODE) (TREE_CODE (NODE) == CONSTRUCTOR \
4110 && vec_safe_is_empty(CONSTRUCTOR_ELTS(NODE))\
4111 && !TREE_HAS_CONSTRUCTOR (NODE))
4112
4113/* True if NODE is a init-list used as a direct-initializer, i.e.
4114 B b{1,2}, not B b({1,2}) or B b = {1,2}. */
4115#define CONSTRUCTOR_IS_DIRECT_INIT(NODE) (TREE_LANG_FLAG_0 (CONSTRUCTOR_CHECK (NODE)))
4116
4117/* True if an uninitialized element in NODE should not be treated as
4118 implicitly value-initialized. Only used in constexpr evaluation. */
4119#define CONSTRUCTOR_NO_IMPLICIT_ZERO(NODE) \
4120 (TREE_LANG_FLAG_1 (CONSTRUCTOR_CHECK (NODE)))
4121
4122/* True if this CONSTRUCTOR should not be used as a variable initializer
4123 because it was loaded from a constexpr variable with mutable fields. */
4124#define CONSTRUCTOR_MUTABLE_POISON(NODE) \
4125 (TREE_LANG_FLAG_2 (CONSTRUCTOR_CHECK (NODE)))
4126
4127/* True if this typed CONSTRUCTOR represents C99 compound-literal syntax rather
4128 than C++11 functional cast syntax. */
4129#define CONSTRUCTOR_C99_COMPOUND_LITERAL(NODE) \
4130 (TREE_LANG_FLAG_3 (CONSTRUCTOR_CHECK (NODE)))
4131
4132#define DIRECT_LIST_INIT_P(NODE) \
4133 (BRACE_ENCLOSED_INITIALIZER_P (NODE) && CONSTRUCTOR_IS_DIRECT_INIT (NODE))
4134
4135/* True if NODE represents a conversion for direct-initialization in a
4136 template. Set by perform_implicit_conversion_flags. */
4137#define IMPLICIT_CONV_EXPR_DIRECT_INIT(NODE) \
4138 (TREE_LANG_FLAG_0 (IMPLICIT_CONV_EXPR_CHECK (NODE)))
4139
4140/* True if NODE represents a dependent conversion of a non-type template
4141 argument. Set by maybe_convert_nontype_argument. */
4142#define IMPLICIT_CONV_EXPR_NONTYPE_ARG(NODE) \
4143 (TREE_LANG_FLAG_1 (IMPLICIT_CONV_EXPR_CHECK (NODE)))
4144
4145/* Nonzero means that an object of this type can not be initialized using
4146 an initializer list. */
4147#define CLASSTYPE_NON_AGGREGATE(NODE) \
4148 (LANG_TYPE_CLASS_CHECK (NODE)->non_aggregate)
4149#define TYPE_NON_AGGREGATE_CLASS(NODE) \
4150 (CLASS_TYPE_P (NODE) && CLASSTYPE_NON_AGGREGATE (NODE))
4151
4152/* Nonzero if there is a non-trivial X::op=(cv X&) for this class. */
4153#define TYPE_HAS_COMPLEX_COPY_ASSIGN(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_copy_assign)
4154
4155/* Nonzero if there is a non-trivial X::X(cv X&) for this class. */
4156#define TYPE_HAS_COMPLEX_COPY_CTOR(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_copy_ctor)
4157
4158/* Nonzero if there is a non-trivial X::op=(X&&) for this class. */
4159#define TYPE_HAS_COMPLEX_MOVE_ASSIGN(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_move_assign)
4160
4161/* Nonzero if there is a non-trivial X::X(X&&) for this class. */
4162#define TYPE_HAS_COMPLEX_MOVE_CTOR(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_move_ctor)
4163
4164/* Nonzero if there is no trivial default constructor for this class. */
4165#define TYPE_HAS_COMPLEX_DFLT(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_dflt)
4166
4167/* Nonzero if TYPE has a trivial destructor. From [class.dtor]:
4168
4169 A destructor is trivial if it is an implicitly declared
4170 destructor and if:
4171
4172 - all of the direct base classes of its class have trivial
4173 destructors,
4174
4175 - for all of the non-static data members of its class that are
4176 of class type (or array thereof), each such class has a
4177 trivial destructor. */
4178#define TYPE_HAS_TRIVIAL_DESTRUCTOR(NODE) \
4179 (!TYPE_HAS_NONTRIVIAL_DESTRUCTOR (NODE))
4180
4181/* Nonzero for _TYPE node means that this type does not have a trivial
4182 destructor. Therefore, destroying an object of this type will
4183 involve a call to a destructor. This can apply to objects of
4184 ARRAY_TYPE is the type of the elements needs a destructor. */
4185#define TYPE_HAS_NONTRIVIAL_DESTRUCTOR(NODE) \
4186 (TYPE_LANG_FLAG_4 (NODE))
4187
4188/* Nonzero for class type means that the default constructor is trivial. */
4189#define TYPE_HAS_TRIVIAL_DFLT(NODE) \
4190 (TYPE_HAS_DEFAULT_CONSTRUCTOR (NODE) && ! TYPE_HAS_COMPLEX_DFLT (NODE))
4191
4192/* Nonzero for class type means that copy initialization of this type can use
4193 a bitwise copy. */
4194#define TYPE_HAS_TRIVIAL_COPY_CTOR(NODE) \
4195 (TYPE_HAS_COPY_CTOR (NODE) && ! TYPE_HAS_COMPLEX_COPY_CTOR (NODE))
4196
4197/* Nonzero for class type means that assignment of this type can use
4198 a bitwise copy. */
4199#define TYPE_HAS_TRIVIAL_COPY_ASSIGN(NODE) \
4200 (TYPE_HAS_COPY_ASSIGN (NODE) && ! TYPE_HAS_COMPLEX_COPY_ASSIGN (NODE))
4201
4202/* Returns true if NODE is a pointer-to-data-member. */
4203#define TYPE_PTRDATAMEM_P(NODE) \
4204 (TREE_CODE (NODE) == OFFSET_TYPE)
4205/* Returns true if NODE is a pointer. */
4206#define TYPE_PTR_P(NODE) \
4207 (TREE_CODE (NODE) == POINTER_TYPE)
4208
4209/* Returns true if NODE is an object type:
4210
4211 [basic.types]
4212
4213 An object type is a (possibly cv-qualified) type that is not a
4214 function type, not a reference type, and not a void type.
4215
4216 Keep these checks in ascending order, for speed. */
4217#define TYPE_OBJ_P(NODE) \
4218 (TREE_CODE (NODE) != REFERENCE_TYPE \
4219 && !VOID_TYPE_P (NODE) \
4220 && TREE_CODE (NODE) != FUNCTION_TYPE \
4221 && TREE_CODE (NODE) != METHOD_TYPE)
4222
4223/* Returns true if NODE is a pointer to an object. Keep these checks
4224 in ascending tree code order. */
4225#define TYPE_PTROB_P(NODE) \
4226 (TYPE_PTR_P (NODE) && TYPE_OBJ_P (TREE_TYPE (NODE)))
4227
4228/* Returns true if NODE is a reference to an object. Keep these checks
4229 in ascending tree code order. */
4230#define TYPE_REF_OBJ_P(NODE) \
4231 (TREE_CODE (NODE) == REFERENCE_TYPE && TYPE_OBJ_P (TREE_TYPE (NODE)))
4232
4233/* Returns true if NODE is a pointer to an object, or a pointer to
4234 void. Keep these checks in ascending tree code order. */
4235#define TYPE_PTROBV_P(NODE) \
4236 (TYPE_PTR_P (NODE) \
4237 && !(TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE \
4238 || TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE))
4239
4240/* Returns true if NODE is a pointer to function type. */
4241#define TYPE_PTRFN_P(NODE) \
4242 (TYPE_PTR_P (NODE) \
4243 && TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE)
4244
4245/* Returns true if NODE is a reference to function type. */
4246#define TYPE_REFFN_P(NODE) \
4247 (TREE_CODE (NODE) == REFERENCE_TYPE \
4248 && TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE)
4249
4250/* Returns true if NODE is a pointer to member function type. */
4251#define TYPE_PTRMEMFUNC_P(NODE) \
4252 (TREE_CODE (NODE) == RECORD_TYPE \
4253 && TYPE_PTRMEMFUNC_FLAG (NODE))
4254
4255#define TYPE_PTRMEMFUNC_FLAG(NODE) \
4256 (TYPE_LANG_FLAG_2 (RECORD_TYPE_CHECK (NODE)))
4257
4258/* Returns true if NODE is a pointer-to-member. */
4259#define TYPE_PTRMEM_P(NODE) \
4260 (TYPE_PTRDATAMEM_P (NODE) || TYPE_PTRMEMFUNC_P (NODE))
4261
4262/* Returns true if NODE is a pointer or a pointer-to-member. */
4263#define TYPE_PTR_OR_PTRMEM_P(NODE) \
4264 (TYPE_PTR_P (NODE) || TYPE_PTRMEM_P (NODE))
4265
4266/* Indicates when overload resolution may resolve to a pointer to
4267 member function. [expr.unary.op]/3 */
4268#define PTRMEM_OK_P(NODE) \
4269 TREE_LANG_FLAG_0 (TREE_CHECK3 ((NODE), ADDR_EXPR, OFFSET_REF, SCOPE_REF))
4270
4271/* Get the POINTER_TYPE to the METHOD_TYPE associated with this
4272 pointer to member function. TYPE_PTRMEMFUNC_P _must_ be true,
4273 before using this macro. */
4274#define TYPE_PTRMEMFUNC_FN_TYPE(NODE) \
4275 (cp_build_qualified_type (TREE_TYPE (TYPE_FIELDS (NODE)),\
4276 cp_type_quals (NODE)))
4277
4278/* As above, but can be used in places that want an lvalue at the expense
4279 of not necessarily having the correct cv-qualifiers. */
4280#define TYPE_PTRMEMFUNC_FN_TYPE_RAW(NODE) \
4281 (TREE_TYPE (TYPE_FIELDS (NODE)))
4282
4283/* Returns `A' for a type like `int (A::*)(double)' */
4284#define TYPE_PTRMEMFUNC_OBJECT_TYPE(NODE) \
4285 TYPE_METHOD_BASETYPE (TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (NODE)))
4286
4287/* The canonical internal RECORD_TYPE from the POINTER_TYPE to
4288 METHOD_TYPE. */
4289#define TYPE_PTRMEMFUNC_TYPE(NODE) \
4290 TYPE_LANG_SLOT_1 (NODE)
4291
4292/* For a pointer-to-member type of the form `T X::*', this is `X'.
4293 For a type like `void (X::*)() const', this type is `X', not `const
4294 X'. To get at the `const X' you have to look at the
4295 TYPE_PTRMEM_POINTED_TO_TYPE; there, the first parameter will have
4296 type `const X*'. */
4297#define TYPE_PTRMEM_CLASS_TYPE(NODE) \
4298 (TYPE_PTRDATAMEM_P (NODE) \
4299 ? TYPE_OFFSET_BASETYPE (NODE) \
4300 : TYPE_PTRMEMFUNC_OBJECT_TYPE (NODE))
4301
4302/* For a pointer-to-member type of the form `T X::*', this is `T'. */
4303#define TYPE_PTRMEM_POINTED_TO_TYPE(NODE) \
4304 (TYPE_PTRDATAMEM_P (NODE) \
4305 ? TREE_TYPE (NODE) \
4306 : TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (NODE)))
4307
4308/* For a pointer-to-member constant `X::Y' this is the RECORD_TYPE for
4309 `X'. */
4310#define PTRMEM_CST_CLASS(NODE) \
4311 TYPE_PTRMEM_CLASS_TYPE (TREE_TYPE (PTRMEM_CST_CHECK (NODE)))
4312
4313/* For a pointer-to-member constant `X::Y' this is the _DECL for
4314 `Y'. */
4315#define PTRMEM_CST_MEMBER(NODE) \
4316 (((ptrmem_cst_t)PTRMEM_CST_CHECK (NODE))->member)
4317
4318/* The expression in question for a TYPEOF_TYPE. */
4319#define TYPEOF_TYPE_EXPR(NODE) (TYPE_VALUES_RAW (TYPEOF_TYPE_CHECK (NODE)))
4320
4321/* The type in question for an UNDERLYING_TYPE. */
4322#define UNDERLYING_TYPE_TYPE(NODE) \
4323 (TYPE_VALUES_RAW (UNDERLYING_TYPE_CHECK (NODE)))
4324
4325/* The type in question for BASES. */
4326#define BASES_TYPE(NODE) \
4327 (TYPE_VALUES_RAW (BASES_CHECK (NODE)))
4328
4329#define BASES_DIRECT(NODE) \
4330 TREE_LANG_FLAG_0 (BASES_CHECK (NODE))
4331
4332/* The expression in question for a DECLTYPE_TYPE. */
4333#define DECLTYPE_TYPE_EXPR(NODE) (TYPE_VALUES_RAW (DECLTYPE_TYPE_CHECK (NODE)))
4334
4335/* Whether the DECLTYPE_TYPE_EXPR of NODE was originally parsed as an
4336 id-expression or a member-access expression. When false, it was
4337 parsed as a full expression. */
4338#define DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P(NODE) \
4339 (DECLTYPE_TYPE_CHECK (NODE))->type_common.string_flag
4340
4341/* These flags indicate that we want different semantics from normal
4342 decltype: lambda capture just drops references, init capture
4343 uses auto semantics, lambda proxies look through implicit dereference. */
4344#define DECLTYPE_FOR_LAMBDA_CAPTURE(NODE) \
4345 TREE_LANG_FLAG_0 (DECLTYPE_TYPE_CHECK (NODE))
4346#define DECLTYPE_FOR_INIT_CAPTURE(NODE) \
4347 TREE_LANG_FLAG_1 (DECLTYPE_TYPE_CHECK (NODE))
4348#define DECLTYPE_FOR_LAMBDA_PROXY(NODE) \
4349 TREE_LANG_FLAG_2 (DECLTYPE_TYPE_CHECK (NODE))
4350#define DECLTYPE_FOR_REF_CAPTURE(NODE) \
4351 TREE_LANG_FLAG_3 (DECLTYPE_TYPE_CHECK (NODE))
4352
4353/* Nonzero for VAR_DECL and FUNCTION_DECL node means that `extern' was
4354 specified in its declaration. This can also be set for an
4355 erroneously declared PARM_DECL. */
4356#define DECL_THIS_EXTERN(NODE) \
4357 DECL_LANG_FLAG_2 (VAR_FUNCTION_OR_PARM_DECL_CHECK (NODE))
4358
4359/* Nonzero for VAR_DECL and FUNCTION_DECL node means that `static' was
4360 specified in its declaration. This can also be set for an
4361 erroneously declared PARM_DECL. */
4362#define DECL_THIS_STATIC(NODE) \
4363 DECL_LANG_FLAG_6 (VAR_FUNCTION_OR_PARM_DECL_CHECK (NODE))
4364
4365/* Nonzero for FIELD_DECL node means that this field is a lambda capture
4366 field for an array of runtime bound. */
4367#define DECL_VLA_CAPTURE_P(NODE) \
4368 DECL_LANG_FLAG_1 (FIELD_DECL_CHECK (NODE))
4369
4370/* Nonzero for PARM_DECL node means that this is an array function
4371 parameter, i.e, a[] rather than *a. */
4372#define DECL_ARRAY_PARAMETER_P(NODE) \
4373 DECL_LANG_FLAG_1 (PARM_DECL_CHECK (NODE))
4374
4375/* Nonzero for a FIELD_DECL who's NSMDI is currently being
4376 instantiated. */
4377#define DECL_INSTANTIATING_NSDMI_P(NODE) \
4378 DECL_LANG_FLAG_2 (FIELD_DECL_CHECK (NODE))
4379
4380/* Nonzero for FIELD_DECL node means that this field is a base class
4381 of the parent object, as opposed to a member field. */
4382#define DECL_FIELD_IS_BASE(NODE) \
4383 DECL_LANG_FLAG_6 (FIELD_DECL_CHECK (NODE))
4384
4385/* Nonzero for FIELD_DECL node means that this field is a simple (no
4386 explicit initializer) lambda capture field, making it invisible to
4387 name lookup in unevaluated contexts. */
4388#define DECL_NORMAL_CAPTURE_P(NODE) \
4389 DECL_LANG_FLAG_7 (FIELD_DECL_CHECK (NODE))
4390
4391/* Nonzero if TYPE is an anonymous union or struct type. We have to use a
4392 flag for this because "A union for which objects or pointers are
4393 declared is not an anonymous union" [class.union]. */
4394#define ANON_AGGR_TYPE_P(NODE) \
4395 (CLASS_TYPE_P (NODE) && LANG_TYPE_CLASS_CHECK (NODE)->anon_aggr)
4396#define SET_ANON_AGGR_TYPE_P(NODE) \
4397 (LANG_TYPE_CLASS_CHECK (NODE)->anon_aggr = 1)
4398
4399/* Nonzero if TYPE is an anonymous union type. */
4400#define ANON_UNION_TYPE_P(NODE) \
4401 (TREE_CODE (NODE) == UNION_TYPE && ANON_AGGR_TYPE_P (NODE))
4402
4403/* Define fields and accessors for nodes representing declared names. */
4404
4405/* Nonzero if TYPE is an unnamed class with a typedef for linkage purposes. */
4406#define TYPE_WAS_UNNAMED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->was_anonymous)
4407
4408/* C++: all of these are overloaded! These apply only to TYPE_DECLs. */
4409
4410/* The format of each node in the DECL_FRIENDLIST is as follows:
4411
4412 The TREE_PURPOSE will be the name of a function, i.e., an
4413 IDENTIFIER_NODE. The TREE_VALUE will be itself a TREE_LIST, whose
4414 TREE_VALUEs are friends with the given name. */
4415#define DECL_FRIENDLIST(NODE) (DECL_INITIAL (NODE))
4416#define FRIEND_NAME(LIST) (TREE_PURPOSE (LIST))
4417#define FRIEND_DECLS(LIST) (TREE_VALUE (LIST))
4418
4419/* The DECL_ACCESS, if non-NULL, is a TREE_LIST. The TREE_PURPOSE of
4420 each node is a type; the TREE_VALUE is the access granted for this
4421 DECL in that type. The DECL_ACCESS is set by access declarations.
4422 For example, if a member that would normally be public in a
4423 derived class is made protected, then the derived class and the
4424 protected_access_node will appear in the DECL_ACCESS for the node. */
4425#define DECL_ACCESS(NODE) (LANG_DECL_U2_CHECK (NODE, 0)->access)
4426
4427/* Nonzero if the FUNCTION_DECL is a global constructor. */
4428#define DECL_GLOBAL_CTOR_P(NODE) \
4429 (LANG_DECL_FN_CHECK (NODE)->global_ctor_p)
4430
4431/* Nonzero if the FUNCTION_DECL is a global destructor. */
4432#define DECL_GLOBAL_DTOR_P(NODE) \
4433 (LANG_DECL_FN_CHECK (NODE)->global_dtor_p)
4434
4435/* Accessor macros for C++ template decl nodes. */
4436
4437/* The DECL_TEMPLATE_PARMS are a list. The TREE_PURPOSE of each node
4438 is a INT_CST whose TREE_INT_CST_LOW indicates the level of the
4439 template parameters, with 1 being the outermost set of template
4440 parameters. The TREE_VALUE is a vector, whose elements are the
4441 template parameters at each level. Each element in the vector is a
4442 TREE_LIST, whose TREE_VALUE is a PARM_DECL (if the parameter is a
4443 non-type parameter), or a TYPE_DECL (if the parameter is a type
4444 parameter). The TREE_PURPOSE is the default value, if any. The
4445 TEMPLATE_PARM_INDEX for the parameter is available as the
4446 DECL_INITIAL (for a PARM_DECL) or as the TREE_TYPE (for a
4447 TYPE_DECL).
4448
4449 FIXME: CONST_CAST_TREE is a hack that hopefully will go away after
4450 tree is converted to C++ class hiearchy. */
4451#define DECL_TEMPLATE_PARMS(NODE) \
4452 ((struct tree_template_decl *)CONST_CAST_TREE (TEMPLATE_DECL_CHECK (NODE)))->arguments
4453#define DECL_INNERMOST_TEMPLATE_PARMS(NODE) \
4454 INNERMOST_TEMPLATE_PARMS (DECL_TEMPLATE_PARMS (NODE))
4455#define DECL_NTPARMS(NODE) \
4456 TREE_VEC_LENGTH (DECL_INNERMOST_TEMPLATE_PARMS (NODE))
4457/* For function, method, class-data templates.
4458
4459 FIXME: CONST_CAST_TREE is a hack that hopefully will go away after
4460 tree is converted to C++ class hiearchy. */
4461#define DECL_TEMPLATE_RESULT(NODE) \
4462 ((struct tree_template_decl *)CONST_CAST_TREE(TEMPLATE_DECL_CHECK (NODE)))->result
4463/* For a function template at namespace scope, DECL_TEMPLATE_INSTANTIATIONS
4464 lists all instantiations and specializations of the function so that
4465 tsubst_friend_function can reassign them to another template if we find
4466 that the namespace-scope template is really a partial instantiation of a
4467 friend template.
4468
4469 For a class template the DECL_TEMPLATE_INSTANTIATIONS lists holds
4470 all instantiations and specializations of the class type, including
4471 partial instantiations and partial specializations, so that if we
4472 explicitly specialize a partial instantiation we can walk the list
4473 in maybe_process_partial_specialization and reassign them or complain
4474 as appropriate.
4475
4476 In both cases, the TREE_PURPOSE of each node contains the arguments
4477 used; the TREE_VALUE contains the generated variable. The template
4478 arguments are always complete. For example, given:
4479
4480 template <class T> struct S1 {
4481 template <class U> struct S2 {};
4482 template <class U> struct S2<U*> {};
4483 };
4484
4485 the record for the partial specialization will contain, as its
4486 argument list, { {T}, {U*} }, and will be on the
4487 DECL_TEMPLATE_INSTANTIATIONS list for `template <class T> template
4488 <class U> struct S1<T>::S2'.
4489
4490 This list is not used for other templates. */
4491#define DECL_TEMPLATE_INSTANTIATIONS(NODE) \
4492 DECL_SIZE_UNIT (TEMPLATE_DECL_CHECK (NODE))
4493
4494/* For a class template, this list contains the partial
4495 specializations of this template. (Full specializations are not
4496 recorded on this list.) The TREE_PURPOSE holds the arguments used
4497 in the partial specialization (e.g., for `template <class T> struct
4498 S<T*, int>' this will be `T*, int'.) The arguments will also include
4499 any outer template arguments. The TREE_VALUE holds the TEMPLATE_DECL
4500 for the partial specialization. The TREE_TYPE is the _TYPE node for
4501 the partial specialization.
4502
4503 This list is not used for other templates. */
4504#define DECL_TEMPLATE_SPECIALIZATIONS(NODE) \
4505 DECL_SIZE (TEMPLATE_DECL_CHECK (NODE))
4506
4507/* Nonzero for a DECL which is actually a template parameter. Keep
4508 these checks in ascending tree code order. */
4509#define DECL_TEMPLATE_PARM_P(NODE) \
4510 (DECL_LANG_FLAG_0 (NODE) \
4511 && (TREE_CODE (NODE) == CONST_DECL \
4512 || TREE_CODE (NODE) == PARM_DECL \
4513 || TREE_CODE (NODE) == TYPE_DECL \
4514 || TREE_CODE (NODE) == TEMPLATE_DECL))
4515
4516/* Mark NODE as a template parameter. */
4517#define SET_DECL_TEMPLATE_PARM_P(NODE) \
4518 (DECL_LANG_FLAG_0 (NODE) = 1)
4519
4520/* Nonzero if NODE is a template template parameter. */
4521#define DECL_TEMPLATE_TEMPLATE_PARM_P(NODE) \
4522 (TREE_CODE (NODE) == TEMPLATE_DECL && DECL_TEMPLATE_PARM_P (NODE))
4523
4524/* Nonzero for a DECL that represents a function template. */
4525#define DECL_FUNCTION_TEMPLATE_P(NODE) \
4526 (TREE_CODE (NODE) == TEMPLATE_DECL \
4527 && DECL_TEMPLATE_RESULT (NODE) != NULL_TREE \
4528 && TREE_CODE (DECL_TEMPLATE_RESULT (NODE)) == FUNCTION_DECL)
4529
4530/* Nonzero for a DECL that represents a class template or alias
4531 template. */
4532#define DECL_TYPE_TEMPLATE_P(NODE) \
4533 (TREE_CODE (NODE) == TEMPLATE_DECL \
4534 && DECL_TEMPLATE_RESULT (NODE) != NULL_TREE \
4535 && TREE_CODE (DECL_TEMPLATE_RESULT (NODE)) == TYPE_DECL)
4536
4537/* Nonzero for a DECL that represents a class template. */
4538#define DECL_CLASS_TEMPLATE_P(NODE) \
4539 (DECL_TYPE_TEMPLATE_P (NODE) \
4540 && DECL_IMPLICIT_TYPEDEF_P (DECL_TEMPLATE_RESULT (NODE)))
4541
4542/* Nonzero for a TEMPLATE_DECL that represents an alias template. */
4543#define DECL_ALIAS_TEMPLATE_P(NODE) \
4544 (DECL_TYPE_TEMPLATE_P (NODE) \
4545 && !DECL_ARTIFICIAL (DECL_TEMPLATE_RESULT (NODE)))
4546
4547/* Nonzero for a NODE which declares a type. */
4548#define DECL_DECLARES_TYPE_P(NODE) \
4549 (TREE_CODE (NODE) == TYPE_DECL || DECL_TYPE_TEMPLATE_P (NODE))
4550
4551/* Nonzero if NODE declares a function. */
4552#define DECL_DECLARES_FUNCTION_P(NODE) \
4553 (TREE_CODE (NODE) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (NODE))
4554
4555/* Nonzero if NODE is the typedef implicitly generated for a type when
4556 the type is declared. In C++, `struct S {};' is roughly
4557 equivalent to `struct S {}; typedef struct S S;' in C.
4558 DECL_IMPLICIT_TYPEDEF_P will hold for the typedef indicated in this
4559 example. In C++, there is a second implicit typedef for each
4560 class, called the injected-class-name, in the scope of `S' itself, so that
4561 you can say `S::S'. DECL_SELF_REFERENCE_P will hold for that typedef. */
4562#define DECL_IMPLICIT_TYPEDEF_P(NODE) \
4563 (TREE_CODE (NODE) == TYPE_DECL && DECL_LANG_FLAG_2 (NODE))
4564#define SET_DECL_IMPLICIT_TYPEDEF_P(NODE) \
4565 (DECL_LANG_FLAG_2 (NODE) = 1)
4566#define DECL_SELF_REFERENCE_P(NODE) \
4567 (TREE_CODE (NODE) == TYPE_DECL && DECL_LANG_FLAG_4 (NODE))
4568#define SET_DECL_SELF_REFERENCE_P(NODE) \
4569 (DECL_LANG_FLAG_4 (NODE) = 1)
4570
4571/* A `primary' template is one that has its own template header and is not
4572 a partial specialization. A member function of a class template is a
4573 template, but not primary. A member template is primary. Friend
4574 templates are primary, too. */
4575
4576/* Returns the primary template corresponding to these parameters. */
4577#define DECL_PRIMARY_TEMPLATE(NODE) \
4578 (TREE_TYPE (DECL_INNERMOST_TEMPLATE_PARMS (NODE)))
4579
4580/* Returns nonzero if NODE is a primary template. */
4581#define PRIMARY_TEMPLATE_P(NODE) (DECL_PRIMARY_TEMPLATE (NODE) == (NODE))
4582
4583/* Nonzero iff NODE is a specialization of a template. The value
4584 indicates the type of specializations:
4585
4586 1=implicit instantiation
4587
4588 2=partial or explicit specialization, e.g.:
4589
4590 template <> int min<int> (int, int),
4591
4592 3=explicit instantiation, e.g.:
4593
4594 template int min<int> (int, int);
4595
4596 Note that NODE will be marked as a specialization even if the
4597 template it is instantiating is not a primary template. For
4598 example, given:
4599
4600 template <typename T> struct O {
4601 void f();
4602 struct I {};
4603 };
4604
4605 both O<int>::f and O<int>::I will be marked as instantiations.
4606
4607 If DECL_USE_TEMPLATE is nonzero, then DECL_TEMPLATE_INFO will also
4608 be non-NULL. */
4609#define DECL_USE_TEMPLATE(NODE) (DECL_LANG_SPECIFIC (NODE)->u.base.use_template)
4610
4611/* Like DECL_USE_TEMPLATE, but for class types. */
4612#define CLASSTYPE_USE_TEMPLATE(NODE) \
4613 (LANG_TYPE_CLASS_CHECK (NODE)->use_template)
4614
4615/* True if NODE is a specialization of a primary template. */
4616#define CLASSTYPE_SPECIALIZATION_OF_PRIMARY_TEMPLATE_P(NODE) \
4617 (CLASS_TYPE_P (NODE) \
4618 && CLASSTYPE_USE_TEMPLATE (NODE) \
4619 && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (NODE)))
4620
4621#define DECL_TEMPLATE_INSTANTIATION(NODE) (DECL_USE_TEMPLATE (NODE) & 1)
4622#define CLASSTYPE_TEMPLATE_INSTANTIATION(NODE) \
4623 (CLASSTYPE_USE_TEMPLATE (NODE) & 1)
4624
4625#define DECL_TEMPLATE_SPECIALIZATION(NODE) (DECL_USE_TEMPLATE (NODE) == 2)
4626#define SET_DECL_TEMPLATE_SPECIALIZATION(NODE) (DECL_USE_TEMPLATE (NODE) = 2)
4627
4628/* Returns true for an explicit or partial specialization of a class
4629 template. */
4630#define CLASSTYPE_TEMPLATE_SPECIALIZATION(NODE) \
4631 (CLASSTYPE_USE_TEMPLATE (NODE) == 2)
4632#define SET_CLASSTYPE_TEMPLATE_SPECIALIZATION(NODE) \
4633 (CLASSTYPE_USE_TEMPLATE (NODE) = 2)
4634
4635#define DECL_IMPLICIT_INSTANTIATION(NODE) (DECL_USE_TEMPLATE (NODE) == 1)
4636#define SET_DECL_IMPLICIT_INSTANTIATION(NODE) (DECL_USE_TEMPLATE (NODE) = 1)
4637#define CLASSTYPE_IMPLICIT_INSTANTIATION(NODE) \
4638 (CLASSTYPE_USE_TEMPLATE (NODE) == 1)
4639#define SET_CLASSTYPE_IMPLICIT_INSTANTIATION(NODE) \
4640 (CLASSTYPE_USE_TEMPLATE (NODE) = 1)
4641
4642#define DECL_EXPLICIT_INSTANTIATION(NODE) (DECL_USE_TEMPLATE (NODE) == 3)
4643#define SET_DECL_EXPLICIT_INSTANTIATION(NODE) (DECL_USE_TEMPLATE (NODE) = 3)
4644#define CLASSTYPE_EXPLICIT_INSTANTIATION(NODE) \
4645 (CLASSTYPE_USE_TEMPLATE (NODE) == 3)
4646#define SET_CLASSTYPE_EXPLICIT_INSTANTIATION(NODE) \
4647 (CLASSTYPE_USE_TEMPLATE (NODE) = 3)
4648
4649/* Nonzero if DECL is a friend function which is an instantiation
4650 from the point of view of the compiler, but not from the point of
4651 view of the language. For example given:
4652 template <class T> struct S { friend void f(T) {}; };
4653 the declaration of `void f(int)' generated when S<int> is
4654 instantiated will not be a DECL_TEMPLATE_INSTANTIATION, but will be
4655 a DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION. */
4656#define DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION(DECL) \
4657 (DECL_LANG_SPECIFIC (DECL) && DECL_TEMPLATE_INFO (DECL) \
4658 && !DECL_USE_TEMPLATE (DECL))
4659
4660/* Nonzero if DECL is a function generated from a function 'temploid',
4661 i.e. template, member of class template, or dependent friend. */
4662#define DECL_TEMPLOID_INSTANTIATION(DECL) \
4663 (DECL_TEMPLATE_INSTANTIATION (DECL) \
4664 || DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (DECL))
4665
4666/* Nonzero if DECL is either defined implicitly by the compiler or
4667 generated from a temploid. */
4668#define DECL_GENERATED_P(DECL) \
4669 (DECL_TEMPLOID_INSTANTIATION (DECL) || DECL_DEFAULTED_FN (DECL))
4670
4671/* Nonzero iff we are currently processing a declaration for an
4672 entity with its own template parameter list, and which is not a
4673 full specialization. */
4674#define PROCESSING_REAL_TEMPLATE_DECL_P() \
4675 (processing_template_decl > template_class_depth (current_scope ()))
4676
4677/* Nonzero if this VAR_DECL or FUNCTION_DECL has already been
4678 instantiated, i.e. its definition has been generated from the
4679 pattern given in the template. */
4680#define DECL_TEMPLATE_INSTANTIATED(NODE) \
4681 DECL_LANG_FLAG_1 (VAR_OR_FUNCTION_DECL_CHECK (NODE))
4682
4683/* We know what we're doing with this decl now. */
4684#define DECL_INTERFACE_KNOWN(NODE) DECL_LANG_FLAG_5 (NODE)
4685
4686/* DECL_EXTERNAL must be set on a decl until the decl is actually emitted,
4687 so that assemble_external will work properly. So we have this flag to
4688 tell us whether the decl is really not external.
4689
4690 This flag does not indicate whether or not the decl is defined in the
4691 current translation unit; it indicates whether or not we should emit the
4692 decl at the end of compilation if it is defined and needed. */
4693#define DECL_NOT_REALLY_EXTERN(NODE) \
4694 (DECL_LANG_SPECIFIC (NODE)->u.base.not_really_extern)
4695
4696#define DECL_REALLY_EXTERN(NODE) \
4697 (DECL_EXTERNAL (NODE) \
4698 && (!DECL_LANG_SPECIFIC (NODE) || !DECL_NOT_REALLY_EXTERN (NODE)))
4699
4700/* A thunk is a stub function.
4701
4702 A thunk is an alternate entry point for an ordinary FUNCTION_DECL.
4703 The address of the ordinary FUNCTION_DECL is given by the
4704 DECL_INITIAL, which is always an ADDR_EXPR whose operand is a
4705 FUNCTION_DECL. The job of the thunk is to either adjust the this
4706 pointer before transferring control to the FUNCTION_DECL, or call
4707 FUNCTION_DECL and then adjust the result value. Note, the result
4708 pointer adjusting thunk must perform a call to the thunked
4709 function, (or be implemented via passing some invisible parameter
4710 to the thunked function, which is modified to perform the
4711 adjustment just before returning).
4712
4713 A thunk may perform either, or both, of the following operations:
4714
4715 o Adjust the this or result pointer by a constant offset.
4716 o Adjust the this or result pointer by looking up a vcall or vbase offset
4717 in the vtable.
4718
4719 A this pointer adjusting thunk converts from a base to a derived
4720 class, and hence adds the offsets. A result pointer adjusting thunk
4721 converts from a derived class to a base, and hence subtracts the
4722 offsets. If both operations are performed, then the constant
4723 adjustment is performed first for this pointer adjustment and last
4724 for the result pointer adjustment.
4725
4726 The constant adjustment is given by THUNK_FIXED_OFFSET. If the
4727 vcall or vbase offset is required, THUNK_VIRTUAL_OFFSET is
4728 used. For this pointer adjusting thunks, it is the vcall offset
4729 into the vtable. For result pointer adjusting thunks it is the
4730 binfo of the virtual base to convert to. Use that binfo's vbase
4731 offset.
4732
4733 It is possible to have equivalent covariant thunks. These are
4734 distinct virtual covariant thunks whose vbase offsets happen to
4735 have the same value. THUNK_ALIAS is used to pick one as the
4736 canonical thunk, which will get all the this pointer adjusting
4737 thunks attached to it. */
4738
4739/* An integer indicating how many bytes should be subtracted from the
4740 this or result pointer when this function is called. */
4741#define THUNK_FIXED_OFFSET(DECL) \
4742 (DECL_LANG_SPECIFIC (THUNK_FUNCTION_CHECK (DECL))->u.fn.u5.fixed_offset)
4743
4744/* A tree indicating how to perform the virtual adjustment. For a this
4745 adjusting thunk it is the number of bytes to be added to the vtable
4746 to find the vcall offset. For a result adjusting thunk, it is the
4747 binfo of the relevant virtual base. If NULL, then there is no
4748 virtual adjust. (The vptr is always located at offset zero from
4749 the this or result pointer.) (If the covariant type is within the
4750 class hierarchy being laid out, the vbase index is not yet known
4751 at the point we need to create the thunks, hence the need to use
4752 binfos.) */
4753
4754#define THUNK_VIRTUAL_OFFSET(DECL) \
4755 (LANG_DECL_U2_CHECK (FUNCTION_DECL_CHECK (DECL), 0)->access)
4756
4757/* A thunk which is equivalent to another thunk. */
4758#define THUNK_ALIAS(DECL) \
4759 (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->u.min.template_info)
4760
4761/* For thunk NODE, this is the FUNCTION_DECL thunked to. It is
4762 possible for the target to be a thunk too. */
4763#define THUNK_TARGET(NODE) \
4764 (LANG_DECL_FN_CHECK (NODE)->befriending_classes)
4765
4766/* True for a SCOPE_REF iff the "template" keyword was used to
4767 indicate that the qualified name denotes a template. */
4768#define QUALIFIED_NAME_IS_TEMPLATE(NODE) \
4769 (TREE_LANG_FLAG_1 (SCOPE_REF_CHECK (NODE)))
4770
4771/* True for an OMP_ATOMIC that has dependent parameters. These are stored
4772 as an expr in operand 1, and integer_zero_node in operand 0. */
4773#define OMP_ATOMIC_DEPENDENT_P(NODE) \
4774 (TREE_CODE (TREE_OPERAND (OMP_ATOMIC_CHECK (NODE), 0)) == INTEGER_CST)
4775
4776/* Used while gimplifying continue statements bound to OMP_FOR nodes. */
4777#define OMP_FOR_GIMPLIFYING_P(NODE) \
4778 (TREE_LANG_FLAG_0 (OMP_LOOP_CHECK (NODE)))
4779
4780/* A language-specific token attached to the OpenMP data clauses to
4781 hold code (or code fragments) related to ctors, dtors, and op=.
4782 See semantics.c for details. */
4783#define CP_OMP_CLAUSE_INFO(NODE) \
4784 TREE_TYPE (OMP_CLAUSE_RANGE_CHECK (NODE, OMP_CLAUSE_PRIVATE, \
4785 OMP_CLAUSE_LINEAR))
4786
4787/* Nonzero if this transaction expression's body contains statements. */
4788#define TRANSACTION_EXPR_IS_STMT(NODE) \
4789 TREE_LANG_FLAG_0 (TRANSACTION_EXPR_CHECK (NODE))
4790
4791/* These macros provide convenient access to the various _STMT nodes
4792 created when parsing template declarations. */
4793#define TRY_STMTS(NODE) TREE_OPERAND (TRY_BLOCK_CHECK (NODE), 0)
4794#define TRY_HANDLERS(NODE) TREE_OPERAND (TRY_BLOCK_CHECK (NODE), 1)
4795
4796#define EH_SPEC_STMTS(NODE) TREE_OPERAND (EH_SPEC_BLOCK_CHECK (NODE), 0)
4797#define EH_SPEC_RAISES(NODE) TREE_OPERAND (EH_SPEC_BLOCK_CHECK (NODE), 1)
4798
4799#define USING_STMT_NAMESPACE(NODE) TREE_OPERAND (USING_STMT_CHECK (NODE), 0)
4800
4801/* Nonzero if this try block is a function try block. */
4802#define FN_TRY_BLOCK_P(NODE) TREE_LANG_FLAG_3 (TRY_BLOCK_CHECK (NODE))
4803#define HANDLER_PARMS(NODE) TREE_OPERAND (HANDLER_CHECK (NODE), 0)
4804#define HANDLER_BODY(NODE) TREE_OPERAND (HANDLER_CHECK (NODE), 1)
4805#define HANDLER_TYPE(NODE) TREE_TYPE (HANDLER_CHECK (NODE))
4806
4807/* CLEANUP_STMT accessors. The statement(s) covered, the cleanup to run
4808 and the VAR_DECL for which this cleanup exists. */
4809#define CLEANUP_BODY(NODE) TREE_OPERAND (CLEANUP_STMT_CHECK (NODE), 0)
4810#define CLEANUP_EXPR(NODE) TREE_OPERAND (CLEANUP_STMT_CHECK (NODE), 1)
4811#define CLEANUP_DECL(NODE) TREE_OPERAND (CLEANUP_STMT_CHECK (NODE), 2)
4812
4813/* IF_STMT accessors. These give access to the condition of the if
4814 statement, the then block of the if statement, and the else block
4815 of the if statement if it exists. */
4816#define IF_COND(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 0)
4817#define THEN_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 1)
4818#define ELSE_CLAUSE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 2)
4819#define IF_SCOPE(NODE) TREE_OPERAND (IF_STMT_CHECK (NODE), 3)
4820#define IF_STMT_CONSTEXPR_P(NODE) TREE_LANG_FLAG_0 (IF_STMT_CHECK (NODE))
4821
4822/* WHILE_STMT accessors. These give access to the condition of the
4823 while statement and the body of the while statement, respectively. */
4824#define WHILE_COND(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 0)
4825#define WHILE_BODY(NODE) TREE_OPERAND (WHILE_STMT_CHECK (NODE), 1)
4826
4827/* DO_STMT accessors. These give access to the condition of the do
4828 statement and the body of the do statement, respectively. */
4829#define DO_COND(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 0)
4830#define DO_BODY(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 1)
4831
4832/* FOR_STMT accessors. These give access to the init statement,
4833 condition, update expression, and body of the for statement,
4834 respectively. */
4835#define FOR_INIT_STMT(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 0)
4836#define FOR_COND(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 1)
4837#define FOR_EXPR(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 2)
4838#define FOR_BODY(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 3)
4839#define FOR_SCOPE(NODE) TREE_OPERAND (FOR_STMT_CHECK (NODE), 4)
4840
4841/* RANGE_FOR_STMT accessors. These give access to the declarator,
4842 expression, body, and scope of the statement, respectively. */
4843#define RANGE_FOR_DECL(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 0)
4844#define RANGE_FOR_EXPR(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 1)
4845#define RANGE_FOR_BODY(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 2)
4846#define RANGE_FOR_SCOPE(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 3)
4847#define RANGE_FOR_IVDEP(NODE) TREE_LANG_FLAG_6 (RANGE_FOR_STMT_CHECK (NODE))
4848
4849#define SWITCH_STMT_COND(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 0)
4850#define SWITCH_STMT_BODY(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 1)
4851#define SWITCH_STMT_TYPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 2)
4852#define SWITCH_STMT_SCOPE(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 3)
4853/* True if there are case labels for all possible values of switch cond, either
4854 because there is a default: case label or because the case label ranges cover
4855 all values. */
4856#define SWITCH_STMT_ALL_CASES_P(NODE) \
4857 TREE_LANG_FLAG_0 (SWITCH_STMT_CHECK (NODE))
4858/* True if the body of a switch stmt contains no BREAK_STMTs. */
4859#define SWITCH_STMT_NO_BREAK_P(NODE) \
4860 TREE_LANG_FLAG_2 (SWITCH_STMT_CHECK (NODE))
4861
4862/* STMT_EXPR accessor. */
4863#define STMT_EXPR_STMT(NODE) TREE_OPERAND (STMT_EXPR_CHECK (NODE), 0)
4864
4865/* EXPR_STMT accessor. This gives the expression associated with an
4866 expression statement. */
4867#define EXPR_STMT_EXPR(NODE) TREE_OPERAND (EXPR_STMT_CHECK (NODE), 0)
4868
4869/* True if this TARGET_EXPR was created by build_cplus_new, and so we can
4870 discard it if it isn't useful. */
4871#define TARGET_EXPR_IMPLICIT_P(NODE) \
4872 TREE_LANG_FLAG_0 (TARGET_EXPR_CHECK (NODE))
4873
4874/* True if this TARGET_EXPR is the result of list-initialization of a
4875 temporary. */
4876#define TARGET_EXPR_LIST_INIT_P(NODE) \
4877 TREE_LANG_FLAG_1 (TARGET_EXPR_CHECK (NODE))
4878
4879/* True if this TARGET_EXPR expresses direct-initialization of an object
4880 to be named later. */
4881#define TARGET_EXPR_DIRECT_INIT_P(NODE) \
4882 TREE_LANG_FLAG_2 (TARGET_EXPR_CHECK (NODE))
4883
4884/* True if NODE is a TARGET_EXPR that just expresses a copy of its INITIAL; if
4885 the initializer has void type, it's doing something more complicated. */
4886#define SIMPLE_TARGET_EXPR_P(NODE) \
4887 (TREE_CODE (NODE) == TARGET_EXPR \
4888 && !VOID_TYPE_P (TREE_TYPE (TARGET_EXPR_INITIAL (NODE))))
4889
4890/* True if EXPR expresses direct-initialization of a TYPE. */
4891#define DIRECT_INIT_EXPR_P(TYPE,EXPR) \
4892 (TREE_CODE (EXPR) == TARGET_EXPR && TREE_LANG_FLAG_2 (EXPR) \
4893 && same_type_ignoring_top_level_qualifiers_p (TYPE, TREE_TYPE (EXPR)))
4894
4895/* True if this CONVERT_EXPR is for a conversion to virtual base in
4896 an NSDMI, and should be re-evaluated when used in a constructor. */
4897#define CONVERT_EXPR_VBASE_PATH(NODE) \
4898 TREE_LANG_FLAG_0 (CONVERT_EXPR_CHECK (NODE))
4899
4900/* True if SIZEOF_EXPR argument is type. */
4901#define SIZEOF_EXPR_TYPE_P(NODE) \
4902 TREE_LANG_FLAG_0 (SIZEOF_EXPR_CHECK (NODE))
4903
4904/* An enumeration of the kind of tags that C++ accepts. */
4905enum tag_types {
4906 none_type = 0, /* Not a tag type. */
4907 record_type, /* "struct" types. */
4908 class_type, /* "class" types. */
4909 union_type, /* "union" types. */
4910 enum_type, /* "enum" types. */
4911 typename_type, /* "typename" types. */
4912 scope_type /* namespace or tagged type name followed by :: */
4913};
4914
4915/* The various kinds of lvalues we distinguish. */
4916enum cp_lvalue_kind_flags {
4917 clk_none = 0, /* Things that are not an lvalue. */
4918 clk_ordinary = 1, /* An ordinary lvalue. */
4919 clk_rvalueref = 2,/* An xvalue (rvalue formed using an rvalue reference) */
4920 clk_class = 4, /* A prvalue of class or array type. */
4921 clk_bitfield = 8, /* An lvalue for a bit-field. */
4922 clk_packed = 16 /* An lvalue for a packed field. */
4923};
4924
4925/* This type is used for parameters and variables which hold
4926 combinations of the flags in enum cp_lvalue_kind_flags. */
4927typedef int cp_lvalue_kind;
4928
4929/* Various kinds of template specialization, instantiation, etc. */
4930enum tmpl_spec_kind {
4931 tsk_none, /* Not a template at all. */
4932 tsk_invalid_member_spec, /* An explicit member template
4933 specialization, but the enclosing
4934 classes have not all been explicitly
4935 specialized. */
4936 tsk_invalid_expl_inst, /* An explicit instantiation containing
4937 template parameter lists. */
4938 tsk_excessive_parms, /* A template declaration with too many
4939 template parameter lists. */
4940 tsk_insufficient_parms, /* A template declaration with too few
4941 parameter lists. */
4942 tsk_template, /* A template declaration. */
4943 tsk_expl_spec, /* An explicit specialization. */
4944 tsk_expl_inst /* An explicit instantiation. */
4945};
4946
4947/* The various kinds of access. BINFO_ACCESS depends on these being
4948 two bit quantities. The numerical values are important; they are
4949 used to initialize RTTI data structures, so changing them changes
4950 the ABI. */
4951enum access_kind {
4952 ak_none = 0, /* Inaccessible. */
4953 ak_public = 1, /* Accessible, as a `public' thing. */
4954 ak_protected = 2, /* Accessible, as a `protected' thing. */
4955 ak_private = 3 /* Accessible, as a `private' thing. */
4956};
4957
4958/* The various kinds of special functions. If you add to this list,
4959 you should update special_function_p as well. */
4960enum special_function_kind {
4961 sfk_none = 0, /* Not a special function. This enumeral
4962 must have value zero; see
4963 special_function_p. */
4964 sfk_constructor, /* A constructor. */
4965 sfk_copy_constructor, /* A copy constructor. */
4966 sfk_move_constructor, /* A move constructor. */
4967 sfk_copy_assignment, /* A copy assignment operator. */
4968 sfk_move_assignment, /* A move assignment operator. */
4969 sfk_destructor, /* A destructor. */
4970 sfk_complete_destructor, /* A destructor for complete objects. */
4971 sfk_base_destructor, /* A destructor for base subobjects. */
4972 sfk_deleting_destructor, /* A destructor for complete objects that
4973 deletes the object after it has been
4974 destroyed. */
4975 sfk_conversion, /* A conversion operator. */
4976 sfk_deduction_guide, /* A class template deduction guide. */
4977 sfk_inheriting_constructor /* An inheriting constructor */
4978};
4979
4980/* The various kinds of linkage. From [basic.link],
4981
4982 A name is said to have linkage when it might denote the same
4983 object, reference, function, type, template, namespace or value
4984 as a name introduced in another scope:
4985
4986 -- When a name has external linkage, the entity it denotes can
4987 be referred to from scopes of other translation units or from
4988 other scopes of the same translation unit.
4989
4990 -- When a name has internal linkage, the entity it denotes can
4991 be referred to by names from other scopes in the same
4992 translation unit.
4993
4994 -- When a name has no linkage, the entity it denotes cannot be
4995 referred to by names from other scopes. */
4996
4997enum linkage_kind {
4998 lk_none, /* No linkage. */
4999 lk_internal, /* Internal linkage. */
5000 lk_external /* External linkage. */
5001};
5002
5003enum duration_kind {
5004 dk_static,
5005 dk_thread,
5006 dk_auto,
5007 dk_dynamic
5008};
5009
5010/* Bitmask flags to control type substitution. */
5011enum tsubst_flags {
5012 tf_none = 0, /* nothing special */
5013 tf_error = 1 << 0, /* give error messages */
5014 tf_warning = 1 << 1, /* give warnings too */
5015 tf_ignore_bad_quals = 1 << 2, /* ignore bad cvr qualifiers */
5016 tf_keep_type_decl = 1 << 3, /* retain typedef type decls
5017 (make_typename_type use) */
5018 tf_ptrmem_ok = 1 << 4, /* pointers to member ok (internal
5019 instantiate_type use) */
5020 tf_user = 1 << 5, /* found template must be a user template
5021 (lookup_template_class use) */
5022 tf_conv = 1 << 6, /* We are determining what kind of
5023 conversion might be permissible,
5024 not actually performing the
5025 conversion. */
5026 tf_decltype = 1 << 7, /* We are the operand of decltype.
5027 Used to implement the special rules
5028 for calls in decltype (5.2.2/11). */
5029 tf_partial = 1 << 8, /* Doing initial explicit argument
5030 substitution in fn_type_unification. */
5031 tf_fndecl_type = 1 << 9, /* Substituting the type of a function
5032 declaration. */
5033 tf_no_cleanup = 1 << 10, /* Do not build a cleanup
5034 (build_target_expr and friends) */
5035 /* Convenient substitution flags combinations. */
5036 tf_warning_or_error = tf_warning | tf_error
5037};
5038
5039/* This type is used for parameters and variables which hold
5040 combinations of the flags in enum tsubst_flags. */
5041typedef int tsubst_flags_t;
5042
5043/* The kind of checking we can do looking in a class hierarchy. */
5044enum base_access_flags {
5045 ba_any = 0, /* Do not check access, allow an ambiguous base,
5046 prefer a non-virtual base */
5047 ba_unique = 1 << 0, /* Must be a unique base. */
5048 ba_check_bit = 1 << 1, /* Check access. */
5049 ba_check = ba_unique | ba_check_bit,
5050 ba_ignore_scope = 1 << 2 /* Ignore access allowed by local scope. */
5051};
5052
5053/* This type is used for parameters and variables which hold
5054 combinations of the flags in enum base_access_flags. */
5055typedef int base_access;
5056
5057/* The various kinds of access check during parsing. */
5058enum deferring_kind {
5059 dk_no_deferred = 0, /* Check access immediately */
5060 dk_deferred = 1, /* Deferred check */
5061 dk_no_check = 2 /* No access check */
5062};
5063
5064/* The kind of base we can find, looking in a class hierarchy.
5065 Values <0 indicate we failed. */
5066enum base_kind {
5067 bk_inaccessible = -3, /* The base is inaccessible */
5068 bk_ambig = -2, /* The base is ambiguous */
5069 bk_not_base = -1, /* It is not a base */
5070 bk_same_type = 0, /* It is the same type */
5071 bk_proper_base = 1, /* It is a proper base */
5072 bk_via_virtual = 2 /* It is a proper base, but via a virtual
5073 path. This might not be the canonical
5074 binfo. */
5075};
5076
5077/* Node for "pointer to (virtual) function".
5078 This may be distinct from ptr_type_node so gdb can distinguish them. */
5079#define vfunc_ptr_type_node vtable_entry_type
5080
5081
5082/* For building calls to `delete'. */
5083extern GTY(()) tree integer_two_node;
5084
5085/* The number of function bodies which we are currently processing.
5086 (Zero if we are at namespace scope, one inside the body of a
5087 function, two inside the body of a function in a local class, etc.) */
5088extern int function_depth;
5089
5090/* Nonzero if we are inside eq_specializations, which affects comparison of
5091 PARM_DECLs in cp_tree_equal. */
5092extern int comparing_specializations;
5093
5094/* In parser.c. */
5095
5096/* Nonzero if we are parsing an unevaluated operand: an operand to
5097 sizeof, typeof, or alignof. This is a count since operands to
5098 sizeof can be nested. */
5099
5100extern int cp_unevaluated_operand;
5101
5102/* RAII class used to inhibit the evaluation of operands during parsing
5103 and template instantiation. Evaluation warnings are also inhibited. */
5104
5105struct cp_unevaluated
5106{
5107 cp_unevaluated ();
5108 ~cp_unevaluated ();
5109};
5110
5111/* in pt.c */
5112
5113/* These values are used for the `STRICT' parameter to type_unification and
5114 fn_type_unification. Their meanings are described with the
5115 documentation for fn_type_unification. */
5116
5117enum unification_kind_t {
5118 DEDUCE_CALL,
5119 DEDUCE_CONV,
5120 DEDUCE_EXACT
5121};
5122
5123// An RAII class used to create a new pointer map for local
5124// specializations. When the stack goes out of scope, the
5125// previous pointer map is restored.
5126enum lss_policy { lss_blank, lss_copy };
5127struct local_specialization_stack
5128{
5129 local_specialization_stack (lss_policy = lss_blank);
5130 ~local_specialization_stack ();
5131
5132 hash_map<tree, tree> *saved;
5133};
5134
5135/* in class.c */
5136
5137extern int current_class_depth;
5138
5139/* An array of all local classes present in this translation unit, in
5140 declaration order. */
5141extern GTY(()) vec<tree, va_gc> *local_classes;
5142
5143/* in decl.c */
5144
5145/* An array of static vars & fns. */
5146extern GTY(()) vec<tree, va_gc> *static_decls;
5147
5148/* An array of vtable-needing types that have no key function, or have
5149 an emitted key function. */
5150extern GTY(()) vec<tree, va_gc> *keyed_classes;
5151
5152/* Here's where we control how name mangling takes place. */
5153
5154/* Cannot use '$' up front, because this confuses gdb
5155 (names beginning with '$' are gdb-local identifiers).
5156
5157 Note that all forms in which the '$' is significant are long enough
5158 for direct indexing (meaning that if we know there is a '$'
5159 at a particular location, we can index into the string at
5160 any other location that provides distinguishing characters). */
5161
5162/* Define NO_DOT_IN_LABEL in your favorite tm file if your assembler
5163 doesn't allow '.' in symbol names. */
5164#ifndef NO_DOT_IN_LABEL
5165
5166#define JOINER '.'
5167
5168#define AUTO_TEMP_NAME "_.tmp_"
5169#define VFIELD_BASE ".vf"
5170#define VFIELD_NAME "_vptr."
5171#define VFIELD_NAME_FORMAT "_vptr.%s"
5172
5173#else /* NO_DOT_IN_LABEL */
5174
5175#ifndef NO_DOLLAR_IN_LABEL
5176
5177#define JOINER '$'
5178
5179#define AUTO_TEMP_NAME "_$tmp_"
5180#define VFIELD_BASE "$vf"
5181#define VFIELD_NAME "_vptr$"
5182#define VFIELD_NAME_FORMAT "_vptr$%s"
5183
5184#else /* NO_DOLLAR_IN_LABEL */
5185
5186#define AUTO_TEMP_NAME "__tmp_"
5187#define TEMP_NAME_P(ID_NODE) \
5188 (!strncmp (IDENTIFIER_POINTER (ID_NODE), AUTO_TEMP_NAME, \
5189 sizeof (AUTO_TEMP_NAME) - 1))
5190#define VTABLE_NAME "__vt_"
5191#define VTABLE_NAME_P(ID_NODE) \
5192 (!strncmp (IDENTIFIER_POINTER (ID_NODE), VTABLE_NAME, \
5193 sizeof (VTABLE_NAME) - 1))
5194#define VFIELD_BASE "__vfb"
5195#define VFIELD_NAME "__vptr_"
5196#define VFIELD_NAME_P(ID_NODE) \
5197 (!strncmp (IDENTIFIER_POINTER (ID_NODE), VFIELD_NAME, \
5198 sizeof (VFIELD_NAME) - 1))
5199#define VFIELD_NAME_FORMAT "__vptr_%s"
5200
5201#endif /* NO_DOLLAR_IN_LABEL */
5202#endif /* NO_DOT_IN_LABEL */
5203
5204#define LAMBDANAME_PREFIX "__lambda"
5205#define LAMBDANAME_FORMAT LAMBDANAME_PREFIX "%d"
5206
5207#define UDLIT_OP_ANSI_PREFIX "operator\"\""
5208#define UDLIT_OP_ANSI_FORMAT UDLIT_OP_ANSI_PREFIX "%s"
5209#define UDLIT_OP_MANGLED_PREFIX "li"
5210#define UDLIT_OP_MANGLED_FORMAT UDLIT_OP_MANGLED_PREFIX "%s"
5211#define UDLIT_OPER_P(ID_NODE) \
5212 (!strncmp (IDENTIFIER_POINTER (ID_NODE), \
5213 UDLIT_OP_ANSI_PREFIX, \
5214 sizeof (UDLIT_OP_ANSI_PREFIX) - 1))
5215#define UDLIT_OP_SUFFIX(ID_NODE) \
5216 (IDENTIFIER_POINTER (ID_NODE) + sizeof (UDLIT_OP_ANSI_PREFIX) - 1)
5217
5218#if !defined(NO_DOLLAR_IN_LABEL) || !defined(NO_DOT_IN_LABEL)
5219
5220#define VTABLE_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[1] == 'v' \
5221 && IDENTIFIER_POINTER (ID_NODE)[2] == 't' \
5222 && IDENTIFIER_POINTER (ID_NODE)[3] == JOINER)
5223
5224#define TEMP_NAME_P(ID_NODE) \
5225 (!strncmp (IDENTIFIER_POINTER (ID_NODE), AUTO_TEMP_NAME, sizeof (AUTO_TEMP_NAME)-1))
5226#define VFIELD_NAME_P(ID_NODE) \
5227 (!strncmp (IDENTIFIER_POINTER (ID_NODE), VFIELD_NAME, sizeof(VFIELD_NAME)-1))
5228
5229#endif /* !defined(NO_DOLLAR_IN_LABEL) || !defined(NO_DOT_IN_LABEL) */
5230
5231
5232/* Nonzero if we're done parsing and into end-of-file activities.
5233 Two if we're done with front-end processing. */
5234
5235extern int at_eof;
5236
5237/* True if note_mangling_alias should enqueue mangling aliases for
5238 later generation, rather than emitting them right away. */
5239
5240extern bool defer_mangling_aliases;
5241
5242/* True if noexcept is part of the type (i.e. in C++17). */
5243
5244extern bool flag_noexcept_type;
5245
5246/* A list of namespace-scope objects which have constructors or
5247 destructors which reside in the global scope. The decl is stored
5248 in the TREE_VALUE slot and the initializer is stored in the
5249 TREE_PURPOSE slot. */
5250extern GTY(()) tree static_aggregates;
5251/* Likewise, for thread local storage. */
5252extern GTY(()) tree tls_aggregates;
5253
5254enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, TYPENAME_FLAG };
5255
5256/* These are uses as bits in flags passed to various functions to
5257 control their behavior. Despite the LOOKUP_ prefix, many of these
5258 do not control name lookup. ??? Functions using these flags should
5259 probably be modified to accept explicit boolean flags for the
5260 behaviors relevant to them. */
5261/* Check for access violations. */
5262#define LOOKUP_PROTECT (1 << 0)
5263#define LOOKUP_NORMAL (LOOKUP_PROTECT)
5264/* Even if the function found by lookup is a virtual function, it
5265 should be called directly. */
5266#define LOOKUP_NONVIRTUAL (1 << 1)
5267/* Non-converting (i.e., "explicit") constructors are not tried. This flag
5268 indicates that we are not performing direct-initialization. */
5269#define LOOKUP_ONLYCONVERTING (1 << 2)
5270#define LOOKUP_IMPLICIT (LOOKUP_NORMAL | LOOKUP_ONLYCONVERTING)
5271/* If a temporary is created, it should be created so that it lives
5272 as long as the current variable bindings; otherwise it only lives
5273 until the end of the complete-expression. It also forces
5274 direct-initialization in cases where other parts of the compiler
5275 have already generated a temporary, such as reference
5276 initialization and the catch parameter. */
5277#define DIRECT_BIND (1 << 3)
5278/* We're performing a user-defined conversion, so more user-defined
5279 conversions are not permitted (only built-in conversions). */
5280#define LOOKUP_NO_CONVERSION (1 << 4)
5281/* The user has explicitly called a destructor. (Therefore, we do
5282 not need to check that the object is non-NULL before calling the
5283 destructor.) */
5284#define LOOKUP_DESTRUCTOR (1 << 5)
5285/* Do not permit references to bind to temporaries. */
5286#define LOOKUP_NO_TEMP_BIND (1 << 6)
5287/* Do not accept objects, and possibly namespaces. */
5288#define LOOKUP_PREFER_TYPES (1 << 7)
5289/* Do not accept objects, and possibly types. */
5290#define LOOKUP_PREFER_NAMESPACES (1 << 8)
5291/* Accept types or namespaces. */
5292#define LOOKUP_PREFER_BOTH (LOOKUP_PREFER_TYPES | LOOKUP_PREFER_NAMESPACES)
5293/* Return friend declarations and un-declared builtin functions.
5294 (Normally, these entities are registered in the symbol table, but
5295 not found by lookup.) */
5296#define LOOKUP_HIDDEN (LOOKUP_PREFER_NAMESPACES << 1)
5297/* We're trying to treat an lvalue as an rvalue. */
5298#define LOOKUP_PREFER_RVALUE (LOOKUP_HIDDEN << 1)
5299/* We're inside an init-list, so narrowing conversions are ill-formed. */
5300#define LOOKUP_NO_NARROWING (LOOKUP_PREFER_RVALUE << 1)
5301/* We're looking up a constructor for list-initialization. */
5302#define LOOKUP_LIST_INIT_CTOR (LOOKUP_NO_NARROWING << 1)
5303/* This is the first parameter of a copy constructor. */
5304#define LOOKUP_COPY_PARM (LOOKUP_LIST_INIT_CTOR << 1)
5305/* We only want to consider list constructors. */
5306#define LOOKUP_LIST_ONLY (LOOKUP_COPY_PARM << 1)
5307/* Return after determining which function to call and checking access.
5308 Used by sythesized_method_walk to determine which functions will
5309 be called to initialize subobjects, in order to determine exception
5310 specification and possible implicit delete.
5311 This is kind of a hack, but exiting early avoids problems with trying
5312 to perform argument conversions when the class isn't complete yet. */
5313#define LOOKUP_SPECULATIVE (LOOKUP_LIST_ONLY << 1)
5314/* Used by calls from defaulted functions to limit the overload set to avoid
5315 cycles trying to declare them (core issue 1092). */
5316#define LOOKUP_DEFAULTED (LOOKUP_SPECULATIVE << 1)
5317/* Used in calls to store_init_value to suppress its usual call to
5318 digest_init. */
5319#define LOOKUP_ALREADY_DIGESTED (LOOKUP_DEFAULTED << 1)
5320/* An instantiation with explicit template arguments. */
5321#define LOOKUP_EXPLICIT_TMPL_ARGS (LOOKUP_ALREADY_DIGESTED << 1)
5322/* Like LOOKUP_NO_TEMP_BIND, but also prevent binding to xvalues. */
5323#define LOOKUP_NO_RVAL_BIND (LOOKUP_EXPLICIT_TMPL_ARGS << 1)
5324/* Used by case_conversion to disregard non-integral conversions. */
5325#define LOOKUP_NO_NON_INTEGRAL (LOOKUP_NO_RVAL_BIND << 1)
5326/* Used for delegating constructors in order to diagnose self-delegation. */
5327#define LOOKUP_DELEGATING_CONS (LOOKUP_NO_NON_INTEGRAL << 1)
5328
5329#define LOOKUP_NAMESPACES_ONLY(F) \
5330 (((F) & LOOKUP_PREFER_NAMESPACES) && !((F) & LOOKUP_PREFER_TYPES))
5331#define LOOKUP_TYPES_ONLY(F) \
5332 (!((F) & LOOKUP_PREFER_NAMESPACES) && ((F) & LOOKUP_PREFER_TYPES))
5333#define LOOKUP_QUALIFIERS_ONLY(F) ((F) & LOOKUP_PREFER_BOTH)
5334
5335
5336/* These flags are used by the conversion code.
5337 CONV_IMPLICIT : Perform implicit conversions (standard and user-defined).
5338 CONV_STATIC : Perform the explicit conversions for static_cast.
5339 CONV_CONST : Perform the explicit conversions for const_cast.
5340 CONV_REINTERPRET: Perform the explicit conversions for reinterpret_cast.
5341 CONV_PRIVATE : Perform upcasts to private bases.
5342 CONV_FORCE_TEMP : Require a new temporary when converting to the same
5343 aggregate type. */
5344
5345#define CONV_IMPLICIT 1
5346#define CONV_STATIC 2
5347#define CONV_CONST 4
5348#define CONV_REINTERPRET 8
5349#define CONV_PRIVATE 16
5350/* #define CONV_NONCONVERTING 32 */
5351#define CONV_FORCE_TEMP 64
5352#define CONV_FOLD 128
5353#define CONV_OLD_CONVERT (CONV_IMPLICIT | CONV_STATIC | CONV_CONST \
5354 | CONV_REINTERPRET)
5355#define CONV_C_CAST (CONV_IMPLICIT | CONV_STATIC | CONV_CONST \
5356 | CONV_REINTERPRET | CONV_PRIVATE | CONV_FORCE_TEMP)
5357#define CONV_BACKEND_CONVERT (CONV_OLD_CONVERT | CONV_FOLD)
5358
5359/* Used by build_expr_type_conversion to indicate which types are
5360 acceptable as arguments to the expression under consideration. */
5361
5362#define WANT_INT 1 /* integer types, including bool */
5363#define WANT_FLOAT 2 /* floating point types */
5364#define WANT_ENUM 4 /* enumerated types */
5365#define WANT_POINTER 8 /* pointer types */
5366#define WANT_NULL 16 /* null pointer constant */
5367#define WANT_VECTOR_OR_COMPLEX 32 /* vector or complex types */
5368#define WANT_ARITH (WANT_INT | WANT_FLOAT | WANT_VECTOR_OR_COMPLEX)
5369
5370/* Used with comptypes, and related functions, to guide type
5371 comparison. */
5372
5373#define COMPARE_STRICT 0 /* Just check if the types are the
5374 same. */
5375#define COMPARE_BASE 1 /* Check to see if the second type is
5376 derived from the first. */
5377#define COMPARE_DERIVED 2 /* Like COMPARE_BASE, but in
5378 reverse. */
5379#define COMPARE_REDECLARATION 4 /* The comparison is being done when
5380 another declaration of an existing
5381 entity is seen. */
5382#define COMPARE_STRUCTURAL 8 /* The comparison is intended to be
5383 structural. The actual comparison
5384 will be identical to
5385 COMPARE_STRICT. */
5386
5387/* Used with start function. */
5388#define SF_DEFAULT 0 /* No flags. */
5389#define SF_PRE_PARSED 1 /* The function declaration has
5390 already been parsed. */
5391#define SF_INCLASS_INLINE 2 /* The function is an inline, defined
5392 in the class body. */
5393
5394/* Used with start_decl's initialized parameter. */
5395#define SD_UNINITIALIZED 0
5396#define SD_INITIALIZED 1
5397#define SD_DEFAULTED 2
5398#define SD_DELETED 3
5399
5400/* Returns nonzero iff TYPE1 and TYPE2 are the same type, or if TYPE2
5401 is derived from TYPE1, or if TYPE2 is a pointer (reference) to a
5402 class derived from the type pointed to (referred to) by TYPE1. */
5403#define same_or_base_type_p(TYPE1, TYPE2) \
5404 comptypes ((TYPE1), (TYPE2), COMPARE_BASE)
5405
5406/* These macros are used to access a TEMPLATE_PARM_INDEX. */
5407#define TEMPLATE_PARM_INDEX_CAST(NODE) \
5408 ((template_parm_index*)TEMPLATE_PARM_INDEX_CHECK (NODE))
5409#define TEMPLATE_PARM_IDX(NODE) (TEMPLATE_PARM_INDEX_CAST (NODE)->index)
5410#define TEMPLATE_PARM_LEVEL(NODE) (TEMPLATE_PARM_INDEX_CAST (NODE)->level)
5411#define TEMPLATE_PARM_DESCENDANTS(NODE) (TREE_CHAIN (NODE))
5412#define TEMPLATE_PARM_ORIG_LEVEL(NODE) (TEMPLATE_PARM_INDEX_CAST (NODE)->orig_level)
5413#define TEMPLATE_PARM_DECL(NODE) (TEMPLATE_PARM_INDEX_CAST (NODE)->decl)
5414#define TEMPLATE_PARM_PARAMETER_PACK(NODE) \
5415 (TREE_LANG_FLAG_0 (TEMPLATE_PARM_INDEX_CHECK (NODE)))
5416
5417/* These macros are for accessing the fields of TEMPLATE_TYPE_PARM,
5418 TEMPLATE_TEMPLATE_PARM and BOUND_TEMPLATE_TEMPLATE_PARM nodes. */
5419#define TEMPLATE_TYPE_PARM_INDEX(NODE) \
5420 (TYPE_VALUES_RAW (TREE_CHECK3 ((NODE), TEMPLATE_TYPE_PARM, \
5421 TEMPLATE_TEMPLATE_PARM, \
5422 BOUND_TEMPLATE_TEMPLATE_PARM)))
5423#define TEMPLATE_TYPE_IDX(NODE) \
5424 (TEMPLATE_PARM_IDX (TEMPLATE_TYPE_PARM_INDEX (NODE)))
5425#define TEMPLATE_TYPE_LEVEL(NODE) \
5426 (TEMPLATE_PARM_LEVEL (TEMPLATE_TYPE_PARM_INDEX (NODE)))
5427#define TEMPLATE_TYPE_ORIG_LEVEL(NODE) \
5428 (TEMPLATE_PARM_ORIG_LEVEL (TEMPLATE_TYPE_PARM_INDEX (NODE)))
5429#define TEMPLATE_TYPE_DECL(NODE) \
5430 (TEMPLATE_PARM_DECL (TEMPLATE_TYPE_PARM_INDEX (NODE)))
5431#define TEMPLATE_TYPE_PARAMETER_PACK(NODE) \
5432 (TEMPLATE_PARM_PARAMETER_PACK (TEMPLATE_TYPE_PARM_INDEX (NODE)))
5433
5434/* For a C++17 class deduction placeholder, the template it represents. */
5435#define CLASS_PLACEHOLDER_TEMPLATE(NODE) \
5436 (DECL_INITIAL (TYPE_NAME (TEMPLATE_TYPE_PARM_CHECK (NODE))))
5437
5438/* Contexts in which auto deduction occurs. These flags are
5439 used to control diagnostics in do_auto_deduction. */
5440
5441enum auto_deduction_context
5442{
5443 adc_unspecified, /* Not given */
5444 adc_variable_type, /* Variable initializer deduction */
5445 adc_return_type, /* Return type deduction */
5446 adc_unify, /* Template argument deduction */
5447 adc_requirement, /* Argument deduction constraint */
5448 adc_decomp_type /* Decomposition declaration initializer deduction */
5449};
5450
5451/* True if this type-parameter belongs to a class template, used by C++17
5452 class template argument deduction. */
5453#define TEMPLATE_TYPE_PARM_FOR_CLASS(NODE) \
5454 (TREE_LANG_FLAG_0 (TEMPLATE_TYPE_PARM_CHECK (NODE)))
5455
5456/* True iff this TEMPLATE_TYPE_PARM represents decltype(auto). */
5457#define AUTO_IS_DECLTYPE(NODE) \
5458 (TYPE_LANG_FLAG_5 (TEMPLATE_TYPE_PARM_CHECK (NODE)))
5459
5460/* These constants can used as bit flags in the process of tree formatting.
5461
5462 TFF_PLAIN_IDENTIFIER: unqualified part of a name.
5463 TFF_SCOPE: include the class and namespace scope of the name.
5464 TFF_CHASE_TYPEDEF: print the original type-id instead of the typedef-name.
5465 TFF_DECL_SPECIFIERS: print decl-specifiers.
5466 TFF_CLASS_KEY_OR_ENUM: precede a class-type name (resp. enum name) with
5467 a class-key (resp. `enum').
5468 TFF_RETURN_TYPE: include function return type.
5469 TFF_FUNCTION_DEFAULT_ARGUMENTS: include function default parameter values.
5470 TFF_EXCEPTION_SPECIFICATION: show function exception specification.
5471 TFF_TEMPLATE_HEADER: show the template<...> header in a
5472 template-declaration.
5473 TFF_TEMPLATE_NAME: show only template-name.
5474 TFF_EXPR_IN_PARENS: parenthesize expressions.
5475 TFF_NO_FUNCTION_ARGUMENTS: don't show function arguments.
5476 TFF_UNQUALIFIED_NAME: do not print the qualifying scope of the
5477 top-level entity.
5478 TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS: do not omit template arguments
5479 identical to their defaults.
5480 TFF_NO_TEMPLATE_BINDINGS: do not print information about the template
5481 arguments for a function template specialization.
5482 TFF_POINTER: we are printing a pointer type. */
5483
5484#define TFF_PLAIN_IDENTIFIER (0)
5485#define TFF_SCOPE (1)
5486#define TFF_CHASE_TYPEDEF (1 << 1)
5487#define TFF_DECL_SPECIFIERS (1 << 2)
5488#define TFF_CLASS_KEY_OR_ENUM (1 << 3)
5489#define TFF_RETURN_TYPE (1 << 4)
5490#define TFF_FUNCTION_DEFAULT_ARGUMENTS (1 << 5)
5491#define TFF_EXCEPTION_SPECIFICATION (1 << 6)
5492#define TFF_TEMPLATE_HEADER (1 << 7)
5493#define TFF_TEMPLATE_NAME (1 << 8)
5494#define TFF_EXPR_IN_PARENS (1 << 9)
5495#define TFF_NO_FUNCTION_ARGUMENTS (1 << 10)
5496#define TFF_UNQUALIFIED_NAME (1 << 11)
5497#define TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS (1 << 12)
5498#define TFF_NO_TEMPLATE_BINDINGS (1 << 13)
5499#define TFF_POINTER (1 << 14)
5500
5501/* Returns the TEMPLATE_DECL associated to a TEMPLATE_TEMPLATE_PARM
5502 node. */
5503#define TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL(NODE) \
5504 ((TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM) \
5505 ? TYPE_TI_TEMPLATE (NODE) \
5506 : TYPE_NAME (NODE))
5507
5508/* in lex.c */
5509
5510extern void init_reswords (void);
5511
5512/* Various flags for the overloaded operator information. */
5513enum ovl_op_flags
5514 {
5515 OVL_OP_FLAG_NONE = 0, /* Don't care. */
5516 OVL_OP_FLAG_UNARY = 1, /* Is unary. */
5517 OVL_OP_FLAG_BINARY = 2, /* Is binary. */
5518 OVL_OP_FLAG_AMBIARY = 3, /* May be unary or binary. */
5519 OVL_OP_FLAG_ALLOC = 4, /* operator new or delete. */
5520 OVL_OP_FLAG_DELETE = 1, /* operator delete. */
5521 OVL_OP_FLAG_VEC = 2 /* vector new or delete. */
5522 };
5523
5524/* Compressed operator codes. Order is determined by operators.def
5525 and does not match that of tree_codes. */
5526enum ovl_op_code
5527 {
5528 OVL_OP_ERROR_MARK,
5529 OVL_OP_NOP_EXPR,
5530#define DEF_OPERATOR(NAME, CODE, MANGLING, FLAGS) OVL_OP_##CODE,
5531#define DEF_ASSN_OPERATOR(NAME, CODE, MANGLING) /* NOTHING */
5532#include "operators.def"
5533 OVL_OP_MAX
5534 };
5535
5536struct GTY(()) ovl_op_info_t {
5537 /* The IDENTIFIER_NODE for the operator. */
5538 tree identifier;
5539 /* The name of the operator. */
5540 const char *name;
5541 /* The mangled name of the operator. */
5542 const char *mangled_name;
5543 /* The (regular) tree code. */
5544 enum tree_code tree_code : 16;
5545 /* The (compressed) operator code. */
5546 enum ovl_op_code ovl_op_code : 8;
5547 /* The ovl_op_flags of the operator */
5548 unsigned flags : 8;
5549};
5550
5551/* Overloaded operator info indexed by ass_op_p & ovl_op_code. */
5552extern GTY(()) ovl_op_info_t ovl_op_info[2][OVL_OP_MAX];
5553/* Mapping from tree_codes to ovl_op_codes. */
5554extern GTY(()) unsigned char ovl_op_mapping[MAX_TREE_CODES];
5555/* Mapping for ambi-ary operators from the binary to the unary. */
5556extern GTY(()) unsigned char ovl_op_alternate[OVL_OP_MAX];
5557
5558/* Given an ass_op_p boolean and a tree code, return a pointer to its
5559 overloaded operator info. Tree codes for non-overloaded operators
5560 map to the error-operator. */
5561#define OVL_OP_INFO(IS_ASS_P, TREE_CODE) \
5562 (&ovl_op_info[(IS_ASS_P) != 0][ovl_op_mapping[(TREE_CODE)]])
5563/* Overloaded operator info for an identifier for which
5564 IDENTIFIER_OVL_OP_P is true. */
5565#define IDENTIFIER_OVL_OP_INFO(NODE) \
5566 (&ovl_op_info[IDENTIFIER_KIND_BIT_0 (NODE)][IDENTIFIER_CP_INDEX (NODE)])
5567#define IDENTIFIER_OVL_OP_FLAGS(NODE) \
5568 (IDENTIFIER_OVL_OP_INFO (NODE)->flags)
5569
5570/* A type-qualifier, or bitmask therefore, using the TYPE_QUAL
5571 constants. */
5572
5573typedef int cp_cv_quals;
5574
5575/* Non-static member functions have an optional virt-specifier-seq.
5576 There is a VIRT_SPEC value for each virt-specifier.
5577 They can be combined by bitwise-or to form the complete set of
5578 virt-specifiers for a member function. */
5579enum virt_specifier
5580 {
5581 VIRT_SPEC_UNSPECIFIED = 0x0,
5582 VIRT_SPEC_FINAL = 0x1,
5583 VIRT_SPEC_OVERRIDE = 0x2
5584 };
5585
5586/* A type-qualifier, or bitmask therefore, using the VIRT_SPEC
5587 constants. */
5588
5589typedef int cp_virt_specifiers;
5590
5591/* Wherever there is a function-cv-qual, there could also be a ref-qualifier:
5592
5593 [dcl.fct]
5594 The return type, the parameter-type-list, the ref-qualifier, and
5595 the cv-qualifier-seq, but not the default arguments or the exception
5596 specification, are part of the function type.
5597
5598 REF_QUAL_NONE Ordinary member function with no ref-qualifier
5599 REF_QUAL_LVALUE Member function with the &-ref-qualifier
5600 REF_QUAL_RVALUE Member function with the &&-ref-qualifier */
5601
5602enum cp_ref_qualifier {
5603 REF_QUAL_NONE = 0,
5604 REF_QUAL_LVALUE = 1,
5605 REF_QUAL_RVALUE = 2
5606};
5607
5608/* A storage class. */
5609
5610enum cp_storage_class {
5611 /* sc_none must be zero so that zeroing a cp_decl_specifier_seq
5612 sets the storage_class field to sc_none. */
5613 sc_none = 0,
5614 sc_auto,
5615 sc_register,
5616 sc_static,
5617 sc_extern,
5618 sc_mutable
5619};
5620
5621/* An individual decl-specifier. This is used to index the array of
5622 locations for the declspecs in struct cp_decl_specifier_seq
5623 below. */
5624
5625enum cp_decl_spec {
5626 ds_first,
5627 ds_signed = ds_first,
5628 ds_unsigned,
5629 ds_short,
5630 ds_long,
5631 ds_const,
5632 ds_volatile,
5633 ds_restrict,
5634 ds_inline,
5635 ds_virtual,
5636 ds_explicit,
5637 ds_friend,
5638 ds_typedef,
5639 ds_alias,
5640 ds_constexpr,
5641 ds_complex,
5642 ds_thread,
5643 ds_type_spec,
5644 ds_redefined_builtin_type_spec,
5645 ds_attribute,
5646 ds_std_attribute,
5647 ds_storage_class,
5648 ds_long_long,
5649 ds_concept,
5650 ds_last /* This enumerator must always be the last one. */
5651};
5652
5653/* A decl-specifier-seq. */
5654
5655struct cp_decl_specifier_seq {
5656 /* An array of locations for the declaration sepecifiers, indexed by
5657 enum cp_decl_spec_word. */
5658 source_location locations[ds_last];
5659 /* The primary type, if any, given by the decl-specifier-seq.
5660 Modifiers, like "short", "const", and "unsigned" are not
5661 reflected here. This field will be a TYPE, unless a typedef-name
5662 was used, in which case it will be a TYPE_DECL. */
5663 tree type;
5664 /* The attributes, if any, provided with the specifier sequence. */
5665 tree attributes;
5666 /* The c++11 attributes that follows the type specifier. */
5667 tree std_attributes;
5668 /* If non-NULL, a built-in type that the user attempted to redefine
5669 to some other type. */
5670 tree redefined_builtin_type;
5671 /* The storage class specified -- or sc_none if no storage class was
5672 explicitly specified. */
5673 cp_storage_class storage_class;
5674 /* For the __intN declspec, this stores the index into the int_n_* arrays. */
5675 int int_n_idx;
5676 /* True iff TYPE_SPEC defines a class or enum. */
5677 BOOL_BITFIELD type_definition_p : 1;
5678 /* True iff multiple types were (erroneously) specified for this
5679 decl-specifier-seq. */
5680 BOOL_BITFIELD multiple_types_p : 1;
5681 /* True iff multiple storage classes were (erroneously) specified
5682 for this decl-specifier-seq or a combination of a storage class
5683 with a typedef specifier. */
5684 BOOL_BITFIELD conflicting_specifiers_p : 1;
5685 /* True iff at least one decl-specifier was found. */
5686 BOOL_BITFIELD any_specifiers_p : 1;
5687 /* True iff at least one type-specifier was found. */
5688 BOOL_BITFIELD any_type_specifiers_p : 1;
5689 /* True iff "int" was explicitly provided. */
5690 BOOL_BITFIELD explicit_int_p : 1;
5691 /* True iff "__intN" was explicitly provided. */
5692 BOOL_BITFIELD explicit_intN_p : 1;
5693 /* True iff "char" was explicitly provided. */
5694 BOOL_BITFIELD explicit_char_p : 1;
5695 /* True iff ds_thread is set for __thread, not thread_local. */
5696 BOOL_BITFIELD gnu_thread_keyword_p : 1;
5697 /* True iff the type is a decltype. */
5698 BOOL_BITFIELD decltype_p : 1;
5699};
5700
5701/* The various kinds of declarators. */
5702
5703enum cp_declarator_kind {
5704 cdk_id,
5705 cdk_function,
5706 cdk_array,
5707 cdk_pointer,
5708 cdk_reference,
5709 cdk_ptrmem,
5710 cdk_decomp,
5711 cdk_error
5712};
5713
5714/* A declarator. */
5715
5716typedef struct cp_declarator cp_declarator;
5717
5718typedef struct cp_parameter_declarator cp_parameter_declarator;
5719
5720/* A parameter, before it has been semantically analyzed. */
5721struct cp_parameter_declarator {
5722 /* The next parameter, or NULL_TREE if none. */
5723 cp_parameter_declarator *next;
5724 /* The decl-specifiers-seq for the parameter. */
5725 cp_decl_specifier_seq decl_specifiers;
5726 /* The declarator for the parameter. */
5727 cp_declarator *declarator;
5728 /* The default-argument expression, or NULL_TREE, if none. */
5729 tree default_argument;
5730 /* True iff this is a template parameter pack. */
5731 bool template_parameter_pack_p;
5732 /* Location within source. */
5733 location_t loc;
5734};
5735
5736/* A declarator. */
5737struct cp_declarator {
5738 /* The kind of declarator. */
5739 ENUM_BITFIELD (cp_declarator_kind) kind : 4;
5740 /* Whether we parsed an ellipsis (`...') just before the declarator,
5741 to indicate this is a parameter pack. */
5742 BOOL_BITFIELD parameter_pack_p : 1;
5743 /* If this declarator is parenthesized, this the open-paren. It is
5744 UNKNOWN_LOCATION when not parenthesized. */
5745 location_t parenthesized;
5746
5747 location_t id_loc; /* Currently only set for cdk_id, cdk_decomp and
5748 cdk_function. */
5749 /* GNU Attributes that apply to this declarator. If the declarator
5750 is a pointer or a reference, these attribute apply to the type
5751 pointed to. */
5752 tree attributes;
5753 /* Standard C++11 attributes that apply to this declarator. If the
5754 declarator is a pointer or a reference, these attributes apply
5755 to the pointer, rather than to the type pointed to. */
5756 tree std_attributes;
5757 /* For all but cdk_id, cdk_decomp and cdk_error, the contained declarator.
5758 For cdk_id, cdk_decomp and cdk_error, guaranteed to be NULL. */
5759 cp_declarator *declarator;
5760 union {
5761 /* For identifiers. */
5762 struct {
5763 /* If non-NULL, the qualifying scope (a NAMESPACE_DECL or
5764 *_TYPE) for this identifier. */
5765 tree qualifying_scope;
5766 /* The unqualified name of the entity -- an IDENTIFIER_NODE,
5767 BIT_NOT_EXPR, or TEMPLATE_ID_EXPR. */
5768 tree unqualified_name;
5769 /* If this is the name of a function, what kind of special
5770 function (if any). */
5771 special_function_kind sfk;
5772 } id;
5773 /* For functions. */
5774 struct {
5775 /* The parameters to the function as a TREE_LIST of decl/default. */
5776 tree parameters;
5777 /* The cv-qualifiers for the function. */
5778 cp_cv_quals qualifiers;
5779 /* The virt-specifiers for the function. */
5780 cp_virt_specifiers virt_specifiers;
5781 /* The ref-qualifier for the function. */
5782 cp_ref_qualifier ref_qualifier;
5783 /* The transaction-safety qualifier for the function. */
5784 tree tx_qualifier;
5785 /* The exception-specification for the function. */
5786 tree exception_specification;
5787 /* The late-specified return type, if any. */
5788 tree late_return_type;
5789 /* The trailing requires-clause, if any. */
5790 tree requires_clause;
5791 } function;
5792 /* For arrays. */
5793 struct {
5794 /* The bounds to the array. */
5795 tree bounds;
5796 } array;
5797 /* For cdk_pointer and cdk_ptrmem. */
5798 struct {
5799 /* The cv-qualifiers for the pointer. */
5800 cp_cv_quals qualifiers;
5801 /* For cdk_ptrmem, the class type containing the member. */
5802 tree class_type;
5803 } pointer;
5804 /* For cdk_reference */
5805 struct {
5806 /* The cv-qualifiers for the reference. These qualifiers are
5807 only used to diagnose ill-formed code. */
5808 cp_cv_quals qualifiers;
5809 /* Whether this is an rvalue reference */
5810 bool rvalue_ref;
5811 } reference;
5812 } u;
5813};
5814
5815/* A level of template instantiation. */
5816struct GTY((chain_next ("%h.next"))) tinst_level {
5817 /* The immediately deeper level in the chain. */
5818 struct tinst_level *next;
5819
5820 /* The original node. Can be either a DECL (for a function or static
5821 data member) or a TYPE (for a class), depending on what we were
5822 asked to instantiate. */
5823 tree decl;
5824
5825 /* The location where the template is instantiated. */
5826 location_t locus;
5827
5828 /* errorcount+sorrycount when we pushed this level. */
5829 int errors;
5830
5831 /* True if the location is in a system header. */
5832 bool in_system_header_p;
5833};
5834
5835bool decl_spec_seq_has_spec_p (const cp_decl_specifier_seq *, cp_decl_spec);
5836
5837/* Return the type of the `this' parameter of FNTYPE. */
5838
5839inline tree
5840type_of_this_parm (const_tree fntype)
5841{
5842 function_args_iterator iter;
5843 gcc_assert (TREE_CODE (fntype) == METHOD_TYPE);
5844 function_args_iter_init (&iter, fntype);
5845 return function_args_iter_cond (&iter);
5846}
5847
5848/* Return the class of the `this' parameter of FNTYPE. */
5849
5850inline tree
5851class_of_this_parm (const_tree fntype)
5852{
5853 return TREE_TYPE (type_of_this_parm (fntype));
5854}
5855
5856/* True iff T is a variable template declaration. */
5857inline bool
5858variable_template_p (tree t)
5859{
5860 if (TREE_CODE (t) != TEMPLATE_DECL)
5861 return false;
5862 if (!PRIMARY_TEMPLATE_P (t))
5863 return false;
5864 if (tree r = DECL_TEMPLATE_RESULT (t))
5865 return VAR_P (r);
5866 return false;
5867}
5868
5869/* True iff T is a variable concept definition. That is, T is
5870 a variable template declared with the concept specifier. */
5871inline bool
5872variable_concept_p (tree t)
5873{
5874 if (TREE_CODE (t) != TEMPLATE_DECL)
5875 return false;
5876 if (tree r = DECL_TEMPLATE_RESULT (t))
5877 return VAR_P (r) && DECL_DECLARED_CONCEPT_P (r);
5878 return false;
5879}
5880
5881/* True iff T is a concept definition. That is, T is a variable or function
5882 template declared with the concept specifier. */
5883inline bool
5884concept_template_p (tree t)
5885{
5886 if (TREE_CODE (t) != TEMPLATE_DECL)
5887 return false;
5888 if (tree r = DECL_TEMPLATE_RESULT (t))
5889 return VAR_OR_FUNCTION_DECL_P (r) && DECL_DECLARED_CONCEPT_P (r);
5890 return false;
5891}
5892
5893/* A parameter list indicating for a function with no parameters,
5894 e.g "int f(void)". */
5895extern cp_parameter_declarator *no_parameters;
5896
5897/* Various dump ids. */
5898extern int class_dump_id;
5899extern int raw_dump_id;
5900
5901/* in call.c */
5902extern bool check_dtor_name (tree, tree);
5903int magic_varargs_p (tree);
5904
5905extern tree build_conditional_expr (location_t, tree, tree, tree,
5906 tsubst_flags_t);
5907extern tree build_addr_func (tree, tsubst_flags_t);
5908extern void set_flags_from_callee (tree);
5909extern tree build_call_a (tree, int, tree*);
5910extern tree build_call_n (tree, int, ...);
5911extern bool null_ptr_cst_p (tree);
5912extern bool null_member_pointer_value_p (tree);
5913extern bool sufficient_parms_p (const_tree);
5914extern tree type_decays_to (tree);
5915extern tree extract_call_expr (tree);
5916extern tree build_user_type_conversion (tree, tree, int,
5917 tsubst_flags_t);
5918extern tree build_new_function_call (tree, vec<tree, va_gc> **,
5919 tsubst_flags_t);
5920extern tree build_operator_new_call (tree, vec<tree, va_gc> **,
5921 tree *, tree *, tree, tree,
5922 tree *, tsubst_flags_t);
5923extern tree build_new_method_call (tree, tree,
5924 vec<tree, va_gc> **, tree,
5925 int, tree *, tsubst_flags_t);
5926extern tree build_special_member_call (tree, tree,
5927 vec<tree, va_gc> **,
5928 tree, int, tsubst_flags_t);
5929extern tree build_new_op (location_t, enum tree_code,
5930 int, tree, tree, tree, tree *,
5931 tsubst_flags_t);
5932extern tree build_op_call (tree, vec<tree, va_gc> **,
5933 tsubst_flags_t);
5934extern bool aligned_allocation_fn_p (tree);
5935extern bool usual_deallocation_fn_p (tree);
5936extern tree build_op_delete_call (enum tree_code, tree, tree,
5937 bool, tree, tree,
5938 tsubst_flags_t);
5939extern bool can_convert (tree, tree, tsubst_flags_t);
5940extern bool can_convert_standard (tree, tree, tsubst_flags_t);
5941extern bool can_convert_arg (tree, tree, tree, int,
5942 tsubst_flags_t);
5943extern bool can_convert_arg_bad (tree, tree, tree, int,
5944 tsubst_flags_t);
5945
5946/* A class for recording information about access failures (e.g. private
5947 fields), so that we can potentially supply a fix-it hint about
5948 an accessor (from a context in which the constness of the object
5949 is known). */
5950
5951class access_failure_info
5952{
5953 public:
5954 access_failure_info () : m_was_inaccessible (false), m_basetype_path (NULL_TREE),
5955 m_field_decl (NULL_TREE) {}
5956
5957 void record_access_failure (tree basetype_path, tree field_decl);
5958 void maybe_suggest_accessor (bool const_p) const;
5959
5960 private:
5961 bool m_was_inaccessible;
5962 tree m_basetype_path;
5963 tree m_field_decl;
5964};
5965
5966extern bool enforce_access (tree, tree, tree,
5967 tsubst_flags_t,
5968 access_failure_info *afi = NULL);
5969extern void push_defarg_context (tree);
5970extern void pop_defarg_context (void);
5971extern tree convert_default_arg (tree, tree, tree, int,
5972 tsubst_flags_t);
5973extern tree convert_arg_to_ellipsis (tree, tsubst_flags_t);
5974extern tree build_x_va_arg (source_location, tree, tree);
5975extern tree cxx_type_promotes_to (tree);
5976extern tree type_passed_as (tree);
5977extern tree convert_for_arg_passing (tree, tree, tsubst_flags_t);
5978extern bool is_properly_derived_from (tree, tree);
5979extern tree initialize_reference (tree, tree, int,
5980 tsubst_flags_t);
5981extern tree extend_ref_init_temps (tree, tree, vec<tree, va_gc>**);
5982extern tree make_temporary_var_for_ref_to_temp (tree, tree);
5983extern bool type_has_extended_temps (tree);
5984extern tree strip_top_quals (tree);
5985extern bool reference_related_p (tree, tree);
5986extern int remaining_arguments (tree);
5987extern tree perform_implicit_conversion (tree, tree, tsubst_flags_t);
5988extern tree perform_implicit_conversion_flags (tree, tree, tsubst_flags_t, int);
5989extern tree build_converted_constant_expr (tree, tree, tsubst_flags_t);
5990extern tree perform_direct_initialization_if_possible (tree, tree, bool,
5991 tsubst_flags_t);
5992extern tree in_charge_arg_for_name (tree);
5993extern tree build_cxx_call (tree, int, tree *,
5994 tsubst_flags_t);
5995extern bool is_std_init_list (tree);
5996extern bool is_list_ctor (tree);
5997extern void validate_conversion_obstack (void);
5998extern void mark_versions_used (tree);
5999extern tree get_function_version_dispatcher (tree);
6000
6001/* in class.c */
6002extern tree build_vfield_ref (tree, tree);
6003extern tree build_if_in_charge (tree true_stmt, tree false_stmt = void_node);
6004extern tree build_base_path (enum tree_code, tree,
6005 tree, int, tsubst_flags_t);
6006extern tree convert_to_base (tree, tree, bool, bool,
6007 tsubst_flags_t);
6008extern tree convert_to_base_statically (tree, tree);
6009extern tree build_vtbl_ref (tree, tree);
6010extern tree build_vfn_ref (tree, tree);
6011extern tree get_vtable_decl (tree, int);
6012extern bool add_method (tree, tree, bool);
6013extern tree declared_access (tree);
6014extern tree currently_open_class (tree);
6015extern tree currently_open_derived_class (tree);
6016extern tree outermost_open_class (void);
6017extern tree current_nonlambda_class_type (void);
6018extern tree finish_struct (tree, tree);
6019extern void finish_struct_1 (tree);
6020extern int resolves_to_fixed_type_p (tree, int *);
6021extern void init_class_processing (void);
6022extern int is_empty_class (tree);
6023extern bool is_really_empty_class (tree);
6024extern void pushclass (tree);
6025extern void popclass (void);
6026extern void push_nested_class (tree);
6027extern void pop_nested_class (void);
6028extern int current_lang_depth (void);
6029extern void push_lang_context (tree);
6030extern void pop_lang_context (void);
6031extern tree instantiate_type (tree, tree, tsubst_flags_t);
6032extern void print_class_statistics (void);
6033extern void build_self_reference (void);
6034extern int same_signature_p (const_tree, const_tree);
6035extern void maybe_add_class_template_decl_list (tree, tree, int);
6036extern void unreverse_member_declarations (tree);
6037extern void invalidate_class_lookup_cache (void);
6038extern void maybe_note_name_used_in_class (tree, tree);
6039extern void note_name_declared_in_class (tree, tree);
6040extern tree get_vtbl_decl_for_binfo (tree);
6041extern bool vptr_via_virtual_p (tree);
6042extern void debug_class (tree);
6043extern void debug_thunks (tree);
6044extern void set_linkage_according_to_type (tree, tree);
6045extern void determine_key_method (tree);
6046extern void check_for_override (tree, tree);
6047extern void push_class_stack (void);
6048extern void pop_class_stack (void);
6049extern bool default_ctor_p (tree);
6050extern bool type_has_user_nondefault_constructor (tree);
6051extern tree in_class_defaulted_default_constructor (tree);
6052extern bool user_provided_p (tree);
6053extern bool type_has_user_provided_constructor (tree);
6054extern bool type_has_non_user_provided_default_constructor (tree);
6055extern bool vbase_has_user_provided_move_assign (tree);
6056extern tree default_init_uninitialized_part (tree);
6057extern bool trivial_default_constructor_is_constexpr (tree);
6058extern bool type_has_constexpr_default_constructor (tree);
6059extern bool type_has_virtual_destructor (tree);
6060extern bool classtype_has_move_assign_or_move_ctor_p (tree, bool user_declared);
6061extern bool type_build_ctor_call (tree);
6062extern bool type_build_dtor_call (tree);
6063extern void explain_non_literal_class (tree);
6064extern void inherit_targ_abi_tags (tree);
6065extern void defaulted_late_check (tree);
6066extern bool defaultable_fn_check (tree);
6067extern void check_abi_tags (tree);
6068extern tree missing_abi_tags (tree);
6069extern void fixup_type_variants (tree);
6070extern void fixup_attribute_variants (tree);
6071extern tree* decl_cloned_function_p (const_tree, bool);
6072extern void clone_function_decl (tree, bool);
6073extern void adjust_clone_args (tree);
6074extern void deduce_noexcept_on_destructor (tree);
6075extern bool uniquely_derived_from_p (tree, tree);
6076extern bool publicly_uniquely_derived_p (tree, tree);
6077extern tree common_enclosing_class (tree, tree);
6078
6079/* in cvt.c */
6080extern tree convert_to_reference (tree, tree, int, int, tree,
6081 tsubst_flags_t);
6082extern tree convert_from_reference (tree);
6083extern tree force_rvalue (tree, tsubst_flags_t);
6084extern tree ocp_convert (tree, tree, int, int,
6085 tsubst_flags_t);
6086extern tree cp_convert (tree, tree, tsubst_flags_t);
6087extern tree cp_convert_and_check (tree, tree, tsubst_flags_t);
6088extern tree cp_fold_convert (tree, tree);
6089extern tree cp_get_callee (tree);
6090extern tree cp_get_callee_fndecl (tree);
6091extern tree cp_get_fndecl_from_callee (tree);
6092extern tree convert_to_void (tree, impl_conv_void,
6093 tsubst_flags_t);
6094extern tree convert_force (tree, tree, int,
6095 tsubst_flags_t);
6096extern tree build_expr_type_conversion (int, tree, bool);
6097extern tree type_promotes_to (tree);
6098extern bool can_convert_qual (tree, tree);
6099extern tree perform_qualification_conversions (tree, tree);
6100extern bool tx_safe_fn_type_p (tree);
6101extern tree tx_unsafe_fn_variant (tree);
6102extern bool fnptr_conv_p (tree, tree);
6103extern tree strip_fnptr_conv (tree);
6104
6105/* in name-lookup.c */
6106extern void maybe_push_cleanup_level (tree);
6107extern tree make_anon_name (void);
6108extern tree check_for_out_of_scope_variable (tree);
6109extern void dump (cp_binding_level &ref);
6110extern void dump (cp_binding_level *ptr);
6111extern void print_other_binding_stack (cp_binding_level *);
6112extern tree maybe_push_decl (tree);
6113extern tree current_decl_namespace (void);
6114
6115/* decl.c */
6116extern tree poplevel (int, int, int);
6117extern void cxx_init_decl_processing (void);
6118enum cp_tree_node_structure_enum cp_tree_node_structure
6119 (union lang_tree_node *);
6120extern void finish_scope (void);
6121extern void push_switch (tree);
6122extern void pop_switch (void);
6123extern void note_break_stmt (void);
6124extern bool note_iteration_stmt_body_start (void);
6125extern void note_iteration_stmt_body_end (bool);
6126extern tree make_lambda_name (void);
6127extern int decls_match (tree, tree, bool = true);
6128extern bool maybe_version_functions (tree, tree);
6129extern tree duplicate_decls (tree, tree, bool);
6130extern tree declare_local_label (tree);
6131extern tree define_label (location_t, tree);
6132extern void check_goto (tree);
6133extern bool check_omp_return (void);
6134extern tree make_typename_type (tree, tree, enum tag_types, tsubst_flags_t);
6135extern tree build_typename_type (tree, tree, tree, tag_types);
6136extern tree make_unbound_class_template (tree, tree, tree, tsubst_flags_t);
6137extern tree build_library_fn_ptr (const char *, tree, int);
6138extern tree build_cp_library_fn_ptr (const char *, tree, int);
6139extern tree push_library_fn (tree, tree, tree, int);
6140extern tree push_void_library_fn (tree, tree, int);
6141extern tree push_throw_library_fn (tree, tree);
6142extern void warn_misplaced_attr_for_class_type (source_location location,
6143 tree class_type);
6144extern tree check_tag_decl (cp_decl_specifier_seq *, bool);
6145extern tree shadow_tag (cp_decl_specifier_seq *);
6146extern tree groktypename (cp_decl_specifier_seq *, const cp_declarator *, bool);
6147extern tree start_decl (const cp_declarator *, cp_decl_specifier_seq *, int, tree, tree, tree *);
6148extern void start_decl_1 (tree, bool);
6149extern bool check_array_initializer (tree, tree, tree);
6150extern void cp_finish_decl (tree, tree, bool, tree, int);
6151extern tree lookup_decomp_type (tree);
6152extern void cp_finish_decomp (tree, tree, unsigned int);
6153extern int cp_complete_array_type (tree *, tree, bool);
6154extern int cp_complete_array_type_or_error (tree *, tree, bool, tsubst_flags_t);
6155extern tree build_ptrmemfunc_type (tree);
6156extern tree build_ptrmem_type (tree, tree);
6157/* the grokdeclarator prototype is in decl.h */
6158extern tree build_this_parm (tree, tree, cp_cv_quals);
6159extern tree grokparms (tree, tree *);
6160extern int copy_fn_p (const_tree);
6161extern bool move_fn_p (const_tree);
6162extern bool move_signature_fn_p (const_tree);
6163extern tree get_scope_of_declarator (const cp_declarator *);
6164extern void grok_special_member_properties (tree);
6165extern bool grok_ctor_properties (const_tree, const_tree);
6166extern bool grok_op_properties (tree, bool);
6167extern tree xref_tag (enum tag_types, tree, tag_scope, bool);
6168extern tree xref_tag_from_type (tree, tree, tag_scope);
6169extern void xref_basetypes (tree, tree);
6170extern tree start_enum (tree, tree, tree, tree, bool, bool *);
6171extern void finish_enum_value_list (tree);
6172extern void finish_enum (tree);
6173extern void build_enumerator (tree, tree, tree, tree, location_t);
6174extern tree lookup_enumerator (tree, tree);
6175extern bool start_preparsed_function (tree, tree, int);
6176extern bool start_function (cp_decl_specifier_seq *,
6177 const cp_declarator *, tree);
6178extern tree begin_function_body (void);
6179extern void finish_function_body (tree);
6180extern tree outer_curly_brace_block (tree);
6181extern tree finish_function (bool);
6182extern tree grokmethod (cp_decl_specifier_seq *, const cp_declarator *, tree);
6183extern void maybe_register_incomplete_var (tree);
6184extern void maybe_commonize_var (tree);
6185extern void complete_vars (tree);
6186extern tree static_fn_type (tree);
6187extern void revert_static_member_fn (tree);
6188extern void fixup_anonymous_aggr (tree);
6189extern tree compute_array_index_type (tree, tree, tsubst_flags_t);
6190extern tree check_default_argument (tree, tree, tsubst_flags_t);
6191extern int wrapup_namespace_globals ();
6192extern tree create_implicit_typedef (tree, tree);
6193extern int local_variable_p (const_tree);
6194extern tree register_dtor_fn (tree);
6195extern tmpl_spec_kind current_tmpl_spec_kind (int);
6196extern tree cp_fname_init (const char *, tree *);
6197extern tree cxx_builtin_function (tree decl);
6198extern tree cxx_builtin_function_ext_scope (tree decl);
6199extern tree check_elaborated_type_specifier (enum tag_types, tree, bool);
6200extern void warn_extern_redeclared_static (tree, tree);
6201extern tree cxx_comdat_group (tree);
6202extern bool cp_missing_noreturn_ok_p (tree);
6203extern bool is_direct_enum_init (tree, tree);
6204extern void initialize_artificial_var (tree, vec<constructor_elt, va_gc> *);
6205extern tree check_var_type (tree, tree);
6206extern tree reshape_init (tree, tree, tsubst_flags_t);
6207extern tree next_initializable_field (tree);
6208extern tree fndecl_declared_return_type (tree);
6209extern bool undeduced_auto_decl (tree);
6210extern bool require_deduced_type (tree, tsubst_flags_t = tf_warning_or_error);
6211
6212extern tree finish_case_label (location_t, tree, tree);
6213extern tree cxx_maybe_build_cleanup (tree, tsubst_flags_t);
6214
6215/* in decl2.c */
6216extern void record_mangling (tree, bool);
6217extern void overwrite_mangling (tree, tree);
6218extern void note_mangling_alias (tree, tree);
6219extern void generate_mangling_aliases (void);
6220extern tree build_memfn_type (tree, tree, cp_cv_quals, cp_ref_qualifier);
6221extern tree build_pointer_ptrmemfn_type (tree);
6222extern tree change_return_type (tree, tree);
6223extern void maybe_retrofit_in_chrg (tree);
6224extern void maybe_make_one_only (tree);
6225extern bool vague_linkage_p (tree);
6226extern void grokclassfn (tree, tree,
6227 enum overload_flags);
6228extern tree grok_array_decl (location_t, tree, tree, bool);
6229extern tree delete_sanity (tree, tree, bool, int, tsubst_flags_t);
6230extern tree check_classfn (tree, tree, tree);
6231extern void check_member_template (tree);
6232extern tree grokfield (const cp_declarator *, cp_decl_specifier_seq *,
6233 tree, bool, tree, tree);
6234extern tree grokbitfield (const cp_declarator *, cp_decl_specifier_seq *,
6235 tree, tree, tree);
6236extern bool any_dependent_type_attributes_p (tree);
6237extern tree cp_reconstruct_complex_type (tree, tree);
6238extern bool attributes_naming_typedef_ok (tree);
6239extern void cplus_decl_attributes (tree *, tree, int);
6240extern void finish_anon_union (tree);
6241extern void cxx_post_compilation_parsing_cleanups (void);
6242extern tree coerce_new_type (tree);
6243extern tree coerce_delete_type (tree);
6244extern void comdat_linkage (tree);
6245extern void determine_visibility (tree);
6246extern void constrain_class_visibility (tree);
6247extern void reset_type_linkage (tree);
6248extern void tentative_decl_linkage (tree);
6249extern void import_export_decl (tree);
6250extern tree build_cleanup (tree);
6251extern tree build_offset_ref_call_from_tree (tree, vec<tree, va_gc> **,
6252 tsubst_flags_t);
6253extern bool decl_defined_p (tree);
6254extern bool decl_constant_var_p (tree);
6255extern bool decl_maybe_constant_var_p (tree);
6256extern void no_linkage_error (tree);
6257extern void check_default_args (tree);
6258extern bool mark_used (tree);
6259extern bool mark_used (tree, tsubst_flags_t);
6260extern void finish_static_data_member_decl (tree, tree, bool, tree, int);
6261extern tree cp_build_parm_decl (tree, tree, tree);
6262extern tree get_guard (tree);
6263extern tree get_guard_cond (tree, bool);
6264extern tree set_guard (tree);
6265extern tree get_tls_wrapper_fn (tree);
6266extern void mark_needed (tree);
6267extern bool decl_needed_p (tree);
6268extern void note_vague_linkage_fn (tree);
6269extern void note_variable_template_instantiation (tree);
6270extern tree build_artificial_parm (tree, tree, tree);
6271extern bool possibly_inlined_p (tree);
6272extern int parm_index (tree);
6273extern tree vtv_start_verification_constructor_init_function (void);
6274extern tree vtv_finish_verification_constructor_init_function (tree);
6275extern bool cp_omp_mappable_type (tree);
6276
6277/* in error.c */
6278extern const char *type_as_string (tree, int);
6279extern const char *type_as_string_translate (tree, int);
6280extern const char *decl_as_string (tree, int);
6281extern const char *decl_as_string_translate (tree, int);
6282extern const char *decl_as_dwarf_string (tree, int);
6283extern const char *expr_as_string (tree, int);
6284extern const char *lang_decl_name (tree, int, bool);
6285extern const char *lang_decl_dwarf_name (tree, int, bool);
6286extern const char *language_to_string (enum languages);
6287extern const char *class_key_or_enum_as_string (tree);
6288extern void maybe_warn_variadic_templates (void);
6289extern void maybe_warn_cpp0x (cpp0x_warn_str str);
6290extern bool pedwarn_cxx98 (location_t, int, const char *, ...) ATTRIBUTE_GCC_DIAG(3,4);
6291extern location_t location_of (tree);
6292extern void qualified_name_lookup_error (tree, tree, tree,
6293 location_t);
6294
6295/* in except.c */
6296extern void init_exception_processing (void);
6297extern tree expand_start_catch_block (tree);
6298extern void expand_end_catch_block (void);
6299extern tree build_exc_ptr (void);
6300extern tree build_throw (tree);
6301extern int nothrow_libfn_p (const_tree);
6302extern void check_handlers (tree);
6303extern tree finish_noexcept_expr (tree, tsubst_flags_t);
6304extern bool expr_noexcept_p (tree, tsubst_flags_t);
6305extern void perform_deferred_noexcept_checks (void);
6306extern bool nothrow_spec_p (const_tree);
6307extern bool type_noexcept_p (const_tree);
6308extern bool type_throw_all_p (const_tree);
6309extern tree build_noexcept_spec (tree, int);
6310extern void choose_personality_routine (enum languages);
6311extern tree build_must_not_throw_expr (tree,tree);
6312extern tree eh_type_info (tree);
6313extern tree begin_eh_spec_block (void);
6314extern void finish_eh_spec_block (tree, tree);
6315extern tree build_eh_type_type (tree);
6316extern tree cp_protect_cleanup_actions (void);
6317extern tree create_try_catch_expr (tree, tree);
6318
6319/* in expr.c */
6320extern tree cplus_expand_constant (tree);
6321extern tree mark_rvalue_use (tree,
6322 location_t = UNKNOWN_LOCATION,
6323 bool = true);
6324extern tree mark_lvalue_use (tree);
6325extern tree mark_lvalue_use_nonread (tree);
6326extern tree mark_type_use (tree);
6327extern tree mark_discarded_use (tree);
6328extern void mark_exp_read (tree);
6329
6330/* friend.c */
6331extern int is_friend (tree, tree);
6332extern void make_friend_class (tree, tree, bool);
6333extern void add_friend (tree, tree, bool);
6334extern tree do_friend (tree, tree, tree, tree, enum overload_flags, bool);
6335
6336extern void set_global_friend (tree);
6337extern bool is_global_friend (tree);
6338
6339/* in init.c */
6340extern tree expand_member_init (tree);
6341extern void emit_mem_initializers (tree);
6342extern tree build_aggr_init (tree, tree, int,
6343 tsubst_flags_t);
6344extern int is_class_type (tree, int);
6345extern tree get_type_value (tree);
6346extern tree build_zero_init (tree, tree, bool);
6347extern tree build_value_init (tree, tsubst_flags_t);
6348extern tree build_value_init_noctor (tree, tsubst_flags_t);
6349extern tree get_nsdmi (tree, bool, tsubst_flags_t);
6350extern tree build_offset_ref (tree, tree, bool,
6351 tsubst_flags_t);
6352extern tree throw_bad_array_new_length (void);
6353extern bool type_has_new_extended_alignment (tree);
6354extern unsigned malloc_alignment (void);
6355extern tree build_new (vec<tree, va_gc> **, tree, tree,
6356 vec<tree, va_gc> **, int,
6357 tsubst_flags_t);
6358extern tree get_temp_regvar (tree, tree);
6359extern tree build_vec_init (tree, tree, tree, bool, int,
6360 tsubst_flags_t);
6361extern tree build_delete (tree, tree,
6362 special_function_kind,
6363 int, int, tsubst_flags_t);
6364extern void push_base_cleanups (void);
6365extern tree build_vec_delete (tree, tree,
6366 special_function_kind, int,
6367 tsubst_flags_t);
6368extern tree create_temporary_var (tree);
6369extern void initialize_vtbl_ptrs (tree);
6370extern tree scalar_constant_value (tree);
6371extern tree decl_really_constant_value (tree);
6372extern int diagnose_uninitialized_cst_or_ref_member (tree, bool, bool);
6373extern tree build_vtbl_address (tree);
6374extern bool maybe_reject_flexarray_init (tree, tree);
6375
6376/* in lex.c */
6377extern void cxx_dup_lang_specific_decl (tree);
6378extern void yyungetc (int, int);
6379
6380extern tree unqualified_name_lookup_error (tree,
6381 location_t = UNKNOWN_LOCATION);
6382extern tree unqualified_fn_lookup_error (cp_expr);
6383extern tree make_conv_op_name (tree);
6384extern tree build_lang_decl (enum tree_code, tree, tree);
6385extern tree build_lang_decl_loc (location_t, enum tree_code, tree, tree);
6386extern void retrofit_lang_decl (tree);
6387extern void fit_decomposition_lang_decl (tree, tree);
6388extern tree copy_decl (tree CXX_MEM_STAT_INFO);
6389extern tree copy_type (tree CXX_MEM_STAT_INFO);
6390extern tree cxx_make_type (enum tree_code);
6391extern tree make_class_type (enum tree_code);
6392extern const char *get_identifier_kind_name (tree);
6393extern void set_identifier_kind (tree, cp_identifier_kind);
6394extern bool cxx_init (void);
6395extern void cxx_finish (void);
6396extern bool in_main_input_context (void);
6397
6398/* in method.c */
6399extern void init_method (void);
6400extern tree make_thunk (tree, bool, tree, tree);
6401extern void finish_thunk (tree);
6402extern void use_thunk (tree, bool);
6403extern bool trivial_fn_p (tree);
6404extern tree forward_parm (tree);
6405extern bool is_trivially_xible (enum tree_code, tree, tree);
6406extern bool is_xible (enum tree_code, tree, tree);
6407extern tree get_defaulted_eh_spec (tree, tsubst_flags_t = tf_warning_or_error);
6408extern void after_nsdmi_defaulted_late_checks (tree);
6409extern bool maybe_explain_implicit_delete (tree);
6410extern void explain_implicit_non_constexpr (tree);
6411extern void deduce_inheriting_ctor (tree);
6412extern void synthesize_method (tree);
6413extern tree lazily_declare_fn (special_function_kind,
6414 tree);
6415extern tree skip_artificial_parms_for (const_tree, tree);
6416extern int num_artificial_parms_for (const_tree);
6417extern tree make_alias_for (tree, tree);
6418extern tree get_copy_ctor (tree, tsubst_flags_t);
6419extern tree get_copy_assign (tree);
6420extern tree get_default_ctor (tree);
6421extern tree get_dtor (tree, tsubst_flags_t);
6422extern tree strip_inheriting_ctors (tree);
6423extern tree inherited_ctor_binfo (tree);
6424extern bool ctor_omit_inherited_parms (tree);
6425extern tree locate_ctor (tree);
6426extern tree implicitly_declare_fn (special_function_kind, tree,
6427 bool, tree, tree);
6428
6429/* In optimize.c */
6430extern bool maybe_clone_body (tree);
6431
6432/* In parser.c */
6433extern tree cp_convert_range_for (tree, tree, tree, tree, unsigned int, bool);
6434extern bool parsing_nsdmi (void);
6435extern bool parsing_default_capturing_generic_lambda_in_template (void);
6436extern void inject_this_parameter (tree, cp_cv_quals);
6437extern location_t defarg_location (tree);
6438extern void maybe_show_extern_c_location (void);
6439
6440/* in pt.c */
6441extern bool check_template_shadow (tree);
6442extern tree get_innermost_template_args (tree, int);
6443extern void maybe_begin_member_template_processing (tree);
6444extern void maybe_end_member_template_processing (void);
6445extern tree finish_member_template_decl (tree);
6446extern void begin_template_parm_list (void);
6447extern bool begin_specialization (void);
6448extern void reset_specialization (void);
6449extern void end_specialization (void);
6450extern void begin_explicit_instantiation (void);
6451extern void end_explicit_instantiation (void);
6452extern void check_unqualified_spec_or_inst (tree, location_t);
6453extern tree check_explicit_specialization (tree, tree, int, int);
6454extern int num_template_headers_for_class (tree);
6455extern void check_template_variable (tree);
6456extern tree make_auto (void);
6457extern tree make_decltype_auto (void);
6458extern tree make_template_placeholder (tree);
6459extern bool template_placeholder_p (tree);
6460extern tree do_auto_deduction (tree, tree, tree);
6461extern tree do_auto_deduction (tree, tree, tree,
6462 tsubst_flags_t,
6463 auto_deduction_context,
6464 tree = NULL_TREE,
6465 int = LOOKUP_NORMAL);
6466extern tree type_uses_auto (tree);
6467extern tree type_uses_auto_or_concept (tree);
6468extern void append_type_to_template_for_access_check (tree, tree, tree,
6469 location_t);
6470extern tree convert_generic_types_to_packs (tree, int, int);
6471extern tree splice_late_return_type (tree, tree);
6472extern bool is_auto (const_tree);
6473extern tree process_template_parm (tree, location_t, tree,
6474 bool, bool);
6475extern tree end_template_parm_list (tree);
6476extern void end_template_parm_list (void);
6477extern void end_template_decl (void);
6478extern tree maybe_update_decl_type (tree, tree);
6479extern bool check_default_tmpl_args (tree, tree, bool, bool, int);
6480extern tree push_template_decl (tree);
6481extern tree push_template_decl_real (tree, bool);
6482extern