OSDN Git Service

gcc/testsuite/ChangeLog
[pf3gnuchains/gcc-fork.git] / gcc / cp / cp-tree.h
1 /* Definitions for C++ parsing and type checking.
2    Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3    2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
4    Free Software Foundation, Inc.
5    Contributed by Michael Tiemann (tiemann@cygnus.com)
6
7 This file is part of GCC.
8
9 GCC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
13
14 GCC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3.  If not see
21 <http://www.gnu.org/licenses/>.  */
22
23 #ifndef GCC_CP_TREE_H
24 #define GCC_CP_TREE_H
25
26 #include "ggc.h"
27 #include "function.h"
28 #include "hashtab.h"
29 #include "vec.h"
30
31 /* In order for the format checking to accept the C++ front end
32    diagnostic framework extensions, you must include this file before
33    diagnostic-core.h, not after.  We override the definition of GCC_DIAG_STYLE
34    in c-common.h.  */
35 #undef GCC_DIAG_STYLE
36 #define GCC_DIAG_STYLE __gcc_cxxdiag__
37 #if defined(GCC_DIAGNOSTIC_CORE_H) || defined (GCC_C_COMMON_H)
38 #error \
39 In order for the format checking to accept the C++ front end diagnostic \
40 framework extensions, you must include this file before diagnostic-core.h and \
41 c-common.h, not after.
42 #endif
43 #include "c-family/c-common.h"
44 #include "diagnostic.h"
45
46 #include "name-lookup.h"
47
48 /* Usage of TREE_LANG_FLAG_?:
49    0: IDENTIFIER_MARKED (IDENTIFIER_NODEs)
50       NEW_EXPR_USE_GLOBAL (in NEW_EXPR).
51       DELETE_EXPR_USE_GLOBAL (in DELETE_EXPR).
52       COMPOUND_EXPR_OVERLOADED (in COMPOUND_EXPR).
53       TREE_INDIRECT_USING (in NAMESPACE_DECL).
54       CLEANUP_P (in TRY_BLOCK)
55       AGGR_INIT_VIA_CTOR_P (in AGGR_INIT_EXPR)
56       PTRMEM_OK_P (in ADDR_EXPR, OFFSET_REF, SCOPE_REF)
57       PAREN_STRING_LITERAL (in STRING_CST)
58       DECL_PRETTY_FUNCTION_P (in VAR_DECL)
59       KOENIG_LOOKUP_P (in CALL_EXPR)
60       STATEMENT_LIST_NO_SCOPE (in STATEMENT_LIST).
61       EXPR_STMT_STMT_EXPR_RESULT (in EXPR_STMT)
62       STMT_EXPR_NO_SCOPE (in STMT_EXPR)
63       BIND_EXPR_TRY_BLOCK (in BIND_EXPR)
64       TYPENAME_IS_ENUM_P (in TYPENAME_TYPE)
65       OMP_FOR_GIMPLIFYING_P (in OMP_FOR)
66       BASELINK_QUALIFIED_P (in BASELINK)
67       TARGET_EXPR_IMPLICIT_P (in TARGET_EXPR)
68       TEMPLATE_PARM_PARAMETER_PACK (in TEMPLATE_PARM_INDEX)
69       ATTR_IS_DEPENDENT (in the TREE_LIST for an attribute)
70       CONSTRUCTOR_IS_DIRECT_INIT (in CONSTRUCTOR)
71       LAMBDA_EXPR_CAPTURES_THIS_P (in LAMBDA_EXPR)
72       DECLTYPE_FOR_LAMBDA_CAPTURE (in DECLTYPE_TYPE)
73       VEC_INIT_EXPR_IS_CONSTEXPR (in VEC_INIT_EXPR)
74       DECL_OVERRIDE_P (in FUNCTION_DECL)
75       IMPLICIT_CONV_EXPR_DIRECT_INIT (in IMPLICIT_CONV_EXPR)
76       TRANSACTION_EXPR_IS_STMT (in TRANSACTION_EXPR)
77    1: IDENTIFIER_VIRTUAL_P (in IDENTIFIER_NODE)
78       TI_PENDING_TEMPLATE_FLAG.
79       TEMPLATE_PARMS_FOR_INLINE.
80       DELETE_EXPR_USE_VEC (in DELETE_EXPR).
81       (TREE_CALLS_NEW) (in _EXPR or _REF) (commented-out).
82       ICS_ELLIPSIS_FLAG (in _CONV)
83       DECL_INITIALIZED_P (in VAR_DECL)
84       TYPENAME_IS_CLASS_P (in TYPENAME_TYPE)
85       STMT_IS_FULL_EXPR_P (in _STMT)
86       TARGET_EXPR_LIST_INIT_P (in TARGET_EXPR)
87       LAMBDA_EXPR_MUTABLE_P (in LAMBDA_EXPR)
88       DECL_FINAL_P (in FUNCTION_DECL)
89       QUALIFIED_NAME_IS_TEMPLATE (in SCOPE_REF)
90    2: IDENTIFIER_OPNAME_P (in IDENTIFIER_NODE)
91       ICS_THIS_FLAG (in _CONV)
92       DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (in VAR_DECL)
93       STATEMENT_LIST_TRY_BLOCK (in STATEMENT_LIST)
94       TYPENAME_IS_RESOLVING_P (in TYPE_NAME_TYPE)
95       LAMBDA_EXPR_DEDUCE_RETURN_TYPE_P (in LAMBDA_EXPR)
96       TARGET_EXPR_DIRECT_INIT_P (in TARGET_EXPR)
97    3: (TREE_REFERENCE_EXPR) (in NON_LVALUE_EXPR) (commented-out).
98       ICS_BAD_FLAG (in _CONV)
99       FN_TRY_BLOCK_P (in TRY_BLOCK)
100       IDENTIFIER_CTOR_OR_DTOR_P (in IDENTIFIER_NODE)
101       BIND_EXPR_BODY_BLOCK (in BIND_EXPR)
102       DECL_NON_TRIVIALLY_INITIALIZED_P (in VAR_DECL)
103    4: TREE_HAS_CONSTRUCTOR (in INDIRECT_REF, SAVE_EXPR, CONSTRUCTOR,
104           or FIELD_DECL).
105       IDENTIFIER_TYPENAME_P (in IDENTIFIER_NODE)
106       DECL_TINFO_P (in VAR_DECL)
107    5: C_IS_RESERVED_WORD (in IDENTIFIER_NODE)
108       DECL_VTABLE_OR_VTT_P (in VAR_DECL)
109    6: IDENTIFIER_REPO_CHOSEN (in IDENTIFIER_NODE)
110       DECL_CONSTRUCTION_VTABLE_P (in VAR_DECL)
111       TYPE_MARKED_P (in _TYPE)
112
113    Usage of TYPE_LANG_FLAG_?:
114    0: TYPE_DEPENDENT_P
115    1: TYPE_HAS_USER_CONSTRUCTOR.
116    2: unused
117    3: TYPE_FOR_JAVA.
118    4: TYPE_HAS_NONTRIVIAL_DESTRUCTOR
119    5: CLASS_TYPE_P (in RECORD_TYPE and UNION_TYPE)
120       ENUM_FIXED_UNDERLYING_TYPE_P (in ENUMERAL_TYPE)
121    6: TYPE_DEPENDENT_P_VALID
122
123    Usage of DECL_LANG_FLAG_?:
124    0: DECL_ERROR_REPORTED (in VAR_DECL).
125       DECL_TEMPLATE_PARM_P (in PARM_DECL, CONST_DECL, TYPE_DECL, or TEMPLATE_DECL)
126       DECL_LOCAL_FUNCTION_P (in FUNCTION_DECL)
127       DECL_MUTABLE_P (in FIELD_DECL)
128       DECL_DEPENDENT_P (in USING_DECL)
129    1: C_TYPEDEF_EXPLICITLY_SIGNED (in TYPE_DECL).
130       DECL_TEMPLATE_INSTANTIATED (in a VAR_DECL or a FUNCTION_DECL)
131       DECL_MEMBER_TEMPLATE_P (in TEMPLATE_DECL)
132       FUNCTION_PARAMETER_PACK_P (in PARM_DECL)
133       USING_DECL_TYPENAME_P (in USING_DECL)
134    2: DECL_THIS_EXTERN (in VAR_DECL or FUNCTION_DECL).
135       DECL_IMPLICIT_TYPEDEF_P (in a TYPE_DECL)
136    3: DECL_IN_AGGR_P.
137    4: DECL_C_BIT_FIELD (in a FIELD_DECL)
138       DECL_ANON_UNION_VAR_P (in a VAR_DECL)
139       DECL_SELF_REFERENCE_P (in a TYPE_DECL)
140       DECL_INVALID_OVERRIDER_P (in a FUNCTION_DECL)
141    5: DECL_INTERFACE_KNOWN.
142    6: DECL_THIS_STATIC (in VAR_DECL or FUNCTION_DECL).
143       DECL_FIELD_IS_BASE (in FIELD_DECL)
144       TYPE_DECL_ALIAS_P (in TYPE_DECL)
145    7: DECL_DEAD_FOR_LOCAL (in VAR_DECL).
146       DECL_THUNK_P (in a member FUNCTION_DECL)
147       DECL_NORMAL_CAPTURE_P (in FIELD_DECL)
148    8: DECL_DECLARED_CONSTEXPR_P (in VAR_DECL, FUNCTION_DECL)
149
150    Usage of language-independent fields in a language-dependent manner:
151
152    TYPE_ALIAS_SET
153      This field is used by TYPENAME_TYPEs, TEMPLATE_TYPE_PARMs, and so
154      forth as a substitute for the mark bits provided in `lang_type'.
155      At present, only the six low-order bits are used.
156
157    TYPE_LANG_SLOT_1
158      For an ENUMERAL_TYPE, this is ENUM_TEMPLATE_INFO.
159      For a FUNCTION_TYPE or METHOD_TYPE, this is TYPE_RAISES_EXCEPTIONS
160
161   BINFO_VIRTUALS
162      For a binfo, this is a TREE_LIST.  There is an entry for each
163      virtual function declared either in BINFO or its direct and
164      indirect primary bases.
165
166      The BV_DELTA of each node gives the amount by which to adjust the
167      `this' pointer when calling the function.  If the method is an
168      overridden version of a base class method, then it is assumed
169      that, prior to adjustment, the this pointer points to an object
170      of the base class.
171
172      The BV_VCALL_INDEX of each node, if non-NULL, gives the vtable
173      index of the vcall offset for this entry.
174
175      The BV_FN is the declaration for the virtual function itself.
176
177      If BV_LOST_PRIMARY is set, it means that this entry is for a lost
178      primary virtual base and can be left null in the vtable.
179
180    BINFO_VTABLE
181      This is an expression with POINTER_TYPE that gives the value
182      to which the vptr should be initialized.  Use get_vtbl_decl_for_binfo
183      to extract the VAR_DECL for the complete vtable.
184
185    DECL_VINDEX
186      This field is NULL for a non-virtual function.  For a virtual
187      function, it is eventually set to an INTEGER_CST indicating the
188      index in the vtable at which this function can be found.  When
189      a virtual function is declared, but before it is known what
190      function is overridden, this field is the error_mark_node.
191
192      Temporarily, it may be set to a TREE_LIST whose TREE_VALUE is
193      the virtual function this one overrides, and whose TREE_CHAIN is
194      the old DECL_VINDEX.  */
195
196 /* Language-specific tree checkers.  */
197
198 #define VAR_OR_FUNCTION_DECL_CHECK(NODE) \
199   TREE_CHECK2(NODE,VAR_DECL,FUNCTION_DECL)
200
201 #define VAR_FUNCTION_OR_PARM_DECL_CHECK(NODE) \
202   TREE_CHECK3(NODE,VAR_DECL,FUNCTION_DECL,PARM_DECL)
203
204 #define VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK(NODE) \
205   TREE_CHECK4(NODE,VAR_DECL,FUNCTION_DECL,TYPE_DECL,TEMPLATE_DECL)
206
207 #define VAR_TEMPL_TYPE_FIELD_OR_FUNCTION_DECL_CHECK(NODE) \
208   TREE_CHECK5(NODE,VAR_DECL,FIELD_DECL,FUNCTION_DECL,TYPE_DECL,TEMPLATE_DECL)
209
210 #define BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK(NODE) \
211   TREE_CHECK(NODE,BOUND_TEMPLATE_TEMPLATE_PARM)
212
213 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
214 #define THUNK_FUNCTION_CHECK(NODE) __extension__                        \
215 ({  __typeof (NODE) const __t = (NODE);                                 \
216     if (TREE_CODE (__t) != FUNCTION_DECL || !__t->decl_common.lang_specific \
217         || !__t->decl_common.lang_specific->u.fn.thunk_p)               \
218       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, 0);     \
219      __t; })
220 #else
221 #define THUNK_FUNCTION_CHECK(NODE) (NODE)
222 #endif
223 \f
224 /* Language-dependent contents of an identifier.  */
225
226 struct GTY(()) lang_identifier {
227   struct c_common_identifier c_common;
228   cxx_binding *namespace_bindings;
229   cxx_binding *bindings;
230   tree class_template_info;
231   tree label_value;
232 };
233
234 /* In an IDENTIFIER_NODE, nonzero if this identifier is actually a
235    keyword.  C_RID_CODE (node) is then the RID_* value of the keyword,
236    and C_RID_YYCODE is the token number wanted by Yacc.  */
237
238 #define C_IS_RESERVED_WORD(ID) TREE_LANG_FLAG_5 (ID)
239
240 #define LANG_IDENTIFIER_CAST(NODE) \
241         ((struct lang_identifier*)IDENTIFIER_NODE_CHECK (NODE))
242
243 struct GTY(()) template_parm_index_s {
244   struct tree_common common;
245   int index;
246   int level;
247   int orig_level;
248   int num_siblings;
249   tree decl;
250 };
251 typedef struct template_parm_index_s template_parm_index;
252
253 struct GTY(()) ptrmem_cst {
254   struct tree_common common;
255   tree member;
256 };
257 typedef struct ptrmem_cst * ptrmem_cst_t;
258
259 #define IDENTIFIER_GLOBAL_VALUE(NODE) \
260   namespace_binding ((NODE), global_namespace)
261 #define SET_IDENTIFIER_GLOBAL_VALUE(NODE, VAL) \
262   set_namespace_binding ((NODE), global_namespace, (VAL))
263 #define IDENTIFIER_NAMESPACE_VALUE(NODE) \
264   namespace_binding ((NODE), current_namespace)
265 #define SET_IDENTIFIER_NAMESPACE_VALUE(NODE, VAL) \
266   set_namespace_binding ((NODE), current_namespace, (VAL))
267
268 #define CLEANUP_P(NODE)         TREE_LANG_FLAG_0 (TRY_BLOCK_CHECK (NODE))
269
270 #define BIND_EXPR_TRY_BLOCK(NODE) \
271   TREE_LANG_FLAG_0 (BIND_EXPR_CHECK (NODE))
272
273 /* Used to mark the block around the member initializers and cleanups.  */
274 #define BIND_EXPR_BODY_BLOCK(NODE) \
275   TREE_LANG_FLAG_3 (BIND_EXPR_CHECK (NODE))
276 #define FUNCTION_NEEDS_BODY_BLOCK(NODE) \
277   (DECL_CONSTRUCTOR_P (NODE) || DECL_DESTRUCTOR_P (NODE) \
278    || LAMBDA_FUNCTION_P (NODE))
279
280 #define STATEMENT_LIST_NO_SCOPE(NODE) \
281   TREE_LANG_FLAG_0 (STATEMENT_LIST_CHECK (NODE))
282 #define STATEMENT_LIST_TRY_BLOCK(NODE) \
283   TREE_LANG_FLAG_2 (STATEMENT_LIST_CHECK (NODE))
284
285 /* Nonzero if this statement should be considered a full-expression,
286    i.e., if temporaries created during this statement should have
287    their destructors run at the end of this statement.  */
288 #define STMT_IS_FULL_EXPR_P(NODE) TREE_LANG_FLAG_1 ((NODE))
289
290 /* Marks the result of a statement expression.  */
291 #define EXPR_STMT_STMT_EXPR_RESULT(NODE) \
292   TREE_LANG_FLAG_0 (EXPR_STMT_CHECK (NODE))
293
294 /* Nonzero if this statement-expression does not have an associated scope.  */
295 #define STMT_EXPR_NO_SCOPE(NODE) \
296    TREE_LANG_FLAG_0 (STMT_EXPR_CHECK (NODE))
297
298 /* Returns nonzero iff TYPE1 and TYPE2 are the same type, in the usual
299    sense of `same'.  */
300 #define same_type_p(TYPE1, TYPE2) \
301   comptypes ((TYPE1), (TYPE2), COMPARE_STRICT)
302
303 /* Returns nonzero iff NODE is a declaration for the global function
304    `main'.  */
305 #define DECL_MAIN_P(NODE)                               \
306    (DECL_EXTERN_C_FUNCTION_P (NODE)                     \
307     && DECL_NAME (NODE) != NULL_TREE                    \
308     && MAIN_NAME_P (DECL_NAME (NODE))                   \
309     && flag_hosted)
310
311 /* The overloaded FUNCTION_DECL.  */
312 #define OVL_FUNCTION(NODE) \
313   (((struct tree_overload*)OVERLOAD_CHECK (NODE))->function)
314 #define OVL_CHAIN(NODE)      TREE_CHAIN (NODE)
315 /* Polymorphic access to FUNCTION and CHAIN.  */
316 #define OVL_CURRENT(NODE)       \
317   ((TREE_CODE (NODE) == OVERLOAD) ? OVL_FUNCTION (NODE) : (NODE))
318 #define OVL_NEXT(NODE)          \
319   ((TREE_CODE (NODE) == OVERLOAD) ? TREE_CHAIN (NODE) : NULL_TREE)
320 /* If set, this was imported in a using declaration.
321    This is not to confuse with being used somewhere, which
322    is not important for this node.  */
323 #define OVL_USED(NODE)          TREE_USED (NODE)
324 /* If set, this OVERLOAD was created for argument-dependent lookup
325    and can be freed afterward.  */
326 #define OVL_ARG_DEPENDENT(NODE) TREE_LANG_FLAG_0 (OVERLOAD_CHECK (NODE))
327
328 struct GTY(()) tree_overload {
329   struct tree_common common;
330   tree function;
331 };
332
333 /* Returns true iff NODE is a BASELINK.  */
334 #define BASELINK_P(NODE) \
335   (TREE_CODE (NODE) == BASELINK)
336 /* The BINFO indicating the base from which the BASELINK_FUNCTIONS came.  */
337 #define BASELINK_BINFO(NODE) \
338   (((struct tree_baselink*) BASELINK_CHECK (NODE))->binfo)
339 /* The functions referred to by the BASELINK; either a FUNCTION_DECL,
340    a TEMPLATE_DECL, an OVERLOAD, or a TEMPLATE_ID_EXPR.  */
341 #define BASELINK_FUNCTIONS(NODE) \
342   (((struct tree_baselink*) BASELINK_CHECK (NODE))->functions)
343 /* The BINFO in which the search for the functions indicated by this baselink
344    began.  This base is used to determine the accessibility of functions
345    selected by overload resolution.  */
346 #define BASELINK_ACCESS_BINFO(NODE) \
347   (((struct tree_baselink*) BASELINK_CHECK (NODE))->access_binfo)
348 /* For a type-conversion operator, the BASELINK_OPTYPE indicates the type
349    to which the conversion should occur.  This value is important if
350    the BASELINK_FUNCTIONS include a template conversion operator --
351    the BASELINK_OPTYPE can be used to determine what type the user
352    requested.  */
353 #define BASELINK_OPTYPE(NODE) \
354   (TREE_CHAIN (BASELINK_CHECK (NODE)))
355 /* Nonzero if this baselink was from a qualified lookup.  */
356 #define BASELINK_QUALIFIED_P(NODE) \
357   TREE_LANG_FLAG_0 (BASELINK_CHECK (NODE))
358
359 struct GTY(()) tree_baselink {
360   struct tree_common common;
361   tree binfo;
362   tree functions;
363   tree access_binfo;
364 };
365
366 /* The different kinds of ids that we encounter.  */
367
368 typedef enum cp_id_kind
369 {
370   /* Not an id at all.  */
371   CP_ID_KIND_NONE,
372   /* An unqualified-id that is not a template-id.  */
373   CP_ID_KIND_UNQUALIFIED,
374   /* An unqualified-id that is a dependent name.  */
375   CP_ID_KIND_UNQUALIFIED_DEPENDENT,
376   /* An unqualified template-id.  */
377   CP_ID_KIND_TEMPLATE_ID,
378   /* A qualified-id.  */
379   CP_ID_KIND_QUALIFIED
380 } cp_id_kind;
381
382
383 /* The various kinds of C++0x warnings we encounter. */
384
385 typedef enum cpp0x_warn_str
386 {
387   /* extended initializer lists */
388   CPP0X_INITIALIZER_LISTS,
389   /* explicit conversion operators */
390   CPP0X_EXPLICIT_CONVERSION,
391   /* variadic templates */
392   CPP0X_VARIADIC_TEMPLATES,
393   /* lambda expressions */
394   CPP0X_LAMBDA_EXPR,
395   /* C++0x auto */
396   CPP0X_AUTO,
397   /* scoped enums */
398   CPP0X_SCOPED_ENUMS,
399   /* defaulted and deleted functions */
400   CPP0X_DEFAULTED_DELETED,
401   /* inline namespaces */
402   CPP0X_INLINE_NAMESPACES,
403   /* override controls, override/final */
404   CPP0X_OVERRIDE_CONTROLS,
405   /* non-static data member initializers */
406   CPP0X_NSDMI,
407   /* user defined literals */
408   CPP0X_USER_DEFINED_LITERALS,
409   /* delegating constructors */
410   CPP0X_DELEGATING_CTORS
411 } cpp0x_warn_str;
412   
413 /* The various kinds of operation used by composite_pointer_type. */
414
415 typedef enum composite_pointer_operation
416 {
417   /* comparison */
418   CPO_COMPARISON,
419   /* conversion */
420   CPO_CONVERSION,
421   /* conditional expression */
422   CPO_CONDITIONAL_EXPR
423 } composite_pointer_operation;
424
425 /* Possible cases of expression list used by build_x_compound_expr_from_list. */
426 typedef enum expr_list_kind {
427   ELK_INIT,             /* initializer */
428   ELK_MEM_INIT,         /* member initializer */
429   ELK_FUNC_CAST         /* functional cast */
430 } expr_list_kind; 
431
432 /* Possible cases of implicit bad rhs conversions. */
433 typedef enum impl_conv_rhs {
434   ICR_DEFAULT_ARGUMENT, /* default argument */
435   ICR_CONVERTING,       /* converting */
436   ICR_INIT,             /* initialization */
437   ICR_ARGPASS,          /* argument passing */
438   ICR_RETURN,           /* return */
439   ICR_ASSIGN            /* assignment */
440 } impl_conv_rhs;
441
442 /* Possible cases of implicit or explicit bad conversions to void. */
443 typedef enum impl_conv_void {
444   ICV_CAST,            /* (explicit) conversion to void */
445   ICV_SECOND_OF_COND,  /* second operand of conditional expression */
446   ICV_THIRD_OF_COND,   /* third operand of conditional expression */
447   ICV_RIGHT_OF_COMMA,  /* right operand of comma operator */
448   ICV_LEFT_OF_COMMA,   /* left operand of comma operator */
449   ICV_STATEMENT,       /* statement */
450   ICV_THIRD_IN_FOR     /* for increment expression */
451 } impl_conv_void;
452
453 /* Macros for access to language-specific slots in an identifier.  */
454
455 #define IDENTIFIER_NAMESPACE_BINDINGS(NODE)     \
456   (LANG_IDENTIFIER_CAST (NODE)->namespace_bindings)
457 #define IDENTIFIER_TEMPLATE(NODE)       \
458   (LANG_IDENTIFIER_CAST (NODE)->class_template_info)
459
460 /* The IDENTIFIER_BINDING is the innermost cxx_binding for the
461     identifier.  It's PREVIOUS is the next outermost binding.  Each
462     VALUE field is a DECL for the associated declaration.  Thus,
463     name lookup consists simply of pulling off the node at the front
464     of the list (modulo oddities for looking up the names of types,
465     and such.)  You can use SCOPE field to determine the scope
466     that bound the name.  */
467 #define IDENTIFIER_BINDING(NODE) \
468   (LANG_IDENTIFIER_CAST (NODE)->bindings)
469
470 /* TREE_TYPE only indicates on local and class scope the current
471    type. For namespace scope, the presence of a type in any namespace
472    is indicated with global_type_node, and the real type behind must
473    be found through lookup.  */
474 #define IDENTIFIER_TYPE_VALUE(NODE) identifier_type_value (NODE)
475 #define REAL_IDENTIFIER_TYPE_VALUE(NODE) TREE_TYPE (NODE)
476 #define SET_IDENTIFIER_TYPE_VALUE(NODE,TYPE) (TREE_TYPE (NODE) = (TYPE))
477 #define IDENTIFIER_HAS_TYPE_VALUE(NODE) (IDENTIFIER_TYPE_VALUE (NODE) ? 1 : 0)
478
479 #define IDENTIFIER_LABEL_VALUE(NODE) \
480   (LANG_IDENTIFIER_CAST (NODE)->label_value)
481 #define SET_IDENTIFIER_LABEL_VALUE(NODE, VALUE)   \
482   IDENTIFIER_LABEL_VALUE (NODE) = (VALUE)
483
484 /* Nonzero if this identifier is used as a virtual function name somewhere
485    (optimizes searches).  */
486 #define IDENTIFIER_VIRTUAL_P(NODE) TREE_LANG_FLAG_1 (NODE)
487
488 /* Nonzero if this identifier is the prefix for a mangled C++ operator
489    name.  */
490 #define IDENTIFIER_OPNAME_P(NODE) TREE_LANG_FLAG_2 (NODE)
491
492 /* Nonzero if this identifier is the name of a type-conversion
493    operator.  */
494 #define IDENTIFIER_TYPENAME_P(NODE) \
495   TREE_LANG_FLAG_4 (NODE)
496
497 /* Nonzero if this identifier is the name of a constructor or
498    destructor.  */
499 #define IDENTIFIER_CTOR_OR_DTOR_P(NODE) \
500   TREE_LANG_FLAG_3 (NODE)
501
502 /* True iff NAME is the DECL_ASSEMBLER_NAME for an entity with vague
503    linkage which the prelinker has assigned to this translation
504    unit.  */
505 #define IDENTIFIER_REPO_CHOSEN(NAME) \
506   (TREE_LANG_FLAG_6 (NAME))
507
508 /* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only.  */
509 #define C_TYPE_FIELDS_READONLY(TYPE) \
510   (LANG_TYPE_CLASS_CHECK (TYPE)->fields_readonly)
511
512 /* The tokens stored in the default argument.  */
513
514 #define DEFARG_TOKENS(NODE) \
515   (((struct tree_default_arg *)DEFAULT_ARG_CHECK (NODE))->tokens)
516 #define DEFARG_INSTANTIATIONS(NODE) \
517   (((struct tree_default_arg *)DEFAULT_ARG_CHECK (NODE))->instantiations)
518
519 struct GTY (()) tree_default_arg {
520   struct tree_common common;
521   struct cp_token_cache *tokens;
522   VEC(tree,gc) *instantiations;
523 };
524
525
526 #define DEFERRED_NOEXCEPT_PATTERN(NODE) \
527   (((struct tree_deferred_noexcept *)DEFERRED_NOEXCEPT_CHECK (NODE))->pattern)
528 #define DEFERRED_NOEXCEPT_ARGS(NODE) \
529   (((struct tree_deferred_noexcept *)DEFERRED_NOEXCEPT_CHECK (NODE))->args)
530 #define DEFERRED_NOEXCEPT_SPEC_P(NODE)                          \
531   ((NODE) && (TREE_PURPOSE (NODE))                              \
532   && (TREE_CODE (TREE_PURPOSE (NODE)) == DEFERRED_NOEXCEPT      \
533       || is_overloaded_fn (TREE_PURPOSE (NODE))))
534
535 struct GTY (()) tree_deferred_noexcept {
536   struct tree_base base;
537   tree pattern;
538   tree args;
539 };
540
541
542 /* The condition associated with the static assertion.  This must be
543    an integral constant expression.  */
544 #define STATIC_ASSERT_CONDITION(NODE) \
545   (((struct tree_static_assert *)STATIC_ASSERT_CHECK (NODE))->condition)
546
547 /* The message associated with the static assertion.  This must be a
548    string constant, which will be emitted as an error message when the
549    static assert condition is false.  */
550 #define STATIC_ASSERT_MESSAGE(NODE) \
551   (((struct tree_static_assert *)STATIC_ASSERT_CHECK (NODE))->message)
552
553 /* Source location information for a static assertion.  */
554 #define STATIC_ASSERT_SOURCE_LOCATION(NODE) \
555   (((struct tree_static_assert *)STATIC_ASSERT_CHECK (NODE))->location)
556
557 struct GTY (()) tree_static_assert {
558   struct tree_common common;
559   tree condition;
560   tree message;
561   location_t location;
562 };
563
564 struct GTY (()) tree_argument_pack_select {
565   struct tree_common common;
566   tree argument_pack;
567   int index;
568 };
569
570 /* The different kinds of traits that we encounter.  */
571
572 typedef enum cp_trait_kind
573 {
574   CPTK_BASES,
575   CPTK_DIRECT_BASES,
576   CPTK_HAS_NOTHROW_ASSIGN,
577   CPTK_HAS_NOTHROW_CONSTRUCTOR,
578   CPTK_HAS_NOTHROW_COPY,
579   CPTK_HAS_TRIVIAL_ASSIGN,
580   CPTK_HAS_TRIVIAL_CONSTRUCTOR,
581   CPTK_HAS_TRIVIAL_COPY,
582   CPTK_HAS_TRIVIAL_DESTRUCTOR,
583   CPTK_HAS_VIRTUAL_DESTRUCTOR,
584   CPTK_IS_ABSTRACT,
585   CPTK_IS_BASE_OF,
586   CPTK_IS_CLASS,
587   CPTK_IS_CONVERTIBLE_TO,
588   CPTK_IS_EMPTY,
589   CPTK_IS_ENUM,
590   CPTK_IS_LITERAL_TYPE,
591   CPTK_IS_POD,
592   CPTK_IS_POLYMORPHIC,
593   CPTK_IS_STD_LAYOUT,
594   CPTK_IS_TRIVIAL,
595   CPTK_IS_UNION,
596   CPTK_UNDERLYING_TYPE
597 } cp_trait_kind;
598
599 /* The types that we are processing.  */
600 #define TRAIT_EXPR_TYPE1(NODE) \
601   (((struct tree_trait_expr *)TRAIT_EXPR_CHECK (NODE))->type1)
602
603 #define TRAIT_EXPR_TYPE2(NODE) \
604   (((struct tree_trait_expr *)TRAIT_EXPR_CHECK (NODE))->type2)
605
606 /* The specific trait that we are processing.  */
607 #define TRAIT_EXPR_KIND(NODE) \
608   (((struct tree_trait_expr *)TRAIT_EXPR_CHECK (NODE))->kind)
609
610 struct GTY (()) tree_trait_expr {
611   struct tree_common common;
612   tree type1;
613   tree type2;  
614   enum cp_trait_kind kind;
615 };
616
617 /* Based off of TYPE_ANONYMOUS_P.  */
618 #define LAMBDA_TYPE_P(NODE) \
619   (CLASS_TYPE_P (NODE) && LAMBDANAME_P (TYPE_LINKAGE_IDENTIFIER (NODE)))
620
621 /* Test if FUNCTION_DECL is a lambda function.  */
622 #define LAMBDA_FUNCTION_P(FNDECL) \
623   (DECL_OVERLOADED_OPERATOR_P (FNDECL) == CALL_EXPR \
624    && LAMBDA_TYPE_P (CP_DECL_CONTEXT (FNDECL)))
625
626 enum cp_lambda_default_capture_mode_type {
627   CPLD_NONE,
628   CPLD_COPY,
629   CPLD_REFERENCE
630 };
631
632 /* The method of default capture, if any.  */
633 #define LAMBDA_EXPR_DEFAULT_CAPTURE_MODE(NODE) \
634   (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->default_capture_mode)
635
636 /* The capture-list, including `this'.  Each capture is stored as a FIELD_DECL
637  * so that the name, type, and field are all together, whether or not it has
638  * been added to the lambda's class type.
639    TREE_LIST:
640      TREE_PURPOSE: The FIELD_DECL for this capture.
641      TREE_VALUE: The initializer. This is part of a GNU extension.  */
642 #define LAMBDA_EXPR_CAPTURE_LIST(NODE) \
643   (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->capture_list)
644
645 /* During parsing of the lambda, the node in the capture-list that holds
646    the 'this' capture.  */
647 #define LAMBDA_EXPR_THIS_CAPTURE(NODE) \
648   (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->this_capture)
649
650 /* Predicate tracking whether `this' is in the effective capture set.  */
651 #define LAMBDA_EXPR_CAPTURES_THIS_P(NODE) \
652   LAMBDA_EXPR_THIS_CAPTURE(NODE)
653
654 /* Predicate tracking whether the lambda was declared 'mutable'.  */
655 #define LAMBDA_EXPR_MUTABLE_P(NODE) \
656   TREE_LANG_FLAG_1 (LAMBDA_EXPR_CHECK (NODE))
657
658 /* True iff we should try to deduce the lambda return type from any return
659    statement.  */
660 #define LAMBDA_EXPR_DEDUCE_RETURN_TYPE_P(NODE) \
661   TREE_LANG_FLAG_2 (LAMBDA_EXPR_CHECK (NODE))
662
663 /* The return type in the expression.
664  * NULL_TREE indicates that none was specified.  */
665 #define LAMBDA_EXPR_RETURN_TYPE(NODE) \
666   (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->return_type)
667
668 /* The source location of the lambda.  */
669 #define LAMBDA_EXPR_LOCATION(NODE) \
670   (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->locus)
671
672 /* The mangling scope for the lambda: FUNCTION_DECL, PARM_DECL, VAR_DECL,
673    FIELD_DECL or NULL_TREE.  If this is NULL_TREE, we have no linkage.  */
674 #define LAMBDA_EXPR_EXTRA_SCOPE(NODE) \
675   (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->extra_scope)
676
677 /* If EXTRA_SCOPE, this is the number of the lambda within that scope.  */
678 #define LAMBDA_EXPR_DISCRIMINATOR(NODE) \
679   (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->discriminator)
680
681 /* During parsing of the lambda, a vector of capture proxies which need
682    to be pushed once we're done processing a nested lambda.  */
683 #define LAMBDA_EXPR_PENDING_PROXIES(NODE) \
684   (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->pending_proxies)
685
686 /* The closure type of the lambda.  Note that the TREE_TYPE of a
687    LAMBDA_EXPR is always NULL_TREE, because we need to instantiate the
688    LAMBDA_EXPR in order to instantiate the type.  */
689 #define LAMBDA_EXPR_CLOSURE(NODE) \
690   (((struct tree_lambda_expr *)LAMBDA_EXPR_CHECK (NODE))->closure)
691
692 struct GTY (()) tree_lambda_expr
693 {
694   struct tree_typed typed;
695   tree capture_list;
696   tree this_capture;
697   tree return_type;
698   tree extra_scope;
699   tree closure;
700   VEC(tree,gc)* pending_proxies;
701   location_t locus;
702   enum cp_lambda_default_capture_mode_type default_capture_mode;
703   int discriminator;
704 };
705
706 /* A (typedef,context,usage location) triplet.
707    It represents a typedef used through a
708    context at a given source location.
709    e.g.
710    struct foo {
711      typedef int myint;
712    };
713
714    struct bar {
715     foo::myint v; // #1<-- this location.
716    };
717
718    In bar, the triplet will be (myint, foo, #1).
719    */
720 struct GTY(()) qualified_typedef_usage_s {
721   tree typedef_decl;
722   tree context;
723   location_t locus;
724 };
725 typedef struct qualified_typedef_usage_s qualified_typedef_usage_t;
726 DEF_VEC_O (qualified_typedef_usage_t);
727 DEF_VEC_ALLOC_O (qualified_typedef_usage_t,gc);
728
729 struct GTY(()) tree_template_info {
730   struct tree_common common;
731   VEC(qualified_typedef_usage_t,gc) *typedefs_needing_access_checking;
732 };
733
734 enum cp_tree_node_structure_enum {
735   TS_CP_GENERIC,
736   TS_CP_IDENTIFIER,
737   TS_CP_TPI,
738   TS_CP_PTRMEM,
739   TS_CP_BINDING,
740   TS_CP_OVERLOAD,
741   TS_CP_BASELINK,
742   TS_CP_WRAPPER,
743   TS_CP_DEFAULT_ARG,
744   TS_CP_DEFERRED_NOEXCEPT,
745   TS_CP_STATIC_ASSERT,
746   TS_CP_ARGUMENT_PACK_SELECT,
747   TS_CP_TRAIT_EXPR,
748   TS_CP_LAMBDA_EXPR,
749   TS_CP_TEMPLATE_INFO,
750   TS_CP_USERDEF_LITERAL,
751   LAST_TS_CP_ENUM
752 };
753
754 /* The resulting tree type.  */
755 union GTY((desc ("cp_tree_node_structure (&%h)"),
756        chain_next ("(union lang_tree_node *) c_tree_chain_next (&%h.generic)"))) lang_tree_node {
757   union tree_node GTY ((tag ("TS_CP_GENERIC"),
758                         desc ("tree_node_structure (&%h)"))) generic;
759   struct template_parm_index_s GTY ((tag ("TS_CP_TPI"))) tpi;
760   struct ptrmem_cst GTY ((tag ("TS_CP_PTRMEM"))) ptrmem;
761   struct tree_overload GTY ((tag ("TS_CP_OVERLOAD"))) overload;
762   struct tree_baselink GTY ((tag ("TS_CP_BASELINK"))) baselink;
763   struct tree_default_arg GTY ((tag ("TS_CP_DEFAULT_ARG"))) default_arg;
764   struct tree_deferred_noexcept GTY ((tag ("TS_CP_DEFERRED_NOEXCEPT"))) deferred_noexcept;
765   struct lang_identifier GTY ((tag ("TS_CP_IDENTIFIER"))) identifier;
766   struct tree_static_assert GTY ((tag ("TS_CP_STATIC_ASSERT"))) 
767     static_assertion;
768   struct tree_argument_pack_select GTY ((tag ("TS_CP_ARGUMENT_PACK_SELECT")))
769     argument_pack_select;
770   struct tree_trait_expr GTY ((tag ("TS_CP_TRAIT_EXPR")))
771     trait_expression;
772   struct tree_lambda_expr GTY ((tag ("TS_CP_LAMBDA_EXPR")))
773     lambda_expression;
774   struct tree_template_info GTY ((tag ("TS_CP_TEMPLATE_INFO")))
775     template_info;
776   struct tree_userdef_literal GTY ((tag ("TS_CP_USERDEF_LITERAL")))
777     userdef_literal;
778 };
779
780 \f
781 enum cp_tree_index
782 {
783     CPTI_JAVA_BYTE_TYPE,
784     CPTI_JAVA_SHORT_TYPE,
785     CPTI_JAVA_INT_TYPE,
786     CPTI_JAVA_LONG_TYPE,
787     CPTI_JAVA_FLOAT_TYPE,
788     CPTI_JAVA_DOUBLE_TYPE,
789     CPTI_JAVA_CHAR_TYPE,
790     CPTI_JAVA_BOOLEAN_TYPE,
791
792     CPTI_WCHAR_DECL,
793     CPTI_VTABLE_ENTRY_TYPE,
794     CPTI_DELTA_TYPE,
795     CPTI_VTABLE_INDEX_TYPE,
796     CPTI_CLEANUP_TYPE,
797     CPTI_VTT_PARM_TYPE,
798
799     CPTI_CLASS_TYPE,
800     CPTI_UNKNOWN_TYPE,
801     CPTI_INIT_LIST_TYPE,
802     CPTI_DEPENDENT_LAMBDA_RETURN_TYPE,
803     CPTI_VTBL_TYPE,
804     CPTI_VTBL_PTR_TYPE,
805     CPTI_STD,
806     CPTI_ABI,
807     CPTI_CONST_TYPE_INFO_TYPE,
808     CPTI_TYPE_INFO_PTR_TYPE,
809     CPTI_ABORT_FNDECL,
810     CPTI_GLOBAL_DELETE_FNDECL,
811     CPTI_AGGR_TAG,
812
813     CPTI_CTOR_IDENTIFIER,
814     CPTI_COMPLETE_CTOR_IDENTIFIER,
815     CPTI_BASE_CTOR_IDENTIFIER,
816     CPTI_DTOR_IDENTIFIER,
817     CPTI_COMPLETE_DTOR_IDENTIFIER,
818     CPTI_BASE_DTOR_IDENTIFIER,
819     CPTI_DELETING_DTOR_IDENTIFIER,
820     CPTI_DELTA_IDENTIFIER,
821     CPTI_IN_CHARGE_IDENTIFIER,
822     CPTI_VTT_PARM_IDENTIFIER,
823     CPTI_NELTS_IDENTIFIER,
824     CPTI_THIS_IDENTIFIER,
825     CPTI_PFN_IDENTIFIER,
826     CPTI_VPTR_IDENTIFIER,
827     CPTI_STD_IDENTIFIER,
828
829     CPTI_LANG_NAME_C,
830     CPTI_LANG_NAME_CPLUSPLUS,
831     CPTI_LANG_NAME_JAVA,
832
833     CPTI_EMPTY_EXCEPT_SPEC,
834     CPTI_NOEXCEPT_TRUE_SPEC,
835     CPTI_NOEXCEPT_FALSE_SPEC,
836     CPTI_JCLASS,
837     CPTI_TERMINATE,
838     CPTI_CALL_UNEXPECTED,
839     CPTI_ATEXIT_FN_PTR_TYPE,
840     CPTI_ATEXIT,
841     CPTI_DSO_HANDLE,
842     CPTI_DCAST,
843
844     CPTI_KEYED_CLASSES,
845
846     CPTI_NULLPTR,
847     CPTI_NULLPTR_TYPE,
848
849     CPTI_MAX
850 };
851
852 extern GTY(()) tree cp_global_trees[CPTI_MAX];
853
854 #define java_byte_type_node             cp_global_trees[CPTI_JAVA_BYTE_TYPE]
855 #define java_short_type_node            cp_global_trees[CPTI_JAVA_SHORT_TYPE]
856 #define java_int_type_node              cp_global_trees[CPTI_JAVA_INT_TYPE]
857 #define java_long_type_node             cp_global_trees[CPTI_JAVA_LONG_TYPE]
858 #define java_float_type_node            cp_global_trees[CPTI_JAVA_FLOAT_TYPE]
859 #define java_double_type_node           cp_global_trees[CPTI_JAVA_DOUBLE_TYPE]
860 #define java_char_type_node             cp_global_trees[CPTI_JAVA_CHAR_TYPE]
861 #define java_boolean_type_node          cp_global_trees[CPTI_JAVA_BOOLEAN_TYPE]
862
863 #define wchar_decl_node                 cp_global_trees[CPTI_WCHAR_DECL]
864 #define vtable_entry_type               cp_global_trees[CPTI_VTABLE_ENTRY_TYPE]
865 /* The type used to represent an offset by which to adjust the `this'
866    pointer in pointer-to-member types.  */
867 #define delta_type_node                 cp_global_trees[CPTI_DELTA_TYPE]
868 /* The type used to represent an index into the vtable.  */
869 #define vtable_index_type               cp_global_trees[CPTI_VTABLE_INDEX_TYPE]
870
871 #define class_type_node                 cp_global_trees[CPTI_CLASS_TYPE]
872 #define unknown_type_node               cp_global_trees[CPTI_UNKNOWN_TYPE]
873 #define init_list_type_node             cp_global_trees[CPTI_INIT_LIST_TYPE]
874 #define dependent_lambda_return_type_node cp_global_trees[CPTI_DEPENDENT_LAMBDA_RETURN_TYPE]
875 #define vtbl_type_node                  cp_global_trees[CPTI_VTBL_TYPE]
876 #define vtbl_ptr_type_node              cp_global_trees[CPTI_VTBL_PTR_TYPE]
877 #define std_node                        cp_global_trees[CPTI_STD]
878 #define abi_node                        cp_global_trees[CPTI_ABI]
879 #define const_type_info_type_node       cp_global_trees[CPTI_CONST_TYPE_INFO_TYPE]
880 #define type_info_ptr_type              cp_global_trees[CPTI_TYPE_INFO_PTR_TYPE]
881 #define abort_fndecl                    cp_global_trees[CPTI_ABORT_FNDECL]
882 #define global_delete_fndecl            cp_global_trees[CPTI_GLOBAL_DELETE_FNDECL]
883 #define current_aggr                    cp_global_trees[CPTI_AGGR_TAG]
884 #define nullptr_node                    cp_global_trees[CPTI_NULLPTR]
885 #define nullptr_type_node               cp_global_trees[CPTI_NULLPTR_TYPE]
886
887 /* We cache these tree nodes so as to call get_identifier less
888    frequently.  */
889
890 /* The name of a constructor that takes an in-charge parameter to
891    decide whether or not to construct virtual base classes.  */
892 #define ctor_identifier                 cp_global_trees[CPTI_CTOR_IDENTIFIER]
893 /* The name of a constructor that constructs virtual base classes.  */
894 #define complete_ctor_identifier        cp_global_trees[CPTI_COMPLETE_CTOR_IDENTIFIER]
895 /* The name of a constructor that does not construct virtual base classes.  */
896 #define base_ctor_identifier            cp_global_trees[CPTI_BASE_CTOR_IDENTIFIER]
897 /* The name of a destructor that takes an in-charge parameter to
898    decide whether or not to destroy virtual base classes and whether
899    or not to delete the object.  */
900 #define dtor_identifier                 cp_global_trees[CPTI_DTOR_IDENTIFIER]
901 /* The name of a destructor that destroys virtual base classes.  */
902 #define complete_dtor_identifier        cp_global_trees[CPTI_COMPLETE_DTOR_IDENTIFIER]
903 /* The name of a destructor that does not destroy virtual base
904    classes.  */
905 #define base_dtor_identifier            cp_global_trees[CPTI_BASE_DTOR_IDENTIFIER]
906 /* The name of a destructor that destroys virtual base classes, and
907    then deletes the entire object.  */
908 #define deleting_dtor_identifier        cp_global_trees[CPTI_DELETING_DTOR_IDENTIFIER]
909 #define delta_identifier                cp_global_trees[CPTI_DELTA_IDENTIFIER]
910 #define in_charge_identifier            cp_global_trees[CPTI_IN_CHARGE_IDENTIFIER]
911 /* The name of the parameter that contains a pointer to the VTT to use
912    for this subobject constructor or destructor.  */
913 #define vtt_parm_identifier             cp_global_trees[CPTI_VTT_PARM_IDENTIFIER]
914 #define nelts_identifier                cp_global_trees[CPTI_NELTS_IDENTIFIER]
915 #define this_identifier                 cp_global_trees[CPTI_THIS_IDENTIFIER]
916 #define pfn_identifier                  cp_global_trees[CPTI_PFN_IDENTIFIER]
917 #define vptr_identifier                 cp_global_trees[CPTI_VPTR_IDENTIFIER]
918 /* The name of the std namespace.  */
919 #define std_identifier                  cp_global_trees[CPTI_STD_IDENTIFIER]
920 #define lang_name_c                     cp_global_trees[CPTI_LANG_NAME_C]
921 #define lang_name_cplusplus             cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS]
922 #define lang_name_java                  cp_global_trees[CPTI_LANG_NAME_JAVA]
923
924 /* Exception specifier used for throw().  */
925 #define empty_except_spec               cp_global_trees[CPTI_EMPTY_EXCEPT_SPEC]
926 #define noexcept_true_spec              cp_global_trees[CPTI_NOEXCEPT_TRUE_SPEC]
927 #define noexcept_false_spec             cp_global_trees[CPTI_NOEXCEPT_FALSE_SPEC]
928
929 /* If non-NULL, a POINTER_TYPE equivalent to (java::lang::Class*).  */
930 #define jclass_node                     cp_global_trees[CPTI_JCLASS]
931
932 /* The declaration for `std::terminate'.  */
933 #define terminate_node                  cp_global_trees[CPTI_TERMINATE]
934
935 /* The declaration for "__cxa_call_unexpected".  */
936 #define call_unexpected_node            cp_global_trees[CPTI_CALL_UNEXPECTED]
937
938 /* The type of the function-pointer argument to "__cxa_atexit" (or
939    "std::atexit", if "__cxa_atexit" is not being used).  */
940 #define atexit_fn_ptr_type_node         cp_global_trees[CPTI_ATEXIT_FN_PTR_TYPE]
941
942 /* A pointer to `std::atexit'.  */
943 #define atexit_node                     cp_global_trees[CPTI_ATEXIT]
944
945 /* A pointer to `__dso_handle'.  */
946 #define dso_handle_node                 cp_global_trees[CPTI_DSO_HANDLE]
947
948 /* The declaration of the dynamic_cast runtime.  */
949 #define dynamic_cast_node               cp_global_trees[CPTI_DCAST]
950
951 /* The type of a destructor.  */
952 #define cleanup_type                    cp_global_trees[CPTI_CLEANUP_TYPE]
953
954 /* The type of the vtt parameter passed to subobject constructors and
955    destructors.  */
956 #define vtt_parm_type                   cp_global_trees[CPTI_VTT_PARM_TYPE]
957
958 /* A TREE_LIST of the dynamic classes whose vtables may have to be
959    emitted in this translation unit.  */
960
961 #define keyed_classes                   cp_global_trees[CPTI_KEYED_CLASSES]
962
963 /* Node to indicate default access. This must be distinct from the
964    access nodes in tree.h.  */
965
966 #define access_default_node             null_node
967
968 /* Global state.  */
969
970 struct GTY(()) saved_scope {
971   VEC(cxx_saved_binding,gc) *old_bindings;
972   tree old_namespace;
973   VEC(tree,gc) *decl_ns_list;
974   tree class_name;
975   tree class_type;
976   tree access_specifier;
977   tree function_decl;
978   VEC(tree,gc) *lang_base;
979   tree lang_name;
980   tree template_parms;
981   cp_binding_level *x_previous_class_level;
982   tree x_saved_tree;
983
984   /* Only used for uses of this in trailing return type.  */
985   tree x_current_class_ptr;
986   tree x_current_class_ref;
987
988   int x_processing_template_decl;
989   int x_processing_specialization;
990   BOOL_BITFIELD x_processing_explicit_instantiation : 1;
991   BOOL_BITFIELD need_pop_function_context : 1;
992
993   int unevaluated_operand;
994   int inhibit_evaluation_warnings;
995
996   struct stmt_tree_s x_stmt_tree;
997
998   cp_binding_level *class_bindings;
999   cp_binding_level *bindings;
1000
1001   struct saved_scope *prev;
1002 };
1003
1004 /* The current open namespace.  */
1005
1006 #define current_namespace scope_chain->old_namespace
1007
1008 /* The stack for namespaces of current declarations.  */
1009
1010 #define decl_namespace_list scope_chain->decl_ns_list
1011
1012 /* IDENTIFIER_NODE: name of current class */
1013
1014 #define current_class_name scope_chain->class_name
1015
1016 /* _TYPE: the type of the current class */
1017
1018 #define current_class_type scope_chain->class_type
1019
1020 /* When parsing a class definition, the access specifier most recently
1021    given by the user, or, if no access specifier was given, the
1022    default value appropriate for the kind of class (i.e., struct,
1023    class, or union).  */
1024
1025 #define current_access_specifier scope_chain->access_specifier
1026
1027 /* Pointer to the top of the language name stack.  */
1028
1029 #define current_lang_base scope_chain->lang_base
1030 #define current_lang_name scope_chain->lang_name
1031
1032 /* When parsing a template declaration, a TREE_LIST represents the
1033    active template parameters.  Each node in the list represents one
1034    level of template parameters.  The innermost level is first in the
1035    list.  The depth of each level is stored as an INTEGER_CST in the
1036    TREE_PURPOSE of each node.  The parameters for that level are
1037    stored in the TREE_VALUE.  */
1038
1039 #define current_template_parms scope_chain->template_parms
1040
1041 #define processing_template_decl scope_chain->x_processing_template_decl
1042 #define processing_specialization scope_chain->x_processing_specialization
1043 #define processing_explicit_instantiation scope_chain->x_processing_explicit_instantiation
1044
1045 /* The cached class binding level, from the most recently exited
1046    class, or NULL if none.  */
1047
1048 #define previous_class_level scope_chain->x_previous_class_level
1049
1050 /* A list of private types mentioned, for deferred access checking.  */
1051
1052 extern GTY(()) struct saved_scope *scope_chain;
1053
1054 struct GTY(()) cxx_int_tree_map {
1055   unsigned int uid;
1056   tree to;
1057 };
1058
1059 extern unsigned int cxx_int_tree_map_hash (const void *);
1060 extern int cxx_int_tree_map_eq (const void *, const void *);
1061
1062 /* Global state pertinent to the current function.  */
1063
1064 struct GTY(()) language_function {
1065   struct c_language_function base;
1066
1067   tree x_cdtor_label;
1068   tree x_current_class_ptr;
1069   tree x_current_class_ref;
1070   tree x_eh_spec_block;
1071   tree x_in_charge_parm;
1072   tree x_vtt_parm;
1073   tree x_return_value;
1074
1075   BOOL_BITFIELD returns_value : 1;
1076   BOOL_BITFIELD returns_null : 1;
1077   BOOL_BITFIELD returns_abnormally : 1;
1078   BOOL_BITFIELD x_in_function_try_handler : 1;
1079   BOOL_BITFIELD x_in_base_initializer : 1;
1080
1081   /* True if this function can throw an exception.  */
1082   BOOL_BITFIELD can_throw : 1;
1083
1084   htab_t GTY((param_is(struct named_label_entry))) x_named_labels;
1085   cp_binding_level *bindings;
1086   VEC(tree,gc) *x_local_names;
1087   htab_t GTY((param_is (struct cxx_int_tree_map))) extern_decl_map;
1088 };
1089
1090 /* The current C++-specific per-function global variables.  */
1091
1092 #define cp_function_chain (cfun->language)
1093
1094 /* In a constructor destructor, the point at which all derived class
1095    destroying/construction has been done.  I.e., just before a
1096    constructor returns, or before any base class destroying will be done
1097    in a destructor.  */
1098
1099 #define cdtor_label cp_function_chain->x_cdtor_label
1100
1101 /* When we're processing a member function, current_class_ptr is the
1102    PARM_DECL for the `this' pointer.  The current_class_ref is an
1103    expression for `*this'.  */
1104
1105 #define current_class_ptr                       \
1106   (*(cfun && cp_function_chain                  \
1107      ? &cp_function_chain->x_current_class_ptr  \
1108      : &scope_chain->x_current_class_ptr))
1109 #define current_class_ref                       \
1110   (*(cfun && cp_function_chain                  \
1111      ? &cp_function_chain->x_current_class_ref  \
1112      : &scope_chain->x_current_class_ref))
1113
1114 /* The EH_SPEC_BLOCK for the exception-specifiers for the current
1115    function, if any.  */
1116
1117 #define current_eh_spec_block cp_function_chain->x_eh_spec_block
1118
1119 /* The `__in_chrg' parameter for the current function.  Only used for
1120    constructors and destructors.  */
1121
1122 #define current_in_charge_parm cp_function_chain->x_in_charge_parm
1123
1124 /* The `__vtt_parm' parameter for the current function.  Only used for
1125    constructors and destructors.  */
1126
1127 #define current_vtt_parm cp_function_chain->x_vtt_parm
1128
1129 /* Set to 0 at beginning of a function definition, set to 1 if
1130    a return statement that specifies a return value is seen.  */
1131
1132 #define current_function_returns_value cp_function_chain->returns_value
1133
1134 /* Set to 0 at beginning of a function definition, set to 1 if
1135    a return statement with no argument is seen.  */
1136
1137 #define current_function_returns_null cp_function_chain->returns_null
1138
1139 /* Set to 0 at beginning of a function definition, set to 1 if
1140    a call to a noreturn function is seen.  */
1141
1142 #define current_function_returns_abnormally \
1143   cp_function_chain->returns_abnormally
1144
1145 /* Nonzero if we are processing a base initializer.  Zero elsewhere.  */
1146 #define in_base_initializer cp_function_chain->x_in_base_initializer
1147
1148 #define in_function_try_handler cp_function_chain->x_in_function_try_handler
1149
1150 /* Expression always returned from function, or error_mark_node
1151    otherwise, for use by the automatic named return value optimization.  */
1152
1153 #define current_function_return_value \
1154   (cp_function_chain->x_return_value)
1155
1156 /* True if NAME is the IDENTIFIER_NODE for an overloaded "operator
1157    new" or "operator delete".  */
1158 #define NEW_DELETE_OPNAME_P(NAME)               \
1159   ((NAME) == ansi_opname (NEW_EXPR)             \
1160    || (NAME) == ansi_opname (VEC_NEW_EXPR)      \
1161    || (NAME) == ansi_opname (DELETE_EXPR)       \
1162    || (NAME) == ansi_opname (VEC_DELETE_EXPR))
1163
1164 #define ansi_opname(CODE) \
1165   (operator_name_info[(int) (CODE)].identifier)
1166 #define ansi_assopname(CODE) \
1167   (assignment_operator_name_info[(int) (CODE)].identifier)
1168
1169 /* TRUE if a tree code represents a statement.  */
1170 extern bool statement_code_p[MAX_TREE_CODES];
1171
1172 #define STATEMENT_CODE_P(CODE) statement_code_p[(int) (CODE)]
1173
1174 enum languages { lang_c, lang_cplusplus, lang_java };
1175
1176 /* Macros to make error reporting functions' lives easier.  */
1177 #define TYPE_IDENTIFIER(NODE) (DECL_NAME (TYPE_NAME (NODE)))
1178 #define TYPE_LINKAGE_IDENTIFIER(NODE) \
1179   (TYPE_IDENTIFIER (TYPE_MAIN_VARIANT (NODE)))
1180 #define TYPE_NAME_STRING(NODE) (IDENTIFIER_POINTER (TYPE_IDENTIFIER (NODE)))
1181 #define TYPE_NAME_LENGTH(NODE) (IDENTIFIER_LENGTH (TYPE_IDENTIFIER (NODE)))
1182
1183 /* Nonzero if NODE has no name for linkage purposes.  */
1184 #define TYPE_ANONYMOUS_P(NODE) \
1185   (TAGGED_TYPE_P (NODE) && ANON_AGGRNAME_P (TYPE_LINKAGE_IDENTIFIER (NODE)))
1186
1187 /* The _DECL for this _TYPE.  */
1188 #define TYPE_MAIN_DECL(NODE) (TYPE_STUB_DECL (TYPE_MAIN_VARIANT (NODE)))
1189
1190 /* Nonzero if T is a class (or struct or union) type.  Also nonzero
1191    for template type parameters, typename types, and instantiated
1192    template template parameters.  Keep these checks in ascending code
1193    order.  */
1194 #define MAYBE_CLASS_TYPE_P(T)                                   \
1195   (TREE_CODE (T) == TEMPLATE_TYPE_PARM                  \
1196    || TREE_CODE (T) == TYPENAME_TYPE                    \
1197    || TREE_CODE (T) == TYPEOF_TYPE                      \
1198    || TREE_CODE (T) == BOUND_TEMPLATE_TEMPLATE_PARM     \
1199    || TREE_CODE (T) == DECLTYPE_TYPE                    \
1200    || CLASS_TYPE_P (T))
1201
1202 /* Set CLASS_TYPE_P for T to VAL.  T must be a class, struct, or
1203    union type.  */
1204 #define SET_CLASS_TYPE_P(T, VAL) \
1205   (TYPE_LANG_FLAG_5 (T) = (VAL))
1206
1207 /* Nonzero if T is a class type.  Zero for template type parameters,
1208    typename types, and so forth.  */
1209 #define CLASS_TYPE_P(T) \
1210   (RECORD_OR_UNION_CODE_P (TREE_CODE (T)) && TYPE_LANG_FLAG_5 (T))
1211
1212 /* Nonzero if T is a class type but not an union.  */
1213 #define NON_UNION_CLASS_TYPE_P(T) \
1214   (CLASS_TYPE_P (T) && TREE_CODE (T) != UNION_TYPE)
1215
1216 /* Keep these checks in ascending code order.  */
1217 #define RECORD_OR_UNION_CODE_P(T)       \
1218   ((T) == RECORD_TYPE || (T) == UNION_TYPE)
1219 #define TAGGED_TYPE_P(T) \
1220   (CLASS_TYPE_P (T) || TREE_CODE (T) == ENUMERAL_TYPE)
1221 #define IS_OVERLOAD_TYPE(T) TAGGED_TYPE_P (T)
1222
1223 /* True if this a "Java" type, defined in 'extern "Java"'.  */
1224 #define TYPE_FOR_JAVA(NODE) TYPE_LANG_FLAG_3 (NODE)
1225
1226 /* True if this type is dependent.  This predicate is only valid if
1227    TYPE_DEPENDENT_P_VALID is true.  */
1228 #define TYPE_DEPENDENT_P(NODE) TYPE_LANG_FLAG_0 (NODE)
1229
1230 /* True if dependent_type_p has been called for this type, with the
1231    result that TYPE_DEPENDENT_P is valid.  */
1232 #define TYPE_DEPENDENT_P_VALID(NODE) TYPE_LANG_FLAG_6(NODE)
1233
1234 /* Nonzero if this type is const-qualified.  */
1235 #define CP_TYPE_CONST_P(NODE)                           \
1236   ((cp_type_quals (NODE) & TYPE_QUAL_CONST) != 0)
1237
1238 /* Nonzero if this type is volatile-qualified.  */
1239 #define CP_TYPE_VOLATILE_P(NODE)                        \
1240   ((cp_type_quals (NODE) & TYPE_QUAL_VOLATILE) != 0)
1241
1242 /* Nonzero if this type is restrict-qualified.  */
1243 #define CP_TYPE_RESTRICT_P(NODE)                        \
1244   ((cp_type_quals (NODE) & TYPE_QUAL_RESTRICT) != 0)
1245
1246 /* Nonzero if this type is const-qualified, but not
1247    volatile-qualified.  Other qualifiers are ignored.  This macro is
1248    used to test whether or not it is OK to bind an rvalue to a
1249    reference.  */
1250 #define CP_TYPE_CONST_NON_VOLATILE_P(NODE)                              \
1251   ((cp_type_quals (NODE) & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE))      \
1252    == TYPE_QUAL_CONST)
1253
1254 #define FUNCTION_ARG_CHAIN(NODE) \
1255   TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (NODE)))
1256
1257 /* Given a FUNCTION_DECL, returns the first TREE_LIST out of TYPE_ARG_TYPES
1258    which refers to a user-written parameter.  */
1259 #define FUNCTION_FIRST_USER_PARMTYPE(NODE) \
1260   skip_artificial_parms_for ((NODE), TYPE_ARG_TYPES (TREE_TYPE (NODE)))
1261
1262 /* Similarly, but for DECL_ARGUMENTS.  */
1263 #define FUNCTION_FIRST_USER_PARM(NODE) \
1264   skip_artificial_parms_for ((NODE), DECL_ARGUMENTS (NODE))
1265
1266 /* Nonzero iff TYPE is derived from PARENT. Ignores accessibility and
1267    ambiguity issues.  */
1268 #define DERIVED_FROM_P(PARENT, TYPE) \
1269   (lookup_base ((TYPE), (PARENT), ba_any, NULL) != NULL_TREE)
1270 /* Nonzero iff TYPE is uniquely derived from PARENT. Ignores
1271    accessibility.  */
1272 #define UNIQUELY_DERIVED_FROM_P(PARENT, TYPE) \
1273   (lookup_base ((TYPE), (PARENT), ba_unique | ba_quiet, NULL) != NULL_TREE)
1274 /* Nonzero iff TYPE is publicly & uniquely derived from PARENT.  */
1275 #define PUBLICLY_UNIQUELY_DERIVED_P(PARENT, TYPE) \
1276   (lookup_base ((TYPE), (PARENT), ba_ignore_scope | ba_check | ba_quiet, \
1277                 NULL) != NULL_TREE)
1278
1279 /* Gives the visibility specification for a class type.  */
1280 #define CLASSTYPE_VISIBILITY(TYPE)              \
1281         DECL_VISIBILITY (TYPE_MAIN_DECL (TYPE))
1282 #define CLASSTYPE_VISIBILITY_SPECIFIED(TYPE)    \
1283         DECL_VISIBILITY_SPECIFIED (TYPE_MAIN_DECL (TYPE))
1284
1285 typedef struct GTY (()) tree_pair_s {
1286   tree purpose;
1287   tree value;
1288 } tree_pair_s;
1289 typedef tree_pair_s *tree_pair_p;
1290 DEF_VEC_O (tree_pair_s);
1291 DEF_VEC_ALLOC_O (tree_pair_s,gc);
1292
1293 /* This is a few header flags for 'struct lang_type'.  Actually,
1294    all but the first are used only for lang_type_class; they
1295    are put in this structure to save space.  */
1296 struct GTY(()) lang_type_header {
1297   BOOL_BITFIELD is_lang_type_class : 1;
1298
1299   BOOL_BITFIELD has_type_conversion : 1;
1300   BOOL_BITFIELD has_copy_ctor : 1;
1301   BOOL_BITFIELD has_default_ctor : 1;
1302   BOOL_BITFIELD const_needs_init : 1;
1303   BOOL_BITFIELD ref_needs_init : 1;
1304   BOOL_BITFIELD has_const_copy_assign : 1;
1305
1306   BOOL_BITFIELD spare : 1;
1307 };
1308
1309 /* This structure provides additional information above and beyond
1310    what is provide in the ordinary tree_type.  In the past, we used it
1311    for the types of class types, template parameters types, typename
1312    types, and so forth.  However, there can be many (tens to hundreds
1313    of thousands) of template parameter types in a compilation, and
1314    there's no need for this additional information in that case.
1315    Therefore, we now use this data structure only for class types.
1316
1317    In the past, it was thought that there would be relatively few
1318    class types.  However, in the presence of heavy use of templates,
1319    many (i.e., thousands) of classes can easily be generated.
1320    Therefore, we should endeavor to keep the size of this structure to
1321    a minimum.  */
1322 struct GTY(()) lang_type_class {
1323   struct lang_type_header h;
1324
1325   unsigned char align;
1326
1327   unsigned has_mutable : 1;
1328   unsigned com_interface : 1;
1329   unsigned non_pod_class : 1;
1330   unsigned nearly_empty_p : 1;
1331   unsigned user_align : 1;
1332   unsigned has_copy_assign : 1;
1333   unsigned has_new : 1;
1334   unsigned has_array_new : 1;
1335
1336   unsigned gets_delete : 2;
1337   unsigned interface_only : 1;
1338   unsigned interface_unknown : 1;
1339   unsigned contains_empty_class_p : 1;
1340   unsigned anon_aggr : 1;
1341   unsigned non_zero_init : 1;
1342   unsigned empty_p : 1;
1343
1344   unsigned vec_new_uses_cookie : 1;
1345   unsigned declared_class : 1;
1346   unsigned diamond_shaped : 1;
1347   unsigned repeated_base : 1;
1348   unsigned being_defined : 1;
1349   unsigned java_interface : 1;
1350   unsigned debug_requested : 1;
1351   unsigned fields_readonly : 1;
1352
1353   unsigned use_template : 2;
1354   unsigned ptrmemfunc_flag : 1;
1355   unsigned was_anonymous : 1;
1356   unsigned lazy_default_ctor : 1;
1357   unsigned lazy_copy_ctor : 1;
1358   unsigned lazy_copy_assign : 1;
1359   unsigned lazy_destructor : 1;
1360
1361   unsigned has_const_copy_ctor : 1;
1362   unsigned has_complex_copy_ctor : 1;
1363   unsigned has_complex_copy_assign : 1;
1364   unsigned non_aggregate : 1;
1365   unsigned has_complex_dflt : 1;
1366   unsigned has_list_ctor : 1;
1367   unsigned non_std_layout : 1;
1368   unsigned is_literal : 1;
1369
1370   unsigned lazy_move_ctor : 1;
1371   unsigned lazy_move_assign : 1;
1372   unsigned has_complex_move_ctor : 1;
1373   unsigned has_complex_move_assign : 1;
1374   unsigned has_constexpr_ctor : 1;
1375   unsigned is_final : 1;
1376
1377   /* When adding a flag here, consider whether or not it ought to
1378      apply to a template instance if it applies to the template.  If
1379      so, make sure to copy it in instantiate_class_template!  */
1380
1381   /* There are some bits left to fill out a 32-bit word.  Keep track
1382      of this by updating the size of this bitfield whenever you add or
1383      remove a flag.  */
1384   unsigned dummy : 2;
1385
1386   tree primary_base;
1387   VEC(tree_pair_s,gc) *vcall_indices;
1388   tree vtables;
1389   tree typeinfo_var;
1390   VEC(tree,gc) *vbases;
1391   binding_table nested_udts;
1392   tree as_base;
1393   VEC(tree,gc) *pure_virtuals;
1394   tree friend_classes;
1395   VEC(tree,gc) * GTY((reorder ("resort_type_method_vec"))) methods;
1396   tree key_method;
1397   tree decl_list;
1398   tree template_info;
1399   tree befriending_classes;
1400   /* In a RECORD_TYPE, information specific to Objective-C++, such
1401      as a list of adopted protocols or a pointer to a corresponding
1402      @interface.  See objc/objc-act.h for details.  */
1403   tree objc_info;
1404   /* sorted_fields is sorted based on a pointer, so we need to be able
1405      to resort it if pointers get rearranged.  */
1406   struct sorted_fields_type * GTY ((reorder ("resort_sorted_fields")))
1407     sorted_fields;
1408   /* FIXME reuse another field?  */
1409   tree lambda_expr;
1410 };
1411
1412 struct GTY(()) lang_type_ptrmem {
1413   struct lang_type_header h;
1414   tree record;
1415 };
1416
1417 struct GTY((variable_size)) lang_type {
1418   union lang_type_u
1419   {
1420     struct lang_type_header GTY((skip (""))) h;
1421     struct lang_type_class  GTY((tag ("1"))) c;
1422     struct lang_type_ptrmem GTY((tag ("0"))) ptrmem;
1423   } GTY((desc ("%h.h.is_lang_type_class"))) u;
1424 };
1425
1426 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
1427
1428 #define LANG_TYPE_CLASS_CHECK(NODE) __extension__               \
1429 ({  struct lang_type *lt = TYPE_LANG_SPECIFIC (NODE);           \
1430     if (! lt->u.h.is_lang_type_class)                           \
1431       lang_check_failed (__FILE__, __LINE__, __FUNCTION__);     \
1432     &lt->u.c; })
1433
1434 #define LANG_TYPE_PTRMEM_CHECK(NODE) __extension__              \
1435 ({  struct lang_type *lt = TYPE_LANG_SPECIFIC (NODE);           \
1436     if (lt->u.h.is_lang_type_class)                             \
1437       lang_check_failed (__FILE__, __LINE__, __FUNCTION__);     \
1438     &lt->u.ptrmem; })
1439
1440 #else
1441
1442 #define LANG_TYPE_CLASS_CHECK(NODE) (&TYPE_LANG_SPECIFIC (NODE)->u.c)
1443 #define LANG_TYPE_PTRMEM_CHECK(NODE) (&TYPE_LANG_SPECIFIC (NODE)->u.ptrmem)
1444
1445 #endif /* ENABLE_TREE_CHECKING */
1446
1447 /* Nonzero for _CLASSTYPE means that operator delete is defined.  */
1448 #define TYPE_GETS_DELETE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->gets_delete)
1449 #define TYPE_GETS_REG_DELETE(NODE) (TYPE_GETS_DELETE (NODE) & 1)
1450
1451 /* Nonzero if `new NODE[x]' should cause the allocation of extra
1452    storage to indicate how many array elements are in use.  */
1453 #define TYPE_VEC_NEW_USES_COOKIE(NODE)                  \
1454   (CLASS_TYPE_P (NODE)                                  \
1455    && LANG_TYPE_CLASS_CHECK (NODE)->vec_new_uses_cookie)
1456
1457 /* Nonzero means that this _CLASSTYPE node defines ways of converting
1458    itself to other types.  */
1459 #define TYPE_HAS_CONVERSION(NODE) \
1460   (LANG_TYPE_CLASS_CHECK (NODE)->h.has_type_conversion)
1461
1462 /* Nonzero means that NODE (a class type) has a default constructor --
1463    but that it has not yet been declared.  */
1464 #define CLASSTYPE_LAZY_DEFAULT_CTOR(NODE) \
1465   (LANG_TYPE_CLASS_CHECK (NODE)->lazy_default_ctor)
1466
1467 /* Nonzero means that NODE (a class type) has a copy constructor --
1468    but that it has not yet been declared.  */
1469 #define CLASSTYPE_LAZY_COPY_CTOR(NODE) \
1470   (LANG_TYPE_CLASS_CHECK (NODE)->lazy_copy_ctor)
1471
1472 /* Nonzero means that NODE (a class type) has a move constructor --
1473    but that it has not yet been declared.  */
1474 #define CLASSTYPE_LAZY_MOVE_CTOR(NODE) \
1475   (LANG_TYPE_CLASS_CHECK (NODE)->lazy_move_ctor)
1476
1477 /* Nonzero means that NODE (a class type) has an assignment operator
1478    -- but that it has not yet been declared.  */
1479 #define CLASSTYPE_LAZY_COPY_ASSIGN(NODE) \
1480   (LANG_TYPE_CLASS_CHECK (NODE)->lazy_copy_assign)
1481
1482 /* Nonzero means that NODE (a class type) has an assignment operator
1483    -- but that it has not yet been declared.  */
1484 #define CLASSTYPE_LAZY_MOVE_ASSIGN(NODE) \
1485   (LANG_TYPE_CLASS_CHECK (NODE)->lazy_move_assign)
1486
1487 /* Nonzero means that NODE (a class type) has a destructor -- but that
1488    it has not yet been declared.  */
1489 #define CLASSTYPE_LAZY_DESTRUCTOR(NODE) \
1490   (LANG_TYPE_CLASS_CHECK (NODE)->lazy_destructor)
1491
1492 /* Nonzero means that NODE (a class type) is final */
1493 #define CLASSTYPE_FINAL(NODE) \
1494   (LANG_TYPE_CLASS_CHECK (NODE)->is_final)
1495
1496
1497 /* Nonzero means that this _CLASSTYPE node overloads operator=(X&).  */
1498 #define TYPE_HAS_COPY_ASSIGN(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_copy_assign)
1499
1500 /* True iff the class type NODE has an "operator =" whose parameter
1501    has a parameter of type "const X&".  */
1502 #define TYPE_HAS_CONST_COPY_ASSIGN(NODE) \
1503   (LANG_TYPE_CLASS_CHECK (NODE)->h.has_const_copy_assign)
1504
1505 /* Nonzero means that this _CLASSTYPE node has an X(X&) constructor.  */
1506 #define TYPE_HAS_COPY_CTOR(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->h.has_copy_ctor)
1507 #define TYPE_HAS_CONST_COPY_CTOR(NODE) \
1508   (LANG_TYPE_CLASS_CHECK (NODE)->has_const_copy_ctor)
1509
1510 /* Nonzero if this class has an X(initializer_list<T>) constructor.  */
1511 #define TYPE_HAS_LIST_CTOR(NODE) \
1512   (LANG_TYPE_CLASS_CHECK (NODE)->has_list_ctor)
1513
1514 /* Nonzero if this class has a constexpr constructor other than a copy/move
1515    constructor.  Note that a class can have constexpr constructors for
1516    static initialization even if it isn't a literal class.  */
1517 #define TYPE_HAS_CONSTEXPR_CTOR(NODE) \
1518   (LANG_TYPE_CLASS_CHECK (NODE)->has_constexpr_ctor)
1519
1520 /* Nonzero if this class defines an overloaded operator new.  (An
1521    operator new [] doesn't count.)  */
1522 #define TYPE_HAS_NEW_OPERATOR(NODE) \
1523   (LANG_TYPE_CLASS_CHECK (NODE)->has_new)
1524
1525 /* Nonzero if this class defines an overloaded operator new[].  */
1526 #define TYPE_HAS_ARRAY_NEW_OPERATOR(NODE) \
1527   (LANG_TYPE_CLASS_CHECK (NODE)->has_array_new)
1528
1529 /* Nonzero means that this type is being defined.  I.e., the left brace
1530    starting the definition of this type has been seen.  */
1531 #define TYPE_BEING_DEFINED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->being_defined)
1532
1533 /* Nonzero means that this type is either complete or being defined, so we
1534    can do lookup in it.  */
1535 #define COMPLETE_OR_OPEN_TYPE_P(NODE) \
1536   (COMPLETE_TYPE_P (NODE) || (CLASS_TYPE_P (NODE) && TYPE_BEING_DEFINED (NODE)))
1537
1538 /* Mark bits for repeated base checks.  */
1539 #define TYPE_MARKED_P(NODE) TREE_LANG_FLAG_6 (TYPE_CHECK (NODE))
1540
1541 /* Nonzero if the class NODE has multiple paths to the same (virtual)
1542    base object.  */
1543 #define CLASSTYPE_DIAMOND_SHAPED_P(NODE) \
1544   (LANG_TYPE_CLASS_CHECK(NODE)->diamond_shaped)
1545
1546 /* Nonzero if the class NODE has multiple instances of the same base
1547    type.  */
1548 #define CLASSTYPE_REPEATED_BASE_P(NODE) \
1549   (LANG_TYPE_CLASS_CHECK(NODE)->repeated_base)
1550
1551 /* The member function with which the vtable will be emitted:
1552    the first noninline non-pure-virtual member function.  NULL_TREE
1553    if there is no key function or if this is a class template */
1554 #define CLASSTYPE_KEY_METHOD(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->key_method)
1555
1556 /* Vector member functions defined in this class.  Each element is
1557    either a FUNCTION_DECL, a TEMPLATE_DECL, or an OVERLOAD.  All
1558    functions with the same name end up in the same slot.  The first
1559    two elements are for constructors, and destructors, respectively.
1560    All template conversion operators to innermost template dependent
1561    types are overloaded on the next slot, if they exist.  Note, the
1562    names for these functions will not all be the same.  The
1563    non-template conversion operators & templated conversions to
1564    non-innermost template types are next, followed by ordinary member
1565    functions.  There may be empty entries at the end of the vector.
1566    The conversion operators are unsorted. The ordinary member
1567    functions are sorted, once the class is complete.  */
1568 #define CLASSTYPE_METHOD_VEC(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->methods)
1569
1570 /* For class templates, this is a TREE_LIST of all member data,
1571    functions, types, and friends in the order of declaration.
1572    The TREE_PURPOSE of each TREE_LIST is NULL_TREE for a friend,
1573    and the RECORD_TYPE for the class template otherwise.  */
1574 #define CLASSTYPE_DECL_LIST(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->decl_list)
1575
1576 /* The slot in the CLASSTYPE_METHOD_VEC where constructors go.  */
1577 #define CLASSTYPE_CONSTRUCTOR_SLOT 0
1578
1579 /* The slot in the CLASSTYPE_METHOD_VEC where destructors go.  */
1580 #define CLASSTYPE_DESTRUCTOR_SLOT 1
1581
1582 /* The first slot in the CLASSTYPE_METHOD_VEC where conversion
1583    operators can appear.  */
1584 #define CLASSTYPE_FIRST_CONVERSION_SLOT 2
1585
1586 /* A FUNCTION_DECL or OVERLOAD for the constructors for NODE.  These
1587    are the constructors that take an in-charge parameter.  */
1588 #define CLASSTYPE_CONSTRUCTORS(NODE) \
1589   (VEC_index (tree, CLASSTYPE_METHOD_VEC (NODE), CLASSTYPE_CONSTRUCTOR_SLOT))
1590
1591 /* A FUNCTION_DECL for the destructor for NODE.  These are the
1592    destructors that take an in-charge parameter.  If
1593    CLASSTYPE_LAZY_DESTRUCTOR is true, then this entry will be NULL
1594    until the destructor is created with lazily_declare_fn.  */
1595 #define CLASSTYPE_DESTRUCTORS(NODE) \
1596   (CLASSTYPE_METHOD_VEC (NODE)                                                \
1597    ? VEC_index (tree, CLASSTYPE_METHOD_VEC (NODE), CLASSTYPE_DESTRUCTOR_SLOT) \
1598    : NULL_TREE)
1599
1600 /* A dictionary of the nested user-defined-types (class-types, or enums)
1601    found within this class.  This table includes nested member class
1602    templates.  */
1603 #define CLASSTYPE_NESTED_UTDS(NODE) \
1604    (LANG_TYPE_CLASS_CHECK (NODE)->nested_udts)
1605
1606 /* Nonzero if NODE has a primary base class, i.e., a base class with
1607    which it shares the virtual function table pointer.  */
1608 #define CLASSTYPE_HAS_PRIMARY_BASE_P(NODE) \
1609   (CLASSTYPE_PRIMARY_BINFO (NODE) != NULL_TREE)
1610
1611 /* If non-NULL, this is the binfo for the primary base class, i.e.,
1612    the base class which contains the virtual function table pointer
1613    for this class.  */
1614 #define CLASSTYPE_PRIMARY_BINFO(NODE) \
1615   (LANG_TYPE_CLASS_CHECK (NODE)->primary_base)
1616
1617 /* A vector of BINFOs for the direct and indirect virtual base classes
1618    that this type uses in a post-order depth-first left-to-right
1619    order.  (In other words, these bases appear in the order that they
1620    should be initialized.)  */
1621 #define CLASSTYPE_VBASECLASSES(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->vbases)
1622
1623 /* The type corresponding to NODE when NODE is used as a base class,
1624    i.e., NODE without virtual base classes.  */
1625
1626 #define CLASSTYPE_AS_BASE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->as_base)
1627
1628 /* True iff NODE is the CLASSTYPE_AS_BASE version of some type.  */
1629
1630 #define IS_FAKE_BASE_TYPE(NODE)                                 \
1631   (TREE_CODE (NODE) == RECORD_TYPE                              \
1632    && TYPE_CONTEXT (NODE) && CLASS_TYPE_P (TYPE_CONTEXT (NODE)) \
1633    && CLASSTYPE_AS_BASE (TYPE_CONTEXT (NODE)) == (NODE))
1634
1635 /* These are the size and alignment of the type without its virtual
1636    base classes, for when we use this type as a base itself.  */
1637 #define CLASSTYPE_SIZE(NODE) TYPE_SIZE (CLASSTYPE_AS_BASE (NODE))
1638 #define CLASSTYPE_SIZE_UNIT(NODE) TYPE_SIZE_UNIT (CLASSTYPE_AS_BASE (NODE))
1639 #define CLASSTYPE_ALIGN(NODE) TYPE_ALIGN (CLASSTYPE_AS_BASE (NODE))
1640 #define CLASSTYPE_USER_ALIGN(NODE) TYPE_USER_ALIGN (CLASSTYPE_AS_BASE (NODE))
1641
1642 /* The alignment of NODE, without its virtual bases, in bytes.  */
1643 #define CLASSTYPE_ALIGN_UNIT(NODE) \
1644   (CLASSTYPE_ALIGN (NODE) / BITS_PER_UNIT)
1645
1646 /* True if this a Java interface type, declared with
1647    '__attribute__ ((java_interface))'.  */
1648 #define TYPE_JAVA_INTERFACE(NODE) \
1649   (LANG_TYPE_CLASS_CHECK (NODE)->java_interface)
1650
1651 /* A VEC(tree) of virtual functions which cannot be inherited by
1652    derived classes.  When deriving from this type, the derived
1653    class must provide its own definition for each of these functions.  */
1654 #define CLASSTYPE_PURE_VIRTUALS(NODE) \
1655   (LANG_TYPE_CLASS_CHECK (NODE)->pure_virtuals)
1656
1657 /* Nonzero means that this type has an X() constructor.  */
1658 #define TYPE_HAS_DEFAULT_CONSTRUCTOR(NODE) \
1659   (LANG_TYPE_CLASS_CHECK (NODE)->h.has_default_ctor)
1660
1661 /* Nonzero means that this type contains a mutable member.  */
1662 #define CLASSTYPE_HAS_MUTABLE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_mutable)
1663 #define TYPE_HAS_MUTABLE_P(NODE) (cp_has_mutable_p (NODE))
1664
1665 /* Nonzero means that this class type is not POD for the purpose of layout
1666    (as defined in the ABI).  This is different from the language's POD.  */
1667 #define CLASSTYPE_NON_LAYOUT_POD_P(NODE) \
1668   (LANG_TYPE_CLASS_CHECK (NODE)->non_pod_class)
1669
1670 /* Nonzero means that this class type is a non-standard-layout class.  */
1671 #define CLASSTYPE_NON_STD_LAYOUT(NODE) \
1672   (LANG_TYPE_CLASS_CHECK (NODE)->non_std_layout)
1673
1674 /* Nonzero means that this class contains pod types whose default
1675    initialization is not a zero initialization (namely, pointers to
1676    data members).  */
1677 #define CLASSTYPE_NON_ZERO_INIT_P(NODE) \
1678   (LANG_TYPE_CLASS_CHECK (NODE)->non_zero_init)
1679
1680 /* Nonzero if this class is "empty" in the sense of the C++ ABI.  */
1681 #define CLASSTYPE_EMPTY_P(NODE) \
1682   (LANG_TYPE_CLASS_CHECK (NODE)->empty_p)
1683
1684 /* Nonzero if this class is "nearly empty", i.e., contains only a
1685    virtual function table pointer.  */
1686 #define CLASSTYPE_NEARLY_EMPTY_P(NODE) \
1687   (LANG_TYPE_CLASS_CHECK (NODE)->nearly_empty_p)
1688
1689 /* Nonzero if this class contains an empty subobject.  */
1690 #define CLASSTYPE_CONTAINS_EMPTY_CLASS_P(NODE) \
1691   (LANG_TYPE_CLASS_CHECK (NODE)->contains_empty_class_p)
1692
1693 /* A list of class types of which this type is a friend.  The
1694    TREE_VALUE is normally a TYPE, but will be a TEMPLATE_DECL in the
1695    case of a template friend.  */
1696 #define CLASSTYPE_FRIEND_CLASSES(NODE) \
1697   (LANG_TYPE_CLASS_CHECK (NODE)->friend_classes)
1698
1699 /* A list of the classes which grant friendship to this class.  */
1700 #define CLASSTYPE_BEFRIENDING_CLASSES(NODE) \
1701   (LANG_TYPE_CLASS_CHECK (NODE)->befriending_classes)
1702
1703 /* The associated LAMBDA_EXPR that made this class.  */
1704 #define CLASSTYPE_LAMBDA_EXPR(NODE) \
1705   (LANG_TYPE_CLASS_CHECK (NODE)->lambda_expr)
1706 /* The extra mangling scope for this closure type.  */
1707 #define LAMBDA_TYPE_EXTRA_SCOPE(NODE) \
1708   (LAMBDA_EXPR_EXTRA_SCOPE (CLASSTYPE_LAMBDA_EXPR (NODE)))
1709
1710 /* Say whether this node was declared as a "class" or a "struct".  */
1711 #define CLASSTYPE_DECLARED_CLASS(NODE) \
1712   (LANG_TYPE_CLASS_CHECK (NODE)->declared_class)
1713
1714 /* Nonzero if this class has const members
1715    which have no specified initialization.  */
1716 #define CLASSTYPE_READONLY_FIELDS_NEED_INIT(NODE)       \
1717   (TYPE_LANG_SPECIFIC (NODE)                            \
1718    ? LANG_TYPE_CLASS_CHECK (NODE)->h.const_needs_init : 0)
1719 #define SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT(NODE, VALUE) \
1720   (LANG_TYPE_CLASS_CHECK (NODE)->h.const_needs_init = (VALUE))
1721
1722 /* Nonzero if this class has ref members
1723    which have no specified initialization.  */
1724 #define CLASSTYPE_REF_FIELDS_NEED_INIT(NODE)            \
1725   (TYPE_LANG_SPECIFIC (NODE)                            \
1726    ? LANG_TYPE_CLASS_CHECK (NODE)->h.ref_needs_init : 0)
1727 #define SET_CLASSTYPE_REF_FIELDS_NEED_INIT(NODE, VALUE) \
1728   (LANG_TYPE_CLASS_CHECK (NODE)->h.ref_needs_init = (VALUE))
1729
1730 /* Nonzero if this class is included from a header file which employs
1731    `#pragma interface', and it is not included in its implementation file.  */
1732 #define CLASSTYPE_INTERFACE_ONLY(NODE) \
1733   (LANG_TYPE_CLASS_CHECK (NODE)->interface_only)
1734
1735 /* True if we have already determined whether or not vtables, VTTs,
1736    typeinfo, and other similar per-class data should be emitted in
1737    this translation unit.  This flag does not indicate whether or not
1738    these items should be emitted; it only indicates that we know one
1739    way or the other.  */
1740 #define CLASSTYPE_INTERFACE_KNOWN(NODE) \
1741   (LANG_TYPE_CLASS_CHECK (NODE)->interface_unknown == 0)
1742 /* The opposite of CLASSTYPE_INTERFACE_KNOWN.  */
1743 #define CLASSTYPE_INTERFACE_UNKNOWN(NODE) \
1744   (LANG_TYPE_CLASS_CHECK (NODE)->interface_unknown)
1745
1746 #define SET_CLASSTYPE_INTERFACE_UNKNOWN_X(NODE,X) \
1747   (LANG_TYPE_CLASS_CHECK (NODE)->interface_unknown = !!(X))
1748 #define SET_CLASSTYPE_INTERFACE_UNKNOWN(NODE) \
1749   (LANG_TYPE_CLASS_CHECK (NODE)->interface_unknown = 1)
1750 #define SET_CLASSTYPE_INTERFACE_KNOWN(NODE) \
1751   (LANG_TYPE_CLASS_CHECK (NODE)->interface_unknown = 0)
1752
1753 /* Nonzero if a _DECL node requires us to output debug info for this class.  */
1754 #define CLASSTYPE_DEBUG_REQUESTED(NODE) \
1755   (LANG_TYPE_CLASS_CHECK (NODE)->debug_requested)
1756 \f
1757 /* Additional macros for inheritance information.  */
1758
1759 /* Nonzero means that this class is on a path leading to a new vtable.  */
1760 #define BINFO_VTABLE_PATH_MARKED(NODE) BINFO_FLAG_1 (NODE)
1761
1762 /* Nonzero means B (a BINFO) has its own vtable.  Any copies will not
1763    have this flag set.  */
1764 #define BINFO_NEW_VTABLE_MARKED(B) (BINFO_FLAG_2 (B))
1765
1766 /* Compare a BINFO_TYPE with another type for equality.  For a binfo,
1767    this is functionally equivalent to using same_type_p, but
1768    measurably faster.  At least one of the arguments must be a
1769    BINFO_TYPE.  The other can be a BINFO_TYPE or a regular type.  If
1770    BINFO_TYPE(T) ever stops being the main variant of the class the
1771    binfo is for, this macro must change.  */
1772 #define SAME_BINFO_TYPE_P(A, B) ((A) == (B))
1773
1774 /* Any subobject that needs a new vtable must have a vptr and must not
1775    be a non-virtual primary base (since it would then use the vtable from a
1776    derived class and never become non-primary.)  */
1777 #define SET_BINFO_NEW_VTABLE_MARKED(B)                                   \
1778   (BINFO_NEW_VTABLE_MARKED (B) = 1,                                      \
1779    gcc_assert (!BINFO_PRIMARY_P (B) || BINFO_VIRTUAL_P (B)),             \
1780    gcc_assert (TYPE_VFIELD (BINFO_TYPE (B))))
1781
1782 /* Nonzero if this binfo is for a dependent base - one that should not
1783    be searched.  */
1784 #define BINFO_DEPENDENT_BASE_P(NODE) BINFO_FLAG_3 (NODE)
1785
1786 /* Nonzero if this binfo has lost its primary base binfo (because that
1787    is a nearly-empty virtual base that has been taken by some other
1788    base in the complete hierarchy.  */
1789 #define BINFO_LOST_PRIMARY_P(NODE) BINFO_FLAG_4 (NODE)
1790
1791 /* Nonzero if this BINFO is a primary base class.  */
1792 #define BINFO_PRIMARY_P(NODE) BINFO_FLAG_5(NODE)
1793
1794 /* Used by various search routines.  */
1795 #define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_0 (NODE)
1796 \f
1797 /* A VEC(tree_pair_s) of the vcall indices associated with the class
1798    NODE.  The PURPOSE of each element is a FUNCTION_DECL for a virtual
1799    function.  The VALUE is the index into the virtual table where the
1800    vcall offset for that function is stored, when NODE is a virtual
1801    base.  */
1802 #define CLASSTYPE_VCALL_INDICES(NODE) \
1803   (LANG_TYPE_CLASS_CHECK (NODE)->vcall_indices)
1804
1805 /* The various vtables for the class NODE.  The primary vtable will be
1806    first, followed by the construction vtables and VTT, if any.  */
1807 #define CLASSTYPE_VTABLES(NODE) \
1808   (LANG_TYPE_CLASS_CHECK (NODE)->vtables)
1809
1810 /* The std::type_info variable representing this class, or NULL if no
1811    such variable has been created.  This field is only set for the
1812    TYPE_MAIN_VARIANT of the class.  */
1813 #define CLASSTYPE_TYPEINFO_VAR(NODE) \
1814   (LANG_TYPE_CLASS_CHECK (NODE)->typeinfo_var)
1815
1816 /* Accessor macros for the BINFO_VIRTUALS list.  */
1817
1818 /* The number of bytes by which to adjust the `this' pointer when
1819    calling this virtual function.  Subtract this value from the this
1820    pointer. Always non-NULL, might be constant zero though.  */
1821 #define BV_DELTA(NODE) (TREE_PURPOSE (NODE))
1822
1823 /* If non-NULL, the vtable index at which to find the vcall offset
1824    when calling this virtual function.  Add the value at that vtable
1825    index to the this pointer.  */
1826 #define BV_VCALL_INDEX(NODE) (TREE_TYPE (NODE))
1827
1828 /* The function to call.  */
1829 #define BV_FN(NODE) (TREE_VALUE (NODE))
1830
1831 /* Whether or not this entry is for a lost primary virtual base.  */
1832 #define BV_LOST_PRIMARY(NODE) (TREE_LANG_FLAG_0 (NODE))
1833 \f
1834 /* For FUNCTION_TYPE or METHOD_TYPE, a list of the exceptions that
1835    this type can raise.  Each TREE_VALUE is a _TYPE.  The TREE_VALUE
1836    will be NULL_TREE to indicate a throw specification of `()', or
1837    no exceptions allowed.  For a noexcept specification, TREE_VALUE
1838    is NULL_TREE and TREE_PURPOSE is the constant-expression.  For
1839    a deferred noexcept-specification, TREE_PURPOSE is a DEFERRED_NOEXCEPT
1840    (for templates) or an OVERLOAD list of functions (for implicitly
1841    declared functions).  */
1842 #define TYPE_RAISES_EXCEPTIONS(NODE) TYPE_LANG_SLOT_1 (NODE)
1843
1844 /* For FUNCTION_TYPE or METHOD_TYPE, return 1 iff it is declared `throw()'
1845    or noexcept(true).  */
1846 #define TYPE_NOTHROW_P(NODE) nothrow_spec_p (TYPE_RAISES_EXCEPTIONS (NODE))
1847
1848 /* For FUNCTION_TYPE or METHOD_TYPE, true if NODE is noexcept.  This is the
1849    case for things declared noexcept(true) and, with -fnothrow-opt, for
1850    throw() functions.  */
1851 #define TYPE_NOEXCEPT_P(NODE) type_noexcept_p (NODE)
1852
1853 /* The binding level associated with the namespace.  */
1854 #define NAMESPACE_LEVEL(NODE) \
1855   (LANG_DECL_NS_CHECK (NODE)->level)
1856 \f
1857 /* Flags shared by all forms of DECL_LANG_SPECIFIC.
1858
1859    Some of the flags live here only to make lang_decl_min/fn smaller.  Do
1860    not make this struct larger than 32 bits; instead, make sel smaller.  */
1861
1862 struct GTY(()) lang_decl_base {
1863   unsigned selector : 16;   /* Larger than necessary for faster access.  */
1864   ENUM_BITFIELD(languages) language : 4;
1865   unsigned use_template : 2;
1866   unsigned not_really_extern : 1;          /* var or fn */
1867   unsigned initialized_in_class : 1;       /* var or fn */
1868   unsigned repo_available_p : 1;           /* var or fn */
1869   unsigned threadprivate_or_deleted_p : 1; /* var or fn */
1870   unsigned anticipated_p : 1;              /* fn or type */
1871   unsigned friend_attr : 1;                /* fn or type */
1872   unsigned template_conv_p : 1;            /* var or template */
1873   unsigned odr_used : 1;                   /* var or fn */
1874   unsigned u2sel : 1;
1875   /* 1 spare bit */
1876 };
1877
1878 /* True for DECL codes which have template info and access.  */
1879 #define LANG_DECL_HAS_MIN(NODE)                 \
1880   (TREE_CODE (NODE) == FUNCTION_DECL            \
1881    || TREE_CODE (NODE) == FIELD_DECL            \
1882    || TREE_CODE (NODE) == VAR_DECL              \
1883    || TREE_CODE (NODE) == CONST_DECL            \
1884    || TREE_CODE (NODE) == TYPE_DECL             \
1885    || TREE_CODE (NODE) == TEMPLATE_DECL         \
1886    || TREE_CODE (NODE) == USING_DECL)
1887
1888 /* DECL_LANG_SPECIFIC for the above codes.  */
1889
1890 struct GTY(()) lang_decl_min {
1891   struct lang_decl_base base;
1892
1893   /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
1894      THUNK_ALIAS.
1895      In a FUNCTION_DECL for which DECL_THUNK_P does not hold,
1896      VAR_DECL, TYPE_DECL, or TEMPLATE_DECL, this is
1897      DECL_TEMPLATE_INFO.  */
1898   tree template_info;
1899
1900   union lang_decl_u2 {
1901     /* In a FUNCTION_DECL for which DECL_THUNK_P holds, this is
1902        THUNK_VIRTUAL_OFFSET.
1903        Otherwise this is DECL_ACCESS.  */
1904     tree GTY ((tag ("0"))) access;
1905
1906     /* For VAR_DECL in function, this is DECL_DISCRIMINATOR.  */
1907     int GTY ((tag ("1"))) discriminator;
1908   } GTY ((desc ("%0.u.base.u2sel"))) u2;
1909 };
1910
1911 /* Additional DECL_LANG_SPECIFIC information for functions.  */
1912
1913 struct GTY(()) lang_decl_fn {
1914   struct lang_decl_min min;
1915
1916   /* In an overloaded operator, this is the value of
1917      DECL_OVERLOADED_OPERATOR_P.  */
1918   ENUM_BITFIELD (tree_code) operator_code : 16;
1919
1920   unsigned global_ctor_p : 1;
1921   unsigned global_dtor_p : 1;
1922   unsigned constructor_attr : 1;
1923   unsigned destructor_attr : 1;
1924   unsigned assignment_operator_p : 1;
1925   unsigned static_function : 1;
1926   unsigned pure_virtual : 1;
1927   unsigned defaulted_p : 1;
1928
1929   unsigned has_in_charge_parm_p : 1;
1930   unsigned has_vtt_parm_p : 1;
1931   unsigned pending_inline_p : 1;
1932   unsigned nonconverting : 1;
1933   unsigned thunk_p : 1;
1934   unsigned this_thunk_p : 1;
1935   unsigned hidden_friend_p : 1;
1936   /* 1 spare bit.  */
1937
1938   /* For a non-thunk function decl, this is a tree list of
1939      friendly classes. For a thunk function decl, it is the
1940      thunked to function decl.  */
1941   tree befriending_classes;
1942
1943   /* For a non-virtual FUNCTION_DECL, this is
1944      DECL_FRIEND_CONTEXT.  For a virtual FUNCTION_DECL for which
1945      DECL_THIS_THUNK_P does not hold, this is DECL_THUNKS. Both
1946      this pointer and result pointer adjusting thunks are
1947      chained here.  This pointer thunks to return pointer thunks
1948      will be chained on the return pointer thunk.  */
1949   tree context;
1950
1951   union lang_decl_u5
1952   {
1953     /* In a non-thunk FUNCTION_DECL or TEMPLATE_DECL, this is
1954        DECL_CLONED_FUNCTION.  */
1955     tree GTY ((tag ("0"))) cloned_function;
1956
1957     /* In a FUNCTION_DECL for which THUNK_P holds this is the
1958        THUNK_FIXED_OFFSET.  */
1959     HOST_WIDE_INT GTY ((tag ("1"))) fixed_offset;
1960   } GTY ((desc ("%1.thunk_p"))) u5;
1961
1962   union lang_decl_u3
1963   {
1964     struct cp_token_cache * GTY ((tag ("1"))) pending_inline_info;
1965     struct language_function * GTY ((tag ("0")))
1966       saved_language_function;
1967   } GTY ((desc ("%1.pending_inline_p"))) u;
1968
1969 };
1970
1971 /* DECL_LANG_SPECIFIC for namespaces.  */
1972
1973 struct GTY(()) lang_decl_ns {
1974   struct lang_decl_base base;
1975   cp_binding_level *level;
1976 };
1977
1978 /* DECL_LANG_SPECIFIC for parameters.  */
1979
1980 struct GTY(()) lang_decl_parm {
1981   struct lang_decl_base base;
1982   int level;
1983   int index;
1984 };
1985
1986 /* DECL_LANG_SPECIFIC for all types.  It would be nice to just make this a
1987    union rather than a struct containing a union as its only field, but
1988    tree.h declares it as a struct.  */
1989
1990 struct GTY((variable_size)) lang_decl {
1991   union GTY((desc ("%h.base.selector"))) lang_decl_u {
1992     struct lang_decl_base GTY ((default)) base;
1993     struct lang_decl_min GTY((tag ("0"))) min;
1994     struct lang_decl_fn GTY ((tag ("1"))) fn;
1995     struct lang_decl_ns GTY((tag ("2"))) ns;
1996     struct lang_decl_parm GTY((tag ("3"))) parm;
1997   } u;
1998 };
1999
2000 /* Looks through a template (if present) to find what it declares.  */
2001 #define STRIP_TEMPLATE(NODE) \
2002   (TREE_CODE (NODE) == TEMPLATE_DECL ? DECL_TEMPLATE_RESULT (NODE) : NODE)
2003
2004 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
2005
2006 #define LANG_DECL_MIN_CHECK(NODE) __extension__                 \
2007 ({ struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE);            \
2008    if (!LANG_DECL_HAS_MIN (NODE))                               \
2009      lang_check_failed (__FILE__, __LINE__, __FUNCTION__);      \
2010    &lt->u.min; })
2011
2012 /* We want to be able to check DECL_CONSTRUCTOR_P and such on a function
2013    template, not just on a FUNCTION_DECL.  So when looking for things in
2014    lang_decl_fn, look down through a TEMPLATE_DECL into its result.  */
2015 #define LANG_DECL_FN_CHECK(NODE) __extension__                          \
2016 ({ struct lang_decl *lt = DECL_LANG_SPECIFIC (STRIP_TEMPLATE (NODE));   \
2017    if (!DECL_DECLARES_FUNCTION_P (NODE) || lt->u.base.selector != 1)    \
2018      lang_check_failed (__FILE__, __LINE__, __FUNCTION__);              \
2019    &lt->u.fn; })
2020
2021 #define LANG_DECL_NS_CHECK(NODE) __extension__                          \
2022 ({ struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE);                    \
2023    if (TREE_CODE (NODE) != NAMESPACE_DECL || lt->u.base.selector != 2)  \
2024      lang_check_failed (__FILE__, __LINE__, __FUNCTION__);              \
2025    &lt->u.ns; })
2026
2027 #define LANG_DECL_PARM_CHECK(NODE) __extension__                \
2028 ({ struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE);            \
2029   if (TREE_CODE (NODE) != PARM_DECL)                            \
2030     lang_check_failed (__FILE__, __LINE__, __FUNCTION__);       \
2031   &lt->u.parm; })
2032
2033 #define LANG_DECL_U2_CHECK(NODE, TF) __extension__              \
2034 ({  struct lang_decl *lt = DECL_LANG_SPECIFIC (NODE);           \
2035     if (!LANG_DECL_HAS_MIN (NODE) || lt->u.base.u2sel != TF)    \
2036       lang_check_failed (__FILE__, __LINE__, __FUNCTION__);     \
2037     &lt->u.min.u2; })
2038
2039 #else
2040
2041 #define LANG_DECL_MIN_CHECK(NODE) \
2042   (&DECL_LANG_SPECIFIC (NODE)->u.min)
2043
2044 #define LANG_DECL_FN_CHECK(NODE) \
2045   (&DECL_LANG_SPECIFIC (STRIP_TEMPLATE (NODE))->u.fn)
2046
2047 #define LANG_DECL_NS_CHECK(NODE) \
2048   (&DECL_LANG_SPECIFIC (NODE)->u.ns)
2049
2050 #define LANG_DECL_PARM_CHECK(NODE) \
2051   (&DECL_LANG_SPECIFIC (NODE)->u.parm)
2052
2053 #define LANG_DECL_U2_CHECK(NODE, TF) \
2054   (&DECL_LANG_SPECIFIC (NODE)->u.min.u2)
2055
2056 #endif /* ENABLE_TREE_CHECKING */
2057
2058 /* For a FUNCTION_DECL or a VAR_DECL, the language linkage for the
2059    declaration.  Some entities (like a member function in a local
2060    class, or a local variable) do not have linkage at all, and this
2061    macro should not be used in those cases.
2062
2063    Implementation note: A FUNCTION_DECL without DECL_LANG_SPECIFIC was
2064    created by language-independent code, and has C linkage.  Most
2065    VAR_DECLs have C++ linkage, and do not have DECL_LANG_SPECIFIC, but
2066    we do create DECL_LANG_SPECIFIC for variables with non-C++ linkage.  */
2067 #define DECL_LANGUAGE(NODE)                             \
2068   (DECL_LANG_SPECIFIC (NODE)                            \
2069    ? DECL_LANG_SPECIFIC (NODE)->u.base.language         \
2070    : (TREE_CODE (NODE) == FUNCTION_DECL                 \
2071       ? lang_c : lang_cplusplus))
2072
2073 /* Set the language linkage for NODE to LANGUAGE.  */
2074 #define SET_DECL_LANGUAGE(NODE, LANGUAGE) \
2075   (DECL_LANG_SPECIFIC (NODE)->u.base.language = (LANGUAGE))
2076
2077 /* For FUNCTION_DECLs: nonzero means that this function is a constructor.  */
2078 #define DECL_CONSTRUCTOR_P(NODE) \
2079   (LANG_DECL_FN_CHECK (NODE)->constructor_attr)
2080
2081 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a complete
2082    object.  */
2083 #define DECL_COMPLETE_CONSTRUCTOR_P(NODE)               \
2084   (DECL_CONSTRUCTOR_P (NODE)                            \
2085    && DECL_NAME (NODE) == complete_ctor_identifier)
2086
2087 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a base
2088    object.  */
2089 #define DECL_BASE_CONSTRUCTOR_P(NODE)           \
2090   (DECL_CONSTRUCTOR_P (NODE)                    \
2091    && DECL_NAME (NODE) == base_ctor_identifier)
2092
2093 /* Nonzero if NODE (a FUNCTION_DECL) is a constructor, but not either the
2094    specialized in-charge constructor or the specialized not-in-charge
2095    constructor.  */
2096 #define DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P(NODE)                \
2097   (DECL_DECLARES_FUNCTION_P (NODE) && DECL_CONSTRUCTOR_P (NODE) \
2098    && !DECL_CLONED_FUNCTION_P (NODE))
2099
2100 /* Nonzero if NODE (a FUNCTION_DECL) is a copy constructor.  */
2101 #define DECL_COPY_CONSTRUCTOR_P(NODE) \
2102   (DECL_CONSTRUCTOR_P (NODE) && copy_fn_p (NODE) > 0)
2103
2104 /* Nonzero if NODE (a FUNCTION_DECL) is a move constructor.  */
2105 #define DECL_MOVE_CONSTRUCTOR_P(NODE) \
2106   (DECL_CONSTRUCTOR_P (NODE) && move_fn_p (NODE))
2107
2108 /* Nonzero if NODE is a destructor.  */
2109 #define DECL_DESTRUCTOR_P(NODE)                         \
2110   (LANG_DECL_FN_CHECK (NODE)->destructor_attr)
2111
2112 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor, but not the
2113    specialized in-charge constructor, in-charge deleting constructor,
2114    or the base destructor.  */
2115 #define DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P(NODE)                 \
2116   (DECL_DECLARES_FUNCTION_P (NODE) && DECL_DESTRUCTOR_P (NODE)  \
2117    && !DECL_CLONED_FUNCTION_P (NODE))
2118
2119 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete
2120    object.  */
2121 #define DECL_COMPLETE_DESTRUCTOR_P(NODE)                \
2122   (DECL_DESTRUCTOR_P (NODE)                             \
2123    && DECL_NAME (NODE) == complete_dtor_identifier)
2124
2125 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a base
2126    object.  */
2127 #define DECL_BASE_DESTRUCTOR_P(NODE)            \
2128   (DECL_DESTRUCTOR_P (NODE)                     \
2129    && DECL_NAME (NODE) == base_dtor_identifier)
2130
2131 /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete
2132    object that deletes the object after it has been destroyed.  */
2133 #define DECL_DELETING_DESTRUCTOR_P(NODE)                \
2134   (DECL_DESTRUCTOR_P (NODE)                             \
2135    && DECL_NAME (NODE) == deleting_dtor_identifier)
2136
2137 /* Nonzero if NODE (a FUNCTION_DECL) is a cloned constructor or
2138    destructor.  */
2139 #define DECL_CLONED_FUNCTION_P(NODE) (!!decl_cloned_function_p (NODE, true))
2140
2141 /* If DECL_CLONED_FUNCTION_P holds, this is the function that was
2142    cloned.  */
2143 #define DECL_CLONED_FUNCTION(NODE) (*decl_cloned_function_p (NODE, false))
2144
2145 /* Perform an action for each clone of FN, if FN is a function with
2146    clones.  This macro should be used like:
2147
2148       FOR_EACH_CLONE (clone, fn)
2149         { ... }
2150
2151   */
2152 #define FOR_EACH_CLONE(CLONE, FN)                       \
2153   if (TREE_CODE (FN) == FUNCTION_DECL                   \
2154       && (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (FN)       \
2155           || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (FN)))   \
2156      for (CLONE = DECL_CHAIN (FN);                      \
2157           CLONE && DECL_CLONED_FUNCTION_P (CLONE);      \
2158           CLONE = DECL_CHAIN (CLONE))
2159
2160 /* Nonzero if NODE has DECL_DISCRIMINATOR and not DECL_ACCESS.  */
2161 #define DECL_DISCRIMINATOR_P(NODE)      \
2162   (TREE_CODE (NODE) == VAR_DECL         \
2163    && DECL_FUNCTION_SCOPE_P (NODE))
2164
2165 /* Discriminator for name mangling.  */
2166 #define DECL_DISCRIMINATOR(NODE) (LANG_DECL_U2_CHECK (NODE, 1)->discriminator)
2167
2168 /* True iff DECL_DISCRIMINATOR is set for a DECL_DISCRIMINATOR_P decl.  */
2169 #define DECL_DISCRIMINATOR_SET_P(NODE) \
2170   (DECL_LANG_SPECIFIC (NODE) && DECL_LANG_SPECIFIC (NODE)->u.base.u2sel == 1)
2171
2172 /* The index of a user-declared parameter in its function, starting at 1.
2173    All artificial parameters will have index 0.  */
2174 #define DECL_PARM_INDEX(NODE) \
2175   (LANG_DECL_PARM_CHECK (NODE)->index)
2176
2177 /* The level of a user-declared parameter in its function, starting at 1.
2178    A parameter of the function will have level 1; a parameter of the first
2179    nested function declarator (i.e. t in void f (void (*p)(T t))) will have
2180    level 2.  */
2181 #define DECL_PARM_LEVEL(NODE) \
2182   (LANG_DECL_PARM_CHECK (NODE)->level)
2183
2184 /* Nonzero if the VTT parm has been added to NODE.  */
2185 #define DECL_HAS_VTT_PARM_P(NODE) \
2186   (LANG_DECL_FN_CHECK (NODE)->has_vtt_parm_p)
2187
2188 /* Nonzero if NODE is a FUNCTION_DECL for which a VTT parameter is
2189    required.  */
2190 #define DECL_NEEDS_VTT_PARM_P(NODE)                     \
2191   (CLASSTYPE_VBASECLASSES (DECL_CONTEXT (NODE))         \
2192    && (DECL_BASE_CONSTRUCTOR_P (NODE)                   \
2193        || DECL_BASE_DESTRUCTOR_P (NODE)))
2194
2195 /* Nonzero if NODE is a user-defined conversion operator.  */
2196 #define DECL_CONV_FN_P(NODE) \
2197   (DECL_NAME (NODE) && IDENTIFIER_TYPENAME_P (DECL_NAME (NODE)))
2198
2199 /* If FN is a conversion operator, the type to which it converts.
2200    Otherwise, NULL_TREE.  */
2201 #define DECL_CONV_FN_TYPE(FN) \
2202   (DECL_CONV_FN_P (FN) ? TREE_TYPE (DECL_NAME (FN)) : NULL_TREE)
2203
2204 /* Nonzero if NODE, which is a TEMPLATE_DECL, is a template
2205    conversion operator to a type dependent on the innermost template
2206    args.  */
2207 #define DECL_TEMPLATE_CONV_FN_P(NODE) \
2208   (DECL_LANG_SPECIFIC (TEMPLATE_DECL_CHECK (NODE))->u.base.template_conv_p)
2209
2210 /* Nonzero if NODE, a static data member, was declared in its class as an
2211    array of unknown bound.  */
2212 #define VAR_HAD_UNKNOWN_BOUND(NODE)                     \
2213   (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE))           \
2214    ? DECL_LANG_SPECIFIC (NODE)->u.base.template_conv_p  \
2215    : false)
2216 #define SET_VAR_HAD_UNKNOWN_BOUND(NODE) \
2217   (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE))->u.base.template_conv_p = true)
2218
2219 /* Set the overloaded operator code for NODE to CODE.  */
2220 #define SET_OVERLOADED_OPERATOR_CODE(NODE, CODE) \
2221   (LANG_DECL_FN_CHECK (NODE)->operator_code = (CODE))
2222
2223 /* If NODE is an overloaded operator, then this returns the TREE_CODE
2224    associated with the overloaded operator.
2225    DECL_ASSIGNMENT_OPERATOR_P must also be checked to determine
2226    whether or not NODE is an assignment operator.  If NODE is not an
2227    overloaded operator, ERROR_MARK is returned.  Since the numerical
2228    value of ERROR_MARK is zero, this macro can be used as a predicate
2229    to test whether or not NODE is an overloaded operator.  */
2230 #define DECL_OVERLOADED_OPERATOR_P(NODE)                \
2231   (IDENTIFIER_OPNAME_P (DECL_NAME (NODE))               \
2232    ? LANG_DECL_FN_CHECK (NODE)->operator_code : ERROR_MARK)
2233
2234 /* Nonzero if NODE is an assignment operator (including += and such).  */
2235 #define DECL_ASSIGNMENT_OPERATOR_P(NODE) \
2236   (LANG_DECL_FN_CHECK (NODE)->assignment_operator_p)
2237
2238 /* For FUNCTION_DECLs: nonzero means that this function is a
2239    constructor or a destructor with an extra in-charge parameter to
2240    control whether or not virtual bases are constructed.  */
2241 #define DECL_HAS_IN_CHARGE_PARM_P(NODE) \
2242   (LANG_DECL_FN_CHECK (NODE)->has_in_charge_parm_p)
2243
2244 /* Nonzero if DECL is a declaration of __builtin_constant_p.  */
2245 #define DECL_IS_BUILTIN_CONSTANT_P(NODE)                \
2246  (TREE_CODE (NODE) == FUNCTION_DECL                     \
2247   && DECL_BUILT_IN_CLASS (NODE) == BUILT_IN_NORMAL      \
2248   && DECL_FUNCTION_CODE (NODE) == BUILT_IN_CONSTANT_P)
2249
2250 /* Nonzero for _DECL means that this decl appears in (or will appear
2251    in) as a member in a RECORD_TYPE or UNION_TYPE node.  It is also for
2252    detecting circularity in case members are multiply defined.  In the
2253    case of a VAR_DECL, it is also used to determine how program storage
2254    should be allocated.  */
2255 #define DECL_IN_AGGR_P(NODE) (DECL_LANG_FLAG_3 (NODE))
2256
2257 /* Nonzero for a VAR_DECL means that the variable's initialization (if
2258    any) has been processed.  (In general, DECL_INITIALIZED_P is
2259    !DECL_EXTERN, but static data members may be initialized even if
2260    not defined.)  */
2261 #define DECL_INITIALIZED_P(NODE) \
2262    (TREE_LANG_FLAG_1 (VAR_DECL_CHECK (NODE)))
2263
2264 /* Nonzero for a VAR_DECL iff an explicit initializer was provided.  */
2265 #define DECL_NONTRIVIALLY_INITIALIZED_P(NODE)   \
2266    (TREE_LANG_FLAG_3 (VAR_DECL_CHECK (NODE)))
2267
2268 /* Nonzero for a VAR_DECL that was initialized with a
2269    constant-expression.  */
2270 #define DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P(NODE) \
2271   (TREE_LANG_FLAG_2 (VAR_DECL_CHECK (NODE)))
2272
2273 /* Nonzero if the DECL was initialized in the class definition itself,
2274    rather than outside the class.  This is used for both static member
2275    VAR_DECLS, and FUNCTION_DECLS that are defined in the class.  */
2276 #define DECL_INITIALIZED_IN_CLASS_P(DECL) \
2277   (DECL_LANG_SPECIFIC (VAR_OR_FUNCTION_DECL_CHECK (DECL)) \
2278    ->u.base.initialized_in_class)
2279
2280 /* Nonzero if the DECL is used in the sense of 3.2 [basic.def.odr].
2281    Only available for decls with DECL_LANG_SPECIFIC.  */
2282 #define DECL_ODR_USED(DECL) \
2283   (DECL_LANG_SPECIFIC (VAR_OR_FUNCTION_DECL_CHECK (DECL)) \
2284    ->u.base.odr_used)
2285
2286 /* Nonzero for DECL means that this decl is just a friend declaration,
2287    and should not be added to the list of members for this class.  */
2288 #define DECL_FRIEND_P(NODE) (DECL_LANG_SPECIFIC (NODE)->u.base.friend_attr)
2289
2290 /* A TREE_LIST of the types which have befriended this FUNCTION_DECL.  */
2291 #define DECL_BEFRIENDING_CLASSES(NODE) \
2292   (LANG_DECL_FN_CHECK (NODE)->befriending_classes)
2293
2294 /* Nonzero for FUNCTION_DECL means that this decl is a static
2295    member function.  */
2296 #define DECL_STATIC_FUNCTION_P(NODE) \
2297   (LANG_DECL_FN_CHECK (NODE)->static_function)
2298
2299 /* Nonzero for FUNCTION_DECL means that this decl is a non-static
2300    member function.  */
2301 #define DECL_NONSTATIC_MEMBER_FUNCTION_P(NODE) \
2302   (TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE)
2303
2304 /* Nonzero for FUNCTION_DECL means that this decl is a member function
2305    (static or non-static).  */
2306 #define DECL_FUNCTION_MEMBER_P(NODE) \
2307   (DECL_NONSTATIC_MEMBER_FUNCTION_P (NODE) || DECL_STATIC_FUNCTION_P (NODE))
2308
2309 /* Nonzero for FUNCTION_DECL means that this member function
2310    has `this' as const X *const.  */
2311 #define DECL_CONST_MEMFUNC_P(NODE)                                       \
2312   (DECL_NONSTATIC_MEMBER_FUNCTION_P (NODE)                               \
2313    && CP_TYPE_CONST_P (TREE_TYPE (TREE_VALUE                             \
2314                                   (TYPE_ARG_TYPES (TREE_TYPE (NODE))))))
2315
2316 /* Nonzero for FUNCTION_DECL means that this member function
2317    has `this' as volatile X *const.  */
2318 #define DECL_VOLATILE_MEMFUNC_P(NODE)                                    \
2319   (DECL_NONSTATIC_MEMBER_FUNCTION_P (NODE)                               \
2320    && CP_TYPE_VOLATILE_P (TREE_TYPE (TREE_VALUE                          \
2321                                   (TYPE_ARG_TYPES (TREE_TYPE (NODE))))))
2322
2323 /* Nonzero for a DECL means that this member is a non-static member.  */
2324 #define DECL_NONSTATIC_MEMBER_P(NODE)           \
2325   (DECL_NONSTATIC_MEMBER_FUNCTION_P (NODE)      \
2326    || TREE_CODE (NODE) == FIELD_DECL)
2327
2328 /* Nonzero for _DECL means that this member object type
2329    is mutable.  */
2330 #define DECL_MUTABLE_P(NODE) (DECL_LANG_FLAG_0 (NODE))
2331
2332 /* Nonzero for _DECL means that this constructor or conversion function is
2333    non-converting.  */
2334 #define DECL_NONCONVERTING_P(NODE) \
2335   (LANG_DECL_FN_CHECK (NODE)->nonconverting)
2336
2337 /* Nonzero for FUNCTION_DECL means that this member function is a pure
2338    virtual function.  */
2339 #define DECL_PURE_VIRTUAL_P(NODE) \
2340   (LANG_DECL_FN_CHECK (NODE)->pure_virtual)
2341
2342 /* True (in a FUNCTION_DECL) if NODE is a virtual function that is an
2343    invalid overrider for a function from a base class.  Once we have
2344    complained about an invalid overrider we avoid complaining about it
2345    again.  */
2346 #define DECL_INVALID_OVERRIDER_P(NODE) \
2347   (DECL_LANG_FLAG_4 (NODE))
2348
2349 /* True (in a FUNCTION_DECL) if NODE is a function declared with
2350    an override virt-specifier */
2351 #define DECL_OVERRIDE_P(NODE) (TREE_LANG_FLAG_0 (NODE))
2352
2353 /* True (in a FUNCTION_DECL) if NODE is a function declared with
2354    a final virt-specifier */
2355 #define DECL_FINAL_P(NODE) (TREE_LANG_FLAG_1 (NODE))
2356
2357 /* The thunks associated with NODE, a FUNCTION_DECL.  */
2358 #define DECL_THUNKS(NODE) \
2359   (LANG_DECL_FN_CHECK (NODE)->context)
2360
2361 /* Nonzero if NODE is a thunk, rather than an ordinary function.  */
2362 #define DECL_THUNK_P(NODE)                      \
2363   (TREE_CODE (NODE) == FUNCTION_DECL            \
2364    && DECL_LANG_SPECIFIC (NODE)                 \
2365    && LANG_DECL_FN_CHECK (NODE)->thunk_p)
2366
2367 /* Set DECL_THUNK_P for node.  */
2368 #define SET_DECL_THUNK_P(NODE, THIS_ADJUSTING)                  \
2369   (LANG_DECL_FN_CHECK (NODE)->thunk_p = 1,                      \
2370    LANG_DECL_FN_CHECK (NODE)->this_thunk_p = (THIS_ADJUSTING))
2371
2372 /* Nonzero if NODE is a this pointer adjusting thunk.  */
2373 #define DECL_THIS_THUNK_P(NODE)                 \
2374   (DECL_THUNK_P (NODE) && LANG_DECL_FN_CHECK (NODE)->this_thunk_p)
2375
2376 /* Nonzero if NODE is a result pointer adjusting thunk.  */
2377 #define DECL_RESULT_THUNK_P(NODE)                       \
2378   (DECL_THUNK_P (NODE) && !LANG_DECL_FN_CHECK (NODE)->this_thunk_p)
2379
2380 /* Nonzero if NODE is a FUNCTION_DECL, but not a thunk.  */
2381 #define DECL_NON_THUNK_FUNCTION_P(NODE)                         \
2382   (TREE_CODE (NODE) == FUNCTION_DECL && !DECL_THUNK_P (NODE))
2383
2384 /* Nonzero if NODE is `extern "C"'.  */
2385 #define DECL_EXTERN_C_P(NODE) \
2386   (DECL_LANGUAGE (NODE) == lang_c)
2387
2388 /* Nonzero if NODE is an `extern "C"' function.  */
2389 #define DECL_EXTERN_C_FUNCTION_P(NODE) \
2390   (DECL_NON_THUNK_FUNCTION_P (NODE) && DECL_EXTERN_C_P (NODE))
2391
2392 /* True iff DECL is an entity with vague linkage whose definition is
2393    available in this translation unit.  */
2394 #define DECL_REPO_AVAILABLE_P(NODE) \
2395   (DECL_LANG_SPECIFIC (NODE)->u.base.repo_available_p)
2396
2397 /* True if DECL is declared 'constexpr'.  */
2398 #define DECL_DECLARED_CONSTEXPR_P(DECL) \
2399   DECL_LANG_FLAG_8 (VAR_OR_FUNCTION_DECL_CHECK (STRIP_TEMPLATE (DECL)))
2400
2401 /* Nonzero if this DECL is the __PRETTY_FUNCTION__ variable in a
2402    template function.  */
2403 #define DECL_PRETTY_FUNCTION_P(NODE) \
2404   (TREE_LANG_FLAG_0 (VAR_DECL_CHECK (NODE)))
2405
2406 /* The _TYPE context in which this _DECL appears.  This field holds the
2407    class where a virtual function instance is actually defined.  */
2408 #define DECL_CLASS_CONTEXT(NODE) \
2409   (DECL_CLASS_SCOPE_P (NODE) ? DECL_CONTEXT (NODE) : NULL_TREE)
2410
2411 /* For a non-member friend function, the class (if any) in which this
2412    friend was defined.  For example, given:
2413
2414      struct S { friend void f (); };
2415
2416    the DECL_FRIEND_CONTEXT for `f' will be `S'.  */
2417 #define DECL_FRIEND_CONTEXT(NODE)                               \
2418   ((DECL_DECLARES_FUNCTION_P (NODE)                             \
2419     && DECL_FRIEND_P (NODE) && !DECL_FUNCTION_MEMBER_P (NODE))  \
2420    ? LANG_DECL_FN_CHECK (NODE)->context                         \
2421    : NULL_TREE)
2422
2423 /* Set the DECL_FRIEND_CONTEXT for NODE to CONTEXT.  */
2424 #define SET_DECL_FRIEND_CONTEXT(NODE, CONTEXT) \
2425   (LANG_DECL_FN_CHECK (NODE)->context = (CONTEXT))
2426
2427 #define CP_DECL_CONTEXT(NODE) \
2428   (!DECL_FILE_SCOPE_P (NODE) ? DECL_CONTEXT (NODE) : global_namespace)
2429 #define CP_TYPE_CONTEXT(NODE) \
2430   (!TYPE_FILE_SCOPE_P (NODE) ? TYPE_CONTEXT (NODE) : global_namespace)
2431 #define FROB_CONTEXT(NODE) \
2432   ((NODE) == global_namespace ? DECL_CONTEXT (NODE) : (NODE))
2433
2434 /* 1 iff NODE has namespace scope, including the global namespace.  */
2435 #define DECL_NAMESPACE_SCOPE_P(NODE)                            \
2436   (!DECL_TEMPLATE_PARM_P (NODE)                                 \
2437    && TREE_CODE (CP_DECL_CONTEXT (NODE)) == NAMESPACE_DECL)
2438
2439 #define TYPE_NAMESPACE_SCOPE_P(NODE) \
2440   (TREE_CODE (CP_TYPE_CONTEXT (NODE)) == NAMESPACE_DECL)
2441
2442 #define NAMESPACE_SCOPE_P(NODE) \
2443   ((DECL_P (NODE) && DECL_NAMESPACE_SCOPE_P (NODE)) \
2444    || (TYPE_P (NODE) && TYPE_NAMESPACE_SCOPE_P (NODE)))
2445
2446 /* 1 iff NODE is a class member.  */
2447 #define DECL_CLASS_SCOPE_P(NODE) \
2448   (DECL_CONTEXT (NODE) && TYPE_P (DECL_CONTEXT (NODE)))
2449
2450 #define TYPE_CLASS_SCOPE_P(NODE) \
2451   (TYPE_CONTEXT (NODE) && TYPE_P (TYPE_CONTEXT (NODE)))
2452
2453 /* 1 iff NODE is function-local.  */
2454 #define DECL_FUNCTION_SCOPE_P(NODE) \
2455   (DECL_CONTEXT (NODE) \
2456    && TREE_CODE (DECL_CONTEXT (NODE)) == FUNCTION_DECL)
2457
2458 #define TYPE_FUNCTION_SCOPE_P(NODE) \
2459   (TYPE_CONTEXT (NODE) && TREE_CODE (TYPE_CONTEXT (NODE)) == FUNCTION_DECL)
2460
2461 /* 1 iff VAR_DECL node NODE is a type-info decl.  This flag is set for
2462    both the primary typeinfo object and the associated NTBS name.  */
2463 #define DECL_TINFO_P(NODE) TREE_LANG_FLAG_4 (VAR_DECL_CHECK (NODE))
2464
2465 /* 1 iff VAR_DECL node NODE is virtual table or VTT.  */
2466 #define DECL_VTABLE_OR_VTT_P(NODE) TREE_LANG_FLAG_5 (VAR_DECL_CHECK (NODE))
2467
2468 /* Returns 1 iff VAR_DECL is a construction virtual table.
2469    DECL_VTABLE_OR_VTT_P will be true in this case and must be checked
2470    before using this macro.  */
2471 #define DECL_CONSTRUCTION_VTABLE_P(NODE) \
2472   TREE_LANG_FLAG_6 (VAR_DECL_CHECK (NODE))
2473
2474 /* 1 iff NODE is function-local, but for types.  */
2475 #define LOCAL_CLASS_P(NODE)                             \
2476   (decl_function_context (TYPE_MAIN_DECL (NODE)) != NULL_TREE)
2477
2478 /* For a NAMESPACE_DECL: the list of using namespace directives
2479    The PURPOSE is the used namespace, the value is the namespace
2480    that is the common ancestor.  */
2481 #define DECL_NAMESPACE_USING(NODE) DECL_VINDEX (NAMESPACE_DECL_CHECK (NODE))
2482
2483 /* In a NAMESPACE_DECL, the DECL_INITIAL is used to record all users
2484    of a namespace, to record the transitive closure of using namespace.  */
2485 #define DECL_NAMESPACE_USERS(NODE) DECL_INITIAL (NAMESPACE_DECL_CHECK (NODE))
2486
2487 /* In a NAMESPACE_DECL, the list of namespaces which have associated
2488    themselves with this one.  */
2489 #define DECL_NAMESPACE_ASSOCIATIONS(NODE) \
2490   (NAMESPACE_DECL_CHECK (NODE)->decl_non_common.saved_tree)
2491
2492 /* In a NAMESPACE_DECL, points to the original namespace if this is
2493    a namespace alias.  */
2494 #define DECL_NAMESPACE_ALIAS(NODE) \
2495         DECL_ABSTRACT_ORIGIN (NAMESPACE_DECL_CHECK (NODE))
2496 #define ORIGINAL_NAMESPACE(NODE)  \
2497   (DECL_NAMESPACE_ALIAS (NODE) ? DECL_NAMESPACE_ALIAS (NODE) : (NODE))
2498
2499 /* Nonzero if NODE is the std namespace.  */
2500 #define DECL_NAMESPACE_STD_P(NODE)                      \
2501   (TREE_CODE (NODE) == NAMESPACE_DECL                   \
2502    && CP_DECL_CONTEXT (NODE) == global_namespace        \
2503    && DECL_NAME (NODE) == std_identifier)
2504
2505 /* In a TREE_LIST concatenating using directives, indicate indirect
2506    directives  */
2507 #define TREE_INDIRECT_USING(NODE) (TREE_LIST_CHECK (NODE)->base.lang_flag_0)
2508
2509 /* In a TREE_LIST in an attribute list, indicates that the attribute
2510    must be applied at instantiation time.  */
2511 #define ATTR_IS_DEPENDENT(NODE) (TREE_LIST_CHECK (NODE)->base.lang_flag_0)
2512
2513 extern tree decl_shadowed_for_var_lookup (tree);
2514 extern void decl_shadowed_for_var_insert (tree, tree);
2515
2516 /* Non zero if this is a using decl for a dependent scope. */
2517 #define DECL_DEPENDENT_P(NODE) DECL_LANG_FLAG_0 (USING_DECL_CHECK (NODE))
2518
2519 /* The scope named in a using decl.  */
2520 #define USING_DECL_SCOPE(NODE) TREE_TYPE (USING_DECL_CHECK (NODE))
2521
2522 /* The decls named by a using decl.  */
2523 #define USING_DECL_DECLS(NODE) DECL_INITIAL (USING_DECL_CHECK (NODE))
2524
2525 /* Non zero if the using decl refers to a dependent type.  */
2526 #define USING_DECL_TYPENAME_P(NODE) DECL_LANG_FLAG_1 (USING_DECL_CHECK (NODE))
2527
2528 /* In a VAR_DECL, true if we have a shadowed local variable
2529    in the shadowed var table for this VAR_DECL.  */
2530 #define DECL_HAS_SHADOWED_FOR_VAR_P(NODE) \
2531   (VAR_DECL_CHECK (NODE)->decl_with_vis.shadowed_for_var_p)
2532
2533 /* In a VAR_DECL for a variable declared in a for statement,
2534    this is the shadowed (local) variable.  */
2535 #define DECL_SHADOWED_FOR_VAR(NODE) \
2536   (DECL_HAS_SHADOWED_FOR_VAR_P(NODE) ? decl_shadowed_for_var_lookup (NODE) : NULL)
2537
2538 #define SET_DECL_SHADOWED_FOR_VAR(NODE, VAL) \
2539   (decl_shadowed_for_var_insert (NODE, VAL))
2540
2541 /* In a FUNCTION_DECL, this is nonzero if this function was defined in
2542    the class definition.  We have saved away the text of the function,
2543    but have not yet processed it.  */
2544 #define DECL_PENDING_INLINE_P(NODE) \
2545   (LANG_DECL_FN_CHECK (NODE)->pending_inline_p)
2546
2547 /* If DECL_PENDING_INLINE_P holds, this is the saved text of the
2548    function.  */
2549 #define DECL_PENDING_INLINE_INFO(NODE) \
2550   (LANG_DECL_FN_CHECK (NODE)->u.pending_inline_info)
2551
2552 /* Nonzero for TYPE_DECL means that it was written 'using name = type'.  */
2553 #define TYPE_DECL_ALIAS_P(NODE) \
2554   DECL_LANG_FLAG_6 (TYPE_DECL_CHECK (NODE))
2555
2556 /* Nonzero for a type which is an alias for another type; i.e, a type
2557    which declaration was written 'using name-of-type =
2558    another-type'.  */
2559 #define TYPE_ALIAS_P(NODE)                      \
2560   (TYPE_P (NODE)                                \
2561    && TYPE_NAME (NODE)                          \
2562    && TREE_CODE (TYPE_NAME (NODE)) == TYPE_DECL \
2563    && TYPE_DECL_ALIAS_P (TYPE_NAME (NODE)))
2564
2565 /* For a class type: if this structure has many fields, we'll sort them
2566    and put them into a TREE_VEC.  */
2567 #define CLASSTYPE_SORTED_FIELDS(NODE) \
2568   (LANG_TYPE_CLASS_CHECK (NODE)->sorted_fields)
2569
2570 /* If non-NULL for a VAR_DECL, FUNCTION_DECL, TYPE_DECL or
2571    TEMPLATE_DECL, the entity is either a template specialization (if
2572    DECL_USE_TEMPLATE is nonzero) or the abstract instance of the
2573    template itself.
2574
2575    In either case, DECL_TEMPLATE_INFO is a TREE_LIST, whose
2576    TREE_PURPOSE is the TEMPLATE_DECL of which this entity is a
2577    specialization or abstract instance.  The TREE_VALUE is the
2578    template arguments used to specialize the template.
2579    
2580    Consider:
2581
2582       template <typename T> struct S { friend void f(T) {} };
2583
2584    In this case, S<int>::f is, from the point of view of the compiler,
2585    an instantiation of a template -- but, from the point of view of
2586    the language, each instantiation of S results in a wholly unrelated
2587    global function f.  In this case, DECL_TEMPLATE_INFO for S<int>::f
2588    will be non-NULL, but DECL_USE_TEMPLATE will be zero.  */
2589 #define DECL_TEMPLATE_INFO(NODE) \
2590   (DECL_LANG_SPECIFIC (VAR_TEMPL_TYPE_FIELD_OR_FUNCTION_DECL_CHECK (NODE)) \
2591    ->u.min.template_info)
2592
2593 /* For a VAR_DECL, indicates that the variable is actually a
2594    non-static data member of anonymous union that has been promoted to
2595    variable status.  */
2596 #define DECL_ANON_UNION_VAR_P(NODE) \
2597   (DECL_LANG_FLAG_4 (VAR_DECL_CHECK (NODE)))
2598
2599 /* Template information for a RECORD_TYPE or UNION_TYPE.  */
2600 #define CLASSTYPE_TEMPLATE_INFO(NODE) \
2601   (LANG_TYPE_CLASS_CHECK (RECORD_OR_UNION_CHECK (NODE))->template_info)
2602
2603 /* Template information for an ENUMERAL_TYPE.  Although an enumeration may
2604    not be a primary template, it may be declared within the scope of a
2605    primary template and the enumeration constants may depend on
2606    non-type template parameters.  */
2607 #define ENUM_TEMPLATE_INFO(NODE) \
2608   (TYPE_LANG_SLOT_1 (ENUMERAL_TYPE_CHECK (NODE)))
2609
2610 /* Template information for a template template parameter.  */
2611 #define TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO(NODE) \
2612   (LANG_TYPE_CLASS_CHECK (BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK (NODE)) \
2613    ->template_info)
2614
2615 /* Template information for an ENUMERAL_, RECORD_, UNION_TYPE, or
2616    BOUND_TEMPLATE_TEMPLATE_PARM type.  Note that if NODE is a
2617    specialization of an alias template, this accessor returns the
2618    template info for the alias template, not the one (if any) for the
2619    template of the underlying type.  */
2620 #define TYPE_TEMPLATE_INFO(NODE)                                        \
2621   (TYPE_ALIAS_P (NODE)                                                  \
2622    ? ((TYPE_NAME (NODE) && DECL_LANG_SPECIFIC (TYPE_NAME (NODE)))       \
2623       ? DECL_TEMPLATE_INFO (TYPE_NAME (NODE))                           \
2624       : NULL_TREE)                                                      \
2625    : ((TREE_CODE (NODE) == ENUMERAL_TYPE)                               \
2626       ? ENUM_TEMPLATE_INFO (NODE)                                       \
2627       : ((TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM)             \
2628          ? TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (NODE)                  \
2629          : (CLASS_TYPE_P (NODE)                                         \
2630             ? CLASSTYPE_TEMPLATE_INFO (NODE)                            \
2631             : NULL_TREE))))
2632
2633
2634 /* Set the template information for an ENUMERAL_, RECORD_, or
2635    UNION_TYPE to VAL.  */
2636 #define SET_TYPE_TEMPLATE_INFO(NODE, VAL)                               \
2637   (TREE_CODE (NODE) == ENUMERAL_TYPE                                    \
2638    ? (ENUM_TEMPLATE_INFO (NODE) = (VAL))                                \
2639    : ((CLASS_TYPE_P (NODE) && !TYPE_ALIAS_P (NODE))                     \
2640       ? (CLASSTYPE_TEMPLATE_INFO (NODE) = (VAL))                        \
2641       : (DECL_TEMPLATE_INFO (TYPE_NAME (NODE)) = (VAL))))
2642
2643 #define TI_TEMPLATE(NODE) TREE_TYPE (TEMPLATE_INFO_CHECK (NODE))
2644 #define TI_ARGS(NODE) TREE_CHAIN (TEMPLATE_INFO_CHECK (NODE))
2645 #define TI_PENDING_TEMPLATE_FLAG(NODE) TREE_LANG_FLAG_1 (NODE)
2646 /* For a given TREE_VEC containing a template argument list,
2647    this property contains the number of arguments that are not
2648    defaulted.  */
2649 #define NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) TREE_CHAIN (TREE_VEC_CHECK (NODE))
2650 /* Below are the setter and getter of the NON_DEFAULT_TEMPLATE_ARGS_COUNT
2651    property.  */
2652 #define SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE, INT_VALUE) \
2653   NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) = build_int_cst (NULL_TREE, INT_VALUE)
2654 #ifdef ENABLE_CHECKING
2655 #define GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) \
2656     int_cst_value (NON_DEFAULT_TEMPLATE_ARGS_COUNT (NODE))
2657 #else
2658 #define GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) \
2659   NON_DEFAULT_TEMPLATE_ARGS_COUNT (NODE) \
2660   ? int_cst_value (NON_DEFAULT_TEMPLATE_ARGS_COUNT (NODE)) \
2661   : TREE_VEC_LENGTH (INNERMOST_TEMPLATE_ARGS (NODE))
2662 #endif
2663 /* The list of typedefs - used in the template - that need
2664    access checking at template instantiation time.  */
2665 #define TI_TYPEDEFS_NEEDING_ACCESS_CHECKING(NODE) \
2666   ((struct tree_template_info*)TEMPLATE_INFO_CHECK \
2667      (NODE))->typedefs_needing_access_checking
2668
2669 /* We use TREE_VECs to hold template arguments.  If there is only one
2670    level of template arguments, then the TREE_VEC contains the
2671    arguments directly.  If there is more than one level of template
2672    arguments, then each entry in the TREE_VEC is itself a TREE_VEC,
2673    containing the template arguments for a single level.  The first
2674    entry in the outer TREE_VEC is the outermost level of template
2675    parameters; the last is the innermost.
2676
2677    It is incorrect to ever form a template argument vector containing
2678    only one level of arguments, but which is a TREE_VEC containing as
2679    its only entry the TREE_VEC for that level.
2680
2681    For each TREE_VEC containing the template arguments for a single
2682    level, it's possible to get or set the number of non defaulted
2683    template arguments by using the accessor macros
2684    GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT or
2685    SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT.  */
2686
2687 /* Nonzero if the template arguments is actually a vector of vectors,
2688    rather than just a vector.  */
2689 #define TMPL_ARGS_HAVE_MULTIPLE_LEVELS(NODE)                 \
2690   (NODE && TREE_VEC_LENGTH (NODE) && TREE_VEC_ELT (NODE, 0)  \
2691    && TREE_CODE (TREE_VEC_ELT (NODE, 0)) == TREE_VEC)
2692
2693 /* The depth of a template argument vector.  When called directly by
2694    the parser, we use a TREE_LIST rather than a TREE_VEC to represent
2695    template arguments.  In fact, we may even see NULL_TREE if there
2696    are no template arguments.  In both of those cases, there is only
2697    one level of template arguments.  */
2698 #define TMPL_ARGS_DEPTH(NODE)                                   \
2699   (TMPL_ARGS_HAVE_MULTIPLE_LEVELS (NODE) ? TREE_VEC_LENGTH (NODE) : 1)
2700
2701 /* The LEVELth level of the template ARGS.  The outermost level of
2702    args is level 1, not level 0.  */
2703 #define TMPL_ARGS_LEVEL(ARGS, LEVEL)            \
2704   (TMPL_ARGS_HAVE_MULTIPLE_LEVELS (ARGS)        \
2705    ? TREE_VEC_ELT (ARGS, (LEVEL) - 1) : (ARGS))
2706
2707 /* Set the LEVELth level of the template ARGS to VAL.  This macro does
2708    not work with single-level argument vectors.  */
2709 #define SET_TMPL_ARGS_LEVEL(ARGS, LEVEL, VAL)   \
2710   (TREE_VEC_ELT (ARGS, (LEVEL) - 1) = (VAL))
2711
2712 /* Accesses the IDXth parameter in the LEVELth level of the ARGS.  */
2713 #define TMPL_ARG(ARGS, LEVEL, IDX)                              \
2714   (TREE_VEC_ELT (TMPL_ARGS_LEVEL (ARGS, LEVEL), IDX))
2715
2716 /* Given a single level of template arguments in NODE, return the
2717    number of arguments.  */
2718 #define NUM_TMPL_ARGS(NODE)                             \
2719   (TREE_VEC_LENGTH (NODE))
2720
2721 /* Returns the innermost level of template arguments in ARGS.  */
2722 #define INNERMOST_TEMPLATE_ARGS(NODE) \
2723   (get_innermost_template_args ((NODE), 1))
2724
2725 /* The number of levels of template parameters given by NODE.  */
2726 #define TMPL_PARMS_DEPTH(NODE) \
2727   ((HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_PURPOSE (NODE)))
2728
2729 /* The TEMPLATE_DECL instantiated or specialized by NODE.  This
2730    TEMPLATE_DECL will be the immediate parent, not the most general
2731    template.  For example, in:
2732
2733       template <class T> struct S { template <class U> void f(U); }
2734
2735    the FUNCTION_DECL for S<int>::f<double> will have, as its
2736    DECL_TI_TEMPLATE, `template <class U> S<int>::f<U>'.
2737
2738    As a special case, for a member friend template of a template
2739    class, this value will not be a TEMPLATE_DECL, but rather an
2740    IDENTIFIER_NODE or OVERLOAD indicating the name of the template and
2741    any explicit template arguments provided.  For example, in:
2742
2743      template <class T> struct S { friend void f<int>(int, double); }
2744
2745    the DECL_TI_TEMPLATE will be an IDENTIFIER_NODE for `f' and the
2746    DECL_TI_ARGS will be {int}.
2747
2748    For a FIELD_DECL with a non-static data member initializer, this value
2749    is the FIELD_DECL it was instantiated from.  */
2750 #define DECL_TI_TEMPLATE(NODE)      TI_TEMPLATE (DECL_TEMPLATE_INFO (NODE))
2751
2752 /* The template arguments used to obtain this decl from the most
2753    general form of DECL_TI_TEMPLATE.  For the example given for
2754    DECL_TI_TEMPLATE, the DECL_TI_ARGS will be {int, double}.  These
2755    are always the full set of arguments required to instantiate this
2756    declaration from the most general template specialized here.  */
2757 #define DECL_TI_ARGS(NODE)          TI_ARGS (DECL_TEMPLATE_INFO (NODE))
2758
2759 /* The TEMPLATE_DECL associated with NODE, a class type.  Even if NODE
2760    will be generated from a partial specialization, the TEMPLATE_DECL
2761    referred to here will be the original template.  For example,
2762    given:
2763
2764       template <typename T> struct S {};
2765       template <typename T> struct S<T*> {};
2766       
2767    the CLASSTPYE_TI_TEMPLATE for S<int*> will be S, not the S<T*>.  */
2768 #define CLASSTYPE_TI_TEMPLATE(NODE) TI_TEMPLATE (CLASSTYPE_TEMPLATE_INFO (NODE))
2769 #define CLASSTYPE_TI_ARGS(NODE)     TI_ARGS (CLASSTYPE_TEMPLATE_INFO (NODE))
2770
2771 /* For a template instantiation TYPE, returns the TYPE corresponding
2772    to the primary template.  Otherwise returns TYPE itself.  */
2773 #define CLASSTYPE_PRIMARY_TEMPLATE_TYPE(TYPE)                           \
2774   ((CLASSTYPE_USE_TEMPLATE ((TYPE))                                     \
2775     && !CLASSTYPE_TEMPLATE_SPECIALIZATION ((TYPE)))                     \
2776    ? TREE_TYPE (DECL_TEMPLATE_RESULT (DECL_PRIMARY_TEMPLATE             \
2777                                       (CLASSTYPE_TI_TEMPLATE ((TYPE))))) \
2778    : (TYPE))
2779
2780 /* Like CLASS_TI_TEMPLATE, but also works for ENUMERAL_TYPEs.  */
2781 #define TYPE_TI_TEMPLATE(NODE)                  \
2782   (TI_TEMPLATE (TYPE_TEMPLATE_INFO (NODE)))
2783
2784 /* Like DECL_TI_ARGS, but for an ENUMERAL_, RECORD_, or UNION_TYPE.  */
2785 #define TYPE_TI_ARGS(NODE)                      \
2786   (TI_ARGS (TYPE_TEMPLATE_INFO (NODE)))
2787
2788 #define INNERMOST_TEMPLATE_PARMS(NODE)  TREE_VALUE (NODE)
2789
2790 /* Nonzero if NODE (a TEMPLATE_DECL) is a member template, in the
2791    sense of [temp.mem].  */
2792 #define DECL_MEMBER_TEMPLATE_P(NODE) \
2793   (DECL_LANG_FLAG_1 (TEMPLATE_DECL_CHECK (NODE)))
2794
2795 /* Nonzero if the NODE corresponds to the template parameters for a
2796    member template, whose inline definition is being processed after
2797    the class definition is complete.  */
2798 #define TEMPLATE_PARMS_FOR_INLINE(NODE) TREE_LANG_FLAG_1 (NODE)
2799
2800 /* Determine if a parameter (i.e., a PARM_DECL) is a function
2801    parameter pack.  */
2802 #define FUNCTION_PARAMETER_PACK_P(NODE) \
2803   (DECL_LANG_FLAG_1 (PARM_DECL_CHECK (NODE)))
2804
2805 /* Determines if NODE is an expansion of one or more parameter packs,
2806    e.g., a TYPE_PACK_EXPANSION or EXPR_PACK_EXPANSION.  */
2807 #define PACK_EXPANSION_P(NODE)                 \
2808   (TREE_CODE (NODE) == TYPE_PACK_EXPANSION     \
2809    || TREE_CODE (NODE) == EXPR_PACK_EXPANSION)
2810
2811 /* Extracts the type or expression pattern from a TYPE_PACK_EXPANSION or
2812    EXPR_PACK_EXPANSION.  */
2813 #define PACK_EXPANSION_PATTERN(NODE)                            \
2814   (TREE_CODE (NODE) == TYPE_PACK_EXPANSION? TREE_TYPE (NODE)    \
2815    : TREE_OPERAND (NODE, 0))
2816
2817 /* Sets the type or expression pattern for a TYPE_PACK_EXPANSION or
2818    EXPR_PACK_EXPANSION.  */
2819 #define SET_PACK_EXPANSION_PATTERN(NODE,VALUE)  \
2820   if (TREE_CODE (NODE) == TYPE_PACK_EXPANSION)  \
2821     TREE_TYPE (NODE) = VALUE;                   \
2822   else                                          \
2823     TREE_OPERAND (NODE, 0) = VALUE
2824
2825 /* The list of parameter packs used in the PACK_EXPANSION_* node. The
2826    TREE_VALUE of each TREE_LIST contains the parameter packs.  */
2827 #define PACK_EXPANSION_PARAMETER_PACKS(NODE)            \
2828   *(TREE_CODE (NODE) == EXPR_PACK_EXPANSION             \
2829     ? &TREE_OPERAND (NODE, 1)                           \
2830     : &TYPE_MINVAL (TYPE_PACK_EXPANSION_CHECK (NODE)))
2831
2832 /* Any additional template args to be applied when substituting into
2833    the pattern, set by tsubst_pack_expansion for partial instantiations.  */
2834 #define PACK_EXPANSION_EXTRA_ARGS(NODE)         \
2835   *(TREE_CODE (NODE) == TYPE_PACK_EXPANSION     \
2836     ? &TYPE_MAXVAL (NODE)                       \
2837     : &TREE_OPERAND ((NODE), 2))
2838
2839 /* Determine if this is an argument pack.  */
2840 #define ARGUMENT_PACK_P(NODE)                          \
2841   (TREE_CODE (NODE) == TYPE_ARGUMENT_PACK              \
2842    || TREE_CODE (NODE) == NONTYPE_ARGUMENT_PACK)
2843
2844 /* The arguments stored in an argument pack. Arguments are stored in a
2845    TREE_VEC, which may have length zero.  */
2846 #define ARGUMENT_PACK_ARGS(NODE)                               \
2847   (TREE_CODE (NODE) == TYPE_ARGUMENT_PACK? TREE_TYPE (NODE)    \
2848    : TREE_OPERAND (NODE, 0))
2849
2850 /* Set the arguments stored in an argument pack. VALUE must be a
2851    TREE_VEC.  */
2852 #define SET_ARGUMENT_PACK_ARGS(NODE,VALUE)     \
2853   if (TREE_CODE (NODE) == TYPE_ARGUMENT_PACK)  \
2854     TREE_TYPE (NODE) = VALUE;                           \
2855   else                                                  \
2856     TREE_OPERAND (NODE, 0) = VALUE
2857
2858 /* Whether the argument pack is "incomplete", meaning that more
2859    arguments can still be deduced. Incomplete argument packs are only
2860    used when the user has provided an explicit template argument list
2861    for a variadic function template. Some of the explicit template
2862    arguments will be placed into the beginning of the argument pack,
2863    but additional arguments might still be deduced.  */
2864 #define ARGUMENT_PACK_INCOMPLETE_P(NODE)        \
2865   TREE_LANG_FLAG_0 (ARGUMENT_PACK_ARGS (NODE))
2866
2867 /* When ARGUMENT_PACK_INCOMPLETE_P, stores the explicit template
2868    arguments used to fill this pack.  */
2869 #define ARGUMENT_PACK_EXPLICIT_ARGS(NODE)       \
2870   TREE_TYPE (ARGUMENT_PACK_ARGS (NODE))
2871
2872 /* In an ARGUMENT_PACK_SELECT, the argument pack from which an
2873    argument will be selected.  */
2874 #define ARGUMENT_PACK_SELECT_FROM_PACK(NODE)                            \
2875   (((struct tree_argument_pack_select *)ARGUMENT_PACK_SELECT_CHECK (NODE))->argument_pack)
2876
2877 /* In an ARGUMENT_PACK_SELECT, the index of the argument we want to
2878    select.  */
2879 #define ARGUMENT_PACK_SELECT_INDEX(NODE)                                \
2880   (((struct tree_argument_pack_select *)ARGUMENT_PACK_SELECT_CHECK (NODE))->index)
2881   
2882 /* In an ARGUMENT_PACK_SELECT, the actual underlying argument that the
2883    ARGUMENT_PACK_SELECT represents. */
2884 #define ARGUMENT_PACK_SELECT_ARG(NODE)                                  \
2885   TREE_VEC_ELT (ARGUMENT_PACK_ARGS (ARGUMENT_PACK_SELECT_FROM_PACK (NODE)), \
2886                 ARGUMENT_PACK_SELECT_INDEX (NODE));
2887
2888 /* In a FUNCTION_DECL, the saved language-specific per-function data.  */
2889 #define DECL_SAVED_FUNCTION_DATA(NODE)                  \
2890   (LANG_DECL_FN_CHECK (FUNCTION_DECL_CHECK (NODE))      \
2891    ->u.saved_language_function)
2892
2893 /* True if NODE is an implicit INDIRECT_EXPR from convert_from_reference.  */
2894 #define REFERENCE_REF_P(NODE)                           \
2895   (TREE_CODE (NODE) == INDIRECT_REF                     \
2896    && TREE_TYPE (TREE_OPERAND (NODE, 0))                \
2897    && (TREE_CODE (TREE_TYPE (TREE_OPERAND ((NODE), 0))) \
2898        == REFERENCE_TYPE))
2899
2900 #define NEW_EXPR_USE_GLOBAL(NODE) \
2901   TREE_LANG_FLAG_0 (NEW_EXPR_CHECK (NODE))
2902 #define DELETE_EXPR_USE_GLOBAL(NODE) \
2903   TREE_LANG_FLAG_0 (DELETE_EXPR_CHECK (NODE))
2904 #define DELETE_EXPR_USE_VEC(NODE) \
2905   TREE_LANG_FLAG_1 (DELETE_EXPR_CHECK (NODE))
2906
2907 /* Indicates that this is a non-dependent COMPOUND_EXPR which will
2908    resolve to a function call.  */
2909 #define COMPOUND_EXPR_OVERLOADED(NODE) \
2910   TREE_LANG_FLAG_0 (COMPOUND_EXPR_CHECK (NODE))
2911
2912 /* In a CALL_EXPR appearing in a template, true if Koenig lookup
2913    should be performed at instantiation time.  */
2914 #define KOENIG_LOOKUP_P(NODE) TREE_LANG_FLAG_0 (CALL_EXPR_CHECK (NODE))
2915
2916 /* Indicates whether a string literal has been parenthesized. Such
2917    usages are disallowed in certain circumstances.  */
2918
2919 #define PAREN_STRING_LITERAL_P(NODE) \
2920   TREE_LANG_FLAG_0 (STRING_CST_CHECK (NODE))
2921
2922 /* Nonzero if this AGGR_INIT_EXPR provides for initialization via a
2923    constructor call, rather than an ordinary function call.  */
2924 #define AGGR_INIT_VIA_CTOR_P(NODE) \
2925   TREE_LANG_FLAG_0 (AGGR_INIT_EXPR_CHECK (NODE))
2926
2927 /* Nonzero if expanding this AGGR_INIT_EXPR should first zero-initialize
2928    the object.  */
2929 #define AGGR_INIT_ZERO_FIRST(NODE) \
2930   TREE_LANG_FLAG_2 (AGGR_INIT_EXPR_CHECK (NODE))
2931
2932 /* AGGR_INIT_EXPR accessors.  These are equivalent to the CALL_EXPR
2933    accessors, except for AGGR_INIT_EXPR_SLOT (which takes the place of
2934    CALL_EXPR_STATIC_CHAIN).  */
2935
2936 #define AGGR_INIT_EXPR_FN(NODE) TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 1)
2937 #define AGGR_INIT_EXPR_SLOT(NODE) \
2938   TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 2)
2939 #define AGGR_INIT_EXPR_ARG(NODE, I) \
2940   TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), (I) + 3)
2941 #define aggr_init_expr_nargs(NODE) (VL_EXP_OPERAND_LENGTH(NODE) - 3)
2942
2943 /* AGGR_INIT_EXPR_ARGP returns a pointer to the argument vector for NODE.
2944    We can't use &AGGR_INIT_EXPR_ARG (NODE, 0) because that will complain if
2945    the argument count is zero when checking is enabled.  Instead, do
2946    the pointer arithmetic to advance past the 3 fixed operands in a
2947    AGGR_INIT_EXPR.  That produces a valid pointer to just past the end of
2948    the operand array, even if it's not valid to dereference it.  */
2949 #define AGGR_INIT_EXPR_ARGP(NODE) \
2950   (&(TREE_OPERAND (AGGR_INIT_EXPR_CHECK (NODE), 0)) + 3)
2951
2952 /* Abstract iterators for AGGR_INIT_EXPRs.  */
2953
2954 /* Structure containing iterator state.  */
2955 typedef struct aggr_init_expr_arg_iterator_d {
2956   tree t;       /* the aggr_init_expr */
2957   int n;        /* argument count */
2958   int i;        /* next argument index */
2959 } aggr_init_expr_arg_iterator;
2960
2961 /* Initialize the abstract argument list iterator object ITER with the
2962    arguments from AGGR_INIT_EXPR node EXP.  */
2963 static inline void
2964 init_aggr_init_expr_arg_iterator (tree exp,
2965                                        aggr_init_expr_arg_iterator *iter)
2966 {
2967   iter->t = exp;
2968   iter->n = aggr_init_expr_nargs (exp);
2969   iter->i = 0;
2970 }
2971
2972 /* Return the next argument from abstract argument list iterator object ITER,
2973    and advance its state.  Return NULL_TREE if there are no more arguments.  */
2974 static inline tree
2975 next_aggr_init_expr_arg (aggr_init_expr_arg_iterator *iter)
2976 {
2977   tree result;
2978   if (iter->i >= iter->n)
2979     return NULL_TREE;
2980   result = AGGR_INIT_EXPR_ARG (iter->t, iter->i);
2981   iter->i++;
2982   return result;
2983 }
2984
2985 /* Initialize the abstract argument list iterator object ITER, then advance
2986    past and return the first argument.  Useful in for expressions, e.g.
2987      for (arg = first_aggr_init_expr_arg (exp, &iter); arg;
2988           arg = next_aggr_init_expr_arg (&iter))   */
2989 static inline tree
2990 first_aggr_init_expr_arg (tree exp, aggr_init_expr_arg_iterator *iter)
2991 {
2992   init_aggr_init_expr_arg_iterator (exp, iter);
2993   return next_aggr_init_expr_arg (iter);
2994 }
2995
2996 /* Test whether there are more arguments in abstract argument list iterator
2997    ITER, without changing its state.  */
2998 static inline bool
2999 more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
3000 {
3001   return (iter->i < iter->n);
3002 }
3003
3004 /* Iterate through each argument ARG of AGGR_INIT_EXPR CALL, using variable
3005    ITER (of type aggr_init_expr_arg_iterator) to hold the iteration state.  */
3006 #define FOR_EACH_AGGR_INIT_EXPR_ARG(arg, iter, call)                    \
3007   for ((arg) = first_aggr_init_expr_arg ((call), &(iter)); (arg);       \
3008        (arg) = next_aggr_init_expr_arg (&(iter)))
3009
3010 /* VEC_INIT_EXPR accessors.  */
3011 #define VEC_INIT_EXPR_SLOT(NODE) TREE_OPERAND (VEC_INIT_EXPR_CHECK (NODE), 0)
3012 #define VEC_INIT_EXPR_INIT(NODE) TREE_OPERAND (VEC_INIT_EXPR_CHECK (NODE), 1)
3013
3014 /* Indicates that a VEC_INIT_EXPR is a potential constant expression.
3015    Only set when the current function is constexpr.  */
3016 #define VEC_INIT_EXPR_IS_CONSTEXPR(NODE) \
3017   TREE_LANG_FLAG_0 (VEC_INIT_EXPR_CHECK (NODE))
3018
3019 /* Indicates that a VEC_INIT_EXPR is expressing value-initialization.  */
3020 #define VEC_INIT_EXPR_VALUE_INIT(NODE) \
3021   TREE_LANG_FLAG_1 (VEC_INIT_EXPR_CHECK (NODE))
3022
3023 /* The condition under which this MUST_NOT_THROW_EXPR actually blocks
3024    exceptions.  NULL_TREE means 'true'.  */
3025 #define MUST_NOT_THROW_COND(NODE) \
3026   TREE_OPERAND (MUST_NOT_THROW_EXPR_CHECK (NODE), 1)
3027
3028 /* The TYPE_MAIN_DECL for a class template type is a TYPE_DECL, not a
3029    TEMPLATE_DECL.  This macro determines whether or not a given class
3030    type is really a template type, as opposed to an instantiation or
3031    specialization of one.  */
3032 #define CLASSTYPE_IS_TEMPLATE(NODE)  \
3033   (CLASSTYPE_TEMPLATE_INFO (NODE)    \
3034    && !CLASSTYPE_USE_TEMPLATE (NODE) \
3035    && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (NODE)))
3036
3037 /* The name used by the user to name the typename type.  Typically,
3038    this is an IDENTIFIER_NODE, and the same as the DECL_NAME on the
3039    corresponding TYPE_DECL.  However, this may also be a
3040    TEMPLATE_ID_EXPR if we had something like `typename X::Y<T>'.  */
3041 #define TYPENAME_TYPE_FULLNAME(NODE) \
3042   (TYPE_VALUES_RAW (TYPENAME_TYPE_CHECK (NODE)))
3043
3044 /* True if a TYPENAME_TYPE was declared as an "enum".  */
3045 #define TYPENAME_IS_ENUM_P(NODE) \
3046   (TREE_LANG_FLAG_0 (TYPENAME_TYPE_CHECK (NODE)))
3047
3048 /* True if a TYPENAME_TYPE was declared as a "class", "struct", or
3049    "union".  */
3050 #define TYPENAME_IS_CLASS_P(NODE) \
3051   (TREE_LANG_FLAG_1 (TYPENAME_TYPE_CHECK (NODE)))
3052
3053 /* True if a TYPENAME_TYPE is in the process of being resolved.  */
3054 #define TYPENAME_IS_RESOLVING_P(NODE) \
3055   (TREE_LANG_FLAG_2 (TYPENAME_TYPE_CHECK (NODE)))
3056
3057 /* [class.virtual]
3058
3059    A class that declares or inherits a virtual function is called a
3060    polymorphic class.  */
3061 #define TYPE_POLYMORPHIC_P(NODE) (TREE_LANG_FLAG_2 (NODE))
3062
3063 /* Nonzero if this class has a virtual function table pointer.  */
3064 #define TYPE_CONTAINS_VPTR_P(NODE)              \
3065   (TYPE_POLYMORPHIC_P (NODE) || CLASSTYPE_VBASECLASSES (NODE))
3066
3067 /* This flag is true of a local VAR_DECL if it was declared in a for
3068    statement, but we are no longer in the scope of the for.  */
3069 #define DECL_DEAD_FOR_LOCAL(NODE) DECL_LANG_FLAG_7 (VAR_DECL_CHECK (NODE))
3070
3071 /* This flag is set on a VAR_DECL that is a DECL_DEAD_FOR_LOCAL
3072    if we already emitted a warning about using it.  */
3073 #define DECL_ERROR_REPORTED(NODE) DECL_LANG_FLAG_0 (VAR_DECL_CHECK (NODE))
3074
3075 /* Nonzero if NODE is a FUNCTION_DECL (for a function with global
3076    scope) declared in a local scope.  */
3077 #define DECL_LOCAL_FUNCTION_P(NODE) \
3078   DECL_LANG_FLAG_0 (FUNCTION_DECL_CHECK (NODE))
3079
3080 /* Nonzero if NODE is a DECL which we know about but which has not
3081    been explicitly declared, such as a built-in function or a friend
3082    declared inside a class.  In the latter case DECL_HIDDEN_FRIEND_P
3083    will be set.  */
3084 #define DECL_ANTICIPATED(NODE) \
3085   (DECL_LANG_SPECIFIC (DECL_COMMON_CHECK (NODE))->u.base.anticipated_p)
3086
3087 /* Nonzero if NODE is a FUNCTION_DECL which was declared as a friend
3088    within a class but has not been declared in the surrounding scope.
3089    The function is invisible except via argument dependent lookup.  */
3090 #define DECL_HIDDEN_FRIEND_P(NODE) \
3091   (LANG_DECL_FN_CHECK (DECL_COMMON_CHECK (NODE))->hidden_friend_p)
3092
3093 /* Nonzero if DECL has been declared threadprivate by
3094    #pragma omp threadprivate.  */
3095 #define CP_DECL_THREADPRIVATE_P(DECL) \
3096   (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (DECL))->u.base.threadprivate_or_deleted_p)
3097
3098 /* Nonzero if DECL was declared with '= delete'.  */
3099 #define DECL_DELETED_FN(DECL) \
3100   (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (DECL))->u.base.threadprivate_or_deleted_p)
3101
3102 /* Nonzero if DECL was declared with '= default' (maybe implicitly).  */
3103 #define DECL_DEFAULTED_FN(DECL) \
3104   (LANG_DECL_FN_CHECK (DECL)->defaulted_p)
3105
3106 /* Nonzero if DECL is explicitly defaulted in the class body.  */
3107 #define DECL_DEFAULTED_IN_CLASS_P(DECL)                                 \
3108   (DECL_DEFAULTED_FN (DECL) && DECL_INITIALIZED_IN_CLASS_P (DECL))
3109 /* Nonzero if DECL was defaulted outside the class body.  */
3110 #define DECL_DEFAULTED_OUTSIDE_CLASS_P(DECL)                            \
3111   (DECL_DEFAULTED_FN (DECL)                                             \
3112    && !(DECL_ARTIFICIAL (DECL) || DECL_INITIALIZED_IN_CLASS_P (DECL)))
3113
3114 /* Record whether a typedef for type `int' was actually `signed int'.  */
3115 #define C_TYPEDEF_EXPLICITLY_SIGNED(EXP) DECL_LANG_FLAG_1 (EXP)
3116
3117 /* Returns nonzero if DECL has external linkage, as specified by the
3118    language standard.  (This predicate may hold even when the
3119    corresponding entity is not actually given external linkage in the
3120    object file; see decl_linkage for details.)  */
3121 #define DECL_EXTERNAL_LINKAGE_P(DECL) \
3122   (decl_linkage (DECL) == lk_external)
3123
3124 /* Keep these codes in ascending code order.  */
3125
3126 #define INTEGRAL_CODE_P(CODE)   \
3127   ((CODE) == ENUMERAL_TYPE      \
3128    || (CODE) == BOOLEAN_TYPE    \
3129    || (CODE) == INTEGER_TYPE)
3130
3131 /* [basic.fundamental]
3132
3133    Types  bool, char, wchar_t, and the signed and unsigned integer types
3134    are collectively called integral types.
3135
3136    Note that INTEGRAL_TYPE_P, as defined in tree.h, allows enumeration
3137    types as well, which is incorrect in C++.  Keep these checks in
3138    ascending code order.  */
3139 #define CP_INTEGRAL_TYPE_P(TYPE)                \
3140   (TREE_CODE (TYPE) == BOOLEAN_TYPE             \
3141    || TREE_CODE (TYPE) == INTEGER_TYPE)
3142
3143 /* Returns true if TYPE is an integral or enumeration name.  Keep
3144    these checks in ascending code order.  */
3145 #define INTEGRAL_OR_ENUMERATION_TYPE_P(TYPE) \
3146    (TREE_CODE (TYPE) == ENUMERAL_TYPE || CP_INTEGRAL_TYPE_P (TYPE))
3147
3148 /* Returns true if TYPE is an integral or unscoped enumeration type.  */
3149 #define INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P(TYPE) \
3150    (UNSCOPED_ENUM_P (TYPE) || CP_INTEGRAL_TYPE_P (TYPE))
3151
3152 /* True if the class type TYPE is a literal type.  */
3153 #define CLASSTYPE_LITERAL_P(TYPE)              \
3154    (LANG_TYPE_CLASS_CHECK (TYPE)->is_literal)
3155
3156 /* [basic.fundamental]
3157
3158    Integral and floating types are collectively called arithmetic
3159    types.  
3160
3161    As a GNU extension, we also accept complex types.
3162
3163    Keep these checks in ascending code order.  */
3164 #define ARITHMETIC_TYPE_P(TYPE) \
3165   (CP_INTEGRAL_TYPE_P (TYPE) \
3166    || TREE_CODE (TYPE) == REAL_TYPE \
3167    || TREE_CODE (TYPE) == COMPLEX_TYPE)
3168
3169 /* True iff TYPE is cv decltype(nullptr).  */
3170 #define NULLPTR_TYPE_P(TYPE) (TREE_CODE (TYPE) == NULLPTR_TYPE)
3171
3172 /* [basic.types]
3173
3174    Arithmetic types, enumeration types, pointer types,
3175    pointer-to-member types, and std::nullptr_t are collectively called
3176    scalar types.
3177    
3178    Keep these checks in ascending code order.  */
3179 #define SCALAR_TYPE_P(TYPE)                     \
3180   (TYPE_PTRMEM_P (TYPE)                         \
3181    || TREE_CODE (TYPE) == ENUMERAL_TYPE         \
3182    || ARITHMETIC_TYPE_P (TYPE)                  \
3183    || TYPE_PTR_P (TYPE)                         \
3184    || TYPE_PTRMEMFUNC_P (TYPE)                  \
3185    || NULLPTR_TYPE_P (TYPE))
3186
3187 /* Determines whether this type is a C++0x scoped enumeration
3188    type. Scoped enumerations types are introduced via "enum class" or
3189    "enum struct", e.g.,
3190
3191      enum class Color {
3192        Red, Green, Blue
3193      };
3194
3195    Scoped enumeration types are different from normal (unscoped)
3196    enumeration types in several ways:
3197    
3198      - The enumerators of a scoped enumeration type are only available
3199        within the scope of the enumeration type and not in the
3200        enclosing scope. For example, the Red color can be referred to
3201        with "Color::Red" but not "Red".
3202
3203      - Scoped enumerators and enumerations do not implicitly convert
3204        to integers or 'bool'.
3205
3206      - The underlying type of the enum is well-defined.  */
3207 #define SCOPED_ENUM_P(TYPE)                                             \
3208   (TREE_CODE (TYPE) == ENUMERAL_TYPE && ENUM_IS_SCOPED (TYPE))
3209
3210 /* Determine whether this is an unscoped enumeration type.  */
3211 #define UNSCOPED_ENUM_P(TYPE)                                           \
3212   (TREE_CODE (TYPE) == ENUMERAL_TYPE && !ENUM_IS_SCOPED (TYPE))
3213
3214 /* Set the flag indicating whether an ENUMERAL_TYPE is a C++0x scoped
3215    enumeration type (1) or a normal (unscoped) enumeration type
3216    (0).  */
3217 #define SET_SCOPED_ENUM_P(TYPE, VAL)                    \
3218   (ENUM_IS_SCOPED (TYPE) = (VAL))
3219
3220 #define SET_OPAQUE_ENUM_P(TYPE, VAL)                    \
3221   (ENUM_IS_OPAQUE (TYPE) = (VAL))
3222
3223 #define OPAQUE_ENUM_P(TYPE)                             \
3224   (TREE_CODE (TYPE) == ENUMERAL_TYPE && ENUM_IS_OPAQUE (TYPE))
3225
3226 /* Determines whether an ENUMERAL_TYPE has an explicit
3227    underlying type.  */
3228 #define ENUM_FIXED_UNDERLYING_TYPE_P(NODE) (TYPE_LANG_FLAG_5 (NODE))
3229
3230 /* Returns the underlying type of the given enumeration type. The
3231    underlying type is determined in different ways, depending on the
3232    properties of the enum:
3233
3234      - In C++0x, the underlying type can be explicitly specified, e.g.,
3235
3236          enum E1 : char { ... } // underlying type is char
3237
3238      - In a C++0x scoped enumeration, the underlying type is int
3239        unless otherwises specified:
3240
3241          enum class E2 { ... } // underlying type is int
3242
3243      - Otherwise, the underlying type is determined based on the
3244        values of the enumerators. In this case, the
3245        ENUM_UNDERLYING_TYPE will not be set until after the definition
3246        of the enumeration is completed by finish_enum.  */
3247 #define ENUM_UNDERLYING_TYPE(TYPE) \
3248   TREE_TYPE (ENUMERAL_TYPE_CHECK (TYPE))
3249
3250 /* [dcl.init.aggr]
3251
3252    An aggregate is an array or a class with no user-provided
3253    constructors, no brace-or-equal-initializers for non-static data
3254    members, no private or protected non-static data members, no
3255    base classes, and no virtual functions.
3256
3257    As an extension, we also treat vectors as aggregates.  Keep these
3258    checks in ascending code order.  */
3259 #define CP_AGGREGATE_TYPE_P(TYPE)                               \
3260   (TREE_CODE (TYPE) == VECTOR_TYPE                              \
3261    ||TREE_CODE (TYPE) == ARRAY_TYPE                             \
3262    || (CLASS_TYPE_P (TYPE) && !CLASSTYPE_NON_AGGREGATE (TYPE)))
3263
3264 /* Nonzero for a class type means that the class type has a
3265    user-declared constructor.  */
3266 #define TYPE_HAS_USER_CONSTRUCTOR(NODE) (TYPE_LANG_FLAG_1 (NODE))
3267
3268 /* When appearing in an INDIRECT_REF, it means that the tree structure
3269    underneath is actually a call to a constructor.  This is needed
3270    when the constructor must initialize local storage (which can
3271    be automatically destroyed), rather than allowing it to allocate
3272    space from the heap.
3273
3274    When appearing in a SAVE_EXPR, it means that underneath
3275    is a call to a constructor.
3276
3277    When appearing in a CONSTRUCTOR, the expression is a
3278    compound literal.
3279
3280    When appearing in a FIELD_DECL, it means that this field
3281    has been duly initialized in its constructor.  */
3282 #define TREE_HAS_CONSTRUCTOR(NODE) (TREE_LANG_FLAG_4 (NODE))
3283
3284 /* True if NODE is a brace-enclosed initializer.  */
3285 #define BRACE_ENCLOSED_INITIALIZER_P(NODE) \
3286   (TREE_CODE (NODE) == CONSTRUCTOR && TREE_TYPE (NODE) == init_list_type_node)
3287
3288 /* True if NODE is a compound-literal, i.e., a brace-enclosed
3289    initializer cast to a particular type.  */
3290 #define COMPOUND_LITERAL_P(NODE) \
3291   (TREE_CODE (NODE) == CONSTRUCTOR && TREE_HAS_CONSTRUCTOR (NODE))
3292
3293 #define EMPTY_CONSTRUCTOR_P(NODE) (TREE_CODE (NODE) == CONSTRUCTOR \
3294                                    && VEC_empty (constructor_elt, \
3295                                                  CONSTRUCTOR_ELTS (NODE)) \
3296                                    && !TREE_HAS_CONSTRUCTOR (NODE))
3297
3298 /* True if NODE is a init-list used as a direct-initializer, i.e.
3299    B b{1,2}, not B b({1,2}) or B b = {1,2}.  */
3300 #define CONSTRUCTOR_IS_DIRECT_INIT(NODE) (TREE_LANG_FLAG_0 (CONSTRUCTOR_CHECK (NODE)))
3301
3302 /* True if NODE represents a conversion for direct-initialization in a
3303    template.  Set by perform_implicit_conversion_flags.  */
3304 #define IMPLICIT_CONV_EXPR_DIRECT_INIT(NODE) \
3305   (TREE_LANG_FLAG_0 (IMPLICIT_CONV_EXPR_CHECK (NODE)))
3306
3307 /* Nonzero means that an object of this type can not be initialized using
3308    an initializer list.  */
3309 #define CLASSTYPE_NON_AGGREGATE(NODE) \
3310   (LANG_TYPE_CLASS_CHECK (NODE)->non_aggregate)
3311 #define TYPE_NON_AGGREGATE_CLASS(NODE) \
3312   (CLASS_TYPE_P (NODE) && CLASSTYPE_NON_AGGREGATE (NODE))
3313
3314 /* Nonzero if there is a non-trivial X::op=(cv X&) for this class.  */
3315 #define TYPE_HAS_COMPLEX_COPY_ASSIGN(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_copy_assign)
3316
3317 /* Nonzero if there is a non-trivial X::X(cv X&) for this class.  */
3318 #define TYPE_HAS_COMPLEX_COPY_CTOR(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_copy_ctor)
3319
3320 /* Nonzero if there is a non-trivial X::op=(X&&) for this class.  */
3321 #define TYPE_HAS_COMPLEX_MOVE_ASSIGN(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_move_assign)
3322
3323 /* Nonzero if there is a non-trivial X::X(X&&) for this class.  */
3324 #define TYPE_HAS_COMPLEX_MOVE_CTOR(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_move_ctor)
3325
3326 /* Nonzero if there is a non-trivial default constructor for this class.  */
3327 #define TYPE_HAS_COMPLEX_DFLT(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_complex_dflt)
3328
3329 /* Nonzero if TYPE has a trivial destructor.  From [class.dtor]:
3330
3331      A destructor is trivial if it is an implicitly declared
3332      destructor and if:
3333
3334        - all of the direct base classes of its class have trivial
3335          destructors,
3336
3337        - for all of the non-static data members of its class that are
3338          of class type (or array thereof), each such class has a
3339          trivial destructor.  */
3340 #define TYPE_HAS_TRIVIAL_DESTRUCTOR(NODE) \
3341   (!TYPE_HAS_NONTRIVIAL_DESTRUCTOR (NODE))
3342
3343 /* Nonzero for _TYPE node means that this type does not have a trivial
3344    destructor.  Therefore, destroying an object of this type will
3345    involve a call to a destructor.  This can apply to objects of
3346    ARRAY_TYPE is the type of the elements needs a destructor.  */
3347 #define TYPE_HAS_NONTRIVIAL_DESTRUCTOR(NODE) \
3348   (TYPE_LANG_FLAG_4 (NODE))
3349
3350 /* Nonzero for class type means that the default constructor is trivial.  */
3351 #define TYPE_HAS_TRIVIAL_DFLT(NODE) \
3352   (TYPE_HAS_DEFAULT_CONSTRUCTOR (NODE) && ! TYPE_HAS_COMPLEX_DFLT (NODE))
3353
3354 /* Nonzero for class type means that copy initialization of this type can use
3355    a bitwise copy.  */
3356 #define TYPE_HAS_TRIVIAL_COPY_CTOR(NODE) \
3357   (TYPE_HAS_COPY_CTOR (NODE) && ! TYPE_HAS_COMPLEX_COPY_CTOR (NODE))
3358
3359 /* Nonzero for class type means that assignment of this type can use
3360    a bitwise copy.  */
3361 #define TYPE_HAS_TRIVIAL_COPY_ASSIGN(NODE) \
3362   (TYPE_HAS_COPY_ASSIGN (NODE) && ! TYPE_HAS_COMPLEX_COPY_ASSIGN (NODE))
3363
3364 /* Returns true if NODE is a pointer-to-data-member.  */
3365 #define TYPE_PTRMEM_P(NODE)                     \
3366   (TREE_CODE (NODE) == OFFSET_TYPE)
3367 /* Returns true if NODE is a pointer.  */
3368 #define TYPE_PTR_P(NODE)                        \
3369   (TREE_CODE (NODE) == POINTER_TYPE)
3370
3371 /* Returns true if NODE is an object type:
3372
3373      [basic.types]
3374
3375      An object type is a (possibly cv-qualified) type that is not a
3376      function type, not a reference type, and not a void type.
3377
3378    Keep these checks in ascending order, for speed.  */
3379 #define TYPE_OBJ_P(NODE)                        \
3380   (TREE_CODE (NODE) != REFERENCE_TYPE           \
3381    && TREE_CODE (NODE) != VOID_TYPE             \
3382    && TREE_CODE (NODE) != FUNCTION_TYPE         \
3383    && TREE_CODE (NODE) != METHOD_TYPE)
3384
3385 /* Returns true if NODE is a pointer to an object.  Keep these checks
3386    in ascending tree code order.  */
3387 #define TYPE_PTROB_P(NODE)                                      \
3388   (TYPE_PTR_P (NODE) && TYPE_OBJ_P (TREE_TYPE (NODE)))
3389
3390 /* Returns true if NODE is a reference to an object.  Keep these checks
3391    in ascending tree code order.  */
3392 #define TYPE_REF_OBJ_P(NODE)                                    \
3393   (TREE_CODE (NODE) == REFERENCE_TYPE && TYPE_OBJ_P (TREE_TYPE (NODE)))
3394
3395 /* Returns true if NODE is a pointer to an object, or a pointer to
3396    void.  Keep these checks in ascending tree code order.  */
3397 #define TYPE_PTROBV_P(NODE)                                     \
3398   (TYPE_PTR_P (NODE)                                            \
3399    && !(TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE           \
3400         || TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE))
3401
3402 /* Returns true if NODE is a pointer to function.  */
3403 #define TYPE_PTRFN_P(NODE)                              \
3404   (TREE_CODE (NODE) == POINTER_TYPE                     \
3405    && TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE)
3406
3407 /* Returns true if NODE is a reference to function.  */
3408 #define TYPE_REFFN_P(NODE)                              \
3409   (TREE_CODE (NODE) == REFERENCE_TYPE                   \
3410    && TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE)
3411
3412 /* Nonzero for _TYPE node means that this type is a pointer to member
3413    function type.  */
3414 #define TYPE_PTRMEMFUNC_P(NODE)         \
3415   (TREE_CODE (NODE) == RECORD_TYPE      \
3416    && TYPE_LANG_SPECIFIC (NODE)         \
3417    && TYPE_PTRMEMFUNC_FLAG (NODE))
3418
3419 #define TYPE_PTRMEMFUNC_FLAG(NODE) \
3420   (LANG_TYPE_CLASS_CHECK (NODE)->ptrmemfunc_flag)
3421
3422 /* Returns true if NODE is a pointer-to-member.  */
3423 #define TYPE_PTR_TO_MEMBER_P(NODE) \
3424   (TYPE_PTRMEM_P (NODE) || TYPE_PTRMEMFUNC_P (NODE))
3425
3426 /* Indicates when overload resolution may resolve to a pointer to
3427    member function. [expr.unary.op]/3 */
3428 #define PTRMEM_OK_P(NODE) \
3429   TREE_LANG_FLAG_0 (TREE_CHECK3 ((NODE), ADDR_EXPR, OFFSET_REF, SCOPE_REF))
3430
3431 /* Get the POINTER_TYPE to the METHOD_TYPE associated with this
3432    pointer to member function.  TYPE_PTRMEMFUNC_P _must_ be true,
3433    before using this macro.  */
3434 #define TYPE_PTRMEMFUNC_FN_TYPE(NODE) \
3435   (TREE_TYPE (TYPE_FIELDS (NODE)))
3436
3437 /* Returns `A' for a type like `int (A::*)(double)' */
3438 #define TYPE_PTRMEMFUNC_OBJECT_TYPE(NODE) \
3439   TYPE_METHOD_BASETYPE (TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (NODE)))
3440
3441 /* These are use to manipulate the canonical RECORD_TYPE from the
3442    hashed POINTER_TYPE, and can only be used on the POINTER_TYPE.  */
3443 #define TYPE_GET_PTRMEMFUNC_TYPE(NODE) \
3444   (TYPE_LANG_SPECIFIC (NODE) ? LANG_TYPE_PTRMEM_CHECK (NODE)->record : NULL)
3445 #define TYPE_SET_PTRMEMFUNC_TYPE(NODE, VALUE)                           \
3446   do {                                                                  \
3447     if (TYPE_LANG_SPECIFIC (NODE) == NULL)                              \
3448       {                                                                 \
3449         TYPE_LANG_SPECIFIC (NODE) = ggc_alloc_cleared_lang_type         \
3450          (sizeof (struct lang_type_ptrmem));                            \
3451         TYPE_LANG_SPECIFIC (NODE)->u.ptrmem.h.is_lang_type_class = 0;   \
3452       }                                                                 \
3453     TYPE_LANG_SPECIFIC (NODE)->u.ptrmem.record = (VALUE);               \
3454   } while (0)
3455
3456 /* For a pointer-to-member type of the form `T X::*', this is `X'.
3457    For a type like `void (X::*)() const', this type is `X', not `const
3458    X'.  To get at the `const X' you have to look at the
3459    TYPE_PTRMEM_POINTED_TO_TYPE; there, the first parameter will have
3460    type `const X*'.  */
3461 #define TYPE_PTRMEM_CLASS_TYPE(NODE)                    \
3462   (TYPE_PTRMEM_P (NODE)                                 \
3463    ? TYPE_OFFSET_BASETYPE (NODE)                \
3464    : TYPE_PTRMEMFUNC_OBJECT_TYPE (NODE))
3465
3466 /* For a pointer-to-member type of the form `T X::*', this is `T'.  */
3467 #define TYPE_PTRMEM_POINTED_TO_TYPE(NODE)               \
3468    (TYPE_PTRMEM_P (NODE)                                \
3469     ? TREE_TYPE (NODE)                                  \
3470     : TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (NODE)))
3471
3472 /* For a pointer-to-member constant `X::Y' this is the RECORD_TYPE for
3473    `X'.  */
3474 #define PTRMEM_CST_CLASS(NODE) \
3475   TYPE_PTRMEM_CLASS_TYPE (TREE_TYPE (PTRMEM_CST_CHECK (NODE)))
3476
3477 /* For a pointer-to-member constant `X::Y' this is the _DECL for
3478    `Y'.  */
3479 #define PTRMEM_CST_MEMBER(NODE) (((ptrmem_cst_t)PTRMEM_CST_CHECK (NODE))->member)
3480
3481 /* The expression in question for a TYPEOF_TYPE.  */
3482 #define TYPEOF_TYPE_EXPR(NODE) (TYPE_VALUES_RAW (TYPEOF_TYPE_CHECK (NODE)))
3483
3484 /* The type in question for an UNDERLYING_TYPE.  */
3485 #define UNDERLYING_TYPE_TYPE(NODE) \
3486   (TYPE_VALUES_RAW (UNDERLYING_TYPE_CHECK (NODE)))
3487
3488 /* The type in question for BASES.  */
3489 #define BASES_TYPE(NODE) \
3490   (TYPE_VALUES_RAW (BASES_CHECK (NODE)))
3491
3492 #define BASES_DIRECT(NODE) \
3493   TREE_LANG_FLAG_0 (BASES_CHECK (NODE))
3494
3495 /* The expression in question for a DECLTYPE_TYPE.  */
3496 #define DECLTYPE_TYPE_EXPR(NODE) (TYPE_VALUES_RAW (DECLTYPE_TYPE_CHECK (NODE)))
3497
3498 /* Whether the DECLTYPE_TYPE_EXPR of NODE was originally parsed as an
3499    id-expression or a member-access expression. When false, it was
3500    parsed as a full expression.  */
3501 #define DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P(NODE) \
3502   (DECLTYPE_TYPE_CHECK (NODE))->type_common.string_flag
3503
3504 /* These flags indicate that we want different semantics from normal
3505    decltype: lambda capture just drops references, lambda proxies look