c-tree.texi revision 90075
1249729Sgshapiro@c Copyright (c) 1999, 2000, 2001 Free Software Foundation, Inc. 238032Speter@c Free Software Foundation, Inc. 3249729Sgshapiro@c This is part of the GCC manual. 4249729Sgshapiro@c For copying conditions, see the file gcc.texi. 5249729Sgshapiro 6249729Sgshapiro@c --------------------------------------------------------------------- 7249729Sgshapiro@c Trees 8249729Sgshapiro@c --------------------------------------------------------------------- 9249729Sgshapiro 10249729Sgshapiro@node Trees 11249729Sgshapiro@chapter Trees: The intermediate representation used by the C and C++ front ends 12249729Sgshapiro@cindex Trees 13249729Sgshapiro@cindex C/C++ Internal Representation 14249729Sgshapiro 15249729SgshapiroThis chapter documents the internal representation used by GCC to 16249729Sgshapirorepresent C and C++ source programs. When presented with a C or C++ 17249729Sgshapirosource program, GCC parses the program, performs semantic analysis 18249729Sgshapiro(including the generation of error messages), and then produces the 19249729Sgshapirointernal representation described here. This representation contains a 20249729Sgshapirocomplete representation for the entire translation unit provided as 21249729Sgshapiroinput to the front end. This representation is then typically processed 22249729Sgshapiroby a code-generator in order to produce machine code, but could also be 23102528Sgshapiroused in the creation of source browsers, intelligent editors, automatic 24102528Sgshapirodocumentation generators, interpreters, and any other programs needing 2538032Speterthe ability to process C or C++ code. 26249729Sgshapiro 27249729SgshapiroThis chapter explains the internal representation. In particular, it 28102528Sgshapirodocuments the internal representation for C and C++ source 2938032Speterconstructs, and the macros, functions, and variables that can be used to 30249729Sgshapiroaccess these constructs. The C++ representation which is largely a superset 31102528Sgshapiroof the representation used in the C front end. There is only one 32249729Sgshapiroconstruct used in C that does not appear in the C++ front end and that 33102528Sgshapirois the GNU ``nested function'' extension. Many of the macros documented 34102528Sgshapirohere do not apply in C because the corresponding language constructs do 3538032Speternot appear in C@. 3638032Speter 37249729SgshapiroIf you are developing a ``back end'', be it is a code-generator or some 3838032Speterother tool, that uses this representation, you may occasionally find 3938032Speterthat you need to ask questions not easily answered by the functions and 4038032Spetermacros available here. If that situation occurs, it is quite likely 4138032Speterthat GCC already supports the functionality you desire, but that the 42102528Sgshapirointerface is simply not documented here. In that case, you should ask 4338032Speterthe GCC maintainers (via mail to @email{gcc@@gcc.gnu.org}) about 4438032Speterdocumenting the functionality you require. Similarly, if you find 45102528Sgshapiroyourself writing functions that do not deal directly with your back end, 4638032Speterbut instead might be useful to other people using the GCC front end, you 47249729Sgshapiroshould submit your patches for inclusion in GCC@. 4838032Speter 49249729Sgshapiro@menu 50249729Sgshapiro* Deficiencies:: Topics net yet covered in this document. 51102528Sgshapiro* Tree overview:: All about @code{tree}s. 52249729Sgshapiro* Types:: Fundamental and aggregate types. 53102528Sgshapiro* Scopes:: Namespaces and classes. 54102528Sgshapiro* Functions:: Overloading, function bodies, and linkage. 5538032Speter* Declarations:: Type declarations and variables. 56102528Sgshapiro* Attributes:: Declaration and type attributes. 57102528Sgshapiro* Expression trees:: From @code{typeid} to @code{throw}. 5838032Speter@end menu 5938032Speter 60102528Sgshapiro@c --------------------------------------------------------------------- 6138032Speter@c Deficiencies 62102528Sgshapiro@c --------------------------------------------------------------------- 63102528Sgshapiro 6438032Speter@node Deficiencies 65102528Sgshapiro@section Deficiencies 66102528Sgshapiro 67102528SgshapiroThere are many places in which this document is incomplet and incorrekt. 6838032SpeterIt is, as of yet, only @emph{preliminary} documentation. 69102528Sgshapiro 70102528Sgshapiro@c --------------------------------------------------------------------- 71102528Sgshapiro@c Overview 7238032Speter@c --------------------------------------------------------------------- 73102528Sgshapiro 74102528Sgshapiro@node Tree overview 75102528Sgshapiro@section Overview 7638032Speter@cindex tree 77102528Sgshapiro@findex TREE_CODE 7838032Speter 79102528SgshapiroThe central data structure used by the internal representation is the 8038032Speter@code{tree}. These nodes, while all of the C type @code{tree}, are of 8138032Spetermany varieties. A @code{tree} is a pointer type, but the object to 82102528Sgshapirowhich it points may be of a variety of types. From this point forward, 83102528Sgshapirowe will refer to trees in ordinary type, rather than in @code{this 84102528Sgshapirofont}, except when talking about the actual C type @code{tree}. 8538032Speter 86102528SgshapiroYou can tell what kind of node a particular tree is by using the 87102528Sgshapiro@code{TREE_CODE} macro. Many, many macros take a trees as input and 88102528Sgshapiroreturn trees as output. However, most macros require a certain kinds of 8938032Spetertree node as input. In other words, there is a type-system for trees, 9038032Speterbut it is not reflected in the C type-system. 9138032Speter 9238032SpeterFor safety, it is useful to configure GCC with @option{--enable-checking}. 9338032SpeterAlthough this results in a significant performance penalty (since all 94102528Sgshapirotree types are checked at run-time), and is therefore inappropriate in a 95102528Sgshapirorelease version, it is extremely helpful during the development process. 96102528Sgshapiro 9738032SpeterMany macros behave as predicates. Many, although not all, of these 98102528Sgshapiropredicates end in @samp{_P}. Do not rely on the result type of these 9938032Spetermacros being of any particular type. You may, however, rely on the fact 100102528Sgshapirothat the type can be compared to @code{0}, so that statements like 101102528Sgshapiro@example 10238032Speterif (TEST_P (t) && !TEST_P (y)) 10338032Speter x = 1; 10438032Speter@end example 105102528Sgshapiro@noindent 10638032Speterand 10738032Speter@example 108249729Sgshapiroint i = (TEST_P (t) != 0); 109249729Sgshapiro@end example 11038032Speter@noindent 11138032Speterare legal. Macros that return @code{int} values now may be changed to 112249729Sgshapiroreturn @code{tree} values, or other pointers in the future. Even those 113249729Sgshapirothat continue to return @code{int} may return multiple nonzero codes 11438032Speterwhere previously they returned only zero and one. Therefore, you should 11538032Speternot write code like 116249729Sgshapiro@example 117249729Sgshapiroif (TEST_P (t) == 1) 118249729Sgshapiro@end example 119249729Sgshapiro@noindent 120249729Sgshapiroas this code is not guaranteed to work correctly in the future. 121249729Sgshapiro 122249729SgshapiroYou should not take the address of values returned by the macros or 123249729Sgshapirofunctions described here. In particular, no guarantee is given that the 124249729Sgshapirovalues are lvalues. 125249729Sgshapiro 126249729SgshapiroIn general, the names of macros are all in uppercase, while the names of 127249729Sgshapirofunctions are entirely in lower case. There are rare exceptions to this 128249729Sgshapirorule. You should assume that any macro or function whose name is made 129249729Sgshapiroup entirely of uppercase letters may evaluate its arguments more than 130249729Sgshapiroonce. You may assume that a macro or function whose name is made up 131249729Sgshapiroentirely of lowercase letters will evaluate its arguments only once. 132249729Sgshapiro 133249729SgshapiroThe @code{error_mark_node} is a special tree. Its tree code is 134249729Sgshapiro@code{ERROR_MARK}, but since there is only ever one node with that code, 135249729Sgshapirothe usual practice is to compare the tree against 136249729Sgshapiro@code{error_mark_node}. (This test is just a test for pointer 137249729Sgshapiroequality.) If an error has occurred during front-end processing the 138249729Sgshapiroflag @code{errorcount} will be set. If the front end has encountered 139249729Sgshapirocode it cannot handle, it will issue a message to the user and set 140249729Sgshapiro@code{sorrycount}. When these flags are set, any macro or function 141249729Sgshapirowhich normally returns a tree of a particular kind may instead return 142249729Sgshapirothe @code{error_mark_node}. Thus, if you intend to do any processing of 143249729Sgshapiroerroneous code, you must be prepared to deal with the 144249729Sgshapiro@code{error_mark_node}. 145249729Sgshapiro 146249729SgshapiroOccasionally, a particular tree slot (like an operand to an expression, 147249729Sgshapiroor a particular field in a declaration) will be referred to as 148249729Sgshapiro``reserved for the back end.'' These slots are used to store RTL when 149249729Sgshapirothe tree is converted to RTL for use by the GCC back end. However, if 15038032Speterthat process is not taking place (e.g., if the front end is being hooked 15138032Speterup to an intelligent editor), then those slots may be used by the 152249729Sgshapiroback end presently in use. 15364562Sgshapiro 154249729SgshapiroIf you encounter situations that do not match this documentation, such 15538032Speteras tree nodes of types not mentioned here, or macros documented to 156249729Sgshapiroreturn entities of a particular kind that instead return entities of 157249729Sgshapirosome different kind, you have found a bug, either in the front end or in 158102528Sgshapirothe documentation. Please report these bugs as you would any other 159102528Sgshapirobug. 16064562Sgshapiro 161249729Sgshapiro@menu 162102528Sgshapiro* Macros and Functions::Macros and functions that can be used with all trees. 16338032Speter* Identifiers:: The names of things. 16464562Sgshapiro* Containers:: Lists and vectors. 165102528Sgshapiro@end menu 16638032Speter 16738032Speter@c --------------------------------------------------------------------- 16864562Sgshapiro@c Trees 169102528Sgshapiro@c --------------------------------------------------------------------- 17038032Speter 171102528Sgshapiro@node Macros and Functions 17238032Speter@subsection Trees 173102528Sgshapiro@cindex tree 17438032Speter 17564562SgshapiroThis section is not here yet. 176102528Sgshapiro 17738032Speter@c --------------------------------------------------------------------- 178102528Sgshapiro@c Identifiers 179102528Sgshapiro@c --------------------------------------------------------------------- 18038032Speter 18138032Speter@node Identifiers 18238032Speter@subsection Identifiers 183102528Sgshapiro@cindex identifier 184102528Sgshapiro@cindex name 18538032Speter@tindex IDENTIFIER_NODE 18638032Speter 18764562SgshapiroAn @code{IDENTIFIER_NODE} represents a slightly more general concept 18838032Speterthat the standard C or C++ concept of identifier. In particular, an 18938032Speter@code{IDENTIFIER_NODE} may contain a @samp{$}, or other extraordinary 19038032Spetercharacters. 19164562Sgshapiro 19238032SpeterThere are never two distinct @code{IDENTIFIER_NODE}s representing the 193102528Sgshapirosame identifier. Therefore, you may use pointer equality to compare 194102528Sgshapiro@code{IDENTIFIER_NODE}s, rather than using a routine like @code{strcmp}. 195102528Sgshapiro 19638032SpeterYou can use the following macros to access identifiers: 19738032Speter@ftable @code 198102528Sgshapiro@item IDENTIFIER_POINTER 19938032SpeterThe string represented by the identifier, represented as a 20038032Speter@code{char*}. This string is always @code{NUL}-terminated, and contains 20138032Speterno embedded @code{NUL} characters. 20238032Speter 203102528Sgshapiro@item IDENTIFIER_LENGTH 204102528SgshapiroThe length of the string returned by @code{IDENTIFIER_POINTER}, not 20564562Sgshapiroincluding the trailing @code{NUL}. This value of 20638032Speter@code{IDENTIFIER_LENGTH (x)} is always the same as @code{strlen 20738032Speter(IDENTIFIER_POINTER (x))}. 20838032Speter 209102528Sgshapiro@item IDENTIFIER_OPNAME_P 210102528SgshapiroThis predicate holds if the identifier represents the name of an 21138032Speteroverloaded operator. In this case, you should not depend on the 21238032Spetercontents of either the @code{IDENTIFIER_POINTER} or the 21338032Speter@code{IDENTIFIER_LENGTH}. 21438032Speter 21538032Speter@item IDENTIFIER_TYPENAME_P 21638032SpeterThis predicate holds if the identifier represents the name of a 21738032Speteruser-defined conversion operator. In this case, the @code{TREE_TYPE} of 21838032Speterthe @code{IDENTIFIER_NODE} holds the type to which the conversion 21964562Sgshapirooperator converts. 22038032Speter 221102528Sgshapiro@end ftable 222102528Sgshapiro 22338032Speter@c --------------------------------------------------------------------- 22438032Speter@c Containers 22538032Speter@c --------------------------------------------------------------------- 22638032Speter 22738032Speter@node Containers 22838032Speter@subsection Containers 22938032Speter@cindex container 23038032Speter@cindex list 231102528Sgshapiro@cindex vector 23238032Speter@tindex TREE_LIST 23338032Speter@tindex TREE_VEC 234102528Sgshapiro@findex TREE_PURPOSE 235102528Sgshapiro@findex TREE_VALUE 23638032Speter@findex TREE_VEC_LENGTH 23738032Speter@findex TREE_VEC_ELT 23838032Speter 23938032SpeterTwo common container data structures can be represented directly with 24038032Spetertree nodes. A @code{TREE_LIST} is a singly linked list containing two 24164562Sgshapirotrees per node. These are the @code{TREE_PURPOSE} and @code{TREE_VALUE} 24264562Sgshapiroof each node. (Often, the @code{TREE_PURPOSE} contains some kind of 24338032Spetertag, or additional information, while the @code{TREE_VALUE} contains the 24438032Spetermajority of the payload. In other cases, the @code{TREE_PURPOSE} is 24538032Spetersimply @code{NULL_TREE}, while in still others both the 24638032Speter@code{TREE_PURPOSE} and @code{TREE_VALUE} are of equal stature.) Given 24738032Speterone @code{TREE_LIST} node, the next node is found by following the 24864562Sgshapiro@code{TREE_CHAIN}. If the @code{TREE_CHAIN} is @code{NULL_TREE}, then 24938032Speteryou have reached the end of the list. 25038032Speter 25164562SgshapiroA @code{TREE_VEC} is a simple vector. The @code{TREE_VEC_LENGTH} is an 25264562Sgshapirointeger (not a tree) giving the number of nodes in the vector. The 253102528Sgshapironodes themselves are accessed using the @code{TREE_VEC_ELT} macro, which 254102528Sgshapirotakes two arguments. The first is the @code{TREE_VEC} in question; the 25564562Sgshapirosecond is an integer indicating which element in the vector is desired. 25664562SgshapiroThe elements are indexed from zero. 257102528Sgshapiro 25864562Sgshapiro@c --------------------------------------------------------------------- 25964562Sgshapiro@c Types 26064562Sgshapiro@c --------------------------------------------------------------------- 26138032Speter 26238032Speter@node Types 26338032Speter@section Types 264102528Sgshapiro@cindex type 265102528Sgshapiro@cindex pointer 266102528Sgshapiro@cindex reference 267102528Sgshapiro@cindex fundamental type 268102528Sgshapiro@cindex array 26938032Speter@tindex VOID_TYPE 270102528Sgshapiro@tindex INTEGER_TYPE 27138032Speter@tindex TYPE_MIN_VALUE 27238032Speter@tindex TYPE_MAX_VALUE 27338032Speter@tindex REAL_TYPE 274@tindex COMPLEX_TYPE 275@tindex ENUMERAL_TYPE 276@tindex BOOLEAN_TYPE 277@tindex POINTER_TYPE 278@tindex REFERENCE_TYPE 279@tindex FUNCTION_TYPE 280@tindex METHOD_TYPE 281@tindex ARRAY_TYPE 282@tindex RECORD_TYPE 283@tindex UNION_TYPE 284@tindex UNKNOWN_TYPE 285@tindex OFFSET_TYPE 286@tindex TYPENAME_TYPE 287@tindex TYPEOF_TYPE 288@findex CP_TYPE_QUALS 289@findex TYPE_UNQUALIFIED 290@findex TYPE_QUAL_CONST 291@findex TYPE_QUAL_VOLATILE 292@findex TYPE_QUAL_RESTRICT 293@findex TYPE_MAIN_VARIANT 294@cindex qualified type 295@findex TYPE_SIZE 296@findex TYPE_ALIGN 297@findex TYPE_PRECISION 298@findex TYPE_ARG_TYPES 299@findex TYPE_METHOD_BASETYPE 300@findex TYPE_PTRMEM_P 301@findex TYPE_OFFSET_BASETYPE 302@findex TREE_TYPE 303@findex TYPE_CONTEXT 304@findex TYPE_NAME 305@findex TYPENAME_TYPE_FULLNAME 306@findex TYPE_FIELDS 307@findex TYPE_PTROBV_P 308 309All types have corresponding tree nodes. However, you should not assume 310that there is exactly one tree node corresponding to each type. There 311are often several nodes each of which correspond to the same type. 312 313For the most part, different kinds of types have different tree codes. 314(For example, pointer types use a @code{POINTER_TYPE} code while arrays 315use an @code{ARRAY_TYPE} code.) However, pointers to member functions 316use the @code{RECORD_TYPE} code. Therefore, when writing a 317@code{switch} statement that depends on the code associated with a 318particular type, you should take care to handle pointers to member 319functions under the @code{RECORD_TYPE} case label. 320 321In C++, an array type is not qualified; rather the type of the array 322elements is qualified. This situation is reflected in the intermediate 323representation. The macros described here will always examine the 324qualification of the underlying element type when applied to an array 325type. (If the element type is itself an array, then the recursion 326continues until a non-array type is found, and the qualification of this 327type is examined.) So, for example, @code{CP_TYPE_CONST_P} will hold of 328the type @code{const int ()[7]}, denoting an array of seven @code{int}s. 329 330The following functions and macros deal with cv-qualification of types: 331@ftable @code 332@item CP_TYPE_QUALS 333This macro returns the set of type qualifiers applied to this type. 334This value is @code{TYPE_UNQUALIFIED} if no qualifiers have been 335applied. The @code{TYPE_QUAL_CONST} bit is set if the type is 336@code{const}-qualified. The @code{TYPE_QUAL_VOLATILE} bit is set if the 337type is @code{volatile}-qualified. The @code{TYPE_QUAL_RESTRICT} bit is 338set if the type is @code{restrict}-qualified. 339 340@item CP_TYPE_CONST_P 341This macro holds if the type is @code{const}-qualified. 342 343@item CP_TYPE_VOLATILE_P 344This macro holds if the type is @code{volatile}-qualified. 345 346@item CP_TYPE_RESTRICT_P 347This macro holds if the type is @code{restrict}-qualified. 348 349@item CP_TYPE_CONST_NON_VOLATILE_P 350This predicate holds for a type that is @code{const}-qualified, but 351@emph{not} @code{volatile}-qualified; other cv-qualifiers are ignored as 352well: only the @code{const}-ness is tested. 353 354@item TYPE_MAIN_VARIANT 355This macro returns the unqualified version of a type. It may be applied 356to an unqualified type, but it is not always the identity function in 357that case. 358@end ftable 359 360A few other macros and functions are usable with all types: 361@ftable @code 362@item TYPE_SIZE 363The number of bits required to represent the type, represented as an 364@code{INTEGER_CST}. For an incomplete type, @code{TYPE_SIZE} will be 365@code{NULL_TREE}. 366 367@item TYPE_ALIGN 368The alignment of the type, in bits, represented as an @code{int}. 369 370@item TYPE_NAME 371This macro returns a declaration (in the form of a @code{TYPE_DECL}) for 372the type. (Note this macro does @emph{not} return a 373@code{IDENTIFIER_NODE}, as you might expect, given its name!) You can 374look at the @code{DECL_NAME} of the @code{TYPE_DECL} to obtain the 375actual name of the type. The @code{TYPE_NAME} will be @code{NULL_TREE} 376for a type that is not a built-in type, the result of a typedef, or a 377named class type. 378 379@item CP_INTEGRAL_TYPE 380This predicate holds if the type is an integral type. Notice that in 381C++, enumerations are @emph{not} integral types. 382 383@item ARITHMETIC_TYPE_P 384This predicate holds if the type is an integral type (in the C++ sense) 385or a floating point type. 386 387@item CLASS_TYPE_P 388This predicate holds for a class-type. 389 390@item TYPE_BUILT_IN 391This predicate holds for a built-in type. 392 393@item TYPE_PTRMEM_P 394This predicate holds if the type is a pointer to data member. 395 396@item TYPE_PTR_P 397This predicate holds if the type is a pointer type, and the pointee is 398not a data member. 399 400@item TYPE_PTRFN_P 401This predicate holds for a pointer to function type. 402 403@item TYPE_PTROB_P 404This predicate holds for a pointer to object type. Note however that it 405does not hold for the generic pointer to object type @code{void *}. You 406may use @code{TYPE_PTROBV_P} to test for a pointer to object type as 407well as @code{void *}. 408 409@item same_type_p 410This predicate takes two types as input, and holds if they are the same 411type. For example, if one type is a @code{typedef} for the other, or 412both are @code{typedef}s for the same type. This predicate also holds if 413the two trees given as input are simply copies of one another; i.e., 414there is no difference between them at the source level, but, for 415whatever reason, a duplicate has been made in the representation. You 416should never use @code{==} (pointer equality) to compare types; always 417use @code{same_type_p} instead. 418@end ftable 419 420Detailed below are the various kinds of types, and the macros that can 421be used to access them. Although other kinds of types are used 422elsewhere in G++, the types described here are the only ones that you 423will encounter while examining the intermediate representation. 424 425@table @code 426@item VOID_TYPE 427Used to represent the @code{void} type. 428 429@item INTEGER_TYPE 430Used to represent the various integral types, including @code{char}, 431@code{short}, @code{int}, @code{long}, and @code{long long}. This code 432is not used for enumeration types, nor for the @code{bool} type. Note 433that GCC's @code{CHAR_TYPE} node is @emph{not} used to represent 434@code{char}. The @code{TYPE_PRECISION} is the number of bits used in 435the representation, represented as an @code{unsigned int}. (Note that 436in the general case this is not the same value as @code{TYPE_SIZE}; 437suppose that there were a 24-bit integer type, but that alignment 438requirements for the ABI required 32-bit alignment. Then, 439@code{TYPE_SIZE} would be an @code{INTEGER_CST} for 32, while 440@code{TYPE_PRECISION} would be 24.) The integer type is unsigned if 441@code{TREE_UNSIGNED} holds; otherwise, it is signed. 442 443The @code{TYPE_MIN_VALUE} is an @code{INTEGER_CST} for the smallest 444integer that may be represented by this type. Similarly, the 445@code{TYPE_MAX_VALUE} is an @code{INTEGER_CST} for the largest integer 446that may be represented by this type. 447 448@item REAL_TYPE 449Used to represent the @code{float}, @code{double}, and @code{long 450double} types. The number of bits in the floating-point representation 451is given by @code{TYPE_PRECISION}, as in the @code{INTEGER_TYPE} case. 452 453@item COMPLEX_TYPE 454Used to represent GCC built-in @code{__complex__} data types. The 455@code{TREE_TYPE} is the type of the real and imaginary parts. 456 457@item ENUMERAL_TYPE 458Used to represent an enumeration type. The @code{TYPE_PRECISION} gives 459(as an @code{int}), the number of bits used to represent the type. If 460there are no negative enumeration constants, @code{TREE_UNSIGNED} will 461hold. The minimum and maximum enumeration constants may be obtained 462with @code{TYPE_MIN_VALUE} and @code{TYPE_MAX_VALUE}, respectively; each 463of these macros returns an @code{INTEGER_CST}. 464 465The actual enumeration constants themselves may be obtained by looking 466at the @code{TYPE_VALUES}. This macro will return a @code{TREE_LIST}, 467containing the constants. The @code{TREE_PURPOSE} of each node will be 468an @code{IDENTIFIER_NODE} giving the name of the constant; the 469@code{TREE_VALUE} will be an @code{INTEGER_CST} giving the value 470assigned to that constant. These constants will appear in the order in 471which they were declared. The @code{TREE_TYPE} of each of these 472constants will be the type of enumeration type itself. 473 474@item BOOLEAN_TYPE 475Used to represent the @code{bool} type. 476 477@item POINTER_TYPE 478Used to represent pointer types, and pointer to data member types. The 479@code{TREE_TYPE} gives the type to which this type points. If the type 480is a pointer to data member type, then @code{TYPE_PTRMEM_P} will hold. 481For a pointer to data member type of the form @samp{T X::*}, 482@code{TYPE_PTRMEM_CLASS_TYPE} will be the type @code{X}, while 483@code{TYPE_PTRMEM_POINTED_TO_TYPE} will be the type @code{T}. 484 485@item REFERENCE_TYPE 486Used to represent reference types. The @code{TREE_TYPE} gives the type 487to which this type refers. 488 489@item FUNCTION_TYPE 490Used to represent the type of non-member functions and of static member 491functions. The @code{TREE_TYPE} gives the return type of the function. 492The @code{TYPE_ARG_TYPES} are a @code{TREE_LIST} of the argument types. 493The @code{TREE_VALUE} of each node in this list is the type of the 494corresponding argument; the @code{TREE_PURPOSE} is an expression for the 495default argument value, if any. If the last node in the list is 496@code{void_list_node} (a @code{TREE_LIST} node whose @code{TREE_VALUE} 497is the @code{void_type_node}), then functions of this type do not take 498variable arguments. Otherwise, they do take a variable number of 499arguments. 500 501Note that in C (but not in C++) a function declared like @code{void f()} 502is an unprototyped function taking a variable number of arguments; the 503@code{TYPE_ARG_TYPES} of such a function will be @code{NULL}. 504 505@item METHOD_TYPE 506Used to represent the type of a non-static member function. Like a 507@code{FUNCTION_TYPE}, the return type is given by the @code{TREE_TYPE}. 508The type of @code{*this}, i.e., the class of which functions of this 509type are a member, is given by the @code{TYPE_METHOD_BASETYPE}. The 510@code{TYPE_ARG_TYPES} is the parameter list, as for a 511@code{FUNCTION_TYPE}, and includes the @code{this} argument. 512 513@item ARRAY_TYPE 514Used to represent array types. The @code{TREE_TYPE} gives the type of 515the elements in the array. If the array-bound is present in the type, 516the @code{TYPE_DOMAIN} is an @code{INTEGER_TYPE} whose 517@code{TYPE_MIN_VALUE} and @code{TYPE_MAX_VALUE} will be the lower and 518upper bounds of the array, respectively. The @code{TYPE_MIN_VALUE} will 519always be an @code{INTEGER_CST} for zero, while the 520@code{TYPE_MAX_VALUE} will be one less than the number of elements in 521the array, i.e., the highest value which may be used to index an element 522in the array. 523 524@item RECORD_TYPE 525Used to represent @code{struct} and @code{class} types, as well as 526pointers to member functions and similar constructs in other languages. 527@code{TYPE_FIELDS} contains the items contained in this type, each of 528which can be a @code{FIELD_DECL}, @code{VAR_DECL}, @code{CONST_DECL}, or 529@code{TYPE_DECL}. You may not make any assumptions about the ordering 530of the fields in the type or whether one or more of them overlap. If 531@code{TYPE_PTRMEMFUNC_P} holds, then this type is a pointer-to-member 532type. In that case, the @code{TYPE_PTRMEMFUNC_FN_TYPE} is a 533@code{POINTER_TYPE} pointing to a @code{METHOD_TYPE}. The 534@code{METHOD_TYPE} is the type of a function pointed to by the 535pointer-to-member function. If @code{TYPE_PTRMEMFUNC_P} does not hold, 536this type is a class type. For more information, see @pxref{Classes}. 537 538@item UNION_TYPE 539Used to represent @code{union} types. Similar to @code{RECORD_TYPE} 540except that all @code{FIELD_DECL} nodes in @code{TYPE_FIELD} start at 541bit position zero. 542 543@item QUAL_UNION_TYPE 544Used to represent part of a variant record in Ada. Similar to 545@code{UNION_TYPE} except that each @code{FIELD_DECL} has a 546@code{DECL_QUALIFIER} field, which contains a boolean expression that 547indicates whether the field is present in the object. The type will only 548have one field, so each field's @code{DECL_QUALIFIER} is only evaluated 549if none of the expressions in the previous fields in @code{TYPE_FIELDS} 550are nonzero. Normally these expressions will reference a field in the 551outer object using a @code{PLACEHOLDER_EXPR}. 552 553@item UNKNOWN_TYPE 554This node is used to represent a type the knowledge of which is 555insufficient for a sound processing. 556 557@item OFFSET_TYPE 558This node is used to represent a data member; for example a 559pointer-to-data-member is represented by a @code{POINTER_TYPE} whose 560@code{TREE_TYPE} is an @code{OFFSET_TYPE}. For a data member @code{X::m} 561the @code{TYPE_OFFSET_BASETYPE} is @code{X} and the @code{TREE_TYPE} is 562the type of @code{m}. 563 564@item TYPENAME_TYPE 565Used to represent a construct of the form @code{typename T::A}. The 566@code{TYPE_CONTEXT} is @code{T}; the @code{TYPE_NAME} is an 567@code{IDENTIFIER_NODE} for @code{A}. If the type is specified via a 568template-id, then @code{TYPENAME_TYPE_FULLNAME} yields a 569@code{TEMPLATE_ID_EXPR}. The @code{TREE_TYPE} is non-@code{NULL} if the 570node is implicitly generated in support for the implicit typename 571extension; in which case the @code{TREE_TYPE} is a type node for the 572base-class. 573 574@item TYPEOF_TYPE 575Used to represent the @code{__typeof__} extension. The 576@code{TYPE_FIELDS} is the expression the type of which is being 577represented. 578@end table 579 580There are variables whose values represent some of the basic types. 581These include: 582@table @code 583@item void_type_node 584A node for @code{void}. 585 586@item integer_type_node 587A node for @code{int}. 588 589@item unsigned_type_node. 590A node for @code{unsigned int}. 591 592@item char_type_node. 593A node for @code{char}. 594@end table 595@noindent 596It may sometimes be useful to compare one of these variables with a type 597in hand, using @code{same_type_p}. 598 599@c --------------------------------------------------------------------- 600@c Scopes 601@c --------------------------------------------------------------------- 602 603@node Scopes 604@section Scopes 605@cindex namespace, class, scope 606 607The root of the entire intermediate representation is the variable 608@code{global_namespace}. This is the namespace specified with @code{::} 609in C++ source code. All other namespaces, types, variables, functions, 610and so forth can be found starting with this namespace. 611 612Besides namespaces, the other high-level scoping construct in C++ is the 613class. (Throughout this manual the term @dfn{class} is used to mean the 614types referred to in the ANSI/ISO C++ Standard as classes; these include 615types defined with the @code{class}, @code{struct}, and @code{union} 616keywords.) 617 618@menu 619* Namespaces:: Member functions, types, etc. 620* Classes:: Members, bases, friends, etc. 621@end menu 622 623@c --------------------------------------------------------------------- 624@c Namespaces 625@c --------------------------------------------------------------------- 626 627@node Namespaces 628@subsection Namespaces 629@cindex namespace 630@tindex NAMESPACE_DECL 631 632A namespace is represented by a @code{NAMESPACE_DECL} node. 633 634However, except for the fact that it is distinguished as the root of the 635representation, the global namespace is no different from any other 636namespace. Thus, in what follows, we describe namespaces generally, 637rather than the global namespace in particular. 638 639The following macros and functions can be used on a @code{NAMESPACE_DECL}: 640 641@ftable @code 642@item DECL_NAME 643This macro is used to obtain the @code{IDENTIFIER_NODE} corresponding to 644the unqualified name of the name of the namespace (@pxref{Identifiers}). 645The name of the global namespace is @samp{::}, even though in C++ the 646global namespace is unnamed. However, you should use comparison with 647@code{global_namespace}, rather than @code{DECL_NAME} to determine 648whether or not a namespaces is the global one. An unnamed namespace 649will have a @code{DECL_NAME} equal to @code{anonymous_namespace_name}. 650Within a single translation unit, all unnamed namespaces will have the 651same name. 652 653@item DECL_CONTEXT 654This macro returns the enclosing namespace. The @code{DECL_CONTEXT} for 655the @code{global_namespace} is @code{NULL_TREE}. 656 657@item DECL_NAMESPACE_ALIAS 658If this declaration is for a namespace alias, then 659@code{DECL_NAMESPACE_ALIAS} is the namespace for which this one is an 660alias. 661 662Do not attempt to use @code{cp_namespace_decls} for a namespace which is 663an alias. Instead, follow @code{DECL_NAMESPACE_ALIAS} links until you 664reach an ordinary, non-alias, namespace, and call 665@code{cp_namespace_decls} there. 666 667@item DECL_NAMESPACE_STD_P 668This predicate holds if the namespace is the special @code{::std} 669namespace. 670 671@item cp_namespace_decls 672This function will return the declarations contained in the namespace, 673including types, overloaded functions, other namespaces, and so forth. 674If there are no declarations, this function will return 675@code{NULL_TREE}. The declarations are connected through their 676@code{TREE_CHAIN} fields. 677 678Although most entries on this list will be declarations, 679@code{TREE_LIST} nodes may also appear. In this case, the 680@code{TREE_VALUE} will be an @code{OVERLOAD}. The value of the 681@code{TREE_PURPOSE} is unspecified; back ends should ignore this value. 682As with the other kinds of declarations returned by 683@code{cp_namespace_decls}, the @code{TREE_CHAIN} will point to the next 684declaration in this list. 685 686For more information on the kinds of declarations that can occur on this 687list, @xref{Declarations}. Some declarations will not appear on this 688list. In particular, no @code{FIELD_DECL}, @code{LABEL_DECL}, or 689@code{PARM_DECL} nodes will appear here. 690 691This function cannot be used with namespaces that have 692@code{DECL_NAMESPACE_ALIAS} set. 693 694@end ftable 695 696@c --------------------------------------------------------------------- 697@c Classes 698@c --------------------------------------------------------------------- 699 700@node Classes 701@subsection Classes 702@cindex class 703@tindex RECORD_TYPE 704@tindex UNION_TYPE 705@findex CLASSTYPE_DECLARED_CLASS 706@findex TYPE_BINFO 707@findex BINFO_TYPE 708@findex TREE_VIA_PUBLIC 709@findex TREE_VIA_PROTECTED 710@findex TREE_VIA_PRIVATE 711@findex TYPE_FIELDS 712@findex TYPE_VFIELD 713@findex TYPE_METHODS 714 715A class type is represented by either a @code{RECORD_TYPE} or a 716@code{UNION_TYPE}. A class declared with the @code{union} tag is 717represented by a @code{UNION_TYPE}, while classes declared with either 718the @code{struct} or the @code{class} tag are represented by 719@code{RECORD_TYPE}s. You can use the @code{CLASSTYPE_DECLARED_CLASS} 720macro to discern whether or not a particular type is a @code{class} as 721opposed to a @code{struct}. This macro will be true only for classes 722declared with the @code{class} tag. 723 724Almost all non-function members are available on the @code{TYPE_FIELDS} 725list. Given one member, the next can be found by following the 726@code{TREE_CHAIN}. You should not depend in any way on the order in 727which fields appear on this list. All nodes on this list will be 728@samp{DECL} nodes. A @code{FIELD_DECL} is used to represent a non-static 729data member, a @code{VAR_DECL} is used to represent a static data 730member, and a @code{TYPE_DECL} is used to represent a type. Note that 731the @code{CONST_DECL} for an enumeration constant will appear on this 732list, if the enumeration type was declared in the class. (Of course, 733the @code{TYPE_DECL} for the enumeration type will appear here as well.) 734There are no entries for base classes on this list. In particular, 735there is no @code{FIELD_DECL} for the ``base-class portion'' of an 736object. 737 738The @code{TYPE_VFIELD} is a compiler-generated field used to point to 739virtual function tables. It may or may not appear on the 740@code{TYPE_FIELDS} list. However, back ends should handle the 741@code{TYPE_VFIELD} just like all the entries on the @code{TYPE_FIELDS} 742list. 743 744The function members are available on the @code{TYPE_METHODS} list. 745Again, subsequent members are found by following the @code{TREE_CHAIN} 746field. If a function is overloaded, each of the overloaded functions 747appears; no @code{OVERLOAD} nodes appear on the @code{TYPE_METHODS} 748list. Implicitly declared functions (including default constructors, 749copy constructors, assignment operators, and destructors) will appear on 750this list as well. 751 752Every class has an associated @dfn{binfo}, which can be obtained with 753@code{TYPE_BINFO}. Binfos are used to represent base-classes. The 754binfo given by @code{TYPE_BINFO} is the degenerate case, whereby every 755class is considered to be its own base-class. The base classes for a 756particular binfo can be obtained with @code{BINFO_BASETYPES}. These 757base-classes are themselves binfos. The class type associated with a 758binfo is given by @code{BINFO_TYPE}. It is always the case that 759@code{BINFO_TYPE (TYPE_BINFO (x))} is the same type as @code{x}, up to 760qualifiers. However, it is not always the case that @code{TYPE_BINFO 761(BINFO_TYPE (y))} is always the same binfo as @code{y}. The reason is 762that if @code{y} is a binfo representing a base-class @code{B} of a 763derived class @code{D}, then @code{BINFO_TYPE (y)} will be @code{B}, and 764@code{TYPE_INFO (BINFO_TYPE (y))} will be @code{B} as its own 765base-class, rather than as a base-class of @code{D}. 766 767The @code{BINFO_BASETYPES} is a @code{TREE_VEC} (@pxref{Containers}). 768Base types appear in left-to-right order in this vector. You can tell 769whether or @code{public}, @code{protected}, or @code{private} 770inheritance was used by using the @code{TREE_VIA_PUBLIC}, 771@code{TREE_VIA_PROTECTED}, and @code{TREE_VIA_PRIVATE} macros. Each of 772these macros takes a @code{BINFO} and is true if and only if the 773indicated kind of inheritance was used. If @code{TREE_VIA_VIRTUAL} 774holds of a binfo, then its @code{BINFO_TYPE} was inherited from 775virtually. 776 777The following macros can be used on a tree node representing a class-type. 778 779@ftable @code 780@item LOCAL_CLASS_P 781This predicate holds if the class is local class @emph{i.e.} declared 782inside a function body. 783 784@item TYPE_POLYMORPHIC_P 785This predicate holds if the class has at least one virtual function 786(declared or inherited). 787 788@item TYPE_HAS_DEFAULT_CONSTRUCTOR 789This predicate holds whenever its argument represents a class-type with 790default constructor. 791 792@item CLASSTYPE_HAS_MUTABLE 793@item TYPE_HAS_MUTABLE_P 794These predicates hold for a class-type having a mutable data member. 795 796@item CLASSTYPE_NON_POD_P 797This predicate holds only for class-types that are not PODs. 798 799@item TYPE_HAS_NEW_OPERATOR 800This predicate holds for a class-type that defines 801@code{operator new}. 802 803@item TYPE_HAS_ARRAY_NEW_OPERATOR 804This predicate holds for a class-type for which 805@code{operator new[]} is defined. 806 807@item TYPE_OVERLOADS_CALL_EXPR 808This predicate holds for class-type for which the function call 809@code{operator()} is overloaded. 810 811@item TYPE_OVERLOADS_ARRAY_REF 812This predicate holds for a class-type that overloads 813@code{operator[]} 814 815@item TYPE_OVERLOADS_ARROW 816This predicate holds for a class-type for which @code{operator->} is 817overloaded. 818 819@end ftable 820 821@c --------------------------------------------------------------------- 822@c Declarations 823@c --------------------------------------------------------------------- 824 825@node Declarations 826@section Declarations 827@cindex declaration 828@cindex variable 829@cindex type declaration 830@tindex LABEL_DECL 831@tindex CONST_DECL 832@tindex TYPE_DECL 833@tindex VAR_DECL 834@tindex PARM_DECL 835@tindex FIELD_DECL 836@tindex NAMESPACE_DECL 837@tindex RESULT_DECL 838@tindex TEMPLATE_DECL 839@tindex THUNK_DECL 840@tindex USING_DECL 841@findex THUNK_DELTA 842@findex DECL_INITIAL 843@findex DECL_SIZE 844@findex DECL_ALIGN 845@findex DECL_EXTERNAL 846 847This section covers the various kinds of declarations that appear in the 848internal representation, except for declarations of functions 849(represented by @code{FUNCTION_DECL} nodes), which are described in 850@ref{Functions}. 851 852Some macros can be used with any kind of declaration. These include: 853@ftable @code 854@item DECL_NAME 855This macro returns an @code{IDENTIFIER_NODE} giving the name of the 856entity. 857 858@item TREE_TYPE 859This macro returns the type of the entity declared. 860 861@item DECL_SOURCE_FILE 862This macro returns the name of the file in which the entity was 863declared, as a @code{char*}. For an entity declared implicitly by the 864compiler (like @code{__builtin_memcpy}), this will be the string 865@code{"<internal>"}. 866 867@item DECL_SOURCE_LINE 868This macro returns the line number at which the entity was declared, as 869an @code{int}. 870 871@item DECL_ARTIFICIAL 872This predicate holds if the declaration was implicitly generated by the 873compiler. For example, this predicate will hold of an implicitly 874declared member function, or of the @code{TYPE_DECL} implicitly 875generated for a class type. Recall that in C++ code like: 876@example 877struct S @{@}; 878@end example 879@noindent 880is roughly equivalent to C code like: 881@example 882struct S @{@}; 883typedef struct S S; 884@end example 885The implicitly generated @code{typedef} declaration is represented by a 886@code{TYPE_DECL} for which @code{DECL_ARTIFICIAL} holds. 887 888@item DECL_NAMESPACE_SCOPE_P 889This predicate holds if the entity was declared at a namespace scope. 890 891@item DECL_CLASS_SCOPE_P 892This predicate holds if the entity was declared at a class scope. 893 894@item DECL_FUNCTION_SCOPE_P 895This predicate holds if the entity was declared inside a function 896body. 897 898@end ftable 899 900The various kinds of declarations include: 901@table @code 902@item LABEL_DECL 903These nodes are used to represent labels in function bodies. For more 904information, see @ref{Functions}. These nodes only appear in block 905scopes. 906 907@item CONST_DECL 908These nodes are used to represent enumeration constants. The value of 909the constant is given by @code{DECL_INITIAL} which will be an 910@code{INTEGER_CST} with the same type as the @code{TREE_TYPE} of the 911@code{CONST_DECL}, i.e., an @code{ENUMERAL_TYPE}. 912 913@item RESULT_DECL 914These nodes represent the value returned by a function. When a value is 915assigned to a @code{RESULT_DECL}, that indicates that the value should 916be returned, via bitwise copy, by the function. You can use 917@code{DECL_SIZE} and @code{DECL_ALIGN} on a @code{RESULT_DECL}, just as 918with a @code{VAR_DECL}. 919 920@item TYPE_DECL 921These nodes represent @code{typedef} declarations. The @code{TREE_TYPE} 922is the type declared to have the name given by @code{DECL_NAME}. In 923some cases, there is no associated name. 924 925@item VAR_DECL 926These nodes represent variables with namespace or block scope, as well 927as static data members. The @code{DECL_SIZE} and @code{DECL_ALIGN} are 928analogous to @code{TYPE_SIZE} and @code{TYPE_ALIGN}. For a declaration, 929you should always use the @code{DECL_SIZE} and @code{DECL_ALIGN} rather 930than the @code{TYPE_SIZE} and @code{TYPE_ALIGN} given by the 931@code{TREE_TYPE}, since special attributes may have been applied to the 932variable to give it a particular size and alignment. You may use the 933predicates @code{DECL_THIS_STATIC} or @code{DECL_THIS_EXTERN} to test 934whether the storage class specifiers @code{static} or @code{extern} were 935used to declare a variable. 936 937If this variable is initialized (but does not require a constructor), 938the @code{DECL_INITIAL} will be an expression for the initializer. The 939initializer should be evaluated, and a bitwise copy into the variable 940performed. If the @code{DECL_INITIAL} is the @code{error_mark_node}, 941there is an initializer, but it is given by an explicit statement later 942in the code; no bitwise copy is required. 943 944GCC provides an extension that allows either automatic variables, or 945global variables, to be placed in particular registers. This extension 946is being used for a particular @code{VAR_DECL} if @code{DECL_REGISTER} 947holds for the @code{VAR_DECL}, and if @code{DECL_ASSEMBLER_NAME} is not 948equal to @code{DECL_NAME}. In that case, @code{DECL_ASSEMBLER_NAME} is 949the name of the register into which the variable will be placed. 950 951@item PARM_DECL 952Used to represent a parameter to a function. Treat these nodes 953similarly to @code{VAR_DECL} nodes. These nodes only appear in the 954@code{DECL_ARGUMENTS} for a @code{FUNCTION_DECL}. 955 956The @code{DECL_ARG_TYPE} for a @code{PARM_DECL} is the type that will 957actually be used when a value is passed to this function. It may be a 958wider type than the @code{TREE_TYPE} of the parameter; for example, the 959ordinary type might be @code{short} while the @code{DECL_ARG_TYPE} is 960@code{int}. 961 962@item FIELD_DECL 963These nodes represent non-static data members. The @code{DECL_SIZE} and 964@code{DECL_ALIGN} behave as for @code{VAR_DECL} nodes. The 965@code{DECL_FIELD_BITPOS} gives the first bit used for this field, as an 966@code{INTEGER_CST}. These values are indexed from zero, where zero 967indicates the first bit in the object. 968 969If @code{DECL_C_BIT_FIELD} holds, this field is a bit-field. 970 971@item NAMESPACE_DECL 972@xref{Namespaces}. 973 974@item TEMPLATE_DECL 975 976These nodes are used to represent class, function, and variable (static 977data member) templates. The @code{DECL_TEMPLATE_SPECIALIZATIONS} are a 978@code{TREE_LIST}. The @code{TREE_VALUE} of each node in the list is a 979@code{TEMPLATE_DECL}s or @code{FUNCTION_DECL}s representing 980specializations (including instantiations) of this template. Back ends 981can safely ignore @code{TEMPLATE_DECL}s, but should examine 982@code{FUNCTION_DECL} nodes on the specializations list just as they 983would ordinary @code{FUNCTION_DECL} nodes. 984 985For a class template, the @code{DECL_TEMPLATE_INSTANTIATIONS} list 986contains the instantiations. The @code{TREE_VALUE} of each node is an 987instantiation of the class. The @code{DECL_TEMPLATE_SPECIALIZATIONS} 988contains partial specializations of the class. 989 990@item USING_DECL 991 992Back ends can safely ignore these nodes. 993 994@end table 995 996@c --------------------------------------------------------------------- 997@c Functions 998@c --------------------------------------------------------------------- 999 1000@node Functions 1001@section Functions 1002@cindex function 1003@tindex FUNCTION_DECL 1004@tindex OVERLOAD 1005@findex OVL_CURRENT 1006@findex OVL_NEXT 1007 1008A function is represented by a @code{FUNCTION_DECL} node. A set of 1009overloaded functions is sometimes represented by a @code{OVERLOAD} node. 1010 1011An @code{OVERLOAD} node is not a declaration, so none of the 1012@samp{DECL_} macros should be used on an @code{OVERLOAD}. An 1013@code{OVERLOAD} node is similar to a @code{TREE_LIST}. Use 1014@code{OVL_CURRENT} to get the function associated with an 1015@code{OVERLOAD} node; use @code{OVL_NEXT} to get the next 1016@code{OVERLOAD} node in the list of overloaded functions. The macros 1017@code{OVL_CURRENT} and @code{OVL_NEXT} are actually polymorphic; you can 1018use them to work with @code{FUNCTION_DECL} nodes as well as with 1019overloads. In the case of a @code{FUNCTION_DECL}, @code{OVL_CURRENT} 1020will always return the function itself, and @code{OVL_NEXT} will always 1021be @code{NULL_TREE}. 1022 1023To determine the scope of a function, you can use the 1024@code{DECL_REAL_CONTEXT} macro. This macro will return the class 1025(either a @code{RECORD_TYPE} or a @code{UNION_TYPE}) or namespace (a 1026@code{NAMESPACE_DECL}) of which the function is a member. For a virtual 1027function, this macro returns the class in which the function was 1028actually defined, not the base class in which the virtual declaration 1029occurred. If a friend function is defined in a class scope, the 1030@code{DECL_CLASS_CONTEXT} macro can be used to determine the class in 1031which it was defined. For example, in 1032@example 1033class C @{ friend void f() @{@} @}; 1034@end example 1035the @code{DECL_REAL_CONTEXT} for @code{f} will be the 1036@code{global_namespace}, but the @code{DECL_CLASS_CONTEXT} will be the 1037@code{RECORD_TYPE} for @code{C}. 1038 1039The @code{DECL_REAL_CONTEXT} and @code{DECL_CLASS_CONTEXT} are not 1040available in C; instead you should simply use @code{DECL_CONTEXT}. In C, 1041the @code{DECL_CONTEXT} for a function maybe another function. This 1042representation indicates that the GNU nested function extension is in 1043use. For details on the semantics of nested functions, see the GCC 1044Manual. The nested function can refer to local variables in its 1045containing function. Such references are not explicitly marked in the 1046tree structure; back ends must look at the @code{DECL_CONTEXT} for the 1047referenced @code{VAR_DECL}. If the @code{DECL_CONTEXT} for the 1048referenced @code{VAR_DECL} is not the same as the function currently 1049being processed, and neither @code{DECL_EXTERNAL} nor @code{DECL_STATIC} 1050hold, then the reference is to a local variable in a containing 1051function, and the back end must take appropriate action. 1052 1053@menu 1054* Function Basics:: Function names, linkage, and so forth. 1055* Function Bodies:: The statements that make up a function body. 1056@end menu 1057 1058@c --------------------------------------------------------------------- 1059@c Function Basics 1060@c --------------------------------------------------------------------- 1061 1062@node Function Basics 1063@subsection Function Basics 1064@cindex constructor 1065@cindex destructor 1066@cindex copy constructor 1067@cindex assignment operator 1068@cindex linkage 1069@findex DECL_NAME 1070@findex DECL_ASSEMBLER_NAME 1071@findex TREE_PUBLIC 1072@findex DECL_LINKONCE_P 1073@findex DECL_FUNCTION_MEMBER_P 1074@findex DECL_CONSTRUCTOR_P 1075@findex DECL_DESTRUCTOR_P 1076@findex DECL_OVERLOADED_OPERATOR_P 1077@findex DECL_CONV_FN_P 1078@findex DECL_ARTIFICIAL 1079@findex DECL_GLOBAL_CTOR_P 1080@findex DECL_GLOBAL_DTOR_P 1081@findex GLOBAL_INIT_PRIORITY 1082 1083The following macros and functions can be used on a @code{FUNCTION_DECL}: 1084@ftable @code 1085@item DECL_MAIN_P 1086This predicate holds for a function that is the program entry point 1087@code{::code}. 1088 1089@item DECL_NAME 1090This macro returns the unqualified name of the function, as an 1091@code{IDENTIFIER_NODE}. For an instantiation of a function template, 1092the @code{DECL_NAME} is the unqualified name of the template, not 1093something like @code{f<int>}. The value of @code{DECL_NAME} is 1094undefined when used on a constructor, destructor, overloaded operator, 1095or type-conversion operator, or any function that is implicitly 1096generated by the compiler. See below for macros that can be used to 1097distinguish these cases. 1098 1099@item DECL_ASSEMBLER_NAME 1100This macro returns the mangled name of the function, also an 1101@code{IDENTIFIER_NODE}. This name does not contain leading underscores 1102on systems that prefix all identifiers with underscores. The mangled 1103name is computed in the same way on all platforms; if special processing 1104is required to deal with the object file format used on a particular 1105platform, it is the responsibility of the back end to perform those 1106modifications. (Of course, the back end should not modify 1107@code{DECL_ASSEMBLER_NAME} itself.) 1108 1109@item DECL_EXTERNAL 1110This predicate holds if the function is undefined. 1111 1112@item TREE_PUBLIC 1113This predicate holds if the function has external linkage. 1114 1115@item DECL_LOCAL_FUNCTION_P 1116This predicate holds if the function was declared at block scope, even 1117though it has a global scope. 1118 1119@item DECL_ANTICIPATED 1120This predicate holds if the function is a built-in function but its 1121prototype is not yet explicitly declared. 1122 1123@item DECL_EXTERN_C_FUNCTION_P 1124This predicate holds if the function is declared as an 1125`@code{extern "C"}' function. 1126 1127@item DECL_LINKONCE_P 1128This macro holds if multiple copies of this function may be emitted in 1129various translation units. It is the responsibility of the linker to 1130merge the various copies. Template instantiations are the most common 1131example of functions for which @code{DECL_LINKONCE_P} holds; G++ 1132instantiates needed templates in all translation units which require them, 1133and then relies on the linker to remove duplicate instantiations. 1134 1135FIXME: This macro is not yet implemented. 1136 1137@item DECL_FUNCTION_MEMBER_P 1138This macro holds if the function is a member of a class, rather than a 1139member of a namespace. 1140 1141@item DECL_STATIC_FUNCTION_P 1142This predicate holds if the function a static member function. 1143 1144@item DECL_NONSTATIC_MEMBER_FUNCTION_P 1145This macro holds for a non-static member function. 1146 1147@item DECL_CONST_MEMFUNC_P 1148This predicate holds for a @code{const}-member function. 1149 1150@item DECL_VOLATILE_MEMFUNC_P 1151This predicate holds for a @code{volatile}-member function. 1152 1153@item DECL_CONSTRUCTOR_P 1154This macro holds if the function is a constructor. 1155 1156@item DECL_NONCONVERTING_P 1157This predicate holds if the constructor is a non-converting constructor. 1158 1159@item DECL_COMPLETE_CONSTRUCTOR_P 1160This predicate holds for a function which is a constructor for an object 1161of a complete type. 1162 1163@item DECL_BASE_CONSTRUCTOR_P 1164This predicate holds for a function which is a constructor for a base 1165class sub-object. 1166 1167@item DECL_COPY_CONSTRUCTOR_P 1168This predicate holds for a function which is a copy-constructor. 1169 1170@item DECL_DESTRUCTOR_P 1171This macro holds if the function is a destructor. 1172 1173@item DECL_COMPLETE_DESTRUCTOR_P 1174This predicate holds if the function is the destructor for an object a 1175complete type. 1176 1177@item DECL_OVERLOADED_OPERATOR_P 1178This macro holds if the function is an overloaded operator. 1179 1180@item DECL_CONV_FN_P 1181This macro holds if the function is a type-conversion operator. 1182 1183@item DECL_GLOBAL_CTOR_P 1184This predicate holds if the function is a file-scope initialization 1185function. 1186 1187@item DECL_GLOBAL_DTOR_P 1188This predicate holds if the function is a file-scope finalization 1189function. 1190 1191@item DECL_THUNK_P 1192This predicate holds if the function is a thunk. 1193 1194These functions represent stub code that adjusts the @code{this} pointer 1195and then jumps to another function. When the jumped-to function 1196returns, control is transferred directly to the caller, without 1197returning to the thunk. The first parameter to the thunk is always the 1198@code{this} pointer; the thunk should add @code{THUNK_DELTA} to this 1199value. (The @code{THUNK_DELTA} is an @code{int}, not an 1200@code{INTEGER_CST}.) 1201 1202Then, if @code{THUNK_VCALL_OFFSET} (an @code{INTEGER_CST}) is nonzero 1203the adjusted @code{this} pointer must be adjusted again. The complete 1204calculation is given by the following pseudo-code: 1205 1206@example 1207this += THUNK_DELTA 1208if (THUNK_VCALL_OFFSET) 1209 this += (*((ptrdiff_t **) this))[THUNK_VCALL_OFFSET] 1210@end example 1211 1212Finally, the thunk should jump to the location given 1213by @code{DECL_INITIAL}; this will always be an expression for the 1214address of a function. 1215 1216@item DECL_NON_THUNK_FUNCTION_P 1217This predicate holds if the function is @emph{not} a thunk function. 1218 1219@item GLOBAL_INIT_PRIORITY 1220If either @code{DECL_GLOBAL_CTOR_P} or @code{DECL_GLOBAL_DTOR_P} holds, 1221then this gives the initialization priority for the function. The 1222linker will arrange that all functions for which 1223@code{DECL_GLOBAL_CTOR_P} holds are run in increasing order of priority 1224before @code{main} is called. When the program exits, all functions for 1225which @code{DECL_GLOBAL_DTOR_P} holds are run in the reverse order. 1226 1227@item DECL_ARTIFICIAL 1228This macro holds if the function was implicitly generated by the 1229compiler, rather than explicitly declared. In addition to implicitly 1230generated class member functions, this macro holds for the special 1231functions created to implement static initialization and destruction, to 1232compute run-time type information, and so forth. 1233 1234@item DECL_ARGUMENTS 1235This macro returns the @code{PARM_DECL} for the first argument to the 1236function. Subsequent @code{PARM_DECL} nodes can be obtained by 1237following the @code{TREE_CHAIN} links. 1238 1239@item DECL_RESULT 1240This macro returns the @code{RESULT_DECL} for the function. 1241 1242@item TREE_TYPE 1243This macro returns the @code{FUNCTION_TYPE} or @code{METHOD_TYPE} for 1244the function. 1245 1246@item TYPE_RAISES_EXCEPTIONS 1247This macro returns the list of exceptions that a (member-)function can 1248raise. The returned list, if non @code{NULL}, is comprised of nodes 1249whose @code{TREE_VALUE} represents a type. 1250 1251@item TYPE_NOTHROW_P 1252This predicate holds when the exception-specification of its arguments 1253if of the form `@code{()}'. 1254 1255@item DECL_ARRAY_DELETE_OPERATOR_P 1256This predicate holds if the function an overloaded 1257@code{operator delete[]}. 1258 1259@end ftable 1260 1261@c --------------------------------------------------------------------- 1262@c Function Bodies 1263@c --------------------------------------------------------------------- 1264 1265@node Function Bodies 1266@subsection Function Bodies 1267@cindex function body 1268@cindex statements 1269@tindex ASM_STMT 1270@findex ASM_STRING 1271@findex ASM_CV_QUAL 1272@findex ASM_INPUTS 1273@findex ASM_OUTPUTS 1274@findex ASM_CLOBBERS 1275@tindex BREAK_STMT 1276@tindex CLEANUP_STMT 1277@findex CLEANUP_DECL 1278@findex CLEANUP_EXPR 1279@tindex COMPOUND_STMT 1280@findex COMPOUND_BODY 1281@tindex CONTINUE_STMT 1282@tindex DECL_STMT 1283@findex DECL_STMT_DECL 1284@tindex DO_STMT 1285@findex DO_BODY 1286@findex DO_COND 1287@tindex EMPTY_CLASS_EXPR 1288@tindex EXPR_STMT 1289@findex EXPR_STMT_EXPR 1290@tindex FOR_STMT 1291@findex FOR_INIT_STMT 1292@findex FOR_COND 1293@findex FOR_EXPR 1294@findex FOR_BODY 1295@tindex FILE_STMT 1296@findex FILE_STMT_FILENAME 1297@tindex GOTO_STMT 1298@findex GOTO_DESTINATION 1299@findex GOTO_FAKE_P 1300@tindex HANDLER 1301@tindex IF_STMT 1302@findex IF_COND 1303@findex THEN_CLAUSE 1304@findex ELSE_CLAUSE 1305@tindex LABEL_STMT 1306@tindex LABEL_STMT_LABEL 1307@tindex RETURN_INIT 1308@tindex RETURN_STMT 1309@findex RETURN_EXPR 1310@tindex SCOPE_STMT 1311@findex SCOPE_BEGIN_P 1312@findex SCOPE_END_P 1313@findex SCOPE_NULLIFIED_P 1314@tindex SUBOBJECT 1315@findex SUBOBJECT_CLEANUP 1316@tindex SWITCH_STMT 1317@findex SWITCH_COND 1318@findex SWITCH_BODY 1319@tindex TRY_BLOCK 1320@findex TRY_STMTS 1321@findex TRY_HANDLERS 1322@findex HANDLER_PARMS 1323@findex HANDLER_BODY 1324@findex USING_STMT 1325@tindex WHILE_STMT 1326@findex WHILE_BODY 1327@findex WHILE_COND 1328 1329A function that has a definition in the current translation unit will 1330have a non-@code{NULL} @code{DECL_INITIAL}. However, back ends should not make 1331use of the particular value given by @code{DECL_INITIAL}. 1332 1333The @code{DECL_SAVED_TREE} macro will give the complete body of the 1334function. This node will usually be a @code{COMPOUND_STMT} representing 1335the outermost block of the function, but it may also be a 1336@code{TRY_BLOCK}, a @code{RETURN_INIT}, or any other valid statement. 1337 1338@subsubsection Statements 1339 1340There are tree nodes corresponding to all of the source-level statement 1341constructs. These are enumerated here, together with a list of the 1342various macros that can be used to obtain information about them. There 1343are a few macros that can be used with all statements: 1344 1345@ftable @code 1346@item STMT_LINENO 1347This macro returns the line number for the statement. If the statement 1348spans multiple lines, this value will be the number of the first line on 1349which the statement occurs. Although we mention @code{CASE_LABEL} below 1350as if it were a statement, they do not allow the use of 1351@code{STMT_LINENO}. There is no way to obtain the line number for a 1352@code{CASE_LABEL}. 1353 1354Statements do not contain information about 1355the file from which they came; that information is implicit in the 1356@code{FUNCTION_DECL} from which the statements originate. 1357 1358@item STMT_IS_FULL_EXPR_P 1359In C++, statements normally constitute ``full expressions''; temporaries 1360created during a statement are destroyed when the statement is complete. 1361However, G++ sometimes represents expressions by statements; these 1362statements will not have @code{STMT_IS_FULL_EXPR_P} set. Temporaries 1363created during such statements should be destroyed when the innermost 1364enclosing statement with @code{STMT_IS_FULL_EXPR_P} set is exited. 1365 1366@end ftable 1367 1368Here is the list of the various statement nodes, and the macros used to 1369access them. This documentation describes the use of these nodes in 1370non-template functions (including instantiations of template functions). 1371In template functions, the same nodes are used, but sometimes in 1372slightly different ways. 1373 1374Many of the statements have substatements. For example, a @code{while} 1375loop will have a body, which is itself a statement. If the substatement 1376is @code{NULL_TREE}, it is considered equivalent to a statement 1377consisting of a single @code{;}, i.e., an expression statement in which 1378the expression has been omitted. A substatement may in fact be a list 1379of statements, connected via their @code{TREE_CHAIN}s. So, you should 1380always process the statement tree by looping over substatements, like 1381this: 1382@example 1383void process_stmt (stmt) 1384 tree stmt; 1385@{ 1386 while (stmt) 1387 @{ 1388 switch (TREE_CODE (stmt)) 1389 @{ 1390 case IF_STMT: 1391 process_stmt (THEN_CLAUSE (stmt)); 1392 /* More processing here. */ 1393 break; 1394 1395 @dots{} 1396 @} 1397 1398 stmt = TREE_CHAIN (stmt); 1399 @} 1400@} 1401@end example 1402In other words, while the @code{then} clause of an @code{if} statement 1403in C++ can be only one statement (although that one statement may be a 1404compound statement), the intermediate representation will sometimes use 1405several statements chained together. 1406 1407@table @code 1408@item ASM_STMT 1409 1410Used to represent an inline assembly statement. For an inline assembly 1411statement like: 1412@example 1413asm ("mov x, y"); 1414@end example 1415The @code{ASM_STRING} macro will return a @code{STRING_CST} node for 1416@code{"mov x, y"}. If the original statement made use of the 1417extended-assembly syntax, then @code{ASM_OUTPUTS}, 1418@code{ASM_INPUTS}, and @code{ASM_CLOBBERS} will be the outputs, inputs, 1419and clobbers for the statement, represented as @code{STRING_CST} nodes. 1420The extended-assembly syntax looks like: 1421@example 1422asm ("fsinx %1,%0" : "=f" (result) : "f" (angle)); 1423@end example 1424The first string is the @code{ASM_STRING}, containing the instruction 1425template. The next two strings are the output and inputs, respectively; 1426this statement has no clobbers. As this example indicates, ``plain'' 1427assembly statements are merely a special case of extended assembly 1428statements; they have no cv-qualifiers, outputs, inputs, or clobbers. 1429All of the strings will be @code{NUL}-terminated, and will contain no 1430embedded @code{NUL}-characters. 1431 1432If the assembly statement is declared @code{volatile}, or if the 1433statement was not an extended assembly statement, and is therefore 1434implicitly volatile, then the predicate @code{ASM_VOLATILE_P} will hold 1435of the @code{ASM_STMT}. 1436 1437@item BREAK_STMT 1438 1439Used to represent a @code{break} statement. There are no additional 1440fields. 1441 1442@item CASE_LABEL 1443 1444Use to represent a @code{case} label, range of @code{case} labels, or a 1445@code{default} label. If @code{CASE_LOW} is @code{NULL_TREE}, then this is a 1446@code{default} label. Otherwise, if @code{CASE_HIGH} is @code{NULL_TREE}, then 1447this is an ordinary @code{case} label. In this case, @code{CASE_LOW} is 1448an expression giving the value of the label. Both @code{CASE_LOW} and 1449@code{CASE_HIGH} are @code{INTEGER_CST} nodes. These values will have 1450the same type as the condition expression in the switch statement. 1451 1452Otherwise, if both @code{CASE_LOW} and @code{CASE_HIGH} are defined, the 1453statement is a range of case labels. Such statements originate with the 1454extension that allows users to write things of the form: 1455@example 1456case 2 ... 5: 1457@end example 1458The first value will be @code{CASE_LOW}, while the second will be 1459@code{CASE_HIGH}. 1460 1461@item CLEANUP_STMT 1462 1463Used to represent an action that should take place upon exit from the 1464enclosing scope. Typically, these actions are calls to destructors for 1465local objects, but back ends cannot rely on this fact. If these nodes 1466are in fact representing such destructors, @code{CLEANUP_DECL} will be 1467the @code{VAR_DECL} destroyed. Otherwise, @code{CLEANUP_DECL} will be 1468@code{NULL_TREE}. In any case, the @code{CLEANUP_EXPR} is the 1469expression to execute. The cleanups executed on exit from a scope 1470should be run in the reverse order of the order in which the associated 1471@code{CLEANUP_STMT}s were encountered. 1472 1473@item COMPOUND_STMT 1474 1475Used to represent a brace-enclosed block. The first substatement is 1476given by @code{COMPOUND_BODY}. Subsequent substatements are found by 1477following the @code{TREE_CHAIN} link from one substatement to the next. 1478The @code{COMPOUND_BODY} will be @code{NULL_TREE} if there are no 1479substatements. 1480 1481@item CONTINUE_STMT 1482 1483Used to represent a @code{continue} statement. There are no additional 1484fields. 1485 1486@item CTOR_STMT 1487 1488Used to mark the beginning (if @code{CTOR_BEGIN_P} holds) or end (if 1489@code{CTOR_END_P} holds of the main body of a constructor. See also 1490@code{SUBOBJECT} for more information on how to use these nodes. 1491 1492@item DECL_STMT 1493 1494Used to represent a local declaration. The @code{DECL_STMT_DECL} macro 1495can be used to obtain the entity declared. This declaration may be a 1496@code{LABEL_DECL}, indicating that the label declared is a local label. 1497(As an extension, GCC allows the declaration of labels with scope.) In 1498C, this declaration may be a @code{FUNCTION_DECL}, indicating the 1499use of the GCC nested function extension. For more information, 1500@pxref{Functions}. 1501 1502@item DO_STMT 1503 1504Used to represent a @code{do} loop. The body of the loop is given by 1505@code{DO_BODY} while the termination condition for the loop is given by 1506@code{DO_COND}. The condition for a @code{do}-statement is always an 1507expression. 1508 1509@item EMPTY_CLASS_EXPR 1510 1511Used to represent a temporary object of a class with no data whose 1512address is never taken. (All such objects are interchangeable.) The 1513@code{TREE_TYPE} represents the type of the object. 1514 1515@item EXPR_STMT 1516 1517Used to represent an expression statement. Use @code{EXPR_STMT_EXPR} to 1518obtain the expression. 1519 1520@item FILE_STMT 1521 1522Used to record a change in filename within the body of a function. 1523Use @code{FILE_STMT_FILENAME} to obtain the new filename. 1524 1525@item FOR_STMT 1526 1527Used to represent a @code{for} statement. The @code{FOR_INIT_STMT} is 1528the initialization statement for the loop. The @code{FOR_COND} is the 1529termination condition. The @code{FOR_EXPR} is the expression executed 1530right before the @code{FOR_COND} on each loop iteration; often, this 1531expression increments a counter. The body of the loop is given by 1532@code{FOR_BODY}. Note that @code{FOR_INIT_STMT} and @code{FOR_BODY} 1533return statements, while @code{FOR_COND} and @code{FOR_EXPR} return 1534expressions. 1535 1536@item GOTO_STMT 1537 1538Used to represent a @code{goto} statement. The @code{GOTO_DESTINATION} will 1539usually be a @code{LABEL_DECL}. However, if the ``computed goto'' extension 1540has been used, the @code{GOTO_DESTINATION} will be an arbitrary expression 1541indicating the destination. This expression will always have pointer type. 1542Additionally the @code{GOTO_FAKE_P} flag is set whenever the goto statement 1543does not come from source code, but it is generated implicitly by the compiler. 1544This is used for branch prediction. 1545 1546@item HANDLER 1547 1548Used to represent a C++ @code{catch} block. The @code{HANDLER_TYPE} 1549is the type of exception that will be caught by this handler; it is 1550equal (by pointer equality) to @code{CATCH_ALL_TYPE} if this handler 1551is for all types. @code{HANDLER_PARMS} is the @code{DECL_STMT} for 1552the catch parameter, and @code{HANDLER_BODY} is the 1553@code{COMPOUND_STMT} for the block itself. 1554 1555@item IF_STMT 1556 1557Used to represent an @code{if} statement. The @code{IF_COND} is the 1558expression. 1559 1560If the condition is a @code{TREE_LIST}, then the @code{TREE_PURPOSE} is 1561a statement (usually a @code{DECL_STMT}). Each time the condition is 1562evaluated, the statement should be executed. Then, the 1563@code{TREE_VALUE} should be used as the conditional expression itself. 1564This representation is used to handle C++ code like this: 1565 1566@example 1567if (int i = 7) @dots{} 1568@end example 1569 1570where there is a new local variable (or variables) declared within the 1571condition. 1572 1573The @code{THEN_CLAUSE} represents the statement given by the @code{then} 1574condition, while the @code{ELSE_CLAUSE} represents the statement given 1575by the @code{else} condition. 1576 1577@item LABEL_STMT 1578 1579Used to represent a label. The @code{LABEL_DECL} declared by this 1580statement can be obtained with the @code{LABEL_STMT_LABEL} macro. The 1581@code{IDENTIFIER_NODE} giving the name of the label can be obtained from 1582the @code{LABEL_DECL} with @code{DECL_NAME}. 1583 1584@item RETURN_INIT 1585 1586If the function uses the G++ ``named return value'' extension, meaning 1587that the function has been defined like: 1588@example 1589S f(int) return s @{@dots{}@} 1590@end example 1591then there will be a @code{RETURN_INIT}. There is never a named 1592returned value for a constructor. The first argument to the 1593@code{RETURN_INIT} is the name of the object returned; the second 1594argument is the initializer for the object. The object is initialized 1595when the @code{RETURN_INIT} is encountered. The object referred to is 1596the actual object returned; this extension is a manual way of doing the 1597``return-value optimization.'' Therefore, the object must actually be 1598constructed in the place where the object will be returned. 1599 1600@item RETURN_STMT 1601 1602Used to represent a @code{return} statement. The @code{RETURN_EXPR} is 1603the expression returned; it will be @code{NULL_TREE} if the statement 1604was just 1605@example 1606return; 1607@end example 1608 1609@item SCOPE_STMT 1610 1611A scope-statement represents the beginning or end of a scope. If 1612@code{SCOPE_BEGIN_P} holds, this statement represents the beginning of a 1613scope; if @code{SCOPE_END_P} holds this statement represents the end of 1614a scope. On exit from a scope, all cleanups from @code{CLEANUP_STMT}s 1615occurring in the scope must be run, in reverse order to the order in 1616which they were encountered. If @code{SCOPE_NULLIFIED_P} or 1617@code{SCOPE_NO_CLEANUPS_P} holds of the scope, back ends should behave 1618as if the @code{SCOPE_STMT} were not present at all. 1619 1620@item SUBOBJECT 1621 1622In a constructor, these nodes are used to mark the point at which a 1623subobject of @code{this} is fully constructed. If, after this point, an 1624exception is thrown before a @code{CTOR_STMT} with @code{CTOR_END_P} set 1625is encountered, the @code{SUBOBJECT_CLEANUP} must be executed. The 1626cleanups must be executed in the reverse order in which they appear. 1627 1628@item SWITCH_STMT 1629 1630Used to represent a @code{switch} statement. The @code{SWITCH_COND} is 1631the expression on which the switch is occurring. See the documentation 1632for an @code{IF_STMT} for more information on the representation used 1633for the condition. The @code{SWITCH_BODY} is the body of the switch 1634statement. 1635 1636@item TRY_BLOCK 1637Used to represent a @code{try} block. The body of the try block is 1638given by @code{TRY_STMTS}. Each of the catch blocks is a @code{HANDLER} 1639node. The first handler is given by @code{TRY_HANDLERS}. Subsequent 1640handlers are obtained by following the @code{TREE_CHAIN} link from one 1641handler to the next. The body of the handler is given by 1642@code{HANDLER_BODY}. 1643 1644If @code{CLEANUP_P} holds of the @code{TRY_BLOCK}, then the 1645@code{TRY_HANDLERS} will not be a @code{HANDLER} node. Instead, it will 1646be an expression that should be executed if an exception is thrown in 1647the try block. It must rethrow the exception after executing that code. 1648And, if an exception is thrown while the expression is executing, 1649@code{terminate} must be called. 1650 1651@item USING_STMT 1652Used to represent a @code{using} directive. The namespace is given by 1653@code{USING_STMT_NAMESPACE}, which will be a NAMESPACE_DECL@. This node 1654is needed inside template functions, to implement using directives 1655during instantiation. 1656 1657@item WHILE_STMT 1658 1659Used to represent a @code{while} loop. The @code{WHILE_COND} is the 1660termination condition for the loop. See the documentation for an 1661@code{IF_STMT} for more information on the representation used for the 1662condition. 1663 1664The @code{WHILE_BODY} is the body of the loop. 1665 1666@end table 1667 1668@c --------------------------------------------------------------------- 1669@c Attributes 1670@c --------------------------------------------------------------------- 1671@node Attributes 1672@section Attributes in trees 1673@cindex attributes 1674 1675Attributes, as specified using the @code{__attribute__} keyword, are 1676represented internally as a @code{TREE_LIST}. The @code{TREE_PURPOSE} 1677is the name of the attribute, as an @code{IDENTIFIER_NODE}. The 1678@code{TREE_VALUE} is a @code{TREE_LIST} of the arguments of the 1679attribute, if any, or @code{NULL_TREE} if there are no arguments; the 1680arguments are stored as the @code{TREE_VALUE} of successive entries in 1681the list, and may be identifiers or expressions. The @code{TREE_CHAIN} 1682of the attribute is the next attribute in a list of attributes applying 1683to the same declaration or type, or @code{NULL_TREE} if there are no 1684further attributes in the list. 1685 1686Attributes may be attached to declarations and to types; these 1687attributes may be accessed with the following macros. All attributes 1688are stored in this way, and many also cause other changes to the 1689declaration or type or to other internal compiler data structures. 1690 1691@deftypefn {Tree Macro} tree DECL_ATTRIBUTES (tree @var{decl}) 1692This macro returns the attributes on the declaration @var{decl}. 1693@end deftypefn 1694 1695@deftypefn {Tree Macro} tree TYPE_ATTRIBUTES (tree @var{type}) 1696This macro returns the attributes on the type @var{type}. 1697@end deftypefn 1698 1699@c --------------------------------------------------------------------- 1700@c Expressions 1701@c --------------------------------------------------------------------- 1702 1703@node Expression trees 1704@section Expressions 1705@cindex expression 1706@findex TREE_OPERAND 1707@tindex INTEGER_CST 1708@findex TREE_INT_CST_HIGH 1709@findex TREE_INT_CST_LOW 1710@findex tree_int_cst_lt 1711@findex tree_int_cst_equal 1712@tindex REAL_CST 1713@tindex COMPLEX_CST 1714@tindex STRING_CST 1715@findex TREE_STRING_LENGTH 1716@findex TREE_STRING_POINTER 1717@tindex PTRMEM_CST 1718@findex PTRMEM_CST_CLASS 1719@findex PTRMEM_CST_MEMBER 1720@tindex VAR_DECL 1721@tindex NEGATE_EXPR 1722@tindex BIT_NOT_EXPR 1723@tindex TRUTH_NOT_EXPR 1724@tindex ADDR_EXPR 1725@tindex INDIRECT_REF 1726@tindex FIX_TRUNC_EXPR 1727@tindex FLOAT_EXPR 1728@tindex COMPLEX_EXPR 1729@tindex CONJ_EXPR 1730@tindex REALPART_EXPR 1731@tindex IMAGPART_EXPR 1732@tindex NOP_EXPR 1733@tindex CONVERT_EXPR 1734@tindex THROW_EXPR 1735@tindex LSHIFT_EXPR 1736@tindex RSHIFT_EXPR 1737@tindex BIT_IOR_EXPR 1738@tindex BIT_XOR_EXPR 1739@tindex BIT_AND_EXPR 1740@tindex TRUTH_ANDIF_EXPR 1741@tindex TRUTH_ORIF_EXPR 1742@tindex TRUTH_AND_EXPR 1743@tindex TRUTH_OR_EXPR 1744@tindex TRUTH_XOR_EXPR 1745@tindex PLUS_EXPR 1746@tindex MINUS_EXPR 1747@tindex MULT_EXPR 1748@tindex TRUNC_DIV_EXPR 1749@tindex TRUNC_MOD_EXPR 1750@tindex RDIV_EXPR 1751@tindex LT_EXPR 1752@tindex LE_EXPR 1753@tindex GT_EXPR 1754@tindex GE_EXPR 1755@tindex EQ_EXPR 1756@tindex NE_EXPR 1757@tindex INIT_EXPR 1758@tindex MODIFY_EXPR 1759@tindex COMPONENT_REF 1760@tindex COMPOUND_EXPR 1761@tindex COND_EXPR 1762@tindex CALL_EXPR 1763@tindex CONSTRUCTOR 1764@tindex COMPOUND_LITERAL_EXPR 1765@tindex STMT_EXPR 1766@tindex BIND_EXPR 1767@tindex LOOP_EXPR 1768@tindex EXIT_EXPR 1769@tindex CLEANUP_POINT_EXPR 1770@tindex ARRAY_REF 1771@tindex VTABLE_REF 1772 1773The internal representation for expressions is for the most part quite 1774straightforward. However, there are a few facts that one must bear in 1775mind. In particular, the expression ``tree'' is actually a directed 1776acyclic graph. (For example there may be many references to the integer 1777constant zero throughout the source program; many of these will be 1778represented by the same expression node.) You should not rely on 1779certain kinds of node being shared, nor should rely on certain kinds of 1780nodes being unshared. 1781 1782The following macros can be used with all expression nodes: 1783 1784@ftable @code 1785@item TREE_TYPE 1786Returns the type of the expression. This value may not be precisely the 1787same type that would be given the expression in the original program. 1788@end ftable 1789 1790In what follows, some nodes that one might expect to always have type 1791@code{bool} are documented to have either integral or boolean type. At 1792some point in the future, the C front end may also make use of this same 1793intermediate representation, and at this point these nodes will 1794certainly have integral type. The previous sentence is not meant to 1795imply that the C++ front end does not or will not give these nodes 1796integral type. 1797 1798Below, we list the various kinds of expression nodes. Except where 1799noted otherwise, the operands to an expression are accessed using the 1800@code{TREE_OPERAND} macro. For example, to access the first operand to 1801a binary plus expression @code{expr}, use: 1802 1803@example 1804TREE_OPERAND (expr, 0) 1805@end example 1806@noindent 1807As this example indicates, the operands are zero-indexed. 1808 1809The table below begins with constants, moves on to unary expressions, 1810then proceeds to binary expressions, and concludes with various other 1811kinds of expressions: 1812 1813@table @code 1814@item INTEGER_CST 1815These nodes represent integer constants. Note that the type of these 1816constants is obtained with @code{TREE_TYPE}; they are not always of type 1817@code{int}. In particular, @code{char} constants are represented with 1818@code{INTEGER_CST} nodes. The value of the integer constant @code{e} is 1819given by @example 1820((TREE_INT_CST_HIGH (e) << HOST_BITS_PER_WIDE_INT) 1821+ TREE_INST_CST_LOW (e)) 1822@end example 1823@noindent 1824HOST_BITS_PER_WIDE_INT is at least thirty-two on all platforms. Both 1825@code{TREE_INT_CST_HIGH} and @code{TREE_INT_CST_LOW} return a 1826@code{HOST_WIDE_INT}. The value of an @code{INTEGER_CST} is interpreted 1827as a signed or unsigned quantity depending on the type of the constant. 1828In general, the expression given above will overflow, so it should not 1829be used to calculate the value of the constant. 1830 1831The variable @code{integer_zero_node} is an integer constant with value 1832zero. Similarly, @code{integer_one_node} is an integer constant with 1833value one. The @code{size_zero_node} and @code{size_one_node} variables 1834are analogous, but have type @code{size_t} rather than @code{int}. 1835 1836The function @code{tree_int_cst_lt} is a predicate which holds if its 1837first argument is less than its second. Both constants are assumed to 1838have the same signedness (i.e., either both should be signed or both 1839should be unsigned.) The full width of the constant is used when doing 1840the comparison; the usual rules about promotions and conversions are 1841ignored. Similarly, @code{tree_int_cst_equal} holds if the two 1842constants are equal. The @code{tree_int_cst_sgn} function returns the 1843sign of a constant. The value is @code{1}, @code{0}, or @code{-1} 1844according on whether the constant is greater than, equal to, or less 1845than zero. Again, the signedness of the constant's type is taken into 1846account; an unsigned constant is never less than zero, no matter what 1847its bit-pattern. 1848 1849@item REAL_CST 1850 1851FIXME: Talk about how to obtain representations of this constant, do 1852comparisons, and so forth. 1853 1854@item COMPLEX_CST 1855These nodes are used to represent complex number constants, that is a 1856@code{__complex__} whose parts are constant nodes. The 1857@code{TREE_REALPART} and @code{TREE_IMAGPART} return the real and the 1858imaginary parts respectively. 1859 1860@item STRING_CST 1861These nodes represent string-constants. The @code{TREE_STRING_LENGTH} 1862returns the length of the string, as an @code{int}. The 1863@code{TREE_STRING_POINTER} is a @code{char*} containing the string 1864itself. The string may not be @code{NUL}-terminated, and it may contain 1865embedded @code{NUL} characters. Therefore, the 1866@code{TREE_STRING_LENGTH} includes the trailing @code{NUL} if it is 1867present. 1868 1869For wide string constants, the @code{TREE_STRING_LENGTH} is the number 1870of bytes in the string, and the @code{TREE_STRING_POINTER} 1871points to an array of the bytes of the string, as represented on the 1872target system (that is, as integers in the target endianness). Wide and 1873non-wide string constants are distinguished only by the @code{TREE_TYPE} 1874of the @code{STRING_CST}. 1875 1876FIXME: The formats of string constants are not well-defined when the 1877target system bytes are not the same width as host system bytes. 1878 1879@item PTRMEM_CST 1880These nodes are used to represent pointer-to-member constants. The 1881@code{PTRMEM_CST_CLASS} is the class type (either a @code{RECORD_TYPE} 1882or @code{UNION_TYPE} within which the pointer points), and the 1883@code{PTRMEM_CST_MEMBER} is the declaration for the pointed to object. 1884Note that the @code{DECL_CONTEXT} for the @code{PTRMEM_CST_MEMBER} is in 1885general different from the @code{PTRMEM_CST_CLASS}. For example, 1886given: 1887@example 1888struct B @{ int i; @}; 1889struct D : public B @{@}; 1890int D::*dp = &D::i; 1891@end example 1892@noindent 1893The @code{PTRMEM_CST_CLASS} for @code{&D::i} is @code{D}, even though 1894the @code{DECL_CONTEXT} for the @code{PTRMEM_CST_MEMBER} is @code{B}, 1895since @code{B::i} is a member of @code{B}, not @code{D}. 1896 1897@item VAR_DECL 1898 1899These nodes represent variables, including static data members. For 1900more information, @pxref{Declarations}. 1901 1902@item NEGATE_EXPR 1903These nodes represent unary negation of the single operand, for both 1904integer and floating-point types. The type of negation can be 1905determined by looking at the type of the expression. 1906 1907@item BIT_NOT_EXPR 1908These nodes represent bitwise complement, and will always have integral 1909type. The only operand is the value to be complemented. 1910 1911@item TRUTH_NOT_EXPR 1912These nodes represent logical negation, and will always have integral 1913(or boolean) type. The operand is the value being negated. 1914 1915@item PREDECREMENT_EXPR 1916@itemx PREINCREMENT_EXPR 1917@itemx POSTDECREMENT_EXPR 1918@itemx POSTINCREMENT_EXPR 1919These nodes represent increment and decrement expressions. The value of 1920the single operand is computed, and the operand incremented or 1921decremented. In the case of @code{PREDECREMENT_EXPR} and 1922@code{PREINCREMENT_EXPR}, the value of the expression is the value 1923resulting after the increment or decrement; in the case of 1924@code{POSTDECREMENT_EXPR} and @code{POSTINCREMENT_EXPR} is the value 1925before the increment or decrement occurs. The type of the operand, like 1926that of the result, will be either integral, boolean, or floating-point. 1927 1928@item ADDR_EXPR 1929These nodes are used to represent the address of an object. (These 1930expressions will always have pointer or reference type.) The operand may 1931be another expression, or it may be a declaration. 1932 1933As an extension, GCC allows users to take the address of a label. In 1934this case, the operand of the @code{ADDR_EXPR} will be a 1935@code{LABEL_DECL}. The type of such an expression is @code{void*}. 1936 1937If the object addressed is not an lvalue, a temporary is created, and 1938the address of the temporary is used. 1939 1940@item INDIRECT_REF 1941These nodes are used to represent the object pointed to by a pointer. 1942The operand is the pointer being dereferenced; it will always have 1943pointer or reference type. 1944 1945@item FIX_TRUNC_EXPR 1946These nodes represent conversion of a floating-point value to an 1947integer. The single operand will have a floating-point type, while the 1948the complete expression will have an integral (or boolean) type. The 1949operand is rounded towards zero. 1950 1951@item FLOAT_EXPR 1952These nodes represent conversion of an integral (or boolean) value to a 1953floating-point value. The single operand will have integral type, while 1954the complete expression will have a floating-point type. 1955 1956FIXME: How is the operand supposed to be rounded? Is this dependent on 1957@option{-mieee}? 1958 1959@item COMPLEX_EXPR 1960These nodes are used to represent complex numbers constructed from two 1961expressions of the same (integer or real) type. The first operand is the 1962real part and the second operand is the imaginary part. 1963 1964@item CONJ_EXPR 1965These nodes represent the conjugate of their operand. 1966 1967@item REALPART_EXPR 1968@item IMAGPART_EXPR 1969These nodes represent respectively the real and the imaginary parts 1970of complex numbers (their sole argument). 1971 1972@item NON_LVALUE_EXPR 1973These nodes indicate that their one and only operand is not an lvalue. 1974A back end can treat these identically to the single operand. 1975 1976@item NOP_EXPR 1977These nodes are used to represent conversions that do not require any 1978code-generation. For example, conversion of a @code{char*} to an 1979@code{int*} does not require any code be generated; such a conversion is 1980represented by a @code{NOP_EXPR}. The single operand is the expression 1981to be converted. The conversion from a pointer to a reference is also 1982represented with a @code{NOP_EXPR}. 1983 1984@item CONVERT_EXPR 1985These nodes are similar to @code{NOP_EXPR}s, but are used in those 1986situations where code may need to be generated. For example, if an 1987@code{int*} is converted to an @code{int} code may need to be generated 1988on some platforms. These nodes are never used for C++-specific 1989conversions, like conversions between pointers to different classes in 1990an inheritance hierarchy. Any adjustments that need to be made in such 1991cases are always indicated explicitly. Similarly, a user-defined 1992conversion is never represented by a @code{CONVERT_EXPR}; instead, the 1993function calls are made explicit. 1994 1995@item THROW_EXPR 1996These nodes represent @code{throw} expressions. The single operand is 1997an expression for the code that should be executed to throw the 1998exception. However, there is one implicit action not represented in 1999that expression; namely the call to @code{__throw}. This function takes 2000no arguments. If @code{setjmp}/@code{longjmp} exceptions are used, the 2001function @code{__sjthrow} is called instead. The normal GCC back end 2002uses the function @code{emit_throw} to generate this code; you can 2003examine this function to see what needs to be done. 2004 2005@item LSHIFT_EXPR 2006@itemx RSHIFT_EXPR 2007These nodes represent left and right shifts, respectively. The first 2008operand is the value to shift; it will always be of integral type. The 2009second operand is an expression for the number of bits by which to 2010shift. Right shift should be treated as arithmetic, i.e., the 2011high-order bits should be zero-filled when the expression has unsigned 2012type and filled with the sign bit when the expression has signed type. 2013Note that the result is undefined if the second operand is larger 2014than the first operand's type size. 2015 2016 2017@item BIT_IOR_EXPR 2018@itemx BIT_XOR_EXPR 2019@itemx BIT_AND_EXPR 2020These nodes represent bitwise inclusive or, bitwise exclusive or, and 2021bitwise and, respectively. Both operands will always have integral 2022type. 2023 2024@item TRUTH_ANDIF_EXPR 2025@itemx TRUTH_ORIF_EXPR 2026These nodes represent logical and and logical or, respectively. These 2027operators are not strict; i.e., the second operand is evaluated only if 2028the value of the expression is not determined by evaluation of the first 2029operand. The type of the operands, and the result type, is always of 2030boolean or integral type. 2031 2032@item TRUTH_AND_EXPR 2033@itemx TRUTH_OR_EXPR 2034@itemx TRUTH_XOR_EXPR 2035These nodes represent logical and, logical or, and logical exclusive or. 2036They are strict; both arguments are always evaluated. There are no 2037corresponding operators in C or C++, but the front end will sometimes 2038generate these expressions anyhow, if it can tell that strictness does 2039not matter. 2040 2041@itemx PLUS_EXPR 2042@itemx MINUS_EXPR 2043@itemx MULT_EXPR 2044@itemx TRUNC_DIV_EXPR 2045@itemx TRUNC_MOD_EXPR 2046@itemx RDIV_EXPR 2047These nodes represent various binary arithmetic operations. 2048Respectively, these operations are addition, subtraction (of the second 2049operand from the first), multiplication, integer division, integer 2050remainder, and floating-point division. The operands to the first three 2051of these may have either integral or floating type, but there will never 2052be case in which one operand is of floating type and the other is of 2053integral type. 2054 2055The result of a @code{TRUNC_DIV_EXPR} is always rounded towards zero. 2056The @code{TRUNC_MOD_EXPR} of two operands @code{a} and @code{b} is 2057always @code{a - a/b} where the division is as if computed by a 2058@code{TRUNC_DIV_EXPR}. 2059 2060@item ARRAY_REF 2061These nodes represent array accesses. The first operand is the array; 2062the second is the index. To calculate the address of the memory 2063accessed, you must scale the index by the size of the type of the array 2064elements. The type of these expressions must be the type of a component of 2065the array. 2066 2067@item ARRAY_RANGE_REF 2068These nodes represent access to a range (or ``slice'') of an array. The 2069operands are the same as that for @code{ARRAY_REF} and have the same 2070meanings. The type of these expressions must be an array whose component 2071type is the same as that of the first operand. The range of that array 2072type determines the amount of data these expressions access. 2073 2074@item EXACT_DIV_EXPR 2075Document. 2076 2077@item LT_EXPR 2078@itemx LE_EXPR 2079@itemx GT_EXPR 2080@itemx GE_EXPR 2081@itemx EQ_EXPR 2082@itemx NE_EXPR 2083 2084These nodes represent the less than, less than or equal to, greater 2085than, greater than or equal to, equal, and not equal comparison 2086operators. The first and second operand with either be both of integral 2087type or both of floating type. The result type of these expressions 2088will always be of integral or boolean type. 2089 2090@item MODIFY_EXPR 2091These nodes represent assignment. The left-hand side is the first 2092operand; the right-hand side is the second operand. The left-hand side 2093will be a @code{VAR_DECL}, @code{INDIRECT_REF}, @code{COMPONENT_REF}, or 2094other lvalue. 2095 2096These nodes are used to represent not only assignment with @samp{=} but 2097also compound assignments (like @samp{+=}), by reduction to @samp{=} 2098assignment. In other words, the representation for @samp{i += 3} looks 2099just like that for @samp{i = i + 3}. 2100 2101@item INIT_EXPR 2102These nodes are just like @code{MODIFY_EXPR}, but are used only when a 2103variable is initialized, rather than assigned to subsequently. 2104 2105@item COMPONENT_REF 2106These nodes represent non-static data member accesses. The first 2107operand is the object (rather than a pointer to it); the second operand 2108is the @code{FIELD_DECL} for the data member. 2109 2110@item COMPOUND_EXPR 2111These nodes represent comma-expressions. The first operand is an 2112expression whose value is computed and thrown away prior to the 2113evaluation of the second operand. The value of the entire expression is 2114the value of the second operand. 2115 2116@item COND_EXPR 2117These nodes represent @code{?:} expressions. The first operand 2118is of boolean or integral type. If it evaluates to a nonzero value, 2119the second operand should be evaluated, and returned as the value of the 2120expression. Otherwise, the third operand is evaluated, and returned as 2121the value of the expression. As a GNU extension, the middle operand of 2122the @code{?:} operator may be omitted in the source, like this: 2123 2124@example 2125x ? : 3 2126@end example 2127@noindent 2128which is equivalent to 2129 2130@example 2131x ? x : 3 2132@end example 2133 2134@noindent 2135assuming that @code{x} is an expression without side-effects. However, 2136in the case that the first operation causes side effects, the 2137side-effects occur only once. Consumers of the internal representation 2138do not need to worry about this oddity; the second operand will be 2139always be present in the internal representation. 2140 2141@item CALL_EXPR 2142These nodes are used to represent calls to functions, including 2143non-static member functions. The first operand is a pointer to the 2144function to call; it is always an expression whose type is a 2145@code{POINTER_TYPE}. The second argument is a @code{TREE_LIST}. The 2146arguments to the call appear left-to-right in the list. The 2147@code{TREE_VALUE} of each list node contains the expression 2148corresponding to that argument. (The value of @code{TREE_PURPOSE} for 2149these nodes is unspecified, and should be ignored.) For non-static 2150member functions, there will be an operand corresponding to the 2151@code{this} pointer. There will always be expressions corresponding to 2152all of the arguments, even if the function is declared with default 2153arguments and some arguments are not explicitly provided at the call 2154sites. 2155 2156@item STMT_EXPR 2157These nodes are used to represent GCC's statement-expression extension. 2158The statement-expression extension allows code like this: 2159@example 2160int f() @{ return (@{ int j; j = 3; j + 7; @}); @} 2161@end example 2162In other words, an sequence of statements may occur where a single 2163expression would normally appear. The @code{STMT_EXPR} node represents 2164such an expression. The @code{STMT_EXPR_STMT} gives the statement 2165contained in the expression; this is always a @code{COMPOUND_STMT}. The 2166value of the expression is the value of the last sub-statement in the 2167@code{COMPOUND_STMT}. More precisely, the value is the value computed 2168by the last @code{EXPR_STMT} in the outermost scope of the 2169@code{COMPOUND_STMT}. For example, in: 2170@example 2171(@{ 3; @}) 2172@end example 2173the value is @code{3} while in: 2174@example 2175(@{ if (x) @{ 3; @} @}) 2176@end example 2177(represented by a nested @code{COMPOUND_STMT}), there is no value. If 2178the @code{STMT_EXPR} does not yield a value, it's type will be 2179@code{void}. 2180 2181@item BIND_EXPR 2182These nodes represent local blocks. The first operand is a list of 2183temporary variables, connected via their @code{TREE_CHAIN} field. These 2184will never require cleanups. The scope of these variables is just the 2185body of the @code{BIND_EXPR}. The body of the @code{BIND_EXPR} is the 2186second operand. 2187 2188@item LOOP_EXPR 2189These nodes represent ``infinite'' loops. The @code{LOOP_EXPR_BODY} 2190represents the body of the loop. It should be executed forever, unless 2191an @code{EXIT_EXPR} is encountered. 2192 2193@item EXIT_EXPR 2194These nodes represent conditional exits from the nearest enclosing 2195@code{LOOP_EXPR}. The single operand is the condition; if it is 2196nonzero, then the loop should be exited. An @code{EXIT_EXPR} will only 2197appear within a @code{LOOP_EXPR}. 2198 2199@item CLEANUP_POINT_EXPR 2200These nodes represent full-expressions. The single operand is an 2201expression to evaluate. Any destructor calls engendered by the creation 2202of temporaries during the evaluation of that expression should be 2203performed immediately after the expression is evaluated. 2204 2205@item CONSTRUCTOR 2206These nodes represent the brace-enclosed initializers for a structure or 2207array. The first operand is reserved for use by the back end. The 2208second operand is a @code{TREE_LIST}. If the @code{TREE_TYPE} of the 2209@code{CONSTRUCTOR} is a @code{RECORD_TYPE} or @code{UNION_TYPE}, then 2210the @code{TREE_PURPOSE} of each node in the @code{TREE_LIST} will be a 2211@code{FIELD_DECL} and the @code{TREE_VALUE} of each node will be the 2212expression used to initialize that field. You should not depend on the 2213fields appearing in any particular order, nor should you assume that all 2214fields will be represented. Unrepresented fields may be assigned any 2215value. 2216 2217If the @code{TREE_TYPE} of the @code{CONSTRUCTOR} is an 2218@code{ARRAY_TYPE}, then the @code{TREE_PURPOSE} of each element in the 2219@code{TREE_LIST} will be an @code{INTEGER_CST}. This constant indicates 2220which element of the array (indexed from zero) is being assigned to; 2221again, the @code{TREE_VALUE} is the corresponding initializer. If the 2222@code{TREE_PURPOSE} is @code{NULL_TREE}, then the initializer is for the 2223next available array element. 2224 2225Conceptually, before any initialization is done, the entire area of 2226storage is initialized to zero. 2227 2228@item COMPOUND_LITERAL_EXPR 2229@findex COMPOUND_LITERAL_EXPR_DECL_STMT 2230@findex COMPOUND_LITERAL_EXPR_DECL 2231These nodes represent ISO C99 compound literals. The 2232@code{COMPOUND_LITERAL_EXPR_DECL_STMT} is a @code{DECL_STMT} 2233containing an anonymous @code{VAR_DECL} for 2234the unnamed object represented by the compound literal; the 2235@code{DECL_INITIAL} of that @code{VAR_DECL} is a @code{CONSTRUCTOR} 2236representing the brace-enclosed list of initializers in the compound 2237literal. That anonymous @code{VAR_DECL} can also be accessed directly 2238by the @code{COMPOUND_LITERAL_EXPR_DECL} macro. 2239 2240@item SAVE_EXPR 2241 2242A @code{SAVE_EXPR} represents an expression (possibly involving 2243side-effects) that is used more than once. The side-effects should 2244occur only the first time the expression is evaluated. Subsequent uses 2245should just reuse the computed value. The first operand to the 2246@code{SAVE_EXPR} is the expression to evaluate. The side-effects should 2247be executed where the @code{SAVE_EXPR} is first encountered in a 2248depth-first preorder traversal of the expression tree. 2249 2250@item TARGET_EXPR 2251A @code{TARGET_EXPR} represents a temporary object. The first operand 2252is a @code{VAR_DECL} for the temporary variable. The second operand is 2253the initializer for the temporary. The initializer is evaluated, and 2254copied (bitwise) into the temporary. 2255 2256Often, a @code{TARGET_EXPR} occurs on the right-hand side of an 2257assignment, or as the second operand to a comma-expression which is 2258itself the right-hand side of an assignment, etc. In this case, we say 2259that the @code{TARGET_EXPR} is ``normal''; otherwise, we say it is 2260``orphaned''. For a normal @code{TARGET_EXPR} the temporary variable 2261should be treated as an alias for the left-hand side of the assignment, 2262rather than as a new temporary variable. 2263 2264The third operand to the @code{TARGET_EXPR}, if present, is a 2265cleanup-expression (i.e., destructor call) for the temporary. If this 2266expression is orphaned, then this expression must be executed when the 2267statement containing this expression is complete. These cleanups must 2268always be executed in the order opposite to that in which they were 2269encountered. Note that if a temporary is created on one branch of a 2270conditional operator (i.e., in the second or third operand to a 2271@code{COND_EXPR}), the cleanup must be run only if that branch is 2272actually executed. 2273 2274See @code{STMT_IS_FULL_EXPR_P} for more information about running these 2275cleanups. 2276 2277@item AGGR_INIT_EXPR 2278An @code{AGGR_INIT_EXPR} represents the initialization as the return 2279value of a function call, or as the result of a constructor. An 2280@code{AGGR_INIT_EXPR} will only appear as the second operand of a 2281@code{TARGET_EXPR}. The first operand to the @code{AGGR_INIT_EXPR} is 2282the address of a function to call, just as in a @code{CALL_EXPR}. The 2283second operand are the arguments to pass that function, as a 2284@code{TREE_LIST}, again in a manner similar to that of a 2285@code{CALL_EXPR}. The value of the expression is that returned by the 2286function. 2287 2288If @code{AGGR_INIT_VIA_CTOR_P} holds of the @code{AGGR_INIT_EXPR}, then 2289the initialization is via a constructor call. The address of the third 2290operand of the @code{AGGR_INIT_EXPR}, which is always a @code{VAR_DECL}, 2291is taken, and this value replaces the first argument in the argument 2292list. In this case, the value of the expression is the @code{VAR_DECL} 2293given by the third operand to the @code{AGGR_INIT_EXPR}; constructors do 2294not return a value. 2295 2296@item VTABLE_REF 2297A @code{VTABLE_REF} indicates that the interior expression computes 2298a value that is a vtable entry. It is used with @option{-fvtable-gc} 2299to track the reference through to front end to the middle end, at 2300which point we transform this to a @code{REG_VTABLE_REF} note, which 2301survives the balance of code generation. 2302 2303The first operand is the expression that computes the vtable reference. 2304The second operand is the @code{VAR_DECL} of the vtable. The third 2305operand is an @code{INTEGER_CST} of the byte offset into the vtable. 2306 2307@end table 2308