1 /* This file contains the definitions and documentation for the
2 additional tree codes used in the GNU C++ compiler (see tree.def
3 for the standard codes).
4 Copyright (C) 1987, 1988, 1990, 1993, 1997, 1998, 2003, 2004, 2005,
5 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2010, 2011
6 Free Software Foundation, Inc.
7 Hacked by Michael Tiemann (tiemann@cygnus.com)
9 This file is part of GCC.
11 GCC is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3, or (at your option)
16 GCC is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with GCC; see the file COPYING3. If not see
23 <http://www.gnu.org/licenses/>. */
26 /* An OFFSET_REF is used in two situations:
28 1. An expression of the form `A::m' where `A' is a class and `m' is
29 a non-static member. In this case, operand 0 will be a TYPE
30 (corresponding to `A') and operand 1 will be a FIELD_DECL,
31 BASELINK, or TEMPLATE_ID_EXPR (corresponding to `m').
33 The expression is a pointer-to-member if its address is taken,
34 but simply denotes a member of the object if its address is not
37 This form is only used during the parsing phase; once semantic
38 analysis has taken place they are eliminated.
40 2. An expression of the form `x.*p'. In this case, operand 0 will
41 be an expression corresponding to `x' and operand 1 will be an
42 expression with pointer-to-member type. */
43 DEFTREECODE (OFFSET_REF, "offset_ref", tcc_reference, 2)
45 /* A pointer-to-member constant. For a pointer-to-member constant
46 `X::Y' The PTRMEM_CST_CLASS is the RECORD_TYPE for `X' and the
47 PTRMEM_CST_MEMBER is the _DECL for `Y'. */
48 DEFTREECODE (PTRMEM_CST, "ptrmem_cst", tcc_constant, 0)
50 /* For NEW_EXPR, operand 0 is the placement list.
51 Operand 1 is the new-declarator.
52 Operand 2 is the number of elements in the array.
53 Operand 3 is the initializer. */
54 DEFTREECODE (NEW_EXPR, "nw_expr", tcc_expression, 4)
55 DEFTREECODE (VEC_NEW_EXPR, "vec_nw_expr", tcc_expression, 3)
57 /* For DELETE_EXPR, operand 0 is the store to be destroyed.
58 Operand 1 is the value to pass to the destroying function
59 saying whether the store should be deallocated as well. */
60 DEFTREECODE (DELETE_EXPR, "dl_expr", tcc_expression, 2)
61 DEFTREECODE (VEC_DELETE_EXPR, "vec_dl_expr", tcc_expression, 2)
63 /* Value is reference to particular overloaded class method.
64 Operand 0 is the class, operand 1 is the field
65 The COMPLEXITY field holds the class level (usually 0). */
66 DEFTREECODE (SCOPE_REF, "scope_ref", tcc_reference, 2)
68 /* When composing an object with a member, this is the result.
69 Operand 0 is the object. Operand 1 is the member (usually
70 a dereferenced pointer to member). */
71 DEFTREECODE (MEMBER_REF, "member_ref", tcc_reference, 2)
73 /* Type conversion operator in C++. TREE_TYPE is type that this
74 operator converts to. Operand is expression to be converted. */
75 DEFTREECODE (TYPE_EXPR, "type_expr", tcc_expression, 1)
77 /* AGGR_INIT_EXPRs have a variably-sized representation similar to
78 that of CALL_EXPRs. Operand 0 is an INTEGER_CST node containing the
79 operand count, operand 1 is the function which performs initialization,
80 operand 2 is the slot which was allocated for this expression, and
81 the remaining operands are the arguments to the initialization function. */
82 DEFTREECODE (AGGR_INIT_EXPR, "aggr_init_expr", tcc_vl_exp, 3)
84 /* Initialization of an array from another array, expressed at a high level
85 so that it works with TARGET_EXPR. Operand 0 is the target, operand 1
86 is the initializer. */
87 DEFTREECODE (VEC_INIT_EXPR, "vec_init_expr", tcc_expression, 2)
89 /* A throw expression. operand 0 is the expression, if there was one,
90 else it is NULL_TREE. */
91 DEFTREECODE (THROW_EXPR, "throw_expr", tcc_expression, 1)
93 /* An empty class object. The TREE_TYPE gives the class type. We use
94 these to avoid actually creating instances of the empty classes. */
95 DEFTREECODE (EMPTY_CLASS_EXPR, "empty_class_expr", tcc_expression, 0)
97 /* A reference to a member function or member functions from a base
98 class. BASELINK_FUNCTIONS gives the FUNCTION_DECL,
99 TEMPLATE_DECL, OVERLOAD, or TEMPLATE_ID_EXPR corresponding to the
100 functions. BASELINK_BINFO gives the base from which the functions
101 come, i.e., the base to which the `this' pointer must be converted
102 before the functions are called. BASELINK_ACCESS_BINFO gives the
103 base used to name the functions.
105 A BASELINK is an expression; the TREE_TYPE of the BASELINK gives
106 the type of the expression. This type is either a FUNCTION_TYPE,
107 METHOD_TYPE, or `unknown_type_node' indicating that the function is
109 DEFTREECODE (BASELINK, "baselink", tcc_exceptional, 0)
111 /* Template definition. The following fields have the specified uses,
112 although there are other macros in cp-tree.h that should be used for
114 DECL_ARGUMENTS template parm vector
115 DECL_TEMPLATE_INFO template text &c
116 DECL_VINDEX list of instantiations already produced;
117 only done for functions so far
119 DECL_INITIAL associated templates (methods &c)
120 DECL_TEMPLATE_RESULT null
121 For non-class templates:
122 TREE_TYPE type of object to be constructed
123 DECL_TEMPLATE_RESULT decl for object to be created
124 (e.g., FUNCTION_DECL with tmpl parms used)
126 DEFTREECODE (TEMPLATE_DECL, "template_decl", tcc_declaration, 0)
128 /* Index into a template parameter list. The TEMPLATE_PARM_IDX gives
129 the index (from 0) of the parameter, while the TEMPLATE_PARM_LEVEL
130 gives the level (from 1) of the parameter.
134 template <class T> // Index 0, Level 1.
137 template <class U, // Index 0, Level 2.
138 class V> // Index 1, Level 2.
142 The DESCENDANTS will be a chain of TEMPLATE_PARM_INDEXs descended
143 from this one. The first descendant will have the same IDX, but
144 its LEVEL will be one less. The TREE_CHAIN field is used to chain
145 together the descendants. The TEMPLATE_PARM_DECL is the
146 declaration of this parameter, either a TYPE_DECL or CONST_DECL.
147 The TEMPLATE_PARM_ORIG_LEVEL is the LEVEL of the most distant
148 parent, i.e., the LEVEL that the parameter originally had when it
149 was declared. For example, if we instantiate S<int>, we will have:
153 template <class U, // Index 0, Level 1, Orig Level 2
154 class V> // Index 1, Level 1, Orig Level 2
158 The LEVEL is the level of the parameter when we are worrying about
159 the types of things; the ORIG_LEVEL is the level when we are
160 worrying about instantiating things. */
161 DEFTREECODE (TEMPLATE_PARM_INDEX, "template_parm_index", tcc_exceptional, 0)
163 /* Index into a template parameter list for template template parameters.
164 This parameter must be a type. The TYPE_FIELDS value will be a
167 It is used without template arguments like TT in C<TT>,
168 TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO is NULL_TREE
169 and TYPE_NAME is a TEMPLATE_DECL. */
170 DEFTREECODE (TEMPLATE_TEMPLATE_PARM, "template_template_parm", tcc_type, 0)
172 /* The ordering of the following codes is optimized for the checking
173 macros in tree.h. Changing the order will degrade the speed of the
174 compiler. TEMPLATE_TYPE_PARM, TYPENAME_TYPE, TYPEOF_TYPE,
175 BOUND_TEMPLATE_TEMPLATE_PARM. */
177 /* Index into a template parameter list. This parameter must be a type.
178 The type.values field will be a TEMPLATE_PARM_INDEX. */
179 DEFTREECODE (TEMPLATE_TYPE_PARM, "template_type_parm", tcc_type, 0)
181 /* A type designated by `typename T::t'. TYPE_CONTEXT is `T',
182 TYPE_NAME is an IDENTIFIER_NODE for `t'. If the type was named via
183 template-id, TYPENAME_TYPE_FULLNAME will hold the TEMPLATE_ID_EXPR.
184 TREE_TYPE is always NULL. */
185 DEFTREECODE (TYPENAME_TYPE, "typename_type", tcc_type, 0)
187 /* A type designated by `__typeof (expr)'. TYPEOF_TYPE_EXPR is the
188 expression in question. */
189 DEFTREECODE (TYPEOF_TYPE, "typeof_type", tcc_type, 0)
191 /* Like TEMPLATE_TEMPLATE_PARM it is used with bound template arguments
193 In this case, TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO contains the
194 template name and its bound arguments. TYPE_NAME is a TYPE_DECL. */
195 DEFTREECODE (BOUND_TEMPLATE_TEMPLATE_PARM, "bound_template_template_parm",
198 /* For template template argument of the form `T::template C'.
199 TYPE_CONTEXT is `T', the template parameter dependent object.
200 TYPE_NAME is an IDENTIFIER_NODE for `C', the member class template. */
201 DEFTREECODE (UNBOUND_CLASS_TEMPLATE, "unbound_class_template", tcc_type, 0)
203 /* A using declaration. USING_DECL_SCOPE contains the specified
204 scope. In a member using decl, unless DECL_DEPENDENT_P is true,
205 USING_DECL_DECLS contains the _DECL or OVERLOAD so named. This is
206 not an alias, but is later expanded into multiple aliases. */
207 DEFTREECODE (USING_DECL, "using_decl", tcc_declaration, 0)
209 /* A using directive. The operand is USING_STMT_NAMESPACE. */
210 DEFTREECODE (USING_STMT, "using_stmt", tcc_statement, 1)
212 /* An un-parsed default argument. Holds a vector of input tokens and
213 a vector of places where the argument was instantiated before
214 parsing had occurred. */
215 DEFTREECODE (DEFAULT_ARG, "default_arg", tcc_exceptional, 0)
217 /* An uninstantiated noexcept-specification. DEFERRED_NOEXCEPT_PATTERN is
218 the pattern from the template, and DEFERRED_NOEXCEPT_ARGS are the
219 template arguments to substitute into the pattern when needed. */
220 DEFTREECODE (DEFERRED_NOEXCEPT, "deferred_noexcept", tcc_exceptional, 0)
222 /* A template-id, like foo<int>. The first operand is the template.
223 The second is NULL if there are no explicit arguments, or a
224 TREE_VEC of arguments. The template will be a FUNCTION_DECL,
225 TEMPLATE_DECL, or an OVERLOAD. If the template-id refers to a
226 member template, the template may be an IDENTIFIER_NODE. */
227 DEFTREECODE (TEMPLATE_ID_EXPR, "template_id_expr", tcc_expression, 2)
229 /* A list-like node for chaining overloading candidates. TREE_TYPE is
230 the original name, and the parameter is the FUNCTION_DECL. */
231 DEFTREECODE (OVERLOAD, "overload", tcc_exceptional, 0)
233 /* A pseudo-destructor, of the form "OBJECT.~DESTRUCTOR" or
234 "OBJECT.SCOPE::~DESTRUCTOR. The first operand is the OBJECT. The
235 second operand (if non-NULL) is the SCOPE. The third operand is
236 the TYPE node corresponding to the DESTRUCTOR. The type of the
237 first operand will always be a scalar type.
239 The type of a PSEUDO_DTOR_EXPR is always "void", even though it can
240 be used as if it were a zero-argument function. We handle the
241 function-call case specially, and giving it "void" type prevents it
242 being used in expressions in ways that are not permitted. */
243 DEFTREECODE (PSEUDO_DTOR_EXPR, "pseudo_dtor_expr", tcc_expression, 3)
245 /* A whole bunch of tree codes for the initial, superficial parsing of
247 DEFTREECODE (MODOP_EXPR, "modop_expr", tcc_expression, 3)
248 DEFTREECODE (CAST_EXPR, "cast_expr", tcc_unary, 1)
249 DEFTREECODE (REINTERPRET_CAST_EXPR, "reinterpret_cast_expr", tcc_unary, 1)
250 DEFTREECODE (CONST_CAST_EXPR, "const_cast_expr", tcc_unary, 1)
251 DEFTREECODE (STATIC_CAST_EXPR, "static_cast_expr", tcc_unary, 1)
252 DEFTREECODE (DYNAMIC_CAST_EXPR, "dynamic_cast_expr", tcc_unary, 1)
253 DEFTREECODE (IMPLICIT_CONV_EXPR, "implicit_conv_expr", tcc_unary, 1)
254 DEFTREECODE (DOTSTAR_EXPR, "dotstar_expr", tcc_expression, 2)
255 DEFTREECODE (TYPEID_EXPR, "typeid_expr", tcc_expression, 1)
256 DEFTREECODE (NOEXCEPT_EXPR, "noexcept_expr", tcc_unary, 1)
258 /* A placeholder for an expression that is not type-dependent, but
259 does occur in a template. When an expression that is not
260 type-dependent appears in a larger expression, we must compute the
261 type of that larger expression. That computation would normally
262 modify the original expression, which would change the mangling of
263 that expression if it appeared in a template argument list. In
264 that situation, we create a NON_DEPENDENT_EXPR to take the place of
265 the original expression. The expression is the only operand -- it
266 is only needed for diagnostics. */
267 DEFTREECODE (NON_DEPENDENT_EXPR, "non_dependent_expr", tcc_expression, 1)
269 /* CTOR_INITIALIZER is a placeholder in template code for a call to
270 setup_vtbl_pointer (and appears in all functions, not just ctors). */
271 DEFTREECODE (CTOR_INITIALIZER, "ctor_initializer", tcc_expression, 1)
273 DEFTREECODE (TRY_BLOCK, "try_block", tcc_statement, 2)
275 DEFTREECODE (EH_SPEC_BLOCK, "eh_spec_block", tcc_statement, 2)
277 /* A HANDLER wraps a catch handler for the HANDLER_TYPE. If this is
278 CATCH_ALL_TYPE, then the handler catches all types. The declaration of
279 the catch variable is in HANDLER_PARMS, and the body block in
281 DEFTREECODE (HANDLER, "handler", tcc_statement, 2)
283 /* A MUST_NOT_THROW_EXPR wraps an expression that may not
284 throw, and must call terminate if it does. */
285 DEFTREECODE (MUST_NOT_THROW_EXPR, "must_not_throw_expr", tcc_expression, 1)
287 /* A CLEANUP_STMT marks the point at which a declaration is fully
288 constructed. The CLEANUP_EXPR is run on behalf of CLEANUP_DECL
289 when CLEANUP_BODY completes. */
290 DEFTREECODE (CLEANUP_STMT, "cleanup_stmt", tcc_statement, 3)
292 /* Represents an 'if' statement. The operands are IF_COND,
293 THEN_CLAUSE, and ELSE_CLAUSE, and the current scope, respectively. */
294 /* ??? It is currently still necessary to distinguish between IF_STMT
295 and COND_EXPR for the benefit of templates. */
296 DEFTREECODE (IF_STMT, "if_stmt", tcc_statement, 4)
298 /* Used to represent a `for' statement. The operands are
299 FOR_INIT_STMT, FOR_COND, FOR_EXPR, and FOR_BODY, respectively. */
300 DEFTREECODE (FOR_STMT, "for_stmt", tcc_statement, 5)
302 /* Used to represent a range-based `for' statement. The operands are
303 RANGE_FOR_DECL, RANGE_FOR_EXPR, RANGE_FOR_BODY, and RANGE_FOR_SCOPE,
304 respectively. Only used in templates. */
305 DEFTREECODE (RANGE_FOR_STMT, "range_for_stmt", tcc_statement, 4)
307 /* Used to represent a 'while' statement. The operands are WHILE_COND
308 and WHILE_BODY, respectively. */
309 DEFTREECODE (WHILE_STMT, "while_stmt", tcc_statement, 2)
311 /* Used to represent a 'do' statement. The operands are DO_BODY and
312 DO_COND, respectively. */
313 DEFTREECODE (DO_STMT, "do_stmt", tcc_statement, 2)
315 /* Used to represent a 'break' statement. */
316 DEFTREECODE (BREAK_STMT, "break_stmt", tcc_statement, 0)
318 /* Used to represent a 'continue' statement. */
319 DEFTREECODE (CONTINUE_STMT, "continue_stmt", tcc_statement, 0)
321 /* Used to represent a 'switch' statement. The operands are
322 SWITCH_STMT_COND, SWITCH_STMT_BODY, SWITCH_STMT_TYPE, and
323 SWITCH_STMT_SCOPE, respectively. */
324 DEFTREECODE (SWITCH_STMT, "switch_stmt", tcc_statement, 4)
326 /* Used to represent an expression statement. Use `EXPR_STMT_EXPR' to
327 obtain the expression. */
328 DEFTREECODE (EXPR_STMT, "expr_stmt", tcc_expression, 1)
330 DEFTREECODE (TAG_DEFN, "tag_defn", tcc_expression, 0)
332 /* Represents an 'offsetof' expression during template expansion. */
333 DEFTREECODE (OFFSETOF_EXPR, "offsetof_expr", tcc_expression, 1)
335 /* Represents a 'sizeof' expression during template expansion. */
336 DEFTREECODE (SIZEOF_EXPR, "sizeof_expr", tcc_expression, 1)
338 /* Represents the -> operator during template expansion. */
339 DEFTREECODE (ARROW_EXPR, "arrow_expr", tcc_expression, 1)
341 /* Represents an '__alignof__' expression during template
343 DEFTREECODE (ALIGNOF_EXPR, "alignof_expr", tcc_expression, 1)
345 /* Represents an Objective-C++ '@encode' expression during template
347 DEFTREECODE (AT_ENCODE_EXPR, "at_encode_expr", tcc_expression, 1)
349 /* A STMT_EXPR represents a statement-expression during template
350 expansion. This is the GCC extension { ( ... ) }. The
351 STMT_EXPR_STMT is the statement given by the expression. */
352 DEFTREECODE (STMT_EXPR, "stmt_expr", tcc_expression, 1)
354 /* Unary plus. Operand 0 is the expression to which the unary plus
356 DEFTREECODE (UNARY_PLUS_EXPR, "unary_plus_expr", tcc_unary, 1)
358 /** C++0x extensions. */
360 /* A static assertion. This is a C++0x extension.
361 STATIC_ASSERT_CONDITION contains the condition that is being
362 checked. STATIC_ASSERT_MESSAGE contains the message (a string
363 literal) to be displayed if the condition fails to hold. */
364 DEFTREECODE (STATIC_ASSERT, "static_assert", tcc_exceptional, 0)
366 /* Represents an argument pack of types (or templates). An argument
367 pack stores zero or more arguments that will be used to instantiate
370 ARGUMENT_PACK_ARGS retrieves the arguments stored in the argument
374 template<typename... Values>
377 tuple<int, float, double> t;
379 Values is a (template) parameter pack. When tuple<int, float,
380 double> is instantiated, the Values parameter pack is instantiated
381 with the argument pack <int, float, double>. ARGUMENT_PACK_ARGS will
382 be a TREE_VEC containing int, float, and double. */
383 DEFTREECODE (TYPE_ARGUMENT_PACK, "type_argument_pack", tcc_type, 0)
385 /* Represents an argument pack of values, which can be used either for
386 non-type template arguments or function call arguments.
388 NONTYPE_ARGUMENT_PACK plays precisely the same role as
389 TYPE_ARGUMENT_PACK, but will be used for packing non-type template
390 arguments (e.g., "int... Dimensions") or function arguments ("const
392 DEFTREECODE (NONTYPE_ARGUMENT_PACK, "nontype_argument_pack", tcc_expression, 1)
394 /* Represents a type expression that will be expanded into a list of
395 types when instantiated with one or more argument packs.
397 PACK_EXPANSION_PATTERN retrieves the expansion pattern. This is
398 the type or expression that we will substitute into with each
399 argument in an argument pack.
401 SET_PACK_EXPANSION_PATTERN sets the expansion pattern.
403 PACK_EXPANSION_PARAMETER_PACKS contains a TREE_LIST of the parameter
404 packs that are used in this pack expansion.
407 template<typename... Values>
408 struct tied : tuple<Values&...> {
412 The derivation from tuple contains a TYPE_PACK_EXPANSION for the
413 template arguments. Its PACK_EXPANSION_PATTERN is "Values&" and its
414 PACK_EXPANSION_PARAMETER_PACKS will contain "Values". */
415 DEFTREECODE (TYPE_PACK_EXPANSION, "type_pack_expansion", tcc_type, 0)
417 /* Represents an expression that will be expanded into a list of
418 expressions when instantiated with one or more argument packs.
420 EXPR_PACK_EXPANSION plays precisely the same role as TYPE_PACK_EXPANSION,
421 but will be used for expressions. */
422 DEFTREECODE (EXPR_PACK_EXPANSION, "expr_pack_expansion", tcc_expression, 3)
424 /* Selects the Ith parameter out of an argument pack. This node will
425 be used when instantiating pack expansions; see
426 tsubst_pack_expansion.
428 ARGUMENT_PACK_SELECT_FROM_PACK contains the *_ARGUMENT_PACK node
429 from which the argument will be selected.
431 ARGUMENT_PACK_SELECT_INDEX contains the index into the argument
432 pack that will be returned by this ARGUMENT_PACK_SELECT node. The
433 index is a machine integer. */
434 DEFTREECODE (ARGUMENT_PACK_SELECT, "argument_pack_select", tcc_exceptional, 0)
436 /** C++ extensions. */
438 /* Represents a trait expression during template expansion. */
439 DEFTREECODE (TRAIT_EXPR, "trait_expr", tcc_exceptional, 0)
441 /* A lambda expression. This is a C++0x extension.
442 LAMBDA_EXPR_DEFAULT_CAPTURE_MODE is an enum for the default, which may be
444 LAMBDA_EXPR_CAPTURE_LIST holds the capture-list, including `this'.
445 LAMBDA_EXPR_THIS_CAPTURE goes straight to the capture of `this', if it exists.
446 LAMBDA_EXPR_PENDING_PROXIES is a vector of capture proxies which need to
447 be pushed once scope returns to the lambda.
448 LAMBDA_EXPR_MUTABLE_P signals whether this lambda was declared mutable.
449 LAMBDA_EXPR_RETURN_TYPE holds the return type, if it was specified. */
450 DEFTREECODE (LAMBDA_EXPR, "lambda_expr", tcc_exceptional, 0)
452 /* The declared type of an expression. This is a C++0x extension.
453 DECLTYPE_TYPE_EXPR is the expression whose type we are computing.
454 DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P states whether the
455 expression was parsed as an id-expression or a member access
456 expression. When false, it was parsed as a full expression.
457 DECLTYPE_FOR_LAMBDA_CAPTURE is set if we want lambda capture semantics.
458 DECLTYPE_FOR_LAMBDA_RETURN is set if we want lambda return deduction. */
459 DEFTREECODE (DECLTYPE_TYPE, "decltype_type", tcc_type, 0)
461 /* A type designated by `__underlying_type (type)'.
462 UNDERLYING_TYPE_TYPE is the type in question. */
463 DEFTREECODE (UNDERLYING_TYPE, "underlying_type", tcc_type, 0)
465 /* A type designated by one of the bases type traits.
466 BASES_TYPE is the type in question. */
467 DEFTREECODE (BASES, "bases", tcc_type, 0)
469 /* Used to represent the template information stored by template
472 TI_TEMPLATE the template declaration associated to the specialization
473 TI_ARGS the arguments of the template specialization
474 TI_TYPEDEFS_NEEDING_ACCESS_CHECKING the vector of typedefs used in
475 the pattern of the template for which access check is needed at template
476 instantiation time. */
477 DEFTREECODE (TEMPLATE_INFO, "template_info", tcc_exceptional, 0)