1169689Skan@c Copyright (c) 1999, 2000, 2001, 2002, 2003, 2004, 2005
290075Sobrien@c Free Software Foundation, Inc.
390075Sobrien@c This is part of the GCC manual.
490075Sobrien@c For copying conditions, see the file gcc.texi.
590075Sobrien
690075Sobrien@c ---------------------------------------------------------------------
790075Sobrien@c Trees
890075Sobrien@c ---------------------------------------------------------------------
990075Sobrien
1090075Sobrien@node Trees
1190075Sobrien@chapter Trees: The intermediate representation used by the C and C++ front ends
1290075Sobrien@cindex Trees
1390075Sobrien@cindex C/C++ Internal Representation
1490075Sobrien
1590075SobrienThis chapter documents the internal representation used by GCC to
1690075Sobrienrepresent C and C++ source programs.  When presented with a C or C++
1790075Sobriensource program, GCC parses the program, performs semantic analysis
1890075Sobrien(including the generation of error messages), and then produces the
1990075Sobrieninternal representation described here.  This representation contains a
2090075Sobriencomplete representation for the entire translation unit provided as
2190075Sobrieninput to the front end.  This representation is then typically processed
2290075Sobrienby a code-generator in order to produce machine code, but could also be
2390075Sobrienused in the creation of source browsers, intelligent editors, automatic
2490075Sobriendocumentation generators, interpreters, and any other programs needing
2590075Sobrienthe ability to process C or C++ code.
2690075Sobrien
2790075SobrienThis chapter explains the internal representation.  In particular, it
2890075Sobriendocuments the internal representation for C and C++ source
2990075Sobrienconstructs, and the macros, functions, and variables that can be used to
3096263Sobrienaccess these constructs.  The C++ representation is largely a superset
3190075Sobrienof the representation used in the C front end.  There is only one
3290075Sobrienconstruct used in C that does not appear in the C++ front end and that
3390075Sobrienis the GNU ``nested function'' extension.  Many of the macros documented
3490075Sobrienhere do not apply in C because the corresponding language constructs do
3590075Sobriennot appear in C@.
3690075Sobrien
3790075SobrienIf you are developing a ``back end'', be it is a code-generator or some
3890075Sobrienother tool, that uses this representation, you may occasionally find
3990075Sobrienthat you need to ask questions not easily answered by the functions and
4090075Sobrienmacros available here.  If that situation occurs, it is quite likely
4190075Sobrienthat GCC already supports the functionality you desire, but that the
4290075Sobrieninterface is simply not documented here.  In that case, you should ask
4390075Sobrienthe GCC maintainers (via mail to @email{gcc@@gcc.gnu.org}) about
4490075Sobriendocumenting the functionality you require.  Similarly, if you find
4590075Sobrienyourself writing functions that do not deal directly with your back end,
4690075Sobrienbut instead might be useful to other people using the GCC front end, you
4790075Sobrienshould submit your patches for inclusion in GCC@.
4890075Sobrien
4990075Sobrien@menu
5090075Sobrien* Deficiencies::        Topics net yet covered in this document.
5190075Sobrien* Tree overview::       All about @code{tree}s.
5290075Sobrien* Types::               Fundamental and aggregate types.
5390075Sobrien* Scopes::              Namespaces and classes.
5490075Sobrien* Functions::           Overloading, function bodies, and linkage.
5590075Sobrien* Declarations::        Type declarations and variables.
5690075Sobrien* Attributes::          Declaration and type attributes.
5790075Sobrien* Expression trees::    From @code{typeid} to @code{throw}.
5890075Sobrien@end menu
5990075Sobrien
6090075Sobrien@c ---------------------------------------------------------------------
6190075Sobrien@c Deficiencies
6290075Sobrien@c ---------------------------------------------------------------------
6390075Sobrien
6490075Sobrien@node Deficiencies
6590075Sobrien@section Deficiencies
6690075Sobrien
6790075SobrienThere are many places in which this document is incomplet and incorrekt.
6890075SobrienIt is, as of yet, only @emph{preliminary} documentation.
6990075Sobrien
7090075Sobrien@c ---------------------------------------------------------------------
7190075Sobrien@c Overview
7290075Sobrien@c ---------------------------------------------------------------------
7390075Sobrien
7490075Sobrien@node Tree overview
7590075Sobrien@section Overview
7690075Sobrien@cindex tree
7790075Sobrien@findex TREE_CODE
7890075Sobrien
7990075SobrienThe central data structure used by the internal representation is the
8090075Sobrien@code{tree}.  These nodes, while all of the C type @code{tree}, are of
8190075Sobrienmany varieties.  A @code{tree} is a pointer type, but the object to
8290075Sobrienwhich it points may be of a variety of types.  From this point forward,
8390075Sobrienwe will refer to trees in ordinary type, rather than in @code{this
8490075Sobrienfont}, except when talking about the actual C type @code{tree}.
8590075Sobrien
8690075SobrienYou can tell what kind of node a particular tree is by using the
87117395Skan@code{TREE_CODE} macro.  Many, many macros take trees as input and
88117395Skanreturn trees as output.  However, most macros require a certain kind of
8990075Sobrientree node as input.  In other words, there is a type-system for trees,
9090075Sobrienbut it is not reflected in the C type-system.
9190075Sobrien
9290075SobrienFor safety, it is useful to configure GCC with @option{--enable-checking}.
9390075SobrienAlthough this results in a significant performance penalty (since all
9490075Sobrientree types are checked at run-time), and is therefore inappropriate in a
9590075Sobrienrelease version, it is extremely helpful during the development process.
9690075Sobrien
9790075SobrienMany macros behave as predicates.  Many, although not all, of these
9890075Sobrienpredicates end in @samp{_P}.  Do not rely on the result type of these
9990075Sobrienmacros being of any particular type.  You may, however, rely on the fact
10090075Sobrienthat the type can be compared to @code{0}, so that statements like
101132718Skan@smallexample
10290075Sobrienif (TEST_P (t) && !TEST_P (y))
10390075Sobrien  x = 1;
104132718Skan@end smallexample
10590075Sobrien@noindent
10690075Sobrienand
107132718Skan@smallexample
10890075Sobrienint i = (TEST_P (t) != 0);
109132718Skan@end smallexample
11090075Sobrien@noindent
11190075Sobrienare legal.  Macros that return @code{int} values now may be changed to
11290075Sobrienreturn @code{tree} values, or other pointers in the future.  Even those
11390075Sobrienthat continue to return @code{int} may return multiple nonzero codes
11490075Sobrienwhere previously they returned only zero and one.  Therefore, you should
11590075Sobriennot write code like
116132718Skan@smallexample
11790075Sobrienif (TEST_P (t) == 1)
118132718Skan@end smallexample
11990075Sobrien@noindent
12090075Sobrienas this code is not guaranteed to work correctly in the future.
12190075Sobrien
12290075SobrienYou should not take the address of values returned by the macros or
12390075Sobrienfunctions described here.  In particular, no guarantee is given that the
12490075Sobrienvalues are lvalues.
12590075Sobrien
12690075SobrienIn general, the names of macros are all in uppercase, while the names of
127132718Skanfunctions are entirely in lowercase.  There are rare exceptions to this
12890075Sobrienrule.  You should assume that any macro or function whose name is made
12990075Sobrienup entirely of uppercase letters may evaluate its arguments more than
13090075Sobrienonce.  You may assume that a macro or function whose name is made up
13190075Sobrienentirely of lowercase letters will evaluate its arguments only once.
13290075Sobrien
13390075SobrienThe @code{error_mark_node} is a special tree.  Its tree code is
13490075Sobrien@code{ERROR_MARK}, but since there is only ever one node with that code,
13590075Sobrienthe usual practice is to compare the tree against
13690075Sobrien@code{error_mark_node}.  (This test is just a test for pointer
13790075Sobrienequality.)  If an error has occurred during front-end processing the
13890075Sobrienflag @code{errorcount} will be set.  If the front end has encountered
13990075Sobriencode it cannot handle, it will issue a message to the user and set
14090075Sobrien@code{sorrycount}.  When these flags are set, any macro or function
14190075Sobrienwhich normally returns a tree of a particular kind may instead return
14290075Sobrienthe @code{error_mark_node}.  Thus, if you intend to do any processing of
14390075Sobrienerroneous code, you must be prepared to deal with the
14490075Sobrien@code{error_mark_node}.
14590075Sobrien
14690075SobrienOccasionally, a particular tree slot (like an operand to an expression,
14790075Sobrienor a particular field in a declaration) will be referred to as
148169689Skan``reserved for the back end''.  These slots are used to store RTL when
14990075Sobrienthe tree is converted to RTL for use by the GCC back end.  However, if
15090075Sobrienthat process is not taking place (e.g., if the front end is being hooked
15190075Sobrienup to an intelligent editor), then those slots may be used by the
15290075Sobrienback end presently in use.
15390075Sobrien
15490075SobrienIf you encounter situations that do not match this documentation, such
15590075Sobrienas tree nodes of types not mentioned here, or macros documented to
15690075Sobrienreturn entities of a particular kind that instead return entities of
15790075Sobriensome different kind, you have found a bug, either in the front end or in
15890075Sobrienthe documentation.  Please report these bugs as you would any other
15990075Sobrienbug.
16090075Sobrien
16190075Sobrien@menu
16290075Sobrien* Macros and Functions::Macros and functions that can be used with all trees.
16390075Sobrien* Identifiers::         The names of things.
16490075Sobrien* Containers::          Lists and vectors.
16590075Sobrien@end menu
16690075Sobrien
16790075Sobrien@c ---------------------------------------------------------------------
16890075Sobrien@c Trees
16990075Sobrien@c ---------------------------------------------------------------------
17090075Sobrien
17190075Sobrien@node Macros and Functions
17290075Sobrien@subsection Trees
17390075Sobrien@cindex tree
17490075Sobrien
17590075SobrienThis section is not here yet.
17690075Sobrien
17790075Sobrien@c ---------------------------------------------------------------------
17890075Sobrien@c Identifiers
17990075Sobrien@c ---------------------------------------------------------------------
18090075Sobrien
18190075Sobrien@node Identifiers
18290075Sobrien@subsection Identifiers
18390075Sobrien@cindex identifier
18490075Sobrien@cindex name
18590075Sobrien@tindex IDENTIFIER_NODE
18690075Sobrien
18790075SobrienAn @code{IDENTIFIER_NODE} represents a slightly more general concept
18890075Sobrienthat the standard C or C++ concept of identifier.  In particular, an
18990075Sobrien@code{IDENTIFIER_NODE} may contain a @samp{$}, or other extraordinary
19090075Sobriencharacters.
19190075Sobrien
19290075SobrienThere are never two distinct @code{IDENTIFIER_NODE}s representing the
19390075Sobriensame identifier.  Therefore, you may use pointer equality to compare
19490075Sobrien@code{IDENTIFIER_NODE}s, rather than using a routine like @code{strcmp}.
19590075Sobrien
19690075SobrienYou can use the following macros to access identifiers:
19790075Sobrien@ftable @code
19890075Sobrien@item IDENTIFIER_POINTER
19990075SobrienThe string represented by the identifier, represented as a
20090075Sobrien@code{char*}.  This string is always @code{NUL}-terminated, and contains
20190075Sobrienno embedded @code{NUL} characters.
20290075Sobrien
20390075Sobrien@item IDENTIFIER_LENGTH
20490075SobrienThe length of the string returned by @code{IDENTIFIER_POINTER}, not
20590075Sobrienincluding the trailing @code{NUL}.  This value of
20690075Sobrien@code{IDENTIFIER_LENGTH (x)} is always the same as @code{strlen
20790075Sobrien(IDENTIFIER_POINTER (x))}.
20890075Sobrien
20990075Sobrien@item IDENTIFIER_OPNAME_P
21090075SobrienThis predicate holds if the identifier represents the name of an
21190075Sobrienoverloaded operator.  In this case, you should not depend on the
21290075Sobriencontents of either the @code{IDENTIFIER_POINTER} or the
21390075Sobrien@code{IDENTIFIER_LENGTH}.
21490075Sobrien
21590075Sobrien@item IDENTIFIER_TYPENAME_P
21690075SobrienThis predicate holds if the identifier represents the name of a
21790075Sobrienuser-defined conversion operator.  In this case, the @code{TREE_TYPE} of
21890075Sobrienthe @code{IDENTIFIER_NODE} holds the type to which the conversion
21990075Sobrienoperator converts.
22090075Sobrien
22190075Sobrien@end ftable
22290075Sobrien
22390075Sobrien@c ---------------------------------------------------------------------
22490075Sobrien@c Containers
22590075Sobrien@c ---------------------------------------------------------------------
22690075Sobrien
22790075Sobrien@node Containers
22890075Sobrien@subsection Containers
22990075Sobrien@cindex container
23090075Sobrien@cindex list
23190075Sobrien@cindex vector
23290075Sobrien@tindex TREE_LIST
23390075Sobrien@tindex TREE_VEC
23490075Sobrien@findex TREE_PURPOSE
23590075Sobrien@findex TREE_VALUE
23690075Sobrien@findex TREE_VEC_LENGTH
23790075Sobrien@findex TREE_VEC_ELT
23890075Sobrien
23990075SobrienTwo common container data structures can be represented directly with
24090075Sobrientree nodes.  A @code{TREE_LIST} is a singly linked list containing two
24190075Sobrientrees per node.  These are the @code{TREE_PURPOSE} and @code{TREE_VALUE}
24290075Sobrienof each node.  (Often, the @code{TREE_PURPOSE} contains some kind of
24390075Sobrientag, or additional information, while the @code{TREE_VALUE} contains the
24490075Sobrienmajority of the payload.  In other cases, the @code{TREE_PURPOSE} is
24590075Sobriensimply @code{NULL_TREE}, while in still others both the
24690075Sobrien@code{TREE_PURPOSE} and @code{TREE_VALUE} are of equal stature.)  Given
24790075Sobrienone @code{TREE_LIST} node, the next node is found by following the
24890075Sobrien@code{TREE_CHAIN}.  If the @code{TREE_CHAIN} is @code{NULL_TREE}, then
24990075Sobrienyou have reached the end of the list.
25090075Sobrien
25190075SobrienA @code{TREE_VEC} is a simple vector.  The @code{TREE_VEC_LENGTH} is an
25290075Sobrieninteger (not a tree) giving the number of nodes in the vector.  The
25390075Sobriennodes themselves are accessed using the @code{TREE_VEC_ELT} macro, which
25490075Sobrientakes two arguments.  The first is the @code{TREE_VEC} in question; the
25590075Sobriensecond is an integer indicating which element in the vector is desired.
25690075SobrienThe elements are indexed from zero.
25790075Sobrien
25890075Sobrien@c ---------------------------------------------------------------------
25990075Sobrien@c Types
26090075Sobrien@c ---------------------------------------------------------------------
26190075Sobrien
26290075Sobrien@node Types
26390075Sobrien@section Types
26490075Sobrien@cindex type
26590075Sobrien@cindex pointer
26690075Sobrien@cindex reference
26790075Sobrien@cindex fundamental type
26890075Sobrien@cindex array
26990075Sobrien@tindex VOID_TYPE
27090075Sobrien@tindex INTEGER_TYPE
27190075Sobrien@tindex TYPE_MIN_VALUE
27290075Sobrien@tindex TYPE_MAX_VALUE
27390075Sobrien@tindex REAL_TYPE
27490075Sobrien@tindex COMPLEX_TYPE
27590075Sobrien@tindex ENUMERAL_TYPE
27690075Sobrien@tindex BOOLEAN_TYPE
27790075Sobrien@tindex POINTER_TYPE
27890075Sobrien@tindex REFERENCE_TYPE
27990075Sobrien@tindex FUNCTION_TYPE
28090075Sobrien@tindex METHOD_TYPE
28190075Sobrien@tindex ARRAY_TYPE
28290075Sobrien@tindex RECORD_TYPE
28390075Sobrien@tindex UNION_TYPE
28490075Sobrien@tindex UNKNOWN_TYPE
28590075Sobrien@tindex OFFSET_TYPE
28690075Sobrien@tindex TYPENAME_TYPE
28790075Sobrien@tindex TYPEOF_TYPE
28890075Sobrien@findex CP_TYPE_QUALS
28990075Sobrien@findex TYPE_UNQUALIFIED
29090075Sobrien@findex TYPE_QUAL_CONST
29190075Sobrien@findex TYPE_QUAL_VOLATILE
29290075Sobrien@findex TYPE_QUAL_RESTRICT
29390075Sobrien@findex TYPE_MAIN_VARIANT
29490075Sobrien@cindex qualified type
29590075Sobrien@findex TYPE_SIZE
29690075Sobrien@findex TYPE_ALIGN
29790075Sobrien@findex TYPE_PRECISION
29890075Sobrien@findex TYPE_ARG_TYPES
29990075Sobrien@findex TYPE_METHOD_BASETYPE
30090075Sobrien@findex TYPE_PTRMEM_P
30190075Sobrien@findex TYPE_OFFSET_BASETYPE
30290075Sobrien@findex TREE_TYPE
30390075Sobrien@findex TYPE_CONTEXT
30490075Sobrien@findex TYPE_NAME
30590075Sobrien@findex TYPENAME_TYPE_FULLNAME
30690075Sobrien@findex TYPE_FIELDS
30790075Sobrien@findex TYPE_PTROBV_P
30890075Sobrien
30990075SobrienAll types have corresponding tree nodes.  However, you should not assume
31090075Sobrienthat there is exactly one tree node corresponding to each type.  There
31190075Sobrienare often several nodes each of which correspond to the same type.
31290075Sobrien
31390075SobrienFor the most part, different kinds of types have different tree codes.
31490075Sobrien(For example, pointer types use a @code{POINTER_TYPE} code while arrays
31590075Sobrienuse an @code{ARRAY_TYPE} code.)  However, pointers to member functions
31690075Sobrienuse the @code{RECORD_TYPE} code.  Therefore, when writing a
31790075Sobrien@code{switch} statement that depends on the code associated with a
31890075Sobrienparticular type, you should take care to handle pointers to member
31990075Sobrienfunctions under the @code{RECORD_TYPE} case label.
32090075Sobrien
32190075SobrienIn C++, an array type is not qualified; rather the type of the array
32290075Sobrienelements is qualified.  This situation is reflected in the intermediate
32390075Sobrienrepresentation.  The macros described here will always examine the
32490075Sobrienqualification of the underlying element type when applied to an array
32590075Sobrientype.  (If the element type is itself an array, then the recursion
32690075Sobriencontinues until a non-array type is found, and the qualification of this
32790075Sobrientype is examined.)  So, for example, @code{CP_TYPE_CONST_P} will hold of
32890075Sobrienthe type @code{const int ()[7]}, denoting an array of seven @code{int}s.
32990075Sobrien
33090075SobrienThe following functions and macros deal with cv-qualification of types:
33190075Sobrien@ftable @code
33290075Sobrien@item CP_TYPE_QUALS
33390075SobrienThis macro returns the set of type qualifiers applied to this type.
33490075SobrienThis value is @code{TYPE_UNQUALIFIED} if no qualifiers have been
33590075Sobrienapplied.  The @code{TYPE_QUAL_CONST} bit is set if the type is
33690075Sobrien@code{const}-qualified.  The @code{TYPE_QUAL_VOLATILE} bit is set if the
33790075Sobrientype is @code{volatile}-qualified.  The @code{TYPE_QUAL_RESTRICT} bit is
33890075Sobrienset if the type is @code{restrict}-qualified.
33990075Sobrien
34090075Sobrien@item CP_TYPE_CONST_P
34190075SobrienThis macro holds if the type is @code{const}-qualified.
34290075Sobrien
34390075Sobrien@item CP_TYPE_VOLATILE_P
34490075SobrienThis macro holds if the type is @code{volatile}-qualified.
34590075Sobrien
34690075Sobrien@item CP_TYPE_RESTRICT_P
34790075SobrienThis macro holds if the type is @code{restrict}-qualified.
34890075Sobrien
34990075Sobrien@item CP_TYPE_CONST_NON_VOLATILE_P
35090075SobrienThis predicate holds for a type that is @code{const}-qualified, but
35190075Sobrien@emph{not} @code{volatile}-qualified; other cv-qualifiers are ignored as
35290075Sobrienwell: only the @code{const}-ness is tested.
35390075Sobrien
35490075Sobrien@item TYPE_MAIN_VARIANT
35590075SobrienThis macro returns the unqualified version of a type.  It may be applied
35690075Sobriento an unqualified type, but it is not always the identity function in
35790075Sobrienthat case.
35890075Sobrien@end ftable
35990075Sobrien
36090075SobrienA few other macros and functions are usable with all types:
36190075Sobrien@ftable @code
36290075Sobrien@item TYPE_SIZE
36390075SobrienThe number of bits required to represent the type, represented as an
36490075Sobrien@code{INTEGER_CST}.  For an incomplete type, @code{TYPE_SIZE} will be
36590075Sobrien@code{NULL_TREE}.
36690075Sobrien
36790075Sobrien@item TYPE_ALIGN
36890075SobrienThe alignment of the type, in bits, represented as an @code{int}.
36990075Sobrien
37090075Sobrien@item TYPE_NAME
37190075SobrienThis macro returns a declaration (in the form of a @code{TYPE_DECL}) for
37290075Sobrienthe type.  (Note this macro does @emph{not} return a
37390075Sobrien@code{IDENTIFIER_NODE}, as you might expect, given its name!)  You can
37490075Sobrienlook at the @code{DECL_NAME} of the @code{TYPE_DECL} to obtain the
37590075Sobrienactual name of the type.  The @code{TYPE_NAME} will be @code{NULL_TREE}
37690075Sobrienfor a type that is not a built-in type, the result of a typedef, or a
37790075Sobriennamed class type.
37890075Sobrien
37990075Sobrien@item CP_INTEGRAL_TYPE
38090075SobrienThis predicate holds if the type is an integral type.  Notice that in
38190075SobrienC++, enumerations are @emph{not} integral types.
38290075Sobrien
38390075Sobrien@item ARITHMETIC_TYPE_P
38490075SobrienThis predicate holds if the type is an integral type (in the C++ sense)
38590075Sobrienor a floating point type.
38690075Sobrien
38790075Sobrien@item CLASS_TYPE_P
38890075SobrienThis predicate holds for a class-type.
38990075Sobrien
39090075Sobrien@item TYPE_BUILT_IN
39190075SobrienThis predicate holds for a built-in type.
39290075Sobrien
39390075Sobrien@item TYPE_PTRMEM_P
39490075SobrienThis predicate holds if the type is a pointer to data member.
39590075Sobrien
39690075Sobrien@item TYPE_PTR_P
39790075SobrienThis predicate holds if the type is a pointer type, and the pointee is
39890075Sobriennot a data member.
39990075Sobrien
40090075Sobrien@item TYPE_PTRFN_P
40190075SobrienThis predicate holds for a pointer to function type.
40290075Sobrien
40390075Sobrien@item TYPE_PTROB_P
40490075SobrienThis predicate holds for a pointer to object type.  Note however that it
40590075Sobriendoes not hold for the generic pointer to object type @code{void *}.  You
40690075Sobrienmay use @code{TYPE_PTROBV_P} to test for a pointer to object type as
40790075Sobrienwell as @code{void *}.
40890075Sobrien
40990075Sobrien@item same_type_p
41090075SobrienThis predicate takes two types as input, and holds if they are the same
41190075Sobrientype.  For example, if one type is a @code{typedef} for the other, or
41290075Sobrienboth are @code{typedef}s for the same type.  This predicate also holds if
41390075Sobrienthe two trees given as input are simply copies of one another; i.e.,
41490075Sobrienthere is no difference between them at the source level, but, for
41590075Sobrienwhatever reason, a duplicate has been made in the representation.  You
41690075Sobrienshould never use @code{==} (pointer equality) to compare types; always
41790075Sobrienuse @code{same_type_p} instead.
41890075Sobrien@end ftable
41990075Sobrien
42090075SobrienDetailed below are the various kinds of types, and the macros that can
42190075Sobrienbe used to access them.  Although other kinds of types are used
42290075Sobrienelsewhere in G++, the types described here are the only ones that you
42390075Sobrienwill encounter while examining the intermediate representation.
42490075Sobrien
42590075Sobrien@table @code
42690075Sobrien@item VOID_TYPE
42790075SobrienUsed to represent the @code{void} type.
42890075Sobrien
42990075Sobrien@item INTEGER_TYPE
43090075SobrienUsed to represent the various integral types, including @code{char},
43190075Sobrien@code{short}, @code{int}, @code{long}, and @code{long long}.  This code
432169689Skanis not used for enumeration types, nor for the @code{bool} type.
433169689SkanThe @code{TYPE_PRECISION} is the number of bits used in
43490075Sobrienthe representation, represented as an @code{unsigned int}.  (Note that
43590075Sobrienin the general case this is not the same value as @code{TYPE_SIZE};
43690075Sobriensuppose that there were a 24-bit integer type, but that alignment
43790075Sobrienrequirements for the ABI required 32-bit alignment.  Then,
43890075Sobrien@code{TYPE_SIZE} would be an @code{INTEGER_CST} for 32, while
43990075Sobrien@code{TYPE_PRECISION} would be 24.)  The integer type is unsigned if
440169689Skan@code{TYPE_UNSIGNED} holds; otherwise, it is signed.
44190075Sobrien
44290075SobrienThe @code{TYPE_MIN_VALUE} is an @code{INTEGER_CST} for the smallest
44390075Sobrieninteger that may be represented by this type.  Similarly, the
44490075Sobrien@code{TYPE_MAX_VALUE} is an @code{INTEGER_CST} for the largest integer
44590075Sobrienthat may be represented by this type.
44690075Sobrien
44790075Sobrien@item REAL_TYPE
44890075SobrienUsed to represent the @code{float}, @code{double}, and @code{long
44990075Sobriendouble} types.  The number of bits in the floating-point representation
45090075Sobrienis given by @code{TYPE_PRECISION}, as in the @code{INTEGER_TYPE} case.
45190075Sobrien
45290075Sobrien@item COMPLEX_TYPE
45390075SobrienUsed to represent GCC built-in @code{__complex__} data types.  The
45490075Sobrien@code{TREE_TYPE} is the type of the real and imaginary parts.
45590075Sobrien
45690075Sobrien@item ENUMERAL_TYPE
45790075SobrienUsed to represent an enumeration type.  The @code{TYPE_PRECISION} gives
45890075Sobrien(as an @code{int}), the number of bits used to represent the type.  If
459169689Skanthere are no negative enumeration constants, @code{TYPE_UNSIGNED} will
46090075Sobrienhold.  The minimum and maximum enumeration constants may be obtained
46190075Sobrienwith @code{TYPE_MIN_VALUE} and @code{TYPE_MAX_VALUE}, respectively; each
46290075Sobrienof these macros returns an @code{INTEGER_CST}.
46390075Sobrien
46490075SobrienThe actual enumeration constants themselves may be obtained by looking
46590075Sobrienat the @code{TYPE_VALUES}.  This macro will return a @code{TREE_LIST},
46690075Sobriencontaining the constants.  The @code{TREE_PURPOSE} of each node will be
46790075Sobrienan @code{IDENTIFIER_NODE} giving the name of the constant; the
46890075Sobrien@code{TREE_VALUE} will be an @code{INTEGER_CST} giving the value
46990075Sobrienassigned to that constant.  These constants will appear in the order in
47090075Sobrienwhich they were declared.  The @code{TREE_TYPE} of each of these
47190075Sobrienconstants will be the type of enumeration type itself.
47290075Sobrien
47390075Sobrien@item BOOLEAN_TYPE
47490075SobrienUsed to represent the @code{bool} type.
47590075Sobrien
47690075Sobrien@item POINTER_TYPE
47790075SobrienUsed to represent pointer types, and pointer to data member types.  The
47890075Sobrien@code{TREE_TYPE} gives the type to which this type points.  If the type
47990075Sobrienis a pointer to data member type, then @code{TYPE_PTRMEM_P} will hold.
48090075SobrienFor a pointer to data member type of the form @samp{T X::*},
48190075Sobrien@code{TYPE_PTRMEM_CLASS_TYPE} will be the type @code{X}, while
48290075Sobrien@code{TYPE_PTRMEM_POINTED_TO_TYPE} will be the type @code{T}.
48390075Sobrien
48490075Sobrien@item REFERENCE_TYPE
48590075SobrienUsed to represent reference types.  The @code{TREE_TYPE} gives the type
48690075Sobriento which this type refers.
48790075Sobrien
48890075Sobrien@item FUNCTION_TYPE
48990075SobrienUsed to represent the type of non-member functions and of static member
49090075Sobrienfunctions.  The @code{TREE_TYPE} gives the return type of the function.
49190075SobrienThe @code{TYPE_ARG_TYPES} are a @code{TREE_LIST} of the argument types.
49290075SobrienThe @code{TREE_VALUE} of each node in this list is the type of the
49390075Sobriencorresponding argument; the @code{TREE_PURPOSE} is an expression for the
49490075Sobriendefault argument value, if any.  If the last node in the list is
49590075Sobrien@code{void_list_node} (a @code{TREE_LIST} node whose @code{TREE_VALUE}
49690075Sobrienis the @code{void_type_node}), then functions of this type do not take
49790075Sobrienvariable arguments.  Otherwise, they do take a variable number of
49890075Sobrienarguments.
49990075Sobrien
50090075SobrienNote that in C (but not in C++) a function declared like @code{void f()}
50190075Sobrienis an unprototyped function taking a variable number of arguments; the
50290075Sobrien@code{TYPE_ARG_TYPES} of such a function will be @code{NULL}.
50390075Sobrien
50490075Sobrien@item METHOD_TYPE
50590075SobrienUsed to represent the type of a non-static member function.  Like a
50690075Sobrien@code{FUNCTION_TYPE}, the return type is given by the @code{TREE_TYPE}.
50790075SobrienThe type of @code{*this}, i.e., the class of which functions of this
50890075Sobrientype are a member, is given by the @code{TYPE_METHOD_BASETYPE}.  The
50990075Sobrien@code{TYPE_ARG_TYPES} is the parameter list, as for a
51090075Sobrien@code{FUNCTION_TYPE}, and includes the @code{this} argument.
51190075Sobrien
51290075Sobrien@item ARRAY_TYPE
51390075SobrienUsed to represent array types.  The @code{TREE_TYPE} gives the type of
51490075Sobrienthe elements in the array.  If the array-bound is present in the type,
51590075Sobrienthe @code{TYPE_DOMAIN} is an @code{INTEGER_TYPE} whose
51690075Sobrien@code{TYPE_MIN_VALUE} and @code{TYPE_MAX_VALUE} will be the lower and
51790075Sobrienupper bounds of the array, respectively.  The @code{TYPE_MIN_VALUE} will
51890075Sobrienalways be an @code{INTEGER_CST} for zero, while the
51990075Sobrien@code{TYPE_MAX_VALUE} will be one less than the number of elements in
52090075Sobrienthe array, i.e., the highest value which may be used to index an element
52190075Sobrienin the array.
52290075Sobrien
52390075Sobrien@item RECORD_TYPE
52490075SobrienUsed to represent @code{struct} and @code{class} types, as well as
52590075Sobrienpointers to member functions and similar constructs in other languages.
52690075Sobrien@code{TYPE_FIELDS} contains the items contained in this type, each of
52790075Sobrienwhich can be a @code{FIELD_DECL}, @code{VAR_DECL}, @code{CONST_DECL}, or
52890075Sobrien@code{TYPE_DECL}.  You may not make any assumptions about the ordering
52990075Sobrienof the fields in the type or whether one or more of them overlap.  If
53090075Sobrien@code{TYPE_PTRMEMFUNC_P} holds, then this type is a pointer-to-member
53190075Sobrientype.  In that case, the @code{TYPE_PTRMEMFUNC_FN_TYPE} is a
53290075Sobrien@code{POINTER_TYPE} pointing to a @code{METHOD_TYPE}.  The
53390075Sobrien@code{METHOD_TYPE} is the type of a function pointed to by the
53490075Sobrienpointer-to-member function.  If @code{TYPE_PTRMEMFUNC_P} does not hold,
53590075Sobrienthis type is a class type.  For more information, see @pxref{Classes}.
53690075Sobrien
53790075Sobrien@item UNION_TYPE
53890075SobrienUsed to represent @code{union} types.  Similar to @code{RECORD_TYPE}
53990075Sobrienexcept that all @code{FIELD_DECL} nodes in @code{TYPE_FIELD} start at
54090075Sobrienbit position zero.
54190075Sobrien
54290075Sobrien@item QUAL_UNION_TYPE
54390075SobrienUsed to represent part of a variant record in Ada.  Similar to
54490075Sobrien@code{UNION_TYPE} except that each @code{FIELD_DECL} has a
54590075Sobrien@code{DECL_QUALIFIER} field, which contains a boolean expression that
54690075Sobrienindicates whether the field is present in the object.  The type will only
54790075Sobrienhave one field, so each field's @code{DECL_QUALIFIER} is only evaluated
54890075Sobrienif none of the expressions in the previous fields in @code{TYPE_FIELDS}
54990075Sobrienare nonzero.  Normally these expressions will reference a field in the
55090075Sobrienouter object using a @code{PLACEHOLDER_EXPR}.
55190075Sobrien
55290075Sobrien@item UNKNOWN_TYPE
55390075SobrienThis node is used to represent a type the knowledge of which is
55490075Sobrieninsufficient for a sound processing.
55590075Sobrien
55690075Sobrien@item OFFSET_TYPE
557132718SkanThis node is used to represent a pointer-to-data member.  For a data
558132718Skanmember @code{X::m} the @code{TYPE_OFFSET_BASETYPE} is @code{X} and the
559132718Skan@code{TREE_TYPE} is the type of @code{m}.
56090075Sobrien
56190075Sobrien@item TYPENAME_TYPE
56290075SobrienUsed to represent a construct of the form @code{typename T::A}.  The
56390075Sobrien@code{TYPE_CONTEXT} is @code{T}; the @code{TYPE_NAME} is an
56490075Sobrien@code{IDENTIFIER_NODE} for @code{A}.  If the type is specified via a
56590075Sobrientemplate-id, then @code{TYPENAME_TYPE_FULLNAME} yields a
56690075Sobrien@code{TEMPLATE_ID_EXPR}.  The @code{TREE_TYPE} is non-@code{NULL} if the
56790075Sobriennode is implicitly generated in support for the implicit typename
56890075Sobrienextension; in which case the @code{TREE_TYPE} is a type node for the
56990075Sobrienbase-class.
57090075Sobrien
57190075Sobrien@item TYPEOF_TYPE
57290075SobrienUsed to represent the @code{__typeof__} extension.  The
57390075Sobrien@code{TYPE_FIELDS} is the expression the type of which is being
57490075Sobrienrepresented.
57590075Sobrien@end table
57690075Sobrien
57790075SobrienThere are variables whose values represent some of the basic types.
57890075SobrienThese include:
57990075Sobrien@table @code
58090075Sobrien@item void_type_node
58190075SobrienA node for @code{void}.
58290075Sobrien
58390075Sobrien@item integer_type_node
58490075SobrienA node for @code{int}.
58590075Sobrien
58690075Sobrien@item unsigned_type_node.
58790075SobrienA node for @code{unsigned int}.
58890075Sobrien
58990075Sobrien@item char_type_node.
59090075SobrienA node for @code{char}.
59190075Sobrien@end table
59290075Sobrien@noindent
59390075SobrienIt may sometimes be useful to compare one of these variables with a type
59490075Sobrienin hand, using @code{same_type_p}.
59590075Sobrien
59690075Sobrien@c ---------------------------------------------------------------------
59790075Sobrien@c Scopes
59890075Sobrien@c ---------------------------------------------------------------------
59990075Sobrien
60090075Sobrien@node Scopes
60190075Sobrien@section Scopes
60290075Sobrien@cindex namespace, class, scope
60390075Sobrien
60490075SobrienThe root of the entire intermediate representation is the variable
60590075Sobrien@code{global_namespace}.  This is the namespace specified with @code{::}
60690075Sobrienin C++ source code.  All other namespaces, types, variables, functions,
60790075Sobrienand so forth can be found starting with this namespace.
60890075Sobrien
60990075SobrienBesides namespaces, the other high-level scoping construct in C++ is the
61090075Sobrienclass.  (Throughout this manual the term @dfn{class} is used to mean the
61190075Sobrientypes referred to in the ANSI/ISO C++ Standard as classes; these include
61290075Sobrientypes defined with the @code{class}, @code{struct}, and @code{union}
61390075Sobrienkeywords.)
61490075Sobrien
61590075Sobrien@menu
61690075Sobrien* Namespaces::          Member functions, types, etc.
61790075Sobrien* Classes::             Members, bases, friends, etc.
61890075Sobrien@end menu
61990075Sobrien
62090075Sobrien@c ---------------------------------------------------------------------
62190075Sobrien@c Namespaces
62290075Sobrien@c ---------------------------------------------------------------------
62390075Sobrien
62490075Sobrien@node Namespaces
62590075Sobrien@subsection Namespaces
62690075Sobrien@cindex namespace
62790075Sobrien@tindex NAMESPACE_DECL
62890075Sobrien
62990075SobrienA namespace is represented by a @code{NAMESPACE_DECL} node.
63090075Sobrien
63190075SobrienHowever, except for the fact that it is distinguished as the root of the
63290075Sobrienrepresentation, the global namespace is no different from any other
63390075Sobriennamespace.  Thus, in what follows, we describe namespaces generally,
63490075Sobrienrather than the global namespace in particular.
63590075Sobrien
63690075SobrienThe following macros and functions can be used on a @code{NAMESPACE_DECL}:
63790075Sobrien
63890075Sobrien@ftable @code
63990075Sobrien@item DECL_NAME
64090075SobrienThis macro is used to obtain the @code{IDENTIFIER_NODE} corresponding to
64190075Sobrienthe unqualified name of the name of the namespace (@pxref{Identifiers}).
64290075SobrienThe name of the global namespace is @samp{::}, even though in C++ the
64390075Sobrienglobal namespace is unnamed.  However, you should use comparison with
64490075Sobrien@code{global_namespace}, rather than @code{DECL_NAME} to determine
645119256Skanwhether or not a namespace is the global one.  An unnamed namespace
64690075Sobrienwill have a @code{DECL_NAME} equal to @code{anonymous_namespace_name}.
64790075SobrienWithin a single translation unit, all unnamed namespaces will have the
64890075Sobriensame name.
64990075Sobrien
65090075Sobrien@item DECL_CONTEXT
65190075SobrienThis macro returns the enclosing namespace.  The @code{DECL_CONTEXT} for
65290075Sobrienthe @code{global_namespace} is @code{NULL_TREE}.
65390075Sobrien
65490075Sobrien@item DECL_NAMESPACE_ALIAS
65590075SobrienIf this declaration is for a namespace alias, then
65690075Sobrien@code{DECL_NAMESPACE_ALIAS} is the namespace for which this one is an
65790075Sobrienalias.
65890075Sobrien
65990075SobrienDo not attempt to use @code{cp_namespace_decls} for a namespace which is
66090075Sobrienan alias.  Instead, follow @code{DECL_NAMESPACE_ALIAS} links until you
66190075Sobrienreach an ordinary, non-alias, namespace, and call
66290075Sobrien@code{cp_namespace_decls} there.
66390075Sobrien
66490075Sobrien@item DECL_NAMESPACE_STD_P
66590075SobrienThis predicate holds if the namespace is the special @code{::std}
66690075Sobriennamespace.
66790075Sobrien
66890075Sobrien@item cp_namespace_decls
66990075SobrienThis function will return the declarations contained in the namespace,
67090075Sobrienincluding types, overloaded functions, other namespaces, and so forth.
67190075SobrienIf there are no declarations, this function will return
67290075Sobrien@code{NULL_TREE}.  The declarations are connected through their
67390075Sobrien@code{TREE_CHAIN} fields.
67490075Sobrien
67590075SobrienAlthough most entries on this list will be declarations,
67690075Sobrien@code{TREE_LIST} nodes may also appear.  In this case, the
67790075Sobrien@code{TREE_VALUE} will be an @code{OVERLOAD}.  The value of the
67890075Sobrien@code{TREE_PURPOSE} is unspecified; back ends should ignore this value.
67990075SobrienAs with the other kinds of declarations returned by
68090075Sobrien@code{cp_namespace_decls}, the @code{TREE_CHAIN} will point to the next
68190075Sobriendeclaration in this list.
68290075Sobrien
68390075SobrienFor more information on the kinds of declarations that can occur on this
68490075Sobrienlist, @xref{Declarations}.  Some declarations will not appear on this
68590075Sobrienlist.  In particular, no @code{FIELD_DECL}, @code{LABEL_DECL}, or
68690075Sobrien@code{PARM_DECL} nodes will appear here.
68790075Sobrien
68890075SobrienThis function cannot be used with namespaces that have
68990075Sobrien@code{DECL_NAMESPACE_ALIAS} set.
69090075Sobrien
69190075Sobrien@end ftable
69290075Sobrien
69390075Sobrien@c ---------------------------------------------------------------------
69490075Sobrien@c Classes
69590075Sobrien@c ---------------------------------------------------------------------
69690075Sobrien
69790075Sobrien@node Classes
69890075Sobrien@subsection Classes
69990075Sobrien@cindex class
70090075Sobrien@tindex RECORD_TYPE
70190075Sobrien@tindex UNION_TYPE
70290075Sobrien@findex CLASSTYPE_DECLARED_CLASS
70390075Sobrien@findex TYPE_BINFO
70490075Sobrien@findex BINFO_TYPE
70590075Sobrien@findex TYPE_FIELDS
70690075Sobrien@findex TYPE_VFIELD
70790075Sobrien@findex TYPE_METHODS
70890075Sobrien
70990075SobrienA class type is represented by either a @code{RECORD_TYPE} or a
71090075Sobrien@code{UNION_TYPE}.  A class declared with the @code{union} tag is
71190075Sobrienrepresented by a @code{UNION_TYPE}, while classes declared with either
71290075Sobrienthe @code{struct} or the @code{class} tag are represented by
71390075Sobrien@code{RECORD_TYPE}s.  You can use the @code{CLASSTYPE_DECLARED_CLASS}
71490075Sobrienmacro to discern whether or not a particular type is a @code{class} as
71590075Sobrienopposed to a @code{struct}.  This macro will be true only for classes
71690075Sobriendeclared with the @code{class} tag.
71790075Sobrien
71890075SobrienAlmost all non-function members are available on the @code{TYPE_FIELDS}
71990075Sobrienlist.  Given one member, the next can be found by following the
72090075Sobrien@code{TREE_CHAIN}.  You should not depend in any way on the order in
72190075Sobrienwhich fields appear on this list.  All nodes on this list will be
72290075Sobrien@samp{DECL} nodes.  A @code{FIELD_DECL} is used to represent a non-static
72390075Sobriendata member, a @code{VAR_DECL} is used to represent a static data
72490075Sobrienmember, and a @code{TYPE_DECL} is used to represent a type.  Note that
72590075Sobrienthe @code{CONST_DECL} for an enumeration constant will appear on this
72690075Sobrienlist, if the enumeration type was declared in the class.  (Of course,
72790075Sobrienthe @code{TYPE_DECL} for the enumeration type will appear here as well.)
72890075SobrienThere are no entries for base classes on this list.  In particular,
72990075Sobrienthere is no @code{FIELD_DECL} for the ``base-class portion'' of an
73090075Sobrienobject.
73190075Sobrien
73290075SobrienThe @code{TYPE_VFIELD} is a compiler-generated field used to point to
73390075Sobrienvirtual function tables.  It may or may not appear on the
73490075Sobrien@code{TYPE_FIELDS} list.  However, back ends should handle the
73590075Sobrien@code{TYPE_VFIELD} just like all the entries on the @code{TYPE_FIELDS}
73690075Sobrienlist.
73790075Sobrien
73890075SobrienThe function members are available on the @code{TYPE_METHODS} list.
73990075SobrienAgain, subsequent members are found by following the @code{TREE_CHAIN}
74090075Sobrienfield.  If a function is overloaded, each of the overloaded functions
74190075Sobrienappears; no @code{OVERLOAD} nodes appear on the @code{TYPE_METHODS}
74290075Sobrienlist.  Implicitly declared functions (including default constructors,
74390075Sobriencopy constructors, assignment operators, and destructors) will appear on
74490075Sobrienthis list as well.
74590075Sobrien
74690075SobrienEvery class has an associated @dfn{binfo}, which can be obtained with
74790075Sobrien@code{TYPE_BINFO}.  Binfos are used to represent base-classes.  The
74890075Sobrienbinfo given by @code{TYPE_BINFO} is the degenerate case, whereby every
749169689Skanclass is considered to be its own base-class.  The base binfos for a
750169689Skanparticular binfo are held in a vector, whose length is obtained with
751169689Skan@code{BINFO_N_BASE_BINFOS}.  The base binfos themselves are obtained
752169689Skanwith @code{BINFO_BASE_BINFO} and @code{BINFO_BASE_ITERATE}.  To add a
753169689Skannew binfo, use @code{BINFO_BASE_APPEND}.  The vector of base binfos can
754169689Skanbe obtained with @code{BINFO_BASE_BINFOS}, but normally you do not need
755169689Skanto use that.  The class type associated with a binfo is given by
756169689Skan@code{BINFO_TYPE}.  It is not always the case that @code{BINFO_TYPE
757169689Skan(TYPE_BINFO (x))}, because of typedefs and qualified types.  Neither is
758169689Skanit the case that @code{TYPE_BINFO (BINFO_TYPE (y))} is the same binfo as
759169689Skan@code{y}.  The reason is that if @code{y} is a binfo representing a
760169689Skanbase-class @code{B} of a derived class @code{D}, then @code{BINFO_TYPE
761169689Skan(y)} will be @code{B}, and @code{TYPE_BINFO (BINFO_TYPE (y))} will be
762169689Skan@code{B} as its own base-class, rather than as a base-class of @code{D}.
76390075Sobrien
764169689SkanThe access to a base type can be found with @code{BINFO_BASE_ACCESS}.
765169689SkanThis will produce @code{access_public_node}, @code{access_private_node}
766169689Skanor @code{access_protected_node}.  If bases are always public,
767169689Skan@code{BINFO_BASE_ACCESSES} may be @code{NULL}.
76890075Sobrien
769169689Skan@code{BINFO_VIRTUAL_P} is used to specify whether the binfo is inherited
770169689Skanvirtually or not.  The other flags, @code{BINFO_MARKED_P} and
771169689Skan@code{BINFO_FLAG_1} to @code{BINFO_FLAG_6} can be used for language
772169689Skanspecific use.
773169689Skan
77490075SobrienThe following macros can be used on a tree node representing a class-type.
77590075Sobrien
77690075Sobrien@ftable @code
77790075Sobrien@item LOCAL_CLASS_P
778169689SkanThis predicate holds if the class is local class @emph{i.e.}@: declared
77990075Sobrieninside a function body.
78090075Sobrien
78190075Sobrien@item TYPE_POLYMORPHIC_P
78290075SobrienThis predicate holds if the class has at least one virtual function
78390075Sobrien(declared or inherited).
78490075Sobrien
78590075Sobrien@item TYPE_HAS_DEFAULT_CONSTRUCTOR
78690075SobrienThis predicate holds whenever its argument represents a class-type with
78790075Sobriendefault constructor.
78890075Sobrien
78990075Sobrien@item CLASSTYPE_HAS_MUTABLE
790132718Skan@itemx TYPE_HAS_MUTABLE_P
79190075SobrienThese predicates hold for a class-type having a mutable data member.
79290075Sobrien
79390075Sobrien@item CLASSTYPE_NON_POD_P
79490075SobrienThis predicate holds only for class-types that are not PODs.
79590075Sobrien
79690075Sobrien@item TYPE_HAS_NEW_OPERATOR
79790075SobrienThis predicate holds for a class-type that defines
79890075Sobrien@code{operator new}.
79990075Sobrien
80090075Sobrien@item TYPE_HAS_ARRAY_NEW_OPERATOR
80190075SobrienThis predicate holds for a class-type for which
80290075Sobrien@code{operator new[]} is defined.
80390075Sobrien
80490075Sobrien@item TYPE_OVERLOADS_CALL_EXPR
80590075SobrienThis predicate holds for class-type for which the function call
80690075Sobrien@code{operator()} is overloaded.
80790075Sobrien
80890075Sobrien@item TYPE_OVERLOADS_ARRAY_REF
80990075SobrienThis predicate holds for a class-type that overloads
81090075Sobrien@code{operator[]}
81190075Sobrien
81290075Sobrien@item TYPE_OVERLOADS_ARROW
81390075SobrienThis predicate holds for a class-type for which @code{operator->} is
81490075Sobrienoverloaded.
81590075Sobrien
81690075Sobrien@end ftable
81790075Sobrien
81890075Sobrien@c ---------------------------------------------------------------------
81990075Sobrien@c Declarations
82090075Sobrien@c ---------------------------------------------------------------------
82190075Sobrien
82290075Sobrien@node Declarations
82390075Sobrien@section Declarations
82490075Sobrien@cindex declaration
82590075Sobrien@cindex variable
82690075Sobrien@cindex type declaration
82790075Sobrien@tindex LABEL_DECL
82890075Sobrien@tindex CONST_DECL
82990075Sobrien@tindex TYPE_DECL
83090075Sobrien@tindex VAR_DECL
83190075Sobrien@tindex PARM_DECL
83290075Sobrien@tindex FIELD_DECL
83390075Sobrien@tindex NAMESPACE_DECL
83490075Sobrien@tindex RESULT_DECL
83590075Sobrien@tindex TEMPLATE_DECL
83690075Sobrien@tindex THUNK_DECL
83790075Sobrien@tindex USING_DECL
83890075Sobrien@findex THUNK_DELTA
83990075Sobrien@findex DECL_INITIAL
84090075Sobrien@findex DECL_SIZE
84190075Sobrien@findex DECL_ALIGN
84290075Sobrien@findex DECL_EXTERNAL
84390075Sobrien
84490075SobrienThis section covers the various kinds of declarations that appear in the
84590075Sobrieninternal representation, except for declarations of functions
84690075Sobrien(represented by @code{FUNCTION_DECL} nodes), which are described in
84790075Sobrien@ref{Functions}.
84890075Sobrien
849169689Skan@menu
850169689Skan* Working with declarations::  Macros and functions that work on
851169689Skandeclarations.
852169689Skan* Internal structure:: How declaration nodes are represented. 
853169689Skan@end menu
854169689Skan
855169689Skan@node Working with declarations
856169689Skan@subsection Working with declarations
857169689Skan
85890075SobrienSome macros can be used with any kind of declaration.  These include:
85990075Sobrien@ftable @code
86090075Sobrien@item DECL_NAME
86190075SobrienThis macro returns an @code{IDENTIFIER_NODE} giving the name of the
86290075Sobrienentity.
86390075Sobrien
86490075Sobrien@item TREE_TYPE
86590075SobrienThis macro returns the type of the entity declared.
86690075Sobrien
867169689Skan@item TREE_FILENAME
86890075SobrienThis macro returns the name of the file in which the entity was
86990075Sobriendeclared, as a @code{char*}.  For an entity declared implicitly by the
87090075Sobriencompiler (like @code{__builtin_memcpy}), this will be the string
87190075Sobrien@code{"<internal>"}.
87290075Sobrien
873169689Skan@item TREE_LINENO
87490075SobrienThis macro returns the line number at which the entity was declared, as
87590075Sobrienan @code{int}.
87690075Sobrien
87790075Sobrien@item DECL_ARTIFICIAL
87890075SobrienThis predicate holds if the declaration was implicitly generated by the
87990075Sobriencompiler.  For example, this predicate will hold of an implicitly
88090075Sobriendeclared member function, or of the @code{TYPE_DECL} implicitly
88190075Sobriengenerated for a class type.  Recall that in C++ code like:
882132718Skan@smallexample
88390075Sobrienstruct S @{@};
884132718Skan@end smallexample
88590075Sobrien@noindent
88690075Sobrienis roughly equivalent to C code like:
887132718Skan@smallexample
88890075Sobrienstruct S @{@};
88990075Sobrientypedef struct S S;
890132718Skan@end smallexample
89190075SobrienThe implicitly generated @code{typedef} declaration is represented by a
89290075Sobrien@code{TYPE_DECL} for which @code{DECL_ARTIFICIAL} holds.
89390075Sobrien
89490075Sobrien@item DECL_NAMESPACE_SCOPE_P
89590075SobrienThis predicate holds if the entity was declared at a namespace scope.
89690075Sobrien
89790075Sobrien@item DECL_CLASS_SCOPE_P
89890075SobrienThis predicate holds if the entity was declared at a class scope.
89990075Sobrien
90090075Sobrien@item DECL_FUNCTION_SCOPE_P
90190075SobrienThis predicate holds if the entity was declared inside a function
90290075Sobrienbody.
90390075Sobrien
90490075Sobrien@end ftable
90590075Sobrien
90690075SobrienThe various kinds of declarations include:
90790075Sobrien@table @code
90890075Sobrien@item LABEL_DECL
90990075SobrienThese nodes are used to represent labels in function bodies.  For more
91090075Sobrieninformation, see @ref{Functions}.  These nodes only appear in block
91190075Sobrienscopes.
91290075Sobrien
91390075Sobrien@item CONST_DECL
91490075SobrienThese nodes are used to represent enumeration constants.  The value of
91590075Sobrienthe constant is given by @code{DECL_INITIAL} which will be an
91690075Sobrien@code{INTEGER_CST} with the same type as the @code{TREE_TYPE} of the
91790075Sobrien@code{CONST_DECL}, i.e., an @code{ENUMERAL_TYPE}.
91890075Sobrien
91990075Sobrien@item RESULT_DECL
92090075SobrienThese nodes represent the value returned by a function.  When a value is
92190075Sobrienassigned to a @code{RESULT_DECL}, that indicates that the value should
92290075Sobrienbe returned, via bitwise copy, by the function.  You can use
92390075Sobrien@code{DECL_SIZE} and @code{DECL_ALIGN} on a @code{RESULT_DECL}, just as
92490075Sobrienwith a @code{VAR_DECL}.
92590075Sobrien
92690075Sobrien@item TYPE_DECL
92790075SobrienThese nodes represent @code{typedef} declarations.  The @code{TREE_TYPE}
92890075Sobrienis the type declared to have the name given by @code{DECL_NAME}.  In
92990075Sobriensome cases, there is no associated name.
93090075Sobrien
93190075Sobrien@item VAR_DECL
93290075SobrienThese nodes represent variables with namespace or block scope, as well
93390075Sobrienas static data members.  The @code{DECL_SIZE} and @code{DECL_ALIGN} are
93490075Sobrienanalogous to @code{TYPE_SIZE} and @code{TYPE_ALIGN}.  For a declaration,
93590075Sobrienyou should always use the @code{DECL_SIZE} and @code{DECL_ALIGN} rather
93690075Sobrienthan the @code{TYPE_SIZE} and @code{TYPE_ALIGN} given by the
93790075Sobrien@code{TREE_TYPE}, since special attributes may have been applied to the
93890075Sobrienvariable to give it a particular size and alignment.  You may use the
93990075Sobrienpredicates @code{DECL_THIS_STATIC} or @code{DECL_THIS_EXTERN} to test
94090075Sobrienwhether the storage class specifiers @code{static} or @code{extern} were
94190075Sobrienused to declare a variable.
94290075Sobrien
94390075SobrienIf this variable is initialized (but does not require a constructor),
94490075Sobrienthe @code{DECL_INITIAL} will be an expression for the initializer.  The
94590075Sobrieninitializer should be evaluated, and a bitwise copy into the variable
94690075Sobrienperformed.  If the @code{DECL_INITIAL} is the @code{error_mark_node},
94790075Sobrienthere is an initializer, but it is given by an explicit statement later
94890075Sobrienin the code; no bitwise copy is required.
94990075Sobrien
95090075SobrienGCC provides an extension that allows either automatic variables, or
95190075Sobrienglobal variables, to be placed in particular registers.  This extension
95290075Sobrienis being used for a particular @code{VAR_DECL} if @code{DECL_REGISTER}
95390075Sobrienholds for the @code{VAR_DECL}, and if @code{DECL_ASSEMBLER_NAME} is not
95490075Sobrienequal to @code{DECL_NAME}.  In that case, @code{DECL_ASSEMBLER_NAME} is
95590075Sobrienthe name of the register into which the variable will be placed.
95690075Sobrien
95790075Sobrien@item PARM_DECL
95890075SobrienUsed to represent a parameter to a function.  Treat these nodes
95990075Sobriensimilarly to @code{VAR_DECL} nodes.  These nodes only appear in the
96090075Sobrien@code{DECL_ARGUMENTS} for a @code{FUNCTION_DECL}.
96190075Sobrien
96290075SobrienThe @code{DECL_ARG_TYPE} for a @code{PARM_DECL} is the type that will
96390075Sobrienactually be used when a value is passed to this function.  It may be a
96490075Sobrienwider type than the @code{TREE_TYPE} of the parameter; for example, the
96590075Sobrienordinary type might be @code{short} while the @code{DECL_ARG_TYPE} is
96690075Sobrien@code{int}.
96790075Sobrien
96890075Sobrien@item FIELD_DECL
96990075SobrienThese nodes represent non-static data members.  The @code{DECL_SIZE} and
970169689Skan@code{DECL_ALIGN} behave as for @code{VAR_DECL} nodes.  
971169689SkanThe position of the field within the parent record is specified by a 
972169689Skancombination of three attributes.  @code{DECL_FIELD_OFFSET} is the position,
973169689Skancounting in bytes, of the @code{DECL_OFFSET_ALIGN}-bit sized word containing
974169689Skanthe bit of the field closest to the beginning of the structure.  
975169689Skan@code{DECL_FIELD_BIT_OFFSET} is the bit offset of the first bit of the field
976169689Skanwithin this word; this may be nonzero even for fields that are not bit-fields,
977169689Skansince @code{DECL_OFFSET_ALIGN} may be greater than the natural alignment
978169689Skanof the field's type.
97990075Sobrien
980169689SkanIf @code{DECL_C_BIT_FIELD} holds, this field is a bit-field.  In a bit-field,
981169689Skan@code{DECL_BIT_FIELD_TYPE} also contains the type that was originally
982169689Skanspecified for it, while DECL_TYPE may be a modified type with lesser precision,
983169689Skanaccording to the size of the bit field.
98490075Sobrien
98590075Sobrien@item NAMESPACE_DECL
98690075Sobrien@xref{Namespaces}.
98790075Sobrien
98890075Sobrien@item TEMPLATE_DECL
98990075Sobrien
99090075SobrienThese nodes are used to represent class, function, and variable (static
99190075Sobriendata member) templates.  The @code{DECL_TEMPLATE_SPECIALIZATIONS} are a
99290075Sobrien@code{TREE_LIST}.  The @code{TREE_VALUE} of each node in the list is a
99390075Sobrien@code{TEMPLATE_DECL}s or @code{FUNCTION_DECL}s representing
99490075Sobrienspecializations (including instantiations) of this template.  Back ends
99590075Sobriencan safely ignore @code{TEMPLATE_DECL}s, but should examine
99690075Sobrien@code{FUNCTION_DECL} nodes on the specializations list just as they
99790075Sobrienwould ordinary @code{FUNCTION_DECL} nodes.
99890075Sobrien
99990075SobrienFor a class template, the @code{DECL_TEMPLATE_INSTANTIATIONS} list
100090075Sobriencontains the instantiations.  The @code{TREE_VALUE} of each node is an
100190075Sobrieninstantiation of the class.  The @code{DECL_TEMPLATE_SPECIALIZATIONS}
100290075Sobriencontains partial specializations of the class.
100390075Sobrien
100490075Sobrien@item USING_DECL
100590075Sobrien
100690075SobrienBack ends can safely ignore these nodes.
100790075Sobrien
100890075Sobrien@end table
100990075Sobrien
1010169689Skan@node Internal structure
1011169689Skan@subsection Internal structure
1012169689Skan
1013169689Skan@code{DECL} nodes are represented internally as a hierarchy of
1014169689Skanstructures.
1015169689Skan
1016169689Skan@menu
1017169689Skan* Current structure hierarchy::  The current DECL node structure
1018169689Skanhierarchy.
1019169689Skan* Adding new DECL node types:: How to add a new DECL node to a
1020169689Skanfrontend.
1021169689Skan@end menu
1022169689Skan
1023169689Skan@node Current structure hierarchy
1024169689Skan@subsubsection Current structure hierarchy
1025169689Skan
1026169689Skan@table @code
1027169689Skan
1028169689Skan@item struct tree_decl_minimal
1029169689SkanThis is the minimal structure to inherit from in order for common
1030169689Skan@code{DECL} macros to work.  The fields it contains are a unique ID,
1031169689Skansource location, context, and name.
1032169689Skan
1033169689Skan@item struct tree_decl_common
1034169689SkanThis structure inherits from @code{struct tree_decl_minimal}.  It
1035169689Skancontains fields that most @code{DECL} nodes need, such as a field to
1036169689Skanstore alignment, machine mode, size, and attributes.
1037169689Skan
1038169689Skan@item struct tree_field_decl
1039169689SkanThis structure inherits from @code{struct tree_decl_common}.  It is
1040169689Skanused to represent @code{FIELD_DECL}.
1041169689Skan
1042169689Skan@item struct tree_label_decl
1043169689SkanThis structure inherits from @code{struct tree_decl_common}.  It is
1044169689Skanused to represent @code{LABEL_DECL}.
1045169689Skan
1046169689Skan@item struct tree_translation_unit_decl
1047169689SkanThis structure inherits from @code{struct tree_decl_common}.  It is
1048169689Skanused to represent @code{TRANSLATION_UNIT_DECL}.
1049169689Skan
1050169689Skan@item struct tree_decl_with_rtl
1051169689SkanThis structure inherits from @code{struct tree_decl_common}.  It
1052169689Skancontains a field to store the low-level RTL associated with a
1053169689Skan@code{DECL} node.
1054169689Skan
1055169689Skan@item struct tree_result_decl
1056169689SkanThis structure inherits from @code{struct tree_decl_with_rtl}.  It is
1057169689Skanused to represent @code{RESULT_DECL}.
1058169689Skan
1059169689Skan@item struct tree_const_decl
1060169689SkanThis structure inherits from @code{struct tree_decl_with_rtl}.  It is
1061169689Skanused to represent @code{CONST_DECL}.
1062169689Skan
1063169689Skan@item struct tree_parm_decl
1064169689SkanThis structure inherits from @code{struct tree_decl_with_rtl}.  It is
1065169689Skanused to represent @code{PARM_DECL}.  
1066169689Skan
1067169689Skan@item struct tree_decl_with_vis
1068169689SkanThis structure inherits from @code{struct tree_decl_with_rtl}.  It
1069169689Skancontains fields necessary to store visibility information, as well as
1070169689Skana section name and assembler name.
1071169689Skan
1072169689Skan@item struct tree_var_decl
1073169689SkanThis structure inherits from @code{struct tree_decl_with_vis}.  It is
1074169689Skanused to represent @code{VAR_DECL}.  
1075169689Skan
1076169689Skan@item struct tree_function_decl
1077169689SkanThis structure inherits from @code{struct tree_decl_with_vis}.  It is
1078169689Skanused to represent @code{FUNCTION_DECL}.  
1079169689Skan
1080169689Skan@end table
1081169689Skan@node Adding new DECL node types
1082169689Skan@subsubsection Adding new DECL node types
1083169689Skan
1084169689SkanAdding a new @code{DECL} tree consists of the following steps
1085169689Skan
1086169689Skan@table @asis
1087169689Skan
1088169689Skan@item Add a new tree code for the @code{DECL} node
1089169689SkanFor language specific @code{DECL} nodes, there is a @file{.def} file
1090169689Skanin each frontend directory where the tree code should be added.
1091169689SkanFor @code{DECL} nodes that are part of the middle-end, the code should
1092169689Skanbe added to @file{tree.def}.
1093169689Skan
1094169689Skan@item Create a new structure type for the @code{DECL} node
1095169689SkanThese structures should inherit from one of the existing structures in
1096169689Skanthe language hierarchy by using that structure as the first member.
1097169689Skan
1098169689Skan@smallexample
1099169689Skanstruct tree_foo_decl
1100169689Skan@{
1101169689Skan   struct tree_decl_with_vis common;
1102169689Skan@}
1103169689Skan@end smallexample
1104169689Skan
1105169689SkanWould create a structure name @code{tree_foo_decl} that inherits from
1106169689Skan@code{struct tree_decl_with_vis}.
1107169689Skan
1108169689SkanFor language specific @code{DECL} nodes, this new structure type
1109169689Skanshould go in the appropriate @file{.h} file.
1110169689SkanFor @code{DECL} nodes that are part of the middle-end, the structure
1111169689Skantype should go in @file{tree.h}.
1112169689Skan
1113169689Skan@item Add a member to the tree structure enumerator for the node
1114169689SkanFor garbage collection and dynamic checking purposes, each @code{DECL}
1115169689Skannode structure type is required to have a unique enumerator value
1116169689Skanspecified with it.
1117169689SkanFor language specific @code{DECL} nodes, this new enumerator value
1118169689Skanshould go in the appropriate @file{.def} file.
1119169689SkanFor @code{DECL} nodes that are part of the middle-end, the enumerator
1120169689Skanvalues are specified in @file{treestruct.def}.
1121169689Skan
1122169689Skan@item Update @code{union tree_node}
1123169689SkanIn order to make your new structure type usable, it must be added to
1124169689Skan@code{union tree_node}.
1125169689SkanFor language specific @code{DECL} nodes, a new entry should be added
1126169689Skanto the appropriate @file{.h} file of the form
1127169689Skan@smallexample
1128169689Skan  struct tree_foo_decl GTY ((tag ("TS_VAR_DECL"))) foo_decl;
1129169689Skan@end smallexample
1130169689SkanFor @code{DECL} nodes that are part of the middle-end, the additional
1131169689Skanmember goes directly into @code{union tree_node} in @file{tree.h}.
1132169689Skan
1133169689Skan@item Update dynamic checking info
1134169689SkanIn order to be able to check whether accessing a named portion of
1135169689Skan@code{union tree_node} is legal, and whether a certain @code{DECL} node
1136169689Skancontains one of the enumerated @code{DECL} node structures in the
1137169689Skanhierarchy, a simple lookup table is used.
1138169689SkanThis lookup table needs to be kept up to date with the tree structure
1139169689Skanhierarchy, or else checking and containment macros will fail
1140169689Skaninappropriately.
1141169689Skan
1142169689SkanFor language specific @code{DECL} nodes, their is an @code{init_ts}
1143169689Skanfunction in an appropriate @file{.c} file, which initializes the lookup
1144169689Skantable.
1145169689SkanCode setting up the table for new @code{DECL} nodes should be added
1146169689Skanthere.
1147169689SkanFor each @code{DECL} tree code and enumerator value representing a
1148169689Skanmember of the inheritance  hierarchy, the table should contain 1 if
1149169689Skanthat tree code inherits (directly or indirectly) from that member.
1150169689SkanThus, a @code{FOO_DECL} node derived from @code{struct decl_with_rtl},
1151169689Skanand enumerator value @code{TS_FOO_DECL}, would be set up as follows
1152169689Skan@smallexample
1153169689Skantree_contains_struct[FOO_DECL][TS_FOO_DECL] = 1;
1154169689Skantree_contains_struct[FOO_DECL][TS_DECL_WRTL] = 1;
1155169689Skantree_contains_struct[FOO_DECL][TS_DECL_COMMON] = 1;
1156169689Skantree_contains_struct[FOO_DECL][TS_DECL_MINIMAL] = 1;
1157169689Skan@end smallexample
1158169689Skan
1159169689SkanFor @code{DECL} nodes that are part of the middle-end, the setup code
1160169689Skangoes into @file{tree.c}.
1161169689Skan
1162169689Skan@item Add macros to access any new fields and flags
1163169689Skan
1164169689SkanEach added field or flag should have a macro that is used to access
1165169689Skanit, that performs appropriate checking to ensure only the right type of
1166169689Skan@code{DECL} nodes access the field.
1167169689Skan
1168169689SkanThese macros generally take the following form
1169169689Skan@smallexample
1170169689Skan#define FOO_DECL_FIELDNAME(NODE) FOO_DECL_CHECK(NODE)->foo_decl.fieldname
1171169689Skan@end smallexample
1172169689SkanHowever, if the structure is simply a base class for further
1173169689Skanstructures, something like the following should be used
1174169689Skan@smallexample
1175169689Skan#define BASE_STRUCT_CHECK(T) CONTAINS_STRUCT_CHECK(T, TS_BASE_STRUCT)
1176169689Skan#define BASE_STRUCT_FIELDNAME(NODE) \
1177169689Skan   (BASE_STRUCT_CHECK(NODE)->base_struct.fieldname
1178169689Skan@end smallexample
1179169689Skan
1180169689Skan@end table
1181169689Skan
1182169689Skan
118390075Sobrien@c ---------------------------------------------------------------------
118490075Sobrien@c Functions
118590075Sobrien@c ---------------------------------------------------------------------
118690075Sobrien
118790075Sobrien@node Functions
118890075Sobrien@section Functions
118990075Sobrien@cindex function
119090075Sobrien@tindex FUNCTION_DECL
119190075Sobrien@tindex OVERLOAD
119290075Sobrien@findex OVL_CURRENT
119390075Sobrien@findex OVL_NEXT
119490075Sobrien
119590075SobrienA function is represented by a @code{FUNCTION_DECL} node.  A set of
119690075Sobrienoverloaded functions is sometimes represented by a @code{OVERLOAD} node.
119790075Sobrien
119890075SobrienAn @code{OVERLOAD} node is not a declaration, so none of the
119990075Sobrien@samp{DECL_} macros should be used on an @code{OVERLOAD}.  An
120090075Sobrien@code{OVERLOAD} node is similar to a @code{TREE_LIST}.  Use
120190075Sobrien@code{OVL_CURRENT} to get the function associated with an
120290075Sobrien@code{OVERLOAD} node; use @code{OVL_NEXT} to get the next
120390075Sobrien@code{OVERLOAD} node in the list of overloaded functions.  The macros
120490075Sobrien@code{OVL_CURRENT} and @code{OVL_NEXT} are actually polymorphic; you can
120590075Sobrienuse them to work with @code{FUNCTION_DECL} nodes as well as with
120690075Sobrienoverloads.  In the case of a @code{FUNCTION_DECL}, @code{OVL_CURRENT}
120790075Sobrienwill always return the function itself, and @code{OVL_NEXT} will always
120890075Sobrienbe @code{NULL_TREE}.
120990075Sobrien
121090075SobrienTo determine the scope of a function, you can use the
1211132718Skan@code{DECL_CONTEXT} macro.  This macro will return the class
121290075Sobrien(either a @code{RECORD_TYPE} or a @code{UNION_TYPE}) or namespace (a
121390075Sobrien@code{NAMESPACE_DECL}) of which the function is a member.  For a virtual
121490075Sobrienfunction, this macro returns the class in which the function was
121590075Sobrienactually defined, not the base class in which the virtual declaration
1216132718Skanoccurred.
1217132718Skan
1218132718SkanIf a friend function is defined in a class scope, the
1219132718Skan@code{DECL_FRIEND_CONTEXT} macro can be used to determine the class in
122090075Sobrienwhich it was defined.  For example, in
1221132718Skan@smallexample
122290075Sobrienclass C @{ friend void f() @{@} @};
1223132718Skan@end smallexample
1224132718Skan@noindent
1225132718Skanthe @code{DECL_CONTEXT} for @code{f} will be the
1226132718Skan@code{global_namespace}, but the @code{DECL_FRIEND_CONTEXT} will be the
122790075Sobrien@code{RECORD_TYPE} for @code{C}.
122890075Sobrien
1229132718SkanIn C, the @code{DECL_CONTEXT} for a function maybe another function.
1230132718SkanThis representation indicates that the GNU nested function extension
1231132718Skanis in use.  For details on the semantics of nested functions, see the
1232132718SkanGCC Manual.  The nested function can refer to local variables in its
123390075Sobriencontaining function.  Such references are not explicitly marked in the
123490075Sobrientree structure; back ends must look at the @code{DECL_CONTEXT} for the
123590075Sobrienreferenced @code{VAR_DECL}.  If the @code{DECL_CONTEXT} for the
123690075Sobrienreferenced @code{VAR_DECL} is not the same as the function currently
1237132718Skanbeing processed, and neither @code{DECL_EXTERNAL} nor
1238132718Skan@code{DECL_STATIC} hold, then the reference is to a local variable in
1239132718Skana containing function, and the back end must take appropriate action.
124090075Sobrien
124190075Sobrien@menu
124290075Sobrien* Function Basics::     Function names, linkage, and so forth.
124390075Sobrien* Function Bodies::     The statements that make up a function body.
124490075Sobrien@end menu
124590075Sobrien
124690075Sobrien@c ---------------------------------------------------------------------
124790075Sobrien@c Function Basics
124890075Sobrien@c ---------------------------------------------------------------------
124990075Sobrien
125090075Sobrien@node Function Basics
125190075Sobrien@subsection Function Basics
125290075Sobrien@cindex constructor
125390075Sobrien@cindex destructor
125490075Sobrien@cindex copy constructor
125590075Sobrien@cindex assignment operator
125690075Sobrien@cindex linkage
125790075Sobrien@findex DECL_NAME
125890075Sobrien@findex DECL_ASSEMBLER_NAME
125990075Sobrien@findex TREE_PUBLIC
126090075Sobrien@findex DECL_LINKONCE_P
126190075Sobrien@findex DECL_FUNCTION_MEMBER_P
126290075Sobrien@findex DECL_CONSTRUCTOR_P
126390075Sobrien@findex DECL_DESTRUCTOR_P
126490075Sobrien@findex DECL_OVERLOADED_OPERATOR_P
126590075Sobrien@findex DECL_CONV_FN_P
126690075Sobrien@findex DECL_ARTIFICIAL
126790075Sobrien@findex DECL_GLOBAL_CTOR_P
126890075Sobrien@findex DECL_GLOBAL_DTOR_P
126990075Sobrien@findex GLOBAL_INIT_PRIORITY
127090075Sobrien
127190075SobrienThe following macros and functions can be used on a @code{FUNCTION_DECL}:
127290075Sobrien@ftable @code
127390075Sobrien@item DECL_MAIN_P
127490075SobrienThis predicate holds for a function that is the program entry point
127590075Sobrien@code{::code}.
127690075Sobrien
127790075Sobrien@item DECL_NAME
127890075SobrienThis macro returns the unqualified name of the function, as an
127990075Sobrien@code{IDENTIFIER_NODE}.  For an instantiation of a function template,
128090075Sobrienthe @code{DECL_NAME} is the unqualified name of the template, not
128190075Sobriensomething like @code{f<int>}.  The value of @code{DECL_NAME} is
128290075Sobrienundefined when used on a constructor, destructor, overloaded operator,
128390075Sobrienor type-conversion operator, or any function that is implicitly
128490075Sobriengenerated by the compiler.  See below for macros that can be used to
128590075Sobriendistinguish these cases.
128690075Sobrien
128790075Sobrien@item DECL_ASSEMBLER_NAME
128890075SobrienThis macro returns the mangled name of the function, also an
128990075Sobrien@code{IDENTIFIER_NODE}.  This name does not contain leading underscores
129090075Sobrienon systems that prefix all identifiers with underscores.  The mangled
129190075Sobrienname is computed in the same way on all platforms; if special processing
129290075Sobrienis required to deal with the object file format used on a particular
129390075Sobrienplatform, it is the responsibility of the back end to perform those
129490075Sobrienmodifications.  (Of course, the back end should not modify
129590075Sobrien@code{DECL_ASSEMBLER_NAME} itself.)
129690075Sobrien
1297169689SkanUsing @code{DECL_ASSEMBLER_NAME} will cause additional memory to be
1298169689Skanallocated (for the mangled name of the entity) so it should be used
1299169689Skanonly when emitting assembly code.  It should not be used within the
1300169689Skanoptimizers to determine whether or not two declarations are the same,
1301169689Skaneven though some of the existing optimizers do use it in that way.
1302169689SkanThese uses will be removed over time.
1303169689Skan
130490075Sobrien@item DECL_EXTERNAL
130590075SobrienThis predicate holds if the function is undefined.
130690075Sobrien
130790075Sobrien@item TREE_PUBLIC
130890075SobrienThis predicate holds if the function has external linkage.
130990075Sobrien
131090075Sobrien@item DECL_LOCAL_FUNCTION_P
131190075SobrienThis predicate holds if the function was declared at block scope, even
131290075Sobrienthough it has a global scope.
131390075Sobrien
131490075Sobrien@item DECL_ANTICIPATED
131590075SobrienThis predicate holds if the function is a built-in function but its
131690075Sobrienprototype is not yet explicitly declared.
131790075Sobrien
131890075Sobrien@item DECL_EXTERN_C_FUNCTION_P
131990075SobrienThis predicate holds if the function is declared as an
132090075Sobrien`@code{extern "C"}' function.
132190075Sobrien
132290075Sobrien@item DECL_LINKONCE_P
132390075SobrienThis macro holds if multiple copies of this function may be emitted in
132490075Sobrienvarious translation units.  It is the responsibility of the linker to
132590075Sobrienmerge the various copies.  Template instantiations are the most common
132690075Sobrienexample of functions for which @code{DECL_LINKONCE_P} holds; G++
132790075Sobrieninstantiates needed templates in all translation units which require them,
132890075Sobrienand then relies on the linker to remove duplicate instantiations.
132990075Sobrien
133090075SobrienFIXME: This macro is not yet implemented.
133190075Sobrien
133290075Sobrien@item DECL_FUNCTION_MEMBER_P
133390075SobrienThis macro holds if the function is a member of a class, rather than a
133490075Sobrienmember of a namespace.
133590075Sobrien
133690075Sobrien@item DECL_STATIC_FUNCTION_P
133790075SobrienThis predicate holds if the function a static member function.
133890075Sobrien
133990075Sobrien@item DECL_NONSTATIC_MEMBER_FUNCTION_P
134090075SobrienThis macro holds for a non-static member function.
134190075Sobrien
134290075Sobrien@item DECL_CONST_MEMFUNC_P
134390075SobrienThis predicate holds for a @code{const}-member function.
134490075Sobrien
134590075Sobrien@item DECL_VOLATILE_MEMFUNC_P
134690075SobrienThis predicate holds for a @code{volatile}-member function.
134790075Sobrien
134890075Sobrien@item DECL_CONSTRUCTOR_P
134990075SobrienThis macro holds if the function is a constructor.
135090075Sobrien
135190075Sobrien@item DECL_NONCONVERTING_P
135290075SobrienThis predicate holds if the constructor is a non-converting constructor.
135390075Sobrien
135490075Sobrien@item DECL_COMPLETE_CONSTRUCTOR_P
135590075SobrienThis predicate holds for a function which is a constructor for an object
135690075Sobrienof a complete type.
135790075Sobrien
135890075Sobrien@item DECL_BASE_CONSTRUCTOR_P
135990075SobrienThis predicate holds for a function which is a constructor for a base
136090075Sobrienclass sub-object.
136190075Sobrien
136290075Sobrien@item DECL_COPY_CONSTRUCTOR_P
136390075SobrienThis predicate holds for a function which is a copy-constructor.
136490075Sobrien
136590075Sobrien@item DECL_DESTRUCTOR_P
136690075SobrienThis macro holds if the function is a destructor.
136790075Sobrien
136890075Sobrien@item DECL_COMPLETE_DESTRUCTOR_P
136990075SobrienThis predicate holds if the function is the destructor for an object a
137090075Sobriencomplete type.
137190075Sobrien
137290075Sobrien@item DECL_OVERLOADED_OPERATOR_P
137390075SobrienThis macro holds if the function is an overloaded operator.
137490075Sobrien
137590075Sobrien@item DECL_CONV_FN_P
137690075SobrienThis macro holds if the function is a type-conversion operator.
137790075Sobrien
137890075Sobrien@item DECL_GLOBAL_CTOR_P
137990075SobrienThis predicate holds if the function is a file-scope initialization
138090075Sobrienfunction.
138190075Sobrien
138290075Sobrien@item DECL_GLOBAL_DTOR_P
138390075SobrienThis predicate holds if the function is a file-scope finalization
138490075Sobrienfunction.
138590075Sobrien
138690075Sobrien@item DECL_THUNK_P
138790075SobrienThis predicate holds if the function is a thunk.
138890075Sobrien
138990075SobrienThese functions represent stub code that adjusts the @code{this} pointer
139090075Sobrienand then jumps to another function.  When the jumped-to function
139190075Sobrienreturns, control is transferred directly to the caller, without
139290075Sobrienreturning to the thunk.  The first parameter to the thunk is always the
139390075Sobrien@code{this} pointer; the thunk should add @code{THUNK_DELTA} to this
139490075Sobrienvalue.  (The @code{THUNK_DELTA} is an @code{int}, not an
139590075Sobrien@code{INTEGER_CST}.)
139690075Sobrien
139790075SobrienThen, if @code{THUNK_VCALL_OFFSET} (an @code{INTEGER_CST}) is nonzero
139890075Sobrienthe adjusted @code{this} pointer must be adjusted again.  The complete
139990075Sobriencalculation is given by the following pseudo-code:
140090075Sobrien
1401103445Skan@smallexample
140290075Sobrienthis += THUNK_DELTA
140390075Sobrienif (THUNK_VCALL_OFFSET)
140490075Sobrien  this += (*((ptrdiff_t **) this))[THUNK_VCALL_OFFSET]
1405103445Skan@end smallexample
140690075Sobrien
140790075SobrienFinally, the thunk should jump to the location given
140890075Sobrienby @code{DECL_INITIAL}; this will always be an expression for the
140990075Sobrienaddress of a function.
141090075Sobrien
141190075Sobrien@item DECL_NON_THUNK_FUNCTION_P
141290075SobrienThis predicate holds if the function is @emph{not} a thunk function.
141390075Sobrien
141490075Sobrien@item GLOBAL_INIT_PRIORITY
141590075SobrienIf either @code{DECL_GLOBAL_CTOR_P} or @code{DECL_GLOBAL_DTOR_P} holds,
141690075Sobrienthen this gives the initialization priority for the function.  The
141790075Sobrienlinker will arrange that all functions for which
141890075Sobrien@code{DECL_GLOBAL_CTOR_P} holds are run in increasing order of priority
141990075Sobrienbefore @code{main} is called.  When the program exits, all functions for
142090075Sobrienwhich @code{DECL_GLOBAL_DTOR_P} holds are run in the reverse order.
142190075Sobrien
142290075Sobrien@item DECL_ARTIFICIAL
142390075SobrienThis macro holds if the function was implicitly generated by the
142490075Sobriencompiler, rather than explicitly declared.  In addition to implicitly
142590075Sobriengenerated class member functions, this macro holds for the special
142690075Sobrienfunctions created to implement static initialization and destruction, to
142790075Sobriencompute run-time type information, and so forth.
142890075Sobrien
142990075Sobrien@item DECL_ARGUMENTS
143090075SobrienThis macro returns the @code{PARM_DECL} for the first argument to the
143190075Sobrienfunction.  Subsequent @code{PARM_DECL} nodes can be obtained by
143290075Sobrienfollowing the @code{TREE_CHAIN} links.
143390075Sobrien
143490075Sobrien@item DECL_RESULT
143590075SobrienThis macro returns the @code{RESULT_DECL} for the function.
143690075Sobrien
143790075Sobrien@item TREE_TYPE
143890075SobrienThis macro returns the @code{FUNCTION_TYPE} or @code{METHOD_TYPE} for
143990075Sobrienthe function.
144090075Sobrien
144190075Sobrien@item TYPE_RAISES_EXCEPTIONS
144290075SobrienThis macro returns the list of exceptions that a (member-)function can
144390075Sobrienraise.  The returned list, if non @code{NULL}, is comprised of nodes
144490075Sobrienwhose @code{TREE_VALUE} represents a type.
144590075Sobrien
144690075Sobrien@item TYPE_NOTHROW_P
144790075SobrienThis predicate holds when the exception-specification of its arguments
144890075Sobrienif of the form `@code{()}'.
144990075Sobrien
145090075Sobrien@item DECL_ARRAY_DELETE_OPERATOR_P
145190075SobrienThis predicate holds if the function an overloaded
145290075Sobrien@code{operator delete[]}.
145390075Sobrien
145490075Sobrien@end ftable
145590075Sobrien
145690075Sobrien@c ---------------------------------------------------------------------
145790075Sobrien@c Function Bodies
145890075Sobrien@c ---------------------------------------------------------------------
145990075Sobrien
146090075Sobrien@node Function Bodies
146190075Sobrien@subsection Function Bodies
146290075Sobrien@cindex function body
146390075Sobrien@cindex statements
146490075Sobrien@tindex BREAK_STMT
146590075Sobrien@tindex CLEANUP_STMT
146690075Sobrien@findex CLEANUP_DECL
146790075Sobrien@findex CLEANUP_EXPR
146890075Sobrien@tindex CONTINUE_STMT
146990075Sobrien@tindex DECL_STMT
147090075Sobrien@findex DECL_STMT_DECL
147190075Sobrien@tindex DO_STMT
147290075Sobrien@findex DO_BODY
147390075Sobrien@findex DO_COND
147490075Sobrien@tindex EMPTY_CLASS_EXPR
147590075Sobrien@tindex EXPR_STMT
147690075Sobrien@findex EXPR_STMT_EXPR
147790075Sobrien@tindex FOR_STMT
147890075Sobrien@findex FOR_INIT_STMT
147990075Sobrien@findex FOR_COND
148090075Sobrien@findex FOR_EXPR
148190075Sobrien@findex FOR_BODY
148290075Sobrien@tindex HANDLER
148390075Sobrien@tindex IF_STMT
148490075Sobrien@findex IF_COND
148590075Sobrien@findex THEN_CLAUSE
148690075Sobrien@findex ELSE_CLAUSE
148790075Sobrien@tindex RETURN_STMT
148890075Sobrien@findex RETURN_EXPR
148990075Sobrien@tindex SUBOBJECT
149090075Sobrien@findex SUBOBJECT_CLEANUP
149190075Sobrien@tindex SWITCH_STMT
149290075Sobrien@findex SWITCH_COND
149390075Sobrien@findex SWITCH_BODY
149490075Sobrien@tindex TRY_BLOCK
149590075Sobrien@findex TRY_STMTS
149690075Sobrien@findex TRY_HANDLERS
149790075Sobrien@findex HANDLER_PARMS
149890075Sobrien@findex HANDLER_BODY
149990075Sobrien@findex USING_STMT
150090075Sobrien@tindex WHILE_STMT
150190075Sobrien@findex WHILE_BODY
150290075Sobrien@findex WHILE_COND
150390075Sobrien
150490075SobrienA function that has a definition in the current translation unit will
150590075Sobrienhave a non-@code{NULL} @code{DECL_INITIAL}.  However, back ends should not make
150690075Sobrienuse of the particular value given by @code{DECL_INITIAL}.
150790075Sobrien
150890075SobrienThe @code{DECL_SAVED_TREE} macro will give the complete body of the
1509169689Skanfunction.
151090075Sobrien
151190075Sobrien@subsubsection Statements
151290075Sobrien
1513169689SkanThere are tree nodes corresponding to all of the source-level
1514169689Skanstatement constructs, used within the C and C++ frontends.  These are
1515169689Skanenumerated here, together with a list of the various macros that can
1516169689Skanbe used to obtain information about them.  There are a few macros that
1517169689Skancan be used with all statements:
151890075Sobrien
151990075Sobrien@ftable @code
152090075Sobrien@item STMT_IS_FULL_EXPR_P
152190075SobrienIn C++, statements normally constitute ``full expressions''; temporaries
152290075Sobriencreated during a statement are destroyed when the statement is complete.
152390075SobrienHowever, G++ sometimes represents expressions by statements; these
152490075Sobrienstatements will not have @code{STMT_IS_FULL_EXPR_P} set.  Temporaries
152590075Sobriencreated during such statements should be destroyed when the innermost
152690075Sobrienenclosing statement with @code{STMT_IS_FULL_EXPR_P} set is exited.
152790075Sobrien
152890075Sobrien@end ftable
152990075Sobrien
153090075SobrienHere is the list of the various statement nodes, and the macros used to
153190075Sobrienaccess them.  This documentation describes the use of these nodes in
153290075Sobriennon-template functions (including instantiations of template functions).
153390075SobrienIn template functions, the same nodes are used, but sometimes in
153490075Sobrienslightly different ways.
153590075Sobrien
153690075SobrienMany of the statements have substatements.  For example, a @code{while}
153790075Sobrienloop will have a body, which is itself a statement.  If the substatement
153890075Sobrienis @code{NULL_TREE}, it is considered equivalent to a statement
153990075Sobrienconsisting of a single @code{;}, i.e., an expression statement in which
154090075Sobrienthe expression has been omitted.  A substatement may in fact be a list
154190075Sobrienof statements, connected via their @code{TREE_CHAIN}s.  So, you should
154290075Sobrienalways process the statement tree by looping over substatements, like
154390075Sobrienthis:
1544132718Skan@smallexample
154590075Sobrienvoid process_stmt (stmt)
154690075Sobrien     tree stmt;
154790075Sobrien@{
154890075Sobrien  while (stmt)
154990075Sobrien    @{
155090075Sobrien      switch (TREE_CODE (stmt))
155190075Sobrien        @{
155290075Sobrien        case IF_STMT:
155390075Sobrien          process_stmt (THEN_CLAUSE (stmt));
1554169689Skan          /* @r{More processing here.}  */
155590075Sobrien          break;
155690075Sobrien
155790075Sobrien        @dots{}
155890075Sobrien        @}
155990075Sobrien
156090075Sobrien      stmt = TREE_CHAIN (stmt);
156190075Sobrien    @}
156290075Sobrien@}
1563132718Skan@end smallexample
156490075SobrienIn other words, while the @code{then} clause of an @code{if} statement
156590075Sobrienin C++ can be only one statement (although that one statement may be a
156690075Sobriencompound statement), the intermediate representation will sometimes use
156790075Sobrienseveral statements chained together.
156890075Sobrien
156990075Sobrien@table @code
1570169689Skan@item ASM_EXPR
157190075Sobrien
157290075SobrienUsed to represent an inline assembly statement.  For an inline assembly
157390075Sobrienstatement like:
1574132718Skan@smallexample
157590075Sobrienasm ("mov x, y");
1576132718Skan@end smallexample
157790075SobrienThe @code{ASM_STRING} macro will return a @code{STRING_CST} node for
157890075Sobrien@code{"mov x, y"}.  If the original statement made use of the
157990075Sobrienextended-assembly syntax, then @code{ASM_OUTPUTS},
158090075Sobrien@code{ASM_INPUTS}, and @code{ASM_CLOBBERS} will be the outputs, inputs,
158190075Sobrienand clobbers for the statement, represented as @code{STRING_CST} nodes.
158290075SobrienThe extended-assembly syntax looks like:
1583132718Skan@smallexample
158490075Sobrienasm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
1585132718Skan@end smallexample
158690075SobrienThe first string is the @code{ASM_STRING}, containing the instruction
158790075Sobrientemplate.  The next two strings are the output and inputs, respectively;
158890075Sobrienthis statement has no clobbers.  As this example indicates, ``plain''
158990075Sobrienassembly statements are merely a special case of extended assembly
159090075Sobrienstatements; they have no cv-qualifiers, outputs, inputs, or clobbers.
159190075SobrienAll of the strings will be @code{NUL}-terminated, and will contain no
159290075Sobrienembedded @code{NUL}-characters.
159390075Sobrien
159490075SobrienIf the assembly statement is declared @code{volatile}, or if the
159590075Sobrienstatement was not an extended assembly statement, and is therefore
159690075Sobrienimplicitly volatile, then the predicate @code{ASM_VOLATILE_P} will hold
1597169689Skanof the @code{ASM_EXPR}.
159890075Sobrien
159990075Sobrien@item BREAK_STMT
160090075Sobrien
160190075SobrienUsed to represent a @code{break} statement.  There are no additional
160290075Sobrienfields.
160390075Sobrien
1604169689Skan@item CASE_LABEL_EXPR
160590075Sobrien
160690075SobrienUse to represent a @code{case} label, range of @code{case} labels, or a
160790075Sobrien@code{default} label.  If @code{CASE_LOW} is @code{NULL_TREE}, then this is a
160890075Sobrien@code{default} label.  Otherwise, if @code{CASE_HIGH} is @code{NULL_TREE}, then
160990075Sobrienthis is an ordinary @code{case} label.  In this case, @code{CASE_LOW} is
161090075Sobrienan expression giving the value of the label.  Both @code{CASE_LOW} and
161190075Sobrien@code{CASE_HIGH} are @code{INTEGER_CST} nodes.  These values will have
161290075Sobrienthe same type as the condition expression in the switch statement.
161390075Sobrien
161490075SobrienOtherwise, if both @code{CASE_LOW} and @code{CASE_HIGH} are defined, the
161590075Sobrienstatement is a range of case labels.  Such statements originate with the
161690075Sobrienextension that allows users to write things of the form:
1617132718Skan@smallexample
161890075Sobriencase 2 ... 5:
1619132718Skan@end smallexample
162090075SobrienThe first value will be @code{CASE_LOW}, while the second will be
162190075Sobrien@code{CASE_HIGH}.
162290075Sobrien
162390075Sobrien@item CLEANUP_STMT
162490075Sobrien
162590075SobrienUsed to represent an action that should take place upon exit from the
162690075Sobrienenclosing scope.  Typically, these actions are calls to destructors for
162790075Sobrienlocal objects, but back ends cannot rely on this fact.  If these nodes
162890075Sobrienare in fact representing such destructors, @code{CLEANUP_DECL} will be
162990075Sobrienthe @code{VAR_DECL} destroyed.  Otherwise, @code{CLEANUP_DECL} will be
163090075Sobrien@code{NULL_TREE}.  In any case, the @code{CLEANUP_EXPR} is the
163190075Sobrienexpression to execute.  The cleanups executed on exit from a scope
163290075Sobrienshould be run in the reverse order of the order in which the associated
163390075Sobrien@code{CLEANUP_STMT}s were encountered.
163490075Sobrien
163590075Sobrien@item CONTINUE_STMT
163690075Sobrien
163790075SobrienUsed to represent a @code{continue} statement.  There are no additional
163890075Sobrienfields.
163990075Sobrien
164090075Sobrien@item CTOR_STMT
164190075Sobrien
164290075SobrienUsed to mark the beginning (if @code{CTOR_BEGIN_P} holds) or end (if
164390075Sobrien@code{CTOR_END_P} holds of the main body of a constructor.  See also
164490075Sobrien@code{SUBOBJECT} for more information on how to use these nodes.
164590075Sobrien
164690075Sobrien@item DECL_STMT
164790075Sobrien
164890075SobrienUsed to represent a local declaration.  The @code{DECL_STMT_DECL} macro
164990075Sobriencan be used to obtain the entity declared.  This declaration may be a
165090075Sobrien@code{LABEL_DECL}, indicating that the label declared is a local label.
165190075Sobrien(As an extension, GCC allows the declaration of labels with scope.)  In
165290075SobrienC, this declaration may be a @code{FUNCTION_DECL}, indicating the
165390075Sobrienuse of the GCC nested function extension.  For more information,
165490075Sobrien@pxref{Functions}.
165590075Sobrien
165690075Sobrien@item DO_STMT
165790075Sobrien
165890075SobrienUsed to represent a @code{do} loop.  The body of the loop is given by
165990075Sobrien@code{DO_BODY} while the termination condition for the loop is given by
166090075Sobrien@code{DO_COND}.  The condition for a @code{do}-statement is always an
166190075Sobrienexpression.
166290075Sobrien
166390075Sobrien@item EMPTY_CLASS_EXPR
166490075Sobrien
166590075SobrienUsed to represent a temporary object of a class with no data whose
166690075Sobrienaddress is never taken.  (All such objects are interchangeable.)  The
166790075Sobrien@code{TREE_TYPE} represents the type of the object.
166890075Sobrien
166990075Sobrien@item EXPR_STMT
167090075Sobrien
167190075SobrienUsed to represent an expression statement.  Use @code{EXPR_STMT_EXPR} to
167290075Sobrienobtain the expression.
167390075Sobrien
167490075Sobrien@item FOR_STMT
167590075Sobrien
167690075SobrienUsed to represent a @code{for} statement.  The @code{FOR_INIT_STMT} is
167790075Sobrienthe initialization statement for the loop.  The @code{FOR_COND} is the
167890075Sobrientermination condition.  The @code{FOR_EXPR} is the expression executed
167990075Sobrienright before the @code{FOR_COND} on each loop iteration; often, this
168090075Sobrienexpression increments a counter.  The body of the loop is given by
168190075Sobrien@code{FOR_BODY}.  Note that @code{FOR_INIT_STMT} and @code{FOR_BODY}
168290075Sobrienreturn statements, while @code{FOR_COND} and @code{FOR_EXPR} return
168390075Sobrienexpressions.
168490075Sobrien
1685169689Skan@item GOTO_EXPR
168690075Sobrien
168790075SobrienUsed to represent a @code{goto} statement.  The @code{GOTO_DESTINATION} will
168890075Sobrienusually be a @code{LABEL_DECL}.  However, if the ``computed goto'' extension
168990075Sobrienhas been used, the @code{GOTO_DESTINATION} will be an arbitrary expression
169090075Sobrienindicating the destination.  This expression will always have pointer type.
169190075Sobrien
169290075Sobrien@item HANDLER
169390075Sobrien
169490075SobrienUsed to represent a C++ @code{catch} block.  The @code{HANDLER_TYPE}
169590075Sobrienis the type of exception that will be caught by this handler; it is
1696132718Skanequal (by pointer equality) to @code{NULL} if this handler is for all
1697132718Skantypes.  @code{HANDLER_PARMS} is the @code{DECL_STMT} for the catch
1698169689Skanparameter, and @code{HANDLER_BODY} is the code for the block itself.
169990075Sobrien
170090075Sobrien@item IF_STMT
170190075Sobrien
170290075SobrienUsed to represent an @code{if} statement.  The @code{IF_COND} is the
170390075Sobrienexpression.
170490075Sobrien
170590075SobrienIf the condition is a @code{TREE_LIST}, then the @code{TREE_PURPOSE} is
170690075Sobriena statement (usually a @code{DECL_STMT}).  Each time the condition is
170790075Sobrienevaluated, the statement should be executed.  Then, the
170890075Sobrien@code{TREE_VALUE} should be used as the conditional expression itself.
170990075SobrienThis representation is used to handle C++ code like this:
171090075Sobrien
1711132718Skan@smallexample
171290075Sobrienif (int i = 7) @dots{}
1713132718Skan@end smallexample
171490075Sobrien
171590075Sobrienwhere there is a new local variable (or variables) declared within the
171690075Sobriencondition.
171790075Sobrien
171890075SobrienThe @code{THEN_CLAUSE} represents the statement given by the @code{then}
171990075Sobriencondition, while the @code{ELSE_CLAUSE} represents the statement given
172090075Sobrienby the @code{else} condition.
172190075Sobrien
1722169689Skan@item LABEL_EXPR
172390075Sobrien
172490075SobrienUsed to represent a label.  The @code{LABEL_DECL} declared by this
1725169689Skanstatement can be obtained with the @code{LABEL_EXPR_LABEL} macro.  The
172690075Sobrien@code{IDENTIFIER_NODE} giving the name of the label can be obtained from
172790075Sobrienthe @code{LABEL_DECL} with @code{DECL_NAME}.
172890075Sobrien
172990075Sobrien@item RETURN_STMT
173090075Sobrien
173190075SobrienUsed to represent a @code{return} statement.  The @code{RETURN_EXPR} is
173290075Sobrienthe expression returned; it will be @code{NULL_TREE} if the statement
173390075Sobrienwas just
1734132718Skan@smallexample
173590075Sobrienreturn;
1736132718Skan@end smallexample
173790075Sobrien
173890075Sobrien@item SUBOBJECT
173990075Sobrien
174090075SobrienIn a constructor, these nodes are used to mark the point at which a
174190075Sobriensubobject of @code{this} is fully constructed.  If, after this point, an
174290075Sobrienexception is thrown before a @code{CTOR_STMT} with @code{CTOR_END_P} set
174390075Sobrienis encountered, the @code{SUBOBJECT_CLEANUP} must be executed.  The
174490075Sobriencleanups must be executed in the reverse order in which they appear.
174590075Sobrien
174690075Sobrien@item SWITCH_STMT
174790075Sobrien
1748169689SkanUsed to represent a @code{switch} statement.  The @code{SWITCH_STMT_COND}
1749169689Skanis the expression on which the switch is occurring.  See the documentation
175090075Sobrienfor an @code{IF_STMT} for more information on the representation used
1751169689Skanfor the condition.  The @code{SWITCH_STMT_BODY} is the body of the switch
1752169689Skanstatement.   The @code{SWITCH_STMT_TYPE} is the original type of switch
175396263Sobrienexpression as given in the source, before any compiler conversions.
175490075Sobrien
175590075Sobrien@item TRY_BLOCK
175690075SobrienUsed to represent a @code{try} block.  The body of the try block is
175790075Sobriengiven by @code{TRY_STMTS}.  Each of the catch blocks is a @code{HANDLER}
175890075Sobriennode.  The first handler is given by @code{TRY_HANDLERS}.  Subsequent
175990075Sobrienhandlers are obtained by following the @code{TREE_CHAIN} link from one
176090075Sobrienhandler to the next.  The body of the handler is given by
176190075Sobrien@code{HANDLER_BODY}.
176290075Sobrien
176390075SobrienIf @code{CLEANUP_P} holds of the @code{TRY_BLOCK}, then the
176490075Sobrien@code{TRY_HANDLERS} will not be a @code{HANDLER} node.  Instead, it will
176590075Sobrienbe an expression that should be executed if an exception is thrown in
176690075Sobrienthe try block.  It must rethrow the exception after executing that code.
176790075SobrienAnd, if an exception is thrown while the expression is executing,
176890075Sobrien@code{terminate} must be called.
176990075Sobrien
177090075Sobrien@item USING_STMT
177190075SobrienUsed to represent a @code{using} directive.  The namespace is given by
177290075Sobrien@code{USING_STMT_NAMESPACE}, which will be a NAMESPACE_DECL@.  This node
177390075Sobrienis needed inside template functions, to implement using directives
177490075Sobrienduring instantiation.
177590075Sobrien
177690075Sobrien@item WHILE_STMT
177790075Sobrien
177890075SobrienUsed to represent a @code{while} loop.  The @code{WHILE_COND} is the
177990075Sobrientermination condition for the loop.  See the documentation for an
178090075Sobrien@code{IF_STMT} for more information on the representation used for the
178190075Sobriencondition.
178290075Sobrien
178390075SobrienThe @code{WHILE_BODY} is the body of the loop.
178490075Sobrien
178590075Sobrien@end table
178690075Sobrien
178790075Sobrien@c ---------------------------------------------------------------------
178890075Sobrien@c Attributes
178990075Sobrien@c ---------------------------------------------------------------------
179090075Sobrien@node Attributes
179190075Sobrien@section Attributes in trees
179290075Sobrien@cindex attributes
179390075Sobrien
179490075SobrienAttributes, as specified using the @code{__attribute__} keyword, are
179590075Sobrienrepresented internally as a @code{TREE_LIST}.  The @code{TREE_PURPOSE}
179690075Sobrienis the name of the attribute, as an @code{IDENTIFIER_NODE}.  The
179790075Sobrien@code{TREE_VALUE} is a @code{TREE_LIST} of the arguments of the
179890075Sobrienattribute, if any, or @code{NULL_TREE} if there are no arguments; the
179990075Sobrienarguments are stored as the @code{TREE_VALUE} of successive entries in
180090075Sobrienthe list, and may be identifiers or expressions.  The @code{TREE_CHAIN}
180190075Sobrienof the attribute is the next attribute in a list of attributes applying
180290075Sobriento the same declaration or type, or @code{NULL_TREE} if there are no
180390075Sobrienfurther attributes in the list.
180490075Sobrien
180590075SobrienAttributes may be attached to declarations and to types; these
180690075Sobrienattributes may be accessed with the following macros.  All attributes
180790075Sobrienare stored in this way, and many also cause other changes to the
180890075Sobriendeclaration or type or to other internal compiler data structures.
180990075Sobrien
181090075Sobrien@deftypefn {Tree Macro} tree DECL_ATTRIBUTES (tree @var{decl})
181190075SobrienThis macro returns the attributes on the declaration @var{decl}.
181290075Sobrien@end deftypefn
181390075Sobrien
181490075Sobrien@deftypefn {Tree Macro} tree TYPE_ATTRIBUTES (tree @var{type})
181590075SobrienThis macro returns the attributes on the type @var{type}.
181690075Sobrien@end deftypefn
181790075Sobrien
181890075Sobrien@c ---------------------------------------------------------------------
181990075Sobrien@c Expressions
182090075Sobrien@c ---------------------------------------------------------------------
182190075Sobrien
182290075Sobrien@node Expression trees
182390075Sobrien@section Expressions
182490075Sobrien@cindex expression
1825169689Skan@findex TREE_TYPE
182690075Sobrien@findex TREE_OPERAND
182790075Sobrien@tindex INTEGER_CST
182890075Sobrien@findex TREE_INT_CST_HIGH
182990075Sobrien@findex TREE_INT_CST_LOW
183090075Sobrien@findex tree_int_cst_lt
183190075Sobrien@findex tree_int_cst_equal
183290075Sobrien@tindex REAL_CST
183390075Sobrien@tindex COMPLEX_CST
183496263Sobrien@tindex VECTOR_CST
183590075Sobrien@tindex STRING_CST
183690075Sobrien@findex TREE_STRING_LENGTH
183790075Sobrien@findex TREE_STRING_POINTER
183890075Sobrien@tindex PTRMEM_CST
183990075Sobrien@findex PTRMEM_CST_CLASS
184090075Sobrien@findex PTRMEM_CST_MEMBER
184190075Sobrien@tindex VAR_DECL
184290075Sobrien@tindex NEGATE_EXPR
1843132718Skan@tindex ABS_EXPR
184490075Sobrien@tindex BIT_NOT_EXPR
184590075Sobrien@tindex TRUTH_NOT_EXPR
1846169689Skan@tindex PREDECREMENT_EXPR
1847169689Skan@tindex PREINCREMENT_EXPR
1848169689Skan@tindex POSTDECREMENT_EXPR
1849169689Skan@tindex POSTINCREMENT_EXPR
185090075Sobrien@tindex ADDR_EXPR
185190075Sobrien@tindex INDIRECT_REF
185290075Sobrien@tindex FIX_TRUNC_EXPR
185390075Sobrien@tindex FLOAT_EXPR
185490075Sobrien@tindex COMPLEX_EXPR
185590075Sobrien@tindex CONJ_EXPR
185690075Sobrien@tindex REALPART_EXPR
185790075Sobrien@tindex IMAGPART_EXPR
1858169689Skan@tindex NON_LVALUE_EXPR
185990075Sobrien@tindex NOP_EXPR
186090075Sobrien@tindex CONVERT_EXPR
186190075Sobrien@tindex THROW_EXPR
186290075Sobrien@tindex LSHIFT_EXPR
186390075Sobrien@tindex RSHIFT_EXPR
186490075Sobrien@tindex BIT_IOR_EXPR
186590075Sobrien@tindex BIT_XOR_EXPR
186690075Sobrien@tindex BIT_AND_EXPR
186790075Sobrien@tindex TRUTH_ANDIF_EXPR
186890075Sobrien@tindex TRUTH_ORIF_EXPR
186990075Sobrien@tindex TRUTH_AND_EXPR
187090075Sobrien@tindex TRUTH_OR_EXPR
187190075Sobrien@tindex TRUTH_XOR_EXPR
187290075Sobrien@tindex PLUS_EXPR
187390075Sobrien@tindex MINUS_EXPR
187490075Sobrien@tindex MULT_EXPR
1875169689Skan@tindex RDIV_EXPR
187690075Sobrien@tindex TRUNC_DIV_EXPR
1877169689Skan@tindex FLOOR_DIV_EXPR
1878169689Skan@tindex CEIL_DIV_EXPR
1879169689Skan@tindex ROUND_DIV_EXPR
188090075Sobrien@tindex TRUNC_MOD_EXPR
1881169689Skan@tindex FLOOR_MOD_EXPR
1882169689Skan@tindex CEIL_MOD_EXPR
1883169689Skan@tindex ROUND_MOD_EXPR
1884169689Skan@tindex EXACT_DIV_EXPR
1885169689Skan@tindex ARRAY_REF
1886169689Skan@tindex ARRAY_RANGE_REF
1887169689Skan@tindex TARGET_MEM_REF
188890075Sobrien@tindex LT_EXPR
188990075Sobrien@tindex LE_EXPR
189090075Sobrien@tindex GT_EXPR
189190075Sobrien@tindex GE_EXPR
189290075Sobrien@tindex EQ_EXPR
189390075Sobrien@tindex NE_EXPR
1894169689Skan@tindex ORDERED_EXPR
1895169689Skan@tindex UNORDERED_EXPR
1896169689Skan@tindex UNLT_EXPR
1897169689Skan@tindex UNLE_EXPR
1898169689Skan@tindex UNGT_EXPR
1899169689Skan@tindex UNGE_EXPR
1900169689Skan@tindex UNEQ_EXPR
1901169689Skan@tindex LTGT_EXPR
1902169689Skan@tindex MODIFY_EXPR
190390075Sobrien@tindex INIT_EXPR
190490075Sobrien@tindex COMPONENT_REF
190590075Sobrien@tindex COMPOUND_EXPR
190690075Sobrien@tindex COND_EXPR
190790075Sobrien@tindex CALL_EXPR
190890075Sobrien@tindex STMT_EXPR
190990075Sobrien@tindex BIND_EXPR
191090075Sobrien@tindex LOOP_EXPR
191190075Sobrien@tindex EXIT_EXPR
191290075Sobrien@tindex CLEANUP_POINT_EXPR
1913169689Skan@tindex CONSTRUCTOR
1914169689Skan@tindex COMPOUND_LITERAL_EXPR
1915169689Skan@tindex SAVE_EXPR
1916169689Skan@tindex TARGET_EXPR
1917169689Skan@tindex AGGR_INIT_EXPR
1918117395Skan@tindex VA_ARG_EXPR
1919169689Skan@tindex OMP_PARALLEL
1920169689Skan@tindex OMP_FOR
1921169689Skan@tindex OMP_SECTIONS
1922169689Skan@tindex OMP_SINGLE
1923169689Skan@tindex OMP_SECTION
1924169689Skan@tindex OMP_MASTER
1925169689Skan@tindex OMP_ORDERED
1926169689Skan@tindex OMP_CRITICAL
1927169689Skan@tindex OMP_RETURN
1928169689Skan@tindex OMP_CONTINUE
1929169689Skan@tindex OMP_ATOMIC
1930169689Skan@tindex OMP_CLAUSE
193190075Sobrien
193290075SobrienThe internal representation for expressions is for the most part quite
193390075Sobrienstraightforward.  However, there are a few facts that one must bear in
193490075Sobrienmind.  In particular, the expression ``tree'' is actually a directed
193590075Sobrienacyclic graph.  (For example there may be many references to the integer
193690075Sobrienconstant zero throughout the source program; many of these will be
193790075Sobrienrepresented by the same expression node.)  You should not rely on
193890075Sobriencertain kinds of node being shared, nor should rely on certain kinds of
193990075Sobriennodes being unshared.
194090075Sobrien
194190075SobrienThe following macros can be used with all expression nodes:
194290075Sobrien
194390075Sobrien@ftable @code
194490075Sobrien@item TREE_TYPE
194590075SobrienReturns the type of the expression.  This value may not be precisely the
194690075Sobriensame type that would be given the expression in the original program.
194790075Sobrien@end ftable
194890075Sobrien
194990075SobrienIn what follows, some nodes that one might expect to always have type
195090075Sobrien@code{bool} are documented to have either integral or boolean type.  At
195190075Sobriensome point in the future, the C front end may also make use of this same
195290075Sobrienintermediate representation, and at this point these nodes will
195390075Sobriencertainly have integral type.  The previous sentence is not meant to
195490075Sobrienimply that the C++ front end does not or will not give these nodes
195590075Sobrienintegral type.
195690075Sobrien
195790075SobrienBelow, we list the various kinds of expression nodes.  Except where
195890075Sobriennoted otherwise, the operands to an expression are accessed using the
195990075Sobrien@code{TREE_OPERAND} macro.  For example, to access the first operand to
196090075Sobriena binary plus expression @code{expr}, use:
196190075Sobrien
1962132718Skan@smallexample
196390075SobrienTREE_OPERAND (expr, 0)
1964132718Skan@end smallexample
196590075Sobrien@noindent
196690075SobrienAs this example indicates, the operands are zero-indexed.
196790075Sobrien
1968169689SkanAll the expressions starting with @code{OMP_} represent directives and
1969169689Skanclauses used by the OpenMP API @w{@uref{http://www.openmp.org/}}.
1970169689Skan
197190075SobrienThe table below begins with constants, moves on to unary expressions,
197290075Sobrienthen proceeds to binary expressions, and concludes with various other
197390075Sobrienkinds of expressions:
197490075Sobrien
197590075Sobrien@table @code
197690075Sobrien@item INTEGER_CST
197790075SobrienThese nodes represent integer constants.  Note that the type of these
197890075Sobrienconstants is obtained with @code{TREE_TYPE}; they are not always of type
197990075Sobrien@code{int}.  In particular, @code{char} constants are represented with
198090075Sobrien@code{INTEGER_CST} nodes.  The value of the integer constant @code{e} is
1981132718Skangiven by
1982132718Skan@smallexample
198390075Sobrien((TREE_INT_CST_HIGH (e) << HOST_BITS_PER_WIDE_INT)
198490075Sobrien+ TREE_INST_CST_LOW (e))
1985132718Skan@end smallexample
198690075Sobrien@noindent
198790075SobrienHOST_BITS_PER_WIDE_INT is at least thirty-two on all platforms.  Both
198890075Sobrien@code{TREE_INT_CST_HIGH} and @code{TREE_INT_CST_LOW} return a
198990075Sobrien@code{HOST_WIDE_INT}.  The value of an @code{INTEGER_CST} is interpreted
199090075Sobrienas a signed or unsigned quantity depending on the type of the constant.
199190075SobrienIn general, the expression given above will overflow, so it should not
199290075Sobrienbe used to calculate the value of the constant.
199390075Sobrien
199490075SobrienThe variable @code{integer_zero_node} is an integer constant with value
199590075Sobrienzero.  Similarly, @code{integer_one_node} is an integer constant with
199690075Sobrienvalue one.  The @code{size_zero_node} and @code{size_one_node} variables
199790075Sobrienare analogous, but have type @code{size_t} rather than @code{int}.
199890075Sobrien
199990075SobrienThe function @code{tree_int_cst_lt} is a predicate which holds if its
200090075Sobrienfirst argument is less than its second.  Both constants are assumed to
200190075Sobrienhave the same signedness (i.e., either both should be signed or both
200290075Sobrienshould be unsigned.)  The full width of the constant is used when doing
200390075Sobrienthe comparison; the usual rules about promotions and conversions are
200490075Sobrienignored.  Similarly, @code{tree_int_cst_equal} holds if the two
200590075Sobrienconstants are equal.  The @code{tree_int_cst_sgn} function returns the
200690075Sobriensign of a constant.  The value is @code{1}, @code{0}, or @code{-1}
200790075Sobrienaccording on whether the constant is greater than, equal to, or less
200890075Sobrienthan zero.  Again, the signedness of the constant's type is taken into
200990075Sobrienaccount; an unsigned constant is never less than zero, no matter what
201090075Sobrienits bit-pattern.
201190075Sobrien
201290075Sobrien@item REAL_CST
201390075Sobrien
201490075SobrienFIXME: Talk about how to obtain representations of this constant, do
201590075Sobriencomparisons, and so forth.
201690075Sobrien
201790075Sobrien@item COMPLEX_CST
201890075SobrienThese nodes are used to represent complex number constants, that is a
201990075Sobrien@code{__complex__} whose parts are constant nodes.  The
202090075Sobrien@code{TREE_REALPART} and @code{TREE_IMAGPART} return the real and the
202190075Sobrienimaginary parts respectively.
202290075Sobrien
202396263Sobrien@item VECTOR_CST
202496263SobrienThese nodes are used to represent vector constants, whose parts are
202596263Sobrienconstant nodes.  Each individual constant node is either an integer or a
202696263Sobriendouble constant node.  The first operand is a @code{TREE_LIST} of the
202796263Sobrienconstant nodes and is accessed through @code{TREE_VECTOR_CST_ELTS}.
202896263Sobrien
202990075Sobrien@item STRING_CST
203090075SobrienThese nodes represent string-constants.  The @code{TREE_STRING_LENGTH}
203190075Sobrienreturns the length of the string, as an @code{int}.  The
203290075Sobrien@code{TREE_STRING_POINTER} is a @code{char*} containing the string
203390075Sobrienitself.  The string may not be @code{NUL}-terminated, and it may contain
203490075Sobrienembedded @code{NUL} characters.  Therefore, the
203590075Sobrien@code{TREE_STRING_LENGTH} includes the trailing @code{NUL} if it is
203690075Sobrienpresent.
203790075Sobrien
203890075SobrienFor wide string constants, the @code{TREE_STRING_LENGTH} is the number
203990075Sobrienof bytes in the string, and the @code{TREE_STRING_POINTER}
204090075Sobrienpoints to an array of the bytes of the string, as represented on the
204190075Sobrientarget system (that is, as integers in the target endianness).  Wide and
204290075Sobriennon-wide string constants are distinguished only by the @code{TREE_TYPE}
204390075Sobrienof the @code{STRING_CST}.
204490075Sobrien
204590075SobrienFIXME: The formats of string constants are not well-defined when the
204690075Sobrientarget system bytes are not the same width as host system bytes.
204790075Sobrien
204890075Sobrien@item PTRMEM_CST
204990075SobrienThese nodes are used to represent pointer-to-member constants.  The
205090075Sobrien@code{PTRMEM_CST_CLASS} is the class type (either a @code{RECORD_TYPE}
205190075Sobrienor @code{UNION_TYPE} within which the pointer points), and the
205290075Sobrien@code{PTRMEM_CST_MEMBER} is the declaration for the pointed to object.
205390075SobrienNote that the @code{DECL_CONTEXT} for the @code{PTRMEM_CST_MEMBER} is in
205490075Sobriengeneral different from the @code{PTRMEM_CST_CLASS}.  For example,
205590075Sobriengiven:
2056132718Skan@smallexample
205790075Sobrienstruct B @{ int i; @};
205890075Sobrienstruct D : public B @{@};
205990075Sobrienint D::*dp = &D::i;
2060132718Skan@end smallexample
206190075Sobrien@noindent
206290075SobrienThe @code{PTRMEM_CST_CLASS} for @code{&D::i} is @code{D}, even though
206390075Sobrienthe @code{DECL_CONTEXT} for the @code{PTRMEM_CST_MEMBER} is @code{B},
206490075Sobriensince @code{B::i} is a member of @code{B}, not @code{D}.
206590075Sobrien
206690075Sobrien@item VAR_DECL
206790075Sobrien
206890075SobrienThese nodes represent variables, including static data members.  For
206990075Sobrienmore information, @pxref{Declarations}.
207090075Sobrien
207190075Sobrien@item NEGATE_EXPR
207290075SobrienThese nodes represent unary negation of the single operand, for both
207390075Sobrieninteger and floating-point types.  The type of negation can be
207490075Sobriendetermined by looking at the type of the expression.
207590075Sobrien
2076132718SkanThe behavior of this operation on signed arithmetic overflow is
2077132718Skancontrolled by the @code{flag_wrapv} and @code{flag_trapv} variables.
2078132718Skan
2079132718Skan@item ABS_EXPR
2080132718SkanThese nodes represent the absolute value of the single operand, for
2081132718Skanboth integer and floating-point types.  This is typically used to
2082132718Skanimplement the @code{abs}, @code{labs} and @code{llabs} builtins for
2083132718Skaninteger types, and the @code{fabs}, @code{fabsf} and @code{fabsl}
2084132718Skanbuiltins for floating point types.  The type of abs operation can
2085132718Skanbe determined by looking at the type of the expression.
2086132718Skan
2087132718SkanThis node is not used for complex types.  To represent the modulus
2088132718Skanor complex abs of a complex value, use the @code{BUILT_IN_CABS},
2089132718Skan@code{BUILT_IN_CABSF} or @code{BUILT_IN_CABSL} builtins, as used
2090132718Skanto implement the C99 @code{cabs}, @code{cabsf} and @code{cabsl}
2091132718Skanbuilt-in functions.
2092132718Skan
209390075Sobrien@item BIT_NOT_EXPR
209490075SobrienThese nodes represent bitwise complement, and will always have integral
209590075Sobrientype.  The only operand is the value to be complemented.
209690075Sobrien
209790075Sobrien@item TRUTH_NOT_EXPR
209890075SobrienThese nodes represent logical negation, and will always have integral
2099169689Skan(or boolean) type.  The operand is the value being negated.  The type
2100169689Skanof the operand and that of the result are always of @code{BOOLEAN_TYPE}
2101169689Skanor @code{INTEGER_TYPE}.
210290075Sobrien
210390075Sobrien@item PREDECREMENT_EXPR
210490075Sobrien@itemx PREINCREMENT_EXPR
210590075Sobrien@itemx POSTDECREMENT_EXPR
210690075Sobrien@itemx POSTINCREMENT_EXPR
210790075SobrienThese nodes represent increment and decrement expressions.  The value of
210890075Sobrienthe single operand is computed, and the operand incremented or
210990075Sobriendecremented.  In the case of @code{PREDECREMENT_EXPR} and
211090075Sobrien@code{PREINCREMENT_EXPR}, the value of the expression is the value
211190075Sobrienresulting after the increment or decrement; in the case of
211290075Sobrien@code{POSTDECREMENT_EXPR} and @code{POSTINCREMENT_EXPR} is the value
211390075Sobrienbefore the increment or decrement occurs.  The type of the operand, like
211490075Sobrienthat of the result, will be either integral, boolean, or floating-point.
211590075Sobrien
211690075Sobrien@item ADDR_EXPR
211790075SobrienThese nodes are used to represent the address of an object.  (These
211890075Sobrienexpressions will always have pointer or reference type.)  The operand may
211990075Sobrienbe another expression, or it may be a declaration.
212090075Sobrien
212190075SobrienAs an extension, GCC allows users to take the address of a label.  In
212290075Sobrienthis case, the operand of the @code{ADDR_EXPR} will be a
212390075Sobrien@code{LABEL_DECL}.  The type of such an expression is @code{void*}.
212490075Sobrien
212590075SobrienIf the object addressed is not an lvalue, a temporary is created, and
212690075Sobrienthe address of the temporary is used.
212790075Sobrien
212890075Sobrien@item INDIRECT_REF
212990075SobrienThese nodes are used to represent the object pointed to by a pointer.
213090075SobrienThe operand is the pointer being dereferenced; it will always have
213190075Sobrienpointer or reference type.
213290075Sobrien
213390075Sobrien@item FIX_TRUNC_EXPR
213490075SobrienThese nodes represent conversion of a floating-point value to an
2135169689Skaninteger.  The single operand will have a floating-point type, while
213690075Sobrienthe complete expression will have an integral (or boolean) type.  The
213790075Sobrienoperand is rounded towards zero.
213890075Sobrien
213990075Sobrien@item FLOAT_EXPR
214090075SobrienThese nodes represent conversion of an integral (or boolean) value to a
214190075Sobrienfloating-point value.  The single operand will have integral type, while
214290075Sobrienthe complete expression will have a floating-point type.
214390075Sobrien
214490075SobrienFIXME: How is the operand supposed to be rounded?  Is this dependent on
214590075Sobrien@option{-mieee}?
214690075Sobrien
214790075Sobrien@item COMPLEX_EXPR
214890075SobrienThese nodes are used to represent complex numbers constructed from two
214990075Sobrienexpressions of the same (integer or real) type.  The first operand is the
215090075Sobrienreal part and the second operand is the imaginary part.
215190075Sobrien
215290075Sobrien@item CONJ_EXPR
215390075SobrienThese nodes represent the conjugate of their operand.
215490075Sobrien
215590075Sobrien@item REALPART_EXPR
2156132718Skan@itemx IMAGPART_EXPR
215790075SobrienThese nodes represent respectively the real and the imaginary parts
215890075Sobrienof complex numbers (their sole argument).
215990075Sobrien
216090075Sobrien@item NON_LVALUE_EXPR
216190075SobrienThese nodes indicate that their one and only operand is not an lvalue.
216290075SobrienA back end can treat these identically to the single operand.
216390075Sobrien
216490075Sobrien@item NOP_EXPR
216590075SobrienThese nodes are used to represent conversions that do not require any
216690075Sobriencode-generation.  For example, conversion of a @code{char*} to an
216790075Sobrien@code{int*} does not require any code be generated; such a conversion is
216890075Sobrienrepresented by a @code{NOP_EXPR}.  The single operand is the expression
216990075Sobriento be converted.  The conversion from a pointer to a reference is also
217090075Sobrienrepresented with a @code{NOP_EXPR}.
217190075Sobrien
217290075Sobrien@item CONVERT_EXPR
217390075SobrienThese nodes are similar to @code{NOP_EXPR}s, but are used in those
217490075Sobriensituations where code may need to be generated.  For example, if an
217590075Sobrien@code{int*} is converted to an @code{int} code may need to be generated
217690075Sobrienon some platforms.  These nodes are never used for C++-specific
217790075Sobrienconversions, like conversions between pointers to different classes in
217890075Sobrienan inheritance hierarchy.  Any adjustments that need to be made in such
217990075Sobriencases are always indicated explicitly.  Similarly, a user-defined
218090075Sobrienconversion is never represented by a @code{CONVERT_EXPR}; instead, the
218190075Sobrienfunction calls are made explicit.
218290075Sobrien
218390075Sobrien@item THROW_EXPR
218490075SobrienThese nodes represent @code{throw} expressions.  The single operand is
218590075Sobrienan expression for the code that should be executed to throw the
218690075Sobrienexception.  However, there is one implicit action not represented in
218790075Sobrienthat expression; namely the call to @code{__throw}.  This function takes
218890075Sobrienno arguments.  If @code{setjmp}/@code{longjmp} exceptions are used, the
218990075Sobrienfunction @code{__sjthrow} is called instead.  The normal GCC back end
219090075Sobrienuses the function @code{emit_throw} to generate this code; you can
219190075Sobrienexamine this function to see what needs to be done.
219290075Sobrien
219390075Sobrien@item LSHIFT_EXPR
219490075Sobrien@itemx RSHIFT_EXPR
219590075SobrienThese nodes represent left and right shifts, respectively.  The first
219690075Sobrienoperand is the value to shift; it will always be of integral type.  The
219790075Sobriensecond operand is an expression for the number of bits by which to
219890075Sobrienshift.  Right shift should be treated as arithmetic, i.e., the
219990075Sobrienhigh-order bits should be zero-filled when the expression has unsigned
220090075Sobrientype and filled with the sign bit when the expression has signed type.
220190075SobrienNote that the result is undefined if the second operand is larger
2202169689Skanthan or equal to the first operand's type size.
220390075Sobrien
220490075Sobrien
220590075Sobrien@item BIT_IOR_EXPR
220690075Sobrien@itemx BIT_XOR_EXPR
220790075Sobrien@itemx BIT_AND_EXPR
220890075SobrienThese nodes represent bitwise inclusive or, bitwise exclusive or, and
220990075Sobrienbitwise and, respectively.  Both operands will always have integral
221090075Sobrientype.
221190075Sobrien
221290075Sobrien@item TRUTH_ANDIF_EXPR
221390075Sobrien@itemx TRUTH_ORIF_EXPR
221490075SobrienThese nodes represent logical and and logical or, respectively.  These
221590075Sobrienoperators are not strict; i.e., the second operand is evaluated only if
221690075Sobrienthe value of the expression is not determined by evaluation of the first
2217169689Skanoperand.  The type of the operands and that of the result are always of
2218169689Skan@code{BOOLEAN_TYPE} or @code{INTEGER_TYPE}.
221990075Sobrien
222090075Sobrien@item TRUTH_AND_EXPR
222190075Sobrien@itemx TRUTH_OR_EXPR
222290075Sobrien@itemx TRUTH_XOR_EXPR
222390075SobrienThese nodes represent logical and, logical or, and logical exclusive or.
222490075SobrienThey are strict; both arguments are always evaluated.  There are no
222590075Sobriencorresponding operators in C or C++, but the front end will sometimes
222690075Sobriengenerate these expressions anyhow, if it can tell that strictness does
2227169689Skannot matter.  The type of the operands and that of the result are
2228169689Skanalways of @code{BOOLEAN_TYPE} or @code{INTEGER_TYPE}.
222990075Sobrien
223090075Sobrien@itemx PLUS_EXPR
223190075Sobrien@itemx MINUS_EXPR
223290075Sobrien@itemx MULT_EXPR
223390075SobrienThese nodes represent various binary arithmetic operations.
223490075SobrienRespectively, these operations are addition, subtraction (of the second
2235169689Skanoperand from the first) and multiplication.  Their operands may have
2236169689Skaneither integral or floating type, but there will never be case in which
2237169689Skanone operand is of floating type and the other is of integral type.
223890075Sobrien
2239132718SkanThe behavior of these operations on signed arithmetic overflow is
2240132718Skancontrolled by the @code{flag_wrapv} and @code{flag_trapv} variables.
2241132718Skan
2242169689Skan@item RDIV_EXPR
2243169689SkanThis node represents a floating point division operation.
2244169689Skan
2245169689Skan@item TRUNC_DIV_EXPR
2246169689Skan@itemx FLOOR_DIV_EXPR
2247169689Skan@itemx CEIL_DIV_EXPR
2248169689Skan@itemx ROUND_DIV_EXPR
2249169689SkanThese nodes represent integer division operations that return an integer
2250169689Skanresult.  @code{TRUNC_DIV_EXPR} rounds towards zero, @code{FLOOR_DIV_EXPR}
2251169689Skanrounds towards negative infinity, @code{CEIL_DIV_EXPR} rounds towards
2252169689Skanpositive infinity and @code{ROUND_DIV_EXPR} rounds to the closest integer.
2253169689SkanInteger division in C and C++ is truncating, i.e.@: @code{TRUNC_DIV_EXPR}.
2254169689Skan
2255169689SkanThe behavior of these operations on signed arithmetic overflow, when
2256169689Skandividing the minimum signed integer by minus one, is controlled by the
2257169689Skan@code{flag_wrapv} and @code{flag_trapv} variables.
2258169689Skan
2259169689Skan@item TRUNC_MOD_EXPR
2260169689Skan@itemx FLOOR_MOD_EXPR
2261169689Skan@itemx CEIL_MOD_EXPR
2262169689Skan@itemx ROUND_MOD_EXPR
2263169689SkanThese nodes represent the integer remainder or modulus operation.
2264169689SkanThe integer modulus of two operands @code{a} and @code{b} is
2265169689Skandefined as @code{a - (a/b)*b} where the division calculated using
2266169689Skanthe corresponding division operator.  Hence for @code{TRUNC_MOD_EXPR}
2267169689Skanthis definition assumes division using truncation towards zero, i.e.@:
2268169689Skan@code{TRUNC_DIV_EXPR}.  Integer remainder in C and C++ uses truncating
2269169689Skandivision, i.e.@: @code{TRUNC_MOD_EXPR}.
2270169689Skan
2271169689Skan@item EXACT_DIV_EXPR
2272169689SkanThe @code{EXACT_DIV_EXPR} code is used to represent integer divisions where
2273169689Skanthe numerator is known to be an exact multiple of the denominator.  This
2274169689Skanallows the backend to choose between the faster of @code{TRUNC_DIV_EXPR},
2275169689Skan@code{CEIL_DIV_EXPR} and @code{FLOOR_DIV_EXPR} for the current target.
2276169689Skan
227790075Sobrien@item ARRAY_REF
227890075SobrienThese nodes represent array accesses.  The first operand is the array;
227990075Sobrienthe second is the index.  To calculate the address of the memory
228090075Sobrienaccessed, you must scale the index by the size of the type of the array
228190075Sobrienelements.  The type of these expressions must be the type of a component of
2282169689Skanthe array.  The third and fourth operands are used after gimplification
2283169689Skanto represent the lower bound and component size but should not be used
2284169689Skandirectly; call @code{array_ref_low_bound} and @code{array_ref_element_size}
2285169689Skaninstead.
228690075Sobrien
228790075Sobrien@item ARRAY_RANGE_REF
228890075SobrienThese nodes represent access to a range (or ``slice'') of an array.  The
228990075Sobrienoperands are the same as that for @code{ARRAY_REF} and have the same
229090075Sobrienmeanings.  The type of these expressions must be an array whose component
229190075Sobrientype is the same as that of the first operand.  The range of that array
229290075Sobrientype determines the amount of data these expressions access.
229390075Sobrien
2294169689Skan@item TARGET_MEM_REF
2295169689SkanThese nodes represent memory accesses whose address directly map to
2296169689Skanan addressing mode of the target architecture.  The first argument
2297169689Skanis @code{TMR_SYMBOL} and must be a @code{VAR_DECL} of an object with
2298169689Skana fixed address.  The second argument is @code{TMR_BASE} and the
2299169689Skanthird one is @code{TMR_INDEX}.  The fourth argument is
2300169689Skan@code{TMR_STEP} and must be an @code{INTEGER_CST}.  The fifth
2301169689Skanargument is @code{TMR_OFFSET} and must be an @code{INTEGER_CST}.
2302169689SkanAny of the arguments may be NULL if the appropriate component
2303169689Skandoes not appear in the address.  Address of the @code{TARGET_MEM_REF}
2304169689Skanis determined in the following way.
230590075Sobrien
2306169689Skan@smallexample
2307169689Skan&TMR_SYMBOL + TMR_BASE + TMR_INDEX * TMR_STEP + TMR_OFFSET
2308169689Skan@end smallexample
2309169689Skan
2310169689SkanThe sixth argument is the reference to the original memory access, which
2311169689Skanis preserved for the purposes of the RTL alias analysis.  The seventh
2312169689Skanargument is a tag representing the results of tree level alias analysis.
2313169689Skan
231490075Sobrien@item LT_EXPR
231590075Sobrien@itemx LE_EXPR
231690075Sobrien@itemx GT_EXPR
231790075Sobrien@itemx GE_EXPR
231890075Sobrien@itemx EQ_EXPR
231990075Sobrien@itemx NE_EXPR
232090075SobrienThese nodes represent the less than, less than or equal to, greater
232190075Sobrienthan, greater than or equal to, equal, and not equal comparison
232290075Sobrienoperators.  The first and second operand with either be both of integral
232390075Sobrientype or both of floating type.  The result type of these expressions
2324169689Skanwill always be of integral or boolean type.  These operations return
2325169689Skanthe result type's zero value for false, and the result type's one value
2326169689Skanfor true.
232790075Sobrien
2328169689SkanFor floating point comparisons, if we honor IEEE NaNs and either operand
2329169689Skanis NaN, then @code{NE_EXPR} always returns true and the remaining operators
2330169689Skanalways return false.  On some targets, comparisons against an IEEE NaN,
2331169689Skanother than equality and inequality, may generate a floating point exception.
2332169689Skan
2333169689Skan@item ORDERED_EXPR
2334169689Skan@itemx UNORDERED_EXPR
2335169689SkanThese nodes represent non-trapping ordered and unordered comparison
2336169689Skanoperators.  These operations take two floating point operands and
2337169689Skandetermine whether they are ordered or unordered relative to each other.
2338169689SkanIf either operand is an IEEE NaN, their comparison is defined to be
2339169689Skanunordered, otherwise the comparison is defined to be ordered.  The
2340169689Skanresult type of these expressions will always be of integral or boolean
2341169689Skantype.  These operations return the result type's zero value for false,
2342169689Skanand the result type's one value for true.
2343169689Skan
2344169689Skan@item UNLT_EXPR
2345169689Skan@itemx UNLE_EXPR
2346169689Skan@itemx UNGT_EXPR
2347169689Skan@itemx UNGE_EXPR
2348169689Skan@itemx UNEQ_EXPR
2349169689Skan@itemx LTGT_EXPR
2350169689SkanThese nodes represent the unordered comparison operators.
2351169689SkanThese operations take two floating point operands and determine whether
2352169689Skanthe operands are unordered or are less than, less than or equal to,
2353169689Skangreater than, greater than or equal to, or equal respectively.  For
2354169689Skanexample, @code{UNLT_EXPR} returns true if either operand is an IEEE
2355169689SkanNaN or the first operand is less than the second.  With the possible
2356169689Skanexception of @code{LTGT_EXPR}, all of these operations are guaranteed
2357169689Skannot to generate a floating point exception.  The result
2358169689Skantype of these expressions will always be of integral or boolean type.
2359169689SkanThese operations return the result type's zero value for false,
2360169689Skanand the result type's one value for true.
2361169689Skan
236290075Sobrien@item MODIFY_EXPR
236390075SobrienThese nodes represent assignment.  The left-hand side is the first
236490075Sobrienoperand; the right-hand side is the second operand.  The left-hand side
236590075Sobrienwill be a @code{VAR_DECL}, @code{INDIRECT_REF}, @code{COMPONENT_REF}, or
236690075Sobrienother lvalue.
236790075Sobrien
236890075SobrienThese nodes are used to represent not only assignment with @samp{=} but
236990075Sobrienalso compound assignments (like @samp{+=}), by reduction to @samp{=}
237090075Sobrienassignment.  In other words, the representation for @samp{i += 3} looks
237190075Sobrienjust like that for @samp{i = i + 3}.
237290075Sobrien
237390075Sobrien@item INIT_EXPR
237490075SobrienThese nodes are just like @code{MODIFY_EXPR}, but are used only when a
2375169689Skanvariable is initialized, rather than assigned to subsequently.  This
2376169689Skanmeans that we can assume that the target of the initialization is not
2377169689Skanused in computing its own value; any reference to the lhs in computing
2378169689Skanthe rhs is undefined.
237990075Sobrien
238090075Sobrien@item COMPONENT_REF
238190075SobrienThese nodes represent non-static data member accesses.  The first
238290075Sobrienoperand is the object (rather than a pointer to it); the second operand
2383169689Skanis the @code{FIELD_DECL} for the data member.  The third operand represents
2384169689Skanthe byte offset of the field, but should not be used directly; call
2385169689Skan@code{component_ref_field_offset} instead.
238690075Sobrien
238790075Sobrien@item COMPOUND_EXPR
238890075SobrienThese nodes represent comma-expressions.  The first operand is an
238990075Sobrienexpression whose value is computed and thrown away prior to the
239090075Sobrienevaluation of the second operand.  The value of the entire expression is
239190075Sobrienthe value of the second operand.
239290075Sobrien
239390075Sobrien@item COND_EXPR
239490075SobrienThese nodes represent @code{?:} expressions.  The first operand
239590075Sobrienis of boolean or integral type.  If it evaluates to a nonzero value,
239690075Sobrienthe second operand should be evaluated, and returned as the value of the
239790075Sobrienexpression.  Otherwise, the third operand is evaluated, and returned as
2398117395Skanthe value of the expression.
239990075Sobrien
2400117395SkanThe second operand must have the same type as the entire expression,
2401117395Skanunless it unconditionally throws an exception or calls a noreturn
2402117395Skanfunction, in which case it should have void type.  The same constraints
2403117395Skanapply to the third operand.  This allows array bounds checks to be
2404117395Skanrepresented conveniently as @code{(i >= 0 && i < 10) ? i : abort()}.
240590075Sobrien
2406117395SkanAs a GNU extension, the C language front-ends allow the second
2407117395Skanoperand of the @code{?:} operator may be omitted in the source.
2408117395SkanFor example, @code{x ? : 3} is equivalent to @code{x ? x : 3},
2409117395Skanassuming that @code{x} is an expression without side-effects.
2410117395SkanIn the tree representation, however, the second operand is always
2411117395Skanpresent, possibly protected by @code{SAVE_EXPR} if the first
2412117395Skanargument does cause side-effects.
241390075Sobrien
241490075Sobrien@item CALL_EXPR
241590075SobrienThese nodes are used to represent calls to functions, including
241690075Sobriennon-static member functions.  The first operand is a pointer to the
241790075Sobrienfunction to call; it is always an expression whose type is a
241890075Sobrien@code{POINTER_TYPE}.  The second argument is a @code{TREE_LIST}.  The
241990075Sobrienarguments to the call appear left-to-right in the list.  The
242090075Sobrien@code{TREE_VALUE} of each list node contains the expression
242190075Sobriencorresponding to that argument.  (The value of @code{TREE_PURPOSE} for
242290075Sobrienthese nodes is unspecified, and should be ignored.)  For non-static
242390075Sobrienmember functions, there will be an operand corresponding to the
242490075Sobrien@code{this} pointer.  There will always be expressions corresponding to
242590075Sobrienall of the arguments, even if the function is declared with default
242690075Sobrienarguments and some arguments are not explicitly provided at the call
242790075Sobriensites.
242890075Sobrien
242990075Sobrien@item STMT_EXPR
243090075SobrienThese nodes are used to represent GCC's statement-expression extension.
243190075SobrienThe statement-expression extension allows code like this:
2432132718Skan@smallexample
243390075Sobrienint f() @{ return (@{ int j; j = 3; j + 7; @}); @}
2434132718Skan@end smallexample
243590075SobrienIn other words, an sequence of statements may occur where a single
243690075Sobrienexpression would normally appear.  The @code{STMT_EXPR} node represents
243790075Sobriensuch an expression.  The @code{STMT_EXPR_STMT} gives the statement
2438169689Skancontained in the expression.  The value of the expression is the value
2439169689Skanof the last sub-statement in the body.  More precisely, the value is the
2440169689Skanvalue computed by the last statement nested inside @code{BIND_EXPR},
2441169689Skan@code{TRY_FINALLY_EXPR}, or @code{TRY_CATCH_EXPR}.  For example, in:
2442132718Skan@smallexample
244390075Sobrien(@{ 3; @})
2444132718Skan@end smallexample
244590075Sobrienthe value is @code{3} while in:
2446132718Skan@smallexample
244790075Sobrien(@{ if (x) @{ 3; @} @})
2448132718Skan@end smallexample
2449169689Skanthere is no value.  If the @code{STMT_EXPR} does not yield a value,
2450169689Skanit's type will be @code{void}.
245190075Sobrien
245290075Sobrien@item BIND_EXPR
245390075SobrienThese nodes represent local blocks.  The first operand is a list of
2454169689Skanvariables, connected via their @code{TREE_CHAIN} field.  These will
2455169689Skannever require cleanups.  The scope of these variables is just the body
2456169689Skanof the @code{BIND_EXPR}.  The body of the @code{BIND_EXPR} is the
245790075Sobriensecond operand.
245890075Sobrien
245990075Sobrien@item LOOP_EXPR
246090075SobrienThese nodes represent ``infinite'' loops.  The @code{LOOP_EXPR_BODY}
246190075Sobrienrepresents the body of the loop.  It should be executed forever, unless
246290075Sobrienan @code{EXIT_EXPR} is encountered.
246390075Sobrien
246490075Sobrien@item EXIT_EXPR
246590075SobrienThese nodes represent conditional exits from the nearest enclosing
246690075Sobrien@code{LOOP_EXPR}.  The single operand is the condition; if it is
246790075Sobriennonzero, then the loop should be exited.  An @code{EXIT_EXPR} will only
246890075Sobrienappear within a @code{LOOP_EXPR}.
246990075Sobrien
247090075Sobrien@item CLEANUP_POINT_EXPR
247190075SobrienThese nodes represent full-expressions.  The single operand is an
247290075Sobrienexpression to evaluate.  Any destructor calls engendered by the creation
247390075Sobrienof temporaries during the evaluation of that expression should be
247490075Sobrienperformed immediately after the expression is evaluated.
247590075Sobrien
247690075Sobrien@item CONSTRUCTOR
247790075SobrienThese nodes represent the brace-enclosed initializers for a structure or
247890075Sobrienarray.  The first operand is reserved for use by the back end.  The
247990075Sobriensecond operand is a @code{TREE_LIST}.  If the @code{TREE_TYPE} of the
248090075Sobrien@code{CONSTRUCTOR} is a @code{RECORD_TYPE} or @code{UNION_TYPE}, then
248190075Sobrienthe @code{TREE_PURPOSE} of each node in the @code{TREE_LIST} will be a
248290075Sobrien@code{FIELD_DECL} and the @code{TREE_VALUE} of each node will be the
2483132718Skanexpression used to initialize that field.
248490075Sobrien
248590075SobrienIf the @code{TREE_TYPE} of the @code{CONSTRUCTOR} is an
248690075Sobrien@code{ARRAY_TYPE}, then the @code{TREE_PURPOSE} of each element in the
2487169689Skan@code{TREE_LIST} will be an @code{INTEGER_CST} or a @code{RANGE_EXPR} of
2488169689Skantwo @code{INTEGER_CST}s.  A single @code{INTEGER_CST} indicates which
2489169689Skanelement of the array (indexed from zero) is being assigned to.  A
2490169689Skan@code{RANGE_EXPR} indicates an inclusive range of elements to
2491169689Skaninitialize.  In both cases the @code{TREE_VALUE} is the corresponding
2492169689Skaninitializer.  It is re-evaluated for each element of a
2493169689Skan@code{RANGE_EXPR}.  If the @code{TREE_PURPOSE} is @code{NULL_TREE}, then
2494169689Skanthe initializer is for the next available array element.
249590075Sobrien
2496132718SkanIn the front end, you should not depend on the fields appearing in any
2497132718Skanparticular order.  However, in the middle end, fields must appear in
2498132718Skandeclaration order.  You should not assume that all fields will be
2499132718Skanrepresented.  Unrepresented fields will be set to zero.
250090075Sobrien
250190075Sobrien@item COMPOUND_LITERAL_EXPR
250290075Sobrien@findex COMPOUND_LITERAL_EXPR_DECL_STMT
250390075Sobrien@findex COMPOUND_LITERAL_EXPR_DECL
250490075SobrienThese nodes represent ISO C99 compound literals.  The
250590075Sobrien@code{COMPOUND_LITERAL_EXPR_DECL_STMT} is a @code{DECL_STMT}
250690075Sobriencontaining an anonymous @code{VAR_DECL} for
250790075Sobrienthe unnamed object represented by the compound literal; the
250890075Sobrien@code{DECL_INITIAL} of that @code{VAR_DECL} is a @code{CONSTRUCTOR}
250990075Sobrienrepresenting the brace-enclosed list of initializers in the compound
251090075Sobrienliteral.  That anonymous @code{VAR_DECL} can also be accessed directly
251190075Sobrienby the @code{COMPOUND_LITERAL_EXPR_DECL} macro.
251290075Sobrien
251390075Sobrien@item SAVE_EXPR
251490075Sobrien
251590075SobrienA @code{SAVE_EXPR} represents an expression (possibly involving
251690075Sobrienside-effects) that is used more than once.  The side-effects should
251790075Sobrienoccur only the first time the expression is evaluated.  Subsequent uses
251890075Sobrienshould just reuse the computed value.  The first operand to the
251990075Sobrien@code{SAVE_EXPR} is the expression to evaluate.  The side-effects should
252090075Sobrienbe executed where the @code{SAVE_EXPR} is first encountered in a
252190075Sobriendepth-first preorder traversal of the expression tree.
252290075Sobrien
252390075Sobrien@item TARGET_EXPR
252490075SobrienA @code{TARGET_EXPR} represents a temporary object.  The first operand
252590075Sobrienis a @code{VAR_DECL} for the temporary variable.  The second operand is
2526169689Skanthe initializer for the temporary.  The initializer is evaluated and,
2527169689Skanif non-void, copied (bitwise) into the temporary.  If the initializer
2528169689Skanis void, that means that it will perform the initialization itself.
252990075Sobrien
253090075SobrienOften, a @code{TARGET_EXPR} occurs on the right-hand side of an
253190075Sobrienassignment, or as the second operand to a comma-expression which is
253290075Sobrienitself the right-hand side of an assignment, etc.  In this case, we say
253390075Sobrienthat the @code{TARGET_EXPR} is ``normal''; otherwise, we say it is
253490075Sobrien``orphaned''.  For a normal @code{TARGET_EXPR} the temporary variable
253590075Sobrienshould be treated as an alias for the left-hand side of the assignment,
253690075Sobrienrather than as a new temporary variable.
253790075Sobrien
253890075SobrienThe third operand to the @code{TARGET_EXPR}, if present, is a
253990075Sobriencleanup-expression (i.e., destructor call) for the temporary.  If this
254090075Sobrienexpression is orphaned, then this expression must be executed when the
254190075Sobrienstatement containing this expression is complete.  These cleanups must
254290075Sobrienalways be executed in the order opposite to that in which they were
254390075Sobrienencountered.  Note that if a temporary is created on one branch of a
254490075Sobrienconditional operator (i.e., in the second or third operand to a
254590075Sobrien@code{COND_EXPR}), the cleanup must be run only if that branch is
254690075Sobrienactually executed.
254790075Sobrien
254890075SobrienSee @code{STMT_IS_FULL_EXPR_P} for more information about running these
254990075Sobriencleanups.
255090075Sobrien
255190075Sobrien@item AGGR_INIT_EXPR
255290075SobrienAn @code{AGGR_INIT_EXPR} represents the initialization as the return
255390075Sobrienvalue of a function call, or as the result of a constructor.  An
2554169689Skan@code{AGGR_INIT_EXPR} will only appear as a full-expression, or as the
2555169689Skansecond operand of a @code{TARGET_EXPR}.  The first operand to the
2556169689Skan@code{AGGR_INIT_EXPR} is the address of a function to call, just as in
2557169689Skana @code{CALL_EXPR}.  The second operand are the arguments to pass that
2558169689Skanfunction, as a @code{TREE_LIST}, again in a manner similar to that of
2559169689Skana @code{CALL_EXPR}.
256090075Sobrien
256190075SobrienIf @code{AGGR_INIT_VIA_CTOR_P} holds of the @code{AGGR_INIT_EXPR}, then
256290075Sobrienthe initialization is via a constructor call.  The address of the third
256390075Sobrienoperand of the @code{AGGR_INIT_EXPR}, which is always a @code{VAR_DECL},
256490075Sobrienis taken, and this value replaces the first argument in the argument
2565169689Skanlist.
256690075Sobrien
2567169689SkanIn either case, the expression is void.
256890075Sobrien
2569117395Skan@item VA_ARG_EXPR
2570117395SkanThis node is used to implement support for the C/C++ variable argument-list
2571117395Skanmechanism.  It represents expressions like @code{va_arg (ap, type)}.
2572117395SkanIts @code{TREE_TYPE} yields the tree representation for @code{type} and
2573117395Skanits sole argument yields the representation for @code{ap}.
2574117395Skan
2575169689Skan@item OMP_PARALLEL
2576169689Skan
2577169689SkanRepresents @code{#pragma omp parallel [clause1 ... clauseN]}. It
2578169689Skanhas four operands:
2579169689Skan
2580169689SkanOperand @code{OMP_PARALLEL_BODY} is valid while in GENERIC and
2581169689SkanHigh GIMPLE forms.  It contains the body of code to be executed
2582169689Skanby all the threads.  During GIMPLE lowering, this operand becomes
2583169689Skan@code{NULL} and the body is emitted linearly after
2584169689Skan@code{OMP_PARALLEL}.
2585169689Skan
2586169689SkanOperand @code{OMP_PARALLEL_CLAUSES} is the list of clauses
2587169689Skanassociated with the directive.
2588169689Skan
2589169689SkanOperand @code{OMP_PARALLEL_FN} is created by
2590169689Skan@code{pass_lower_omp}, it contains the @code{FUNCTION_DECL}
2591169689Skanfor the function that will contain the body of the parallel
2592169689Skanregion.
2593169689Skan
2594169689SkanOperand @code{OMP_PARALLEL_DATA_ARG} is also created by
2595169689Skan@code{pass_lower_omp}. If there are shared variables to be
2596169689Skancommunicated to the children threads, this operand will contain
2597169689Skanthe @code{VAR_DECL} that contains all the shared values and
2598169689Skanvariables.
2599169689Skan
2600169689Skan@item OMP_FOR
2601169689Skan
2602169689SkanRepresents @code{#pragma omp for [clause1 ... clauseN]}.  It
2603169689Skanhas 5 operands:
2604169689Skan
2605169689SkanOperand @code{OMP_FOR_BODY} contains the loop body.
2606169689Skan
2607169689SkanOperand @code{OMP_FOR_CLAUSES} is the list of clauses
2608169689Skanassociated with the directive.
2609169689Skan
2610169689SkanOperand @code{OMP_FOR_INIT} is the loop initialization code of
2611169689Skanthe form @code{VAR = N1}.
2612169689Skan
2613169689SkanOperand @code{OMP_FOR_COND} is the loop conditional expression
2614169689Skanof the form @code{VAR @{<,>,<=,>=@} N2}.
2615169689Skan
2616169689SkanOperand @code{OMP_FOR_INCR} is the loop index increment of the
2617169689Skanform @code{VAR @{+=,-=@} INCR}.
2618169689Skan
2619169689SkanOperand @code{OMP_FOR_PRE_BODY} contains side-effect code from
2620169689Skanoperands @code{OMP_FOR_INIT}, @code{OMP_FOR_COND} and
2621169689Skan@code{OMP_FOR_INC}.  These side-effects are part of the
2622169689Skan@code{OMP_FOR} block but must be evaluated before the start of
2623169689Skanloop body.
2624169689Skan
2625169689SkanThe loop index variable @code{VAR} must be a signed integer variable,
2626169689Skanwhich is implicitly private to each thread.  Bounds
2627169689Skan@code{N1} and @code{N2} and the increment expression
2628169689Skan@code{INCR} are required to be loop invariant integer
2629169689Skanexpressions that are evaluated without any synchronization. The
2630169689Skanevaluation order, frequency of evaluation and side-effects are
2631169689Skanunspecified by the standard.
2632169689Skan
2633169689Skan@item OMP_SECTIONS
2634169689Skan
2635169689SkanRepresents @code{#pragma omp sections [clause1 ... clauseN]}.
2636169689Skan
2637169689SkanOperand @code{OMP_SECTIONS_BODY} contains the sections body,
2638169689Skanwhich in turn contains a set of @code{OMP_SECTION} nodes for
2639169689Skaneach of the concurrent sections delimited by @code{#pragma omp
2640169689Skansection}.
2641169689Skan
2642169689SkanOperand @code{OMP_SECTIONS_CLAUSES} is the list of clauses
2643169689Skanassociated with the directive.
2644169689Skan
2645169689Skan@item OMP_SECTION
2646169689Skan
2647169689SkanSection delimiter for @code{OMP_SECTIONS}.
2648169689Skan
2649169689Skan@item OMP_SINGLE
2650169689Skan
2651169689SkanRepresents @code{#pragma omp single}.
2652169689Skan
2653169689SkanOperand @code{OMP_SINGLE_BODY} contains the body of code to be
2654169689Skanexecuted by a single thread.
2655169689Skan
2656169689SkanOperand @code{OMP_SINGLE_CLAUSES} is the list of clauses
2657169689Skanassociated with the directive.
2658169689Skan
2659169689Skan@item OMP_MASTER
2660169689Skan
2661169689SkanRepresents @code{#pragma omp master}.
2662169689Skan
2663169689SkanOperand @code{OMP_MASTER_BODY} contains the body of code to be
2664169689Skanexecuted by the master thread.
2665169689Skan
2666169689Skan@item OMP_ORDERED
2667169689Skan
2668169689SkanRepresents @code{#pragma omp ordered}.
2669169689Skan
2670169689SkanOperand @code{OMP_ORDERED_BODY} contains the body of code to be
2671169689Skanexecuted in the sequential order dictated by the loop index
2672169689Skanvariable.
2673169689Skan
2674169689Skan@item OMP_CRITICAL
2675169689Skan
2676169689SkanRepresents @code{#pragma omp critical [name]}.
2677169689Skan
2678169689SkanOperand @code{OMP_CRITICAL_BODY} is the critical section.
2679169689Skan
2680169689SkanOperand @code{OMP_CRITICAL_NAME} is an optional identifier to
2681169689Skanlabel the critical section.
2682169689Skan
2683169689Skan@item OMP_RETURN
2684169689Skan
2685169689SkanThis does not represent any OpenMP directive, it is an artificial
2686169689Skanmarker to indicate the end of the body of an OpenMP. It is used
2687169689Skanby the flow graph (@code{tree-cfg.c}) and OpenMP region
2688169689Skanbuilding code (@code{omp-low.c}).
2689169689Skan
2690169689Skan@item OMP_CONTINUE
2691169689Skan
2692169689SkanSimilarly, this instruction does not represent an OpenMP
2693169689Skandirective, it is used by @code{OMP_FOR} and
2694169689Skan@code{OMP_SECTIONS} to mark the place where the code needs to
2695169689Skanloop to the next iteration (in the case of @code{OMP_FOR}) or
2696169689Skanthe next section (in the case of @code{OMP_SECTIONS}).
2697169689Skan
2698169689SkanIn some cases, @code{OMP_CONTINUE} is placed right before
2699169689Skan@code{OMP_RETURN}.  But if there are cleanups that need to
2700169689Skanoccur right after the looping body, it will be emitted between
2701169689Skan@code{OMP_CONTINUE} and @code{OMP_RETURN}.
2702169689Skan
2703169689Skan@item OMP_ATOMIC
2704169689Skan
2705169689SkanRepresents @code{#pragma omp atomic}.
2706169689Skan
2707169689SkanOperand 0 is the address at which the atomic operation is to be
2708169689Skanperformed.
2709169689Skan
2710169689SkanOperand 1 is the expression to evaluate.  The gimplifier tries
2711169689Skanthree alternative code generation strategies.  Whenever possible,
2712169689Skanan atomic update built-in is used.  If that fails, a
2713169689Skancompare-and-swap loop is attempted.  If that also fails, a
2714169689Skanregular critical section around the expression is used.
2715169689Skan
2716169689Skan@item OMP_CLAUSE
2717169689Skan
2718169689SkanRepresents clauses associated with one of the @code{OMP_} directives.
2719169689SkanClauses are represented by separate sub-codes defined in
2720169689Skan@file{tree.h}.  Clauses codes can be one of:
2721169689Skan@code{OMP_CLAUSE_PRIVATE}, @code{OMP_CLAUSE_SHARED},
2722169689Skan@code{OMP_CLAUSE_FIRSTPRIVATE},
2723169689Skan@code{OMP_CLAUSE_LASTPRIVATE}, @code{OMP_CLAUSE_COPYIN},
2724169689Skan@code{OMP_CLAUSE_COPYPRIVATE}, @code{OMP_CLAUSE_IF},
2725169689Skan@code{OMP_CLAUSE_NUM_THREADS}, @code{OMP_CLAUSE_SCHEDULE},
2726169689Skan@code{OMP_CLAUSE_NOWAIT}, @code{OMP_CLAUSE_ORDERED},
2727169689Skan@code{OMP_CLAUSE_DEFAULT}, and @code{OMP_CLAUSE_REDUCTION}.  Each code
2728169689Skanrepresents the corresponding OpenMP clause.
2729169689Skan
2730169689SkanClauses associated with the same directive are chained together
2731169689Skanvia @code{OMP_CLAUSE_CHAIN}. Those clauses that accept a list
2732169689Skanof variables are restricted to exactly one, accessed with
2733169689Skan@code{OMP_CLAUSE_VAR}.  Therefore, multiple variables under the
2734169689Skansame clause @code{C} need to be represented as multiple @code{C} clauses
2735169689Skanchained together.  This facilitates adding new clauses during
2736169689Skancompilation.
2737169689Skan
273890075Sobrien@end table
2739