cp-tree.def revision 169689
150397Sobrien/* This file contains the definitions and documentation for the 250397Sobrien additional tree codes used in the GNU C++ compiler (see tree.def 350397Sobrien for the standard codes). 4169689Skan Copyright (C) 1987, 1988, 1990, 1993, 1997, 1998, 2003, 2004, 2005, 5169689Skan 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 650397Sobrien Hacked by Michael Tiemann (tiemann@cygnus.com) 750397Sobrien 8132718SkanThis file is part of GCC. 950397Sobrien 10132718SkanGCC is free software; you can redistribute it and/or modify 1150397Sobrienit under the terms of the GNU General Public License as published by 1250397Sobrienthe Free Software Foundation; either version 2, or (at your option) 1350397Sobrienany later version. 1450397Sobrien 15132718SkanGCC is distributed in the hope that it will be useful, 1650397Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of 1750397SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1850397SobrienGNU General Public License for more details. 1950397Sobrien 2050397SobrienYou should have received a copy of the GNU General Public License 21132718Skanalong with GCC; see the file COPYING. If not, write to 22169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor, 23169689SkanBoston, MA 02110-1301, USA. */ 2450397Sobrien 25169689Skan 26117395Skan/* An OFFSET_REF is used in two situations: 27117395Skan 28117395Skan 1. An expression of the form `A::m' where `A' is a class and `m' is 29132718Skan a non-static member. In this case, operand 0 will be a TYPE 30132718Skan (corresponding to `A') and operand 1 will be a FIELD_DECL, 31132718Skan BASELINK, or TEMPLATE_ID_EXPR (corresponding to `m'). 32117395Skan 33117395Skan The expression is a pointer-to-member if its address is taken, 34169689Skan but simply denotes a member of the object if its address is not 35169689Skan taken. 36169689Skan 37132718Skan This form is only used during the parsing phase; once semantic 38132718Skan analysis has taken place they are eliminated. 39117395Skan 40117395Skan 2. An expression of the form `x.*p'. In this case, operand 0 will 41117395Skan be an expression corresponding to `x' and operand 1 will be an 42132718Skan expression with pointer-to-member type. */ 43169689SkanDEFTREECODE (OFFSET_REF, "offset_ref", tcc_reference, 2) 4450397Sobrien 4552284Sobrien/* A pointer-to-member constant. For a pointer-to-member constant 4652284Sobrien `X::Y' The PTRMEM_CST_CLASS is the RECORD_TYPE for `X' and the 4752284Sobrien PTRMEM_CST_MEMBER is the _DECL for `Y'. */ 48169689SkanDEFTREECODE (PTRMEM_CST, "ptrmem_cst", tcc_constant, 0) 4952284Sobrien 5050397Sobrien/* For NEW_EXPR, operand 0 is the placement list. 5150397Sobrien Operand 1 is the new-declarator. 52169689Skan Operand 2 is the number of elements in the array. 53169689Skan Operand 3 is the initializer. */ 54169689SkanDEFTREECODE (NEW_EXPR, "nw_expr", tcc_expression, 4) 55169689SkanDEFTREECODE (VEC_NEW_EXPR, "vec_nw_expr", tcc_expression, 3) 5650397Sobrien 5750397Sobrien/* For DELETE_EXPR, operand 0 is the store to be destroyed. 5850397Sobrien Operand 1 is the value to pass to the destroying function 5950397Sobrien saying whether the store should be deallocated as well. */ 60169689SkanDEFTREECODE (DELETE_EXPR, "dl_expr", tcc_expression, 2) 61169689SkanDEFTREECODE (VEC_DELETE_EXPR, "vec_dl_expr", tcc_expression, 2) 6250397Sobrien 6350397Sobrien/* Value is reference to particular overloaded class method. 64132718Skan Operand 0 is the class, operand 1 is the field 6550397Sobrien The COMPLEXITY field holds the class level (usually 0). */ 66169689SkanDEFTREECODE (SCOPE_REF, "scope_ref", tcc_reference, 2) 6750397Sobrien 6850397Sobrien/* When composing an object with a member, this is the result. 6950397Sobrien Operand 0 is the object. Operand 1 is the member (usually 7050397Sobrien a dereferenced pointer to member). */ 71169689SkanDEFTREECODE (MEMBER_REF, "member_ref", tcc_reference, 2) 7250397Sobrien 7350397Sobrien/* Type conversion operator in C++. TREE_TYPE is type that this 7450397Sobrien operator converts to. Operand is expression to be converted. */ 75169689SkanDEFTREECODE (TYPE_EXPR, "type_expr", tcc_expression, 1) 7650397Sobrien 7750397Sobrien/* For AGGR_INIT_EXPR, operand 0 is function which performs initialization, 7850397Sobrien operand 1 is argument list to initialization function, 7950397Sobrien and operand 2 is the slot which was allocated for this expression. */ 80169689SkanDEFTREECODE (AGGR_INIT_EXPR, "aggr_init_expr", tcc_expression, 3) 8150397Sobrien 8250397Sobrien/* A throw expression. operand 0 is the expression, if there was one, 8350397Sobrien else it is NULL_TREE. */ 84169689SkanDEFTREECODE (THROW_EXPR, "throw_expr", tcc_expression, 1) 8550397Sobrien 8690075Sobrien/* An empty class object. The TREE_TYPE gives the class type. We use 8790075Sobrien these to avoid actually creating instances of the empty classes. */ 88169689SkanDEFTREECODE (EMPTY_CLASS_EXPR, "empty_class_expr", tcc_expression, 0) 8950397Sobrien 90117395Skan/* A reference to a member function or member functions from a base 91117395Skan class. BASELINK_FUNCTIONS gives the FUNCTION_DECL, 92117395Skan TEMPLATE_DECL, OVERLOAD, or TEMPLATE_ID_EXPR corresponding to the 93117395Skan functions. BASELINK_BINFO gives the base from which the functions 94117395Skan come, i.e., the base to which the `this' pointer must be converted 95117395Skan before the functions are called. BASELINK_ACCESS_BINFO gives the 96169689Skan base used to name the functions. 97117395Skan 98117395Skan A BASELINK is an expression; the TREE_TYPE of the BASELINK gives 99117395Skan the type of the expression. This type is either a FUNCTION_TYPE, 100117395Skan METHOD_TYPE, or `unknown_type_node' indicating that the function is 101169689Skan overloaded. */ 102169689SkanDEFTREECODE (BASELINK, "baselink", tcc_exceptional, 0) 103117395Skan 10450397Sobrien/* Template definition. The following fields have the specified uses, 10550397Sobrien although there are other macros in cp-tree.h that should be used for 10650397Sobrien accessing this data. 107169689Skan DECL_ARGUMENTS template parm vector 108169689Skan DECL_TEMPLATE_INFO template text &c 10950397Sobrien DECL_VINDEX list of instantiations already produced; 11050397Sobrien only done for functions so far 11150397Sobrien For class template: 112169689Skan DECL_INITIAL associated templates (methods &c) 113169689Skan DECL_TEMPLATE_RESULT null 11450397Sobrien For non-class templates: 11550397Sobrien TREE_TYPE type of object to be constructed 116169689Skan DECL_TEMPLATE_RESULT decl for object to be created 117169689Skan (e.g., FUNCTION_DECL with tmpl parms used) 11850397Sobrien */ 119169689SkanDEFTREECODE (TEMPLATE_DECL, "template_decl", tcc_declaration, 0) 12050397Sobrien 12150397Sobrien/* Index into a template parameter list. The TEMPLATE_PARM_IDX gives 12250397Sobrien the index (from 0) of the parameter, while the TEMPLATE_PARM_LEVEL 12350397Sobrien gives the level (from 1) of the parameter. 12450397Sobrien 12550397Sobrien Here's an example: 126169689Skan 12750397Sobrien template <class T> // Index 0, Level 1. 12850397Sobrien struct S 12950397Sobrien { 13050397Sobrien template <class U, // Index 0, Level 2. 131169689Skan class V> // Index 1, Level 2. 13250397Sobrien void f(); 133169689Skan }; 13450397Sobrien 13550397Sobrien The DESCENDANTS will be a chain of TEMPLATE_PARM_INDEXs descended 13650397Sobrien from this one. The first descendant will have the same IDX, but 13750397Sobrien its LEVEL will be one less. The TREE_CHAIN field is used to chain 13850397Sobrien together the descendants. The TEMPLATE_PARM_DECL is the 13950397Sobrien declaration of this parameter, either a TYPE_DECL or CONST_DECL. 14050397Sobrien The TEMPLATE_PARM_ORIG_LEVEL is the LEVEL of the most distant 14150397Sobrien parent, i.e., the LEVEL that the parameter originally had when it 14250397Sobrien was declared. For example, if we instantiate S<int>, we will have: 14350397Sobrien 14450397Sobrien struct S<int> 14550397Sobrien { 14650397Sobrien template <class U, // Index 0, Level 1, Orig Level 2 147169689Skan class V> // Index 1, Level 1, Orig Level 2 14850397Sobrien void f(); 14950397Sobrien }; 150169689Skan 15150397Sobrien The LEVEL is the level of the parameter when we are worrying about 15250397Sobrien the types of things; the ORIG_LEVEL is the level when we are 15350397Sobrien worrying about instantiating things. */ 154169689SkanDEFTREECODE (TEMPLATE_PARM_INDEX, "template_parm_index", tcc_exceptional, 0) 15550397Sobrien 15690075Sobrien/* Index into a template parameter list for template template parameters. 157169689Skan This parameter must be a type. The TYPE_FIELDS value will be a 15890075Sobrien TEMPLATE_PARM_INDEX. 15990075Sobrien 160169689Skan It is used without template arguments like TT in C<TT>, 16190075Sobrien TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO is NULL_TREE 16290075Sobrien and TYPE_NAME is a TEMPLATE_DECL. */ 163169689SkanDEFTREECODE (TEMPLATE_TEMPLATE_PARM, "template_template_parm", tcc_type, 0) 16450397Sobrien 165169689Skan/* The ordering of the following codes is optimized for the checking 166169689Skan macros in tree.h. Changing the order will degrade the speed of the 167169689Skan compiler. TEMPLATE_TYPE_PARM, TYPENAME_TYPE, TYPEOF_TYPE, 168169689Skan BOUND_TEMPLATE_TEMPLATE_PARM. */ 16990075Sobrien 170169689Skan/* Index into a template parameter list. This parameter must be a type. 171169689Skan The type.values field will be a TEMPLATE_PARM_INDEX. */ 172169689SkanDEFTREECODE (TEMPLATE_TYPE_PARM, "template_type_parm", tcc_type, 0) 173169689Skan 17452284Sobrien/* A type designated by `typename T::t'. TYPE_CONTEXT is `T', 17552284Sobrien TYPE_NAME is an IDENTIFIER_NODE for `t'. If the type was named via 17652284Sobrien template-id, TYPENAME_TYPE_FULLNAME will hold the TEMPLATE_ID_EXPR. 177169689Skan TREE_TYPE is always NULL. */ 178169689SkanDEFTREECODE (TYPENAME_TYPE, "typename_type", tcc_type, 0) 17950397Sobrien 180169689Skan/* A type designated by `__typeof (expr)'. TYPEOF_TYPE_EXPR is the 181169689Skan expression in question. */ 182169689SkanDEFTREECODE (TYPEOF_TYPE, "typeof_type", tcc_type, 0) 183169689Skan 184169689Skan/* Like TEMPLATE_TEMPLATE_PARM it is used with bound template arguments 185169689Skan like TT<int>. 186169689Skan In this case, TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO contains the 187169689Skan template name and its bound arguments. TYPE_NAME is a TYPE_DECL. */ 188169689SkanDEFTREECODE (BOUND_TEMPLATE_TEMPLATE_PARM, "bound_template_template_parm", 189169689Skan tcc_type, 0) 190169689Skan 19190075Sobrien/* For template template argument of the form `T::template C'. 19290075Sobrien TYPE_CONTEXT is `T', the template parameter dependent object. 19390075Sobrien TYPE_NAME is an IDENTIFIER_NODE for `C', the member class template. */ 194169689SkanDEFTREECODE (UNBOUND_CLASS_TEMPLATE, "unbound_class_template", tcc_type, 0) 19590075Sobrien 196169689Skan/* A using declaration. USING_DECL_SCOPE contains the specified 197169689Skan scope. In a member using decl, unless DECL_DEPENDENT_P is true, 198169689Skan USING_DECL_DECLS contains the _DECL or OVERLOAD so named. This is 199169689Skan not an alias, but is later expanded into multiple aliases. */ 200169689SkanDEFTREECODE (USING_DECL, "using_decl", tcc_declaration, 0) 20152284Sobrien 202169689Skan/* A using directive. The operand is USING_STMT_NAMESPACE. */ 203169689SkanDEFTREECODE (USING_STMT, "using_directive", tcc_statement, 1) 20450397Sobrien 205169689Skan/* An un-parsed default argument. Holds a vector of input tokens and 206169689Skan a vector of places where the argument was instantiated before 207169689Skan parsing had occurred. */ 208169689SkanDEFTREECODE (DEFAULT_ARG, "default_arg", tcc_exceptional, 0) 20990075Sobrien 21052284Sobrien/* A template-id, like foo<int>. The first operand is the template. 211132718Skan The second is NULL if there are no explicit arguments, or a 212132718Skan TREE_VEC of arguments. The template will be a FUNCTION_DECL, 213132718Skan TEMPLATE_DECL, or an OVERLOAD. If the template-id refers to a 214132718Skan member template, the template may be an IDENTIFIER_NODE. */ 215169689SkanDEFTREECODE (TEMPLATE_ID_EXPR, "template_id_expr", tcc_expression, 2) 21650397Sobrien 217169689Skan/* A list-like node for chaining overloading candidates. TREE_TYPE is 21850397Sobrien the original name, and the parameter is the FUNCTION_DECL. */ 219169689SkanDEFTREECODE (OVERLOAD, "overload", tcc_exceptional, 0) 22050397Sobrien 221169689Skan/* A pseudo-destructor, of the form "OBJECT.~DESTRUCTOR" or 222169689Skan "OBJECT.SCOPE::~DESTRUCTOR. The first operand is the OBJECT. The 223169689Skan second operand (if non-NULL) is the SCOPE. The third operand is 224169689Skan the TYPE node corresponding to the DESTRUCTOR. The type of the 225169689Skan first operand will always be a scalar type. 22650397Sobrien 227169689Skan The type of a PSEUDO_DTOR_EXPR is always "void", even though it can 228169689Skan be used as if it were a zero-argument function. We handle the 229169689Skan function-call case specially, and giving it "void" type prevents it 230169689Skan being used in expressions in ways that are not permitted. */ 231169689SkanDEFTREECODE (PSEUDO_DTOR_EXPR, "pseudo_dtor_expr", tcc_expression, 3) 232169689Skan 23350397Sobrien/* A whole bunch of tree codes for the initial, superficial parsing of 23450397Sobrien templates. */ 235169689SkanDEFTREECODE (MODOP_EXPR, "modop_expr", tcc_expression, 3) 236169689SkanDEFTREECODE (CAST_EXPR, "cast_expr", tcc_unary, 1) 237169689SkanDEFTREECODE (REINTERPRET_CAST_EXPR, "reinterpret_cast_expr", tcc_unary, 1) 238169689SkanDEFTREECODE (CONST_CAST_EXPR, "const_cast_expr", tcc_unary, 1) 239169689SkanDEFTREECODE (STATIC_CAST_EXPR, "static_cast_expr", tcc_unary, 1) 240169689SkanDEFTREECODE (DYNAMIC_CAST_EXPR, "dynamic_cast_expr", tcc_unary, 1) 241169689SkanDEFTREECODE (DOTSTAR_EXPR, "dotstar_expr", tcc_expression, 2) 242169689SkanDEFTREECODE (TYPEID_EXPR, "typeid_expr", tcc_expression, 1) 24350397Sobrien 244132718Skan/* A placeholder for an expression that is not type-dependent, but 245132718Skan does occur in a template. When an expression that is not 246132718Skan type-dependent appears in a larger expression, we must compute the 247132718Skan type of that larger expression. That computation would normally 248132718Skan modify the original expression, which would change the mangling of 249132718Skan that expression if it appeared in a template argument list. In 250132718Skan that situation, we create a NON_DEPENDENT_EXPR to take the place of 251132718Skan the original expression. The expression is the only operand -- it 252169689Skan is only needed for diagnostics. */ 253169689SkanDEFTREECODE (NON_DEPENDENT_EXPR, "non_dependent_expr", tcc_expression, 1) 254132718Skan 25590075Sobrien/* CTOR_INITIALIZER is a placeholder in template code for a call to 25690075Sobrien setup_vtbl_pointer (and appears in all functions, not just ctors). */ 257169689SkanDEFTREECODE (CTOR_INITIALIZER, "ctor_initializer", tcc_expression, 1) 258169689Skan 259169689SkanDEFTREECODE (TRY_BLOCK, "try_block", tcc_statement, 2) 260169689Skan 261169689SkanDEFTREECODE (EH_SPEC_BLOCK, "eh_spec_block", tcc_statement, 2) 262169689Skan 26390075Sobrien/* A HANDLER wraps a catch handler for the HANDLER_TYPE. If this is 26490075Sobrien CATCH_ALL_TYPE, then the handler catches all types. The declaration of 26590075Sobrien the catch variable is in HANDLER_PARMS, and the body block in 26690075Sobrien HANDLER_BODY. */ 267169689SkanDEFTREECODE (HANDLER, "handler", tcc_statement, 2) 26850397Sobrien 26990075Sobrien/* A MUST_NOT_THROW_EXPR wraps an expression that may not 27090075Sobrien throw, and must call terminate if it does. */ 271169689SkanDEFTREECODE (MUST_NOT_THROW_EXPR, "must_not_throw_expr", tcc_expression, 1) 27290075Sobrien 273169689Skan/* A CLEANUP_STMT marks the point at which a declaration is fully 274169689Skan constructed. The CLEANUP_EXPR is run on behalf of CLEANUP_DECL 275169689Skan when CLEANUP_BODY completes. */ 276169689SkanDEFTREECODE (CLEANUP_STMT, "cleanup_stmt", tcc_statement, 3) 27750397Sobrien 278169689Skan/* Represents an 'if' statement. The operands are IF_COND, 279169689Skan THEN_CLAUSE, and ELSE_CLAUSE, respectively. */ 280169689Skan/* ??? It is currently still necessary to distinguish between IF_STMT 281169689Skan and COND_EXPR for the benefit of templates. */ 282169689SkanDEFTREECODE (IF_STMT, "if_stmt", tcc_statement, 3) 28350397Sobrien 284169689Skan/* Used to represent a `for' statement. The operands are 285169689Skan FOR_INIT_STMT, FOR_COND, FOR_EXPR, and FOR_BODY, respectively. */ 286169689SkanDEFTREECODE (FOR_STMT, "for_stmt", tcc_statement, 4) 287117395Skan 288169689Skan/* Used to represent a 'while' statement. The operands are WHILE_COND 289169689Skan and WHILE_BODY, respectively. */ 290169689SkanDEFTREECODE (WHILE_STMT, "while_stmt", tcc_statement, 2) 29150397Sobrien 292169689Skan/* Used to represent a 'do' statement. The operands are DO_BODY and 293169689Skan DO_COND, respectively. */ 294169689SkanDEFTREECODE (DO_STMT, "do_stmt", tcc_statement, 2) 295169689Skan 296169689Skan/* Used to represent a 'break' statement. */ 297169689SkanDEFTREECODE (BREAK_STMT, "break_stmt", tcc_statement, 0) 298169689Skan 299169689Skan/* Used to represent a 'continue' statement. */ 300169689SkanDEFTREECODE (CONTINUE_STMT, "continue_stmt", tcc_statement, 0) 301169689Skan 302169689Skan/* Used to represent a 'switch' statement. The operands are 303169689Skan SWITCH_STMT_COND, SWITCH_STMT_BODY and SWITCH_STMT_TYPE, respectively. */ 304169689SkanDEFTREECODE (SWITCH_STMT, "switch_stmt", tcc_statement, 3) 305169689Skan 306169689Skan/* Used to represent an expression statement. Use `EXPR_STMT_EXPR' to 307169689Skan obtain the expression. */ 308169689SkanDEFTREECODE (EXPR_STMT, "expr_stmt", tcc_expression, 1) 309169689Skan 310169689SkanDEFTREECODE (TAG_DEFN, "tag_defn", tcc_expression, 0) 311169689Skan 312169689Skan/* Template instantiation level node. 313169689Skan 314169689Skan TINST_DECL contains the original DECL node. 315169689Skan TINST_LOCATION contains the location where the template is instantiated. 316169689Skan TINST_IN_SYSTEM_HEADER_P is true if the location is in a system header. 317169689Skan 318169689Skan A stack of template instantiation nodes is kept through the TREE_CHAIN 319169689Skan fields of these nodes. */ 320169689Skan 321169689SkanDEFTREECODE (TINST_LEVEL, "TINST_LEVEL", tcc_exceptional, 0) 322169689Skan 323169689Skan/* Represents an 'offsetof' expression during template expansion. */ 324169689SkanDEFTREECODE (OFFSETOF_EXPR, "offsetof_expr", tcc_expression, 1) 325169689Skan 326169689Skan/* Represents a 'sizeof' expression during template expansion. */ 327169689SkanDEFTREECODE (SIZEOF_EXPR, "sizeof_expr", tcc_expression, 1) 328169689Skan 329169689Skan/* Represents the -> operator during template expansion. */ 330169689SkanDEFTREECODE (ARROW_EXPR, "arrow_expr", tcc_expression, 1) 331169689Skan 332169689Skan/* Represents an '__alignof__' expression during template 333169689Skan expansion. */ 334169689SkanDEFTREECODE (ALIGNOF_EXPR, "alignof_expr", tcc_expression, 1) 335169689Skan 336169689Skan/* A STMT_EXPR represents a statement-expression during template 337169689Skan expansion. This is the GCC extension { ( ... ) }. The 338169689Skan STMT_EXPR_STMT is the statement given by the expression. */ 339169689SkanDEFTREECODE (STMT_EXPR, "stmt_expr", tcc_expression, 1) 340169689Skan 341169689Skan/* Unary plus. Operand 0 is the expression to which the unary plus 342169689Skan is applied. */ 343169689SkanDEFTREECODE (UNARY_PLUS_EXPR, "unary_plus_expr", tcc_unary, 1) 344169689Skan 34550397Sobrien/* 34650397SobrienLocal variables: 34750397Sobrienmode:c 34850397SobrienEnd: 34950397Sobrien*/ 350