OSDN Git Service

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