-@c Copyright (c) 1999, 2000, 2001 Free Software Foundation, Inc.
+@c Copyright (c) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
@c Free Software Foundation, Inc.
@c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
@c ---------------------------------------------------------------------
@node Trees
-@chapter Trees: The intermediate representation used by the C and C++ front-ends
+@chapter Trees: The intermediate representation used by the C and C++ front ends
@cindex Trees
@cindex C/C++ Internal Representation
-This chapter documents the internal representation used by GCC and C++ to
+This chapter documents the internal representation used by GCC to
represent C and C++ source programs. When presented with a C or C++
source program, GCC parses the program, performs semantic analysis
(including the generation of error messages), and then produces the
internal representation described here. This representation contains a
complete representation for the entire translation unit provided as
-input to the front-end. This representation is then typically processed
+input to the front end. This representation is then typically processed
by a code-generator in order to produce machine code, but could also be
used in the creation of source browsers, intelligent editors, automatic
documentation generators, interpreters, and any other programs needing
This chapter explains the internal representation. In particular, it
documents the internal representation for C and C++ source
constructs, and the macros, functions, and variables that can be used to
-access these constructs. The C++ representation which is largely a superset
-of the representation used in the C front-end. There is only one
-construct used in C that does not appear in the C++ front-end and that
+access these constructs. The C++ representation is largely a superset
+of the representation used in the C front end. There is only one
+construct used in C that does not appear in the C++ front end and that
is the GNU ``nested function'' extension. Many of the macros documented
here do not apply in C because the corresponding language constructs do
-not appear in C.
+not appear in C@.
-If you are developing a ``back-end'', be it is a code-generator or some
+If you are developing a ``back end'', be it is a code-generator or some
other tool, that uses this representation, you may occasionally find
that you need to ask questions not easily answered by the functions and
macros available here. If that situation occurs, it is quite likely
interface is simply not documented here. In that case, you should ask
the GCC maintainers (via mail to @email{gcc@@gcc.gnu.org}) about
documenting the functionality you require. Similarly, if you find
-yourself writing functions that do not deal directly with your back-end,
-but instead might be useful to other people using the GCC front-end, you
-should submit your patches for inclusion in GCC.
+yourself writing functions that do not deal directly with your back end,
+but instead might be useful to other people using the GCC front end, you
+should submit your patches for inclusion in GCC@.
@menu
* Deficiencies:: Topics net yet covered in this document.
* Scopes:: Namespaces and classes.
* Functions:: Overloading, function bodies, and linkage.
* Declarations:: Type declarations and variables.
+* Attributes:: Declaration and type attributes.
* Expression trees:: From @code{typeid} to @code{throw}.
@end menu
font}, except when talking about the actual C type @code{tree}.
You can tell what kind of node a particular tree is by using the
-@code{TREE_CODE} macro. Many, many macros take a trees as input and
-return trees as output. However, most macros require a certain kinds of
+@code{TREE_CODE} macro. Many, many macros take trees as input and
+return trees as output. However, most macros require a certain kind of
tree node as input. In other words, there is a type-system for trees,
but it is not reflected in the C type-system.
-For safety, it is useful to configure G++ with @code{--enable-checking}.
+For safety, it is useful to configure GCC with @option{--enable-checking}.
Although this results in a significant performance penalty (since all
tree types are checked at run-time), and is therefore inappropriate in a
release version, it is extremely helpful during the development process.
predicates end in @samp{_P}. Do not rely on the result type of these
macros being of any particular type. You may, however, rely on the fact
that the type can be compared to @code{0}, so that statements like
-@example
+@smallexample
if (TEST_P (t) && !TEST_P (y))
x = 1;
-@end example
+@end smallexample
@noindent
and
-@example
+@smallexample
int i = (TEST_P (t) != 0);
-@end example
+@end smallexample
@noindent
are legal. Macros that return @code{int} values now may be changed to
return @code{tree} values, or other pointers in the future. Even those
-that continue to return @code{int} may return multiple non-zero codes
+that continue to return @code{int} may return multiple nonzero codes
where previously they returned only zero and one. Therefore, you should
not write code like
-@example
+@smallexample
if (TEST_P (t) == 1)
-@end example
+@end smallexample
@noindent
as this code is not guaranteed to work correctly in the future.
values are lvalues.
In general, the names of macros are all in uppercase, while the names of
-functions are entirely in lower case. There are rare exceptions to this
+functions are entirely in lowercase. There are rare exceptions to this
rule. You should assume that any macro or function whose name is made
up entirely of uppercase letters may evaluate its arguments more than
once. You may assume that a macro or function whose name is made up
the usual practice is to compare the tree against
@code{error_mark_node}. (This test is just a test for pointer
equality.) If an error has occurred during front-end processing the
-flag @code{errorcount} will be set. If the front-end has encountered
+flag @code{errorcount} will be set. If the front end has encountered
code it cannot handle, it will issue a message to the user and set
@code{sorrycount}. When these flags are set, any macro or function
which normally returns a tree of a particular kind may instead return
Occasionally, a particular tree slot (like an operand to an expression,
or a particular field in a declaration) will be referred to as
-``reserved for the back-end.'' These slots are used to store RTL when
-the tree is converted to RTL for use by the GCC back-end. However, if
-that process is not taking place (e.g., if the front-end is being hooked
+``reserved for the back end.'' These slots are used to store RTL when
+the tree is converted to RTL for use by the GCC back end. However, if
+that process is not taking place (e.g., if the front end is being hooked
up to an intelligent editor), then those slots may be used by the
-back-end presently in use.
+back end presently in use.
If you encounter situations that do not match this documentation, such
as tree nodes of types not mentioned here, or macros documented to
return entities of a particular kind that instead return entities of
-some different kind, you have found a bug, either in the front-end or in
+some different kind, you have found a bug, either in the front end or in
the documentation. Please report these bugs as you would any other
bug.
@code{IDENTIFIER_NODE}, as you might expect, given its name!) You can
look at the @code{DECL_NAME} of the @code{TYPE_DECL} to obtain the
actual name of the type. The @code{TYPE_NAME} will be @code{NULL_TREE}
-for a type that is not a builtin type, the result of a typedef, or a
+for a type that is not a built-in type, the result of a typedef, or a
named class type.
@item CP_INTEGRAL_TYPE
This predicate holds for a class-type.
@item TYPE_BUILT_IN
-This predicate holds for a builtin type.
+This predicate holds for a built-in type.
@item TYPE_PTRMEM_P
This predicate holds if the type is a pointer to data member.
@item TYPE_PTROB_P
This predicate holds for a pointer to object type. Note however that it
-does not hold for the generic pointer to object type @code{void *}. You
+does not hold for the generic pointer to object type @code{void *}. You
may use @code{TYPE_PTROBV_P} to test for a pointer to object type as
well as @code{void *}.
requirements for the ABI required 32-bit alignment. Then,
@code{TYPE_SIZE} would be an @code{INTEGER_CST} for 32, while
@code{TYPE_PRECISION} would be 24.) The integer type is unsigned if
-@code{TREE_UNSIGNED} holds; otherwise, it is signed.
+@code{TYPE_UNSIGNED} holds; otherwise, it is signed.
The @code{TYPE_MIN_VALUE} is an @code{INTEGER_CST} for the smallest
integer that may be represented by this type. Similarly, the
is given by @code{TYPE_PRECISION}, as in the @code{INTEGER_TYPE} case.
@item COMPLEX_TYPE
-Used to represent GCC builtin @code{__complex__} data types. The
+Used to represent GCC built-in @code{__complex__} data types. The
@code{TREE_TYPE} is the type of the real and imaginary parts.
@item ENUMERAL_TYPE
Used to represent an enumeration type. The @code{TYPE_PRECISION} gives
(as an @code{int}), the number of bits used to represent the type. If
-there are no negative enumeration constants, @code{TREE_UNSIGNED} will
+there are no negative enumeration constants, @code{TYPE_UNSIGNED} will
hold. The minimum and maximum enumeration constants may be obtained
with @code{TYPE_MIN_VALUE} and @code{TYPE_MAX_VALUE}, respectively; each
of these macros returns an @code{INTEGER_CST}.
Note that in C (but not in C++) a function declared like @code{void f()}
is an unprototyped function taking a variable number of arguments; the
-@code{TYPE_ARG_TYPES} of such a function will be NULL.
+@code{TYPE_ARG_TYPES} of such a function will be @code{NULL}.
@item METHOD_TYPE
Used to represent the type of a non-static member function. Like a
@item RECORD_TYPE
Used to represent @code{struct} and @code{class} types, as well as
-pointers to member functions. If @code{TYPE_PTRMEMFUNC_P} holds, then
-this type is a pointer-to-member type. In that case, the
-@code{TYPE_PTRMEMFUNC_FN_TYPE} is a @code{POINTER_TYPE} pointing to a
-@code{METHOD_TYPE}. The @code{METHOD_TYPE} is the type of a function
-pointed to by the pointer-to-member function. If
-@code{TYPE_PTRMEMFUNC_P} does not hold, this type is a class type. For
-more information, see @pxref{Classes}.
+pointers to member functions and similar constructs in other languages.
+@code{TYPE_FIELDS} contains the items contained in this type, each of
+which can be a @code{FIELD_DECL}, @code{VAR_DECL}, @code{CONST_DECL}, or
+@code{TYPE_DECL}. You may not make any assumptions about the ordering
+of the fields in the type or whether one or more of them overlap. If
+@code{TYPE_PTRMEMFUNC_P} holds, then this type is a pointer-to-member
+type. In that case, the @code{TYPE_PTRMEMFUNC_FN_TYPE} is a
+@code{POINTER_TYPE} pointing to a @code{METHOD_TYPE}. The
+@code{METHOD_TYPE} is the type of a function pointed to by the
+pointer-to-member function. If @code{TYPE_PTRMEMFUNC_P} does not hold,
+this type is a class type. For more information, see @pxref{Classes}.
+
+@item UNION_TYPE
+Used to represent @code{union} types. Similar to @code{RECORD_TYPE}
+except that all @code{FIELD_DECL} nodes in @code{TYPE_FIELD} start at
+bit position zero.
+
+@item QUAL_UNION_TYPE
+Used to represent part of a variant record in Ada. Similar to
+@code{UNION_TYPE} except that each @code{FIELD_DECL} has a
+@code{DECL_QUALIFIER} field, which contains a boolean expression that
+indicates whether the field is present in the object. The type will only
+have one field, so each field's @code{DECL_QUALIFIER} is only evaluated
+if none of the expressions in the previous fields in @code{TYPE_FIELDS}
+are nonzero. Normally these expressions will reference a field in the
+outer object using a @code{PLACEHOLDER_EXPR}.
@item UNKNOWN_TYPE
This node is used to represent a type the knowledge of which is
insufficient for a sound processing.
@item OFFSET_TYPE
-This node is used to represent a data member; for example a
-pointer-to-data-member is represented by a @code{POINTER_TYPE} whose
-@code{TREE_TYPE} is an @code{OFFSET_TYPE}. For a data member @code{X::m}
-the @code{TYPE_OFFSET_BASETYPE} is @code{X} and the @code{TREE_TYPE} is
-the type of @code{m}.
+This node is used to represent a pointer-to-data member. For a data
+member @code{X::m} the @code{TYPE_OFFSET_BASETYPE} is @code{X} and the
+@code{TREE_TYPE} is the type of @code{m}.
@item TYPENAME_TYPE
Used to represent a construct of the form @code{typename T::A}. The
@code{TYPE_CONTEXT} is @code{T}; the @code{TYPE_NAME} is an
-@code{IDENTIFIER_NODE} for @code{A}. If the type is specified via a
+@code{IDENTIFIER_NODE} for @code{A}. If the type is specified via a
template-id, then @code{TYPENAME_TYPE_FULLNAME} yields a
@code{TEMPLATE_ID_EXPR}. The @code{TREE_TYPE} is non-@code{NULL} if the
node is implicitly generated in support for the implicit typename
Used to represent the @code{__typeof__} extension. The
@code{TYPE_FIELDS} is the expression the type of which is being
represented.
-
-@item UNION_TYPE
-Used to represent @code{union} types. For more information, @pxref{Classes}.
@end table
There are variables whose values represent some of the basic types.
namespace. Thus, in what follows, we describe namespaces generally,
rather than the global namespace in particular.
-The @code{::std} namespace, however, @emph{is} special, unless
-@code{flag_honor_std} is set. This variable is set by the use
-@samp{-fhonor-std} (or an option that implies it, like
-@samp{-fnew-abi}), when invoking G++. When @code{flag_honor_std} is
-set, the @code{std} namespace is just like any other namespace. When
-@code{flag_honor_std} is not set, however, the @code{::std} namespace is
-treated as a synonym for the global namespace, thereby allowing users to
-write code that will work with compilers that put the standard library
-in the @code{::std} namespace, even though the library supplied with G++
-does not do so, as of GCC 2.95. The @code{std} namespace is represented
-by the variable @code{std_node}. Although @code{std_node} is a
-@code{NAMESPACE_DECL}, it does not have all the fields required of a
-real namespace, and the macros and functions described here do not work,
-in general. It is safest simply to ignore @code{std_node} should you
-encounter it while examining the internal representation. In
-particular, you will encounter @code{std_node} while looking at the
-members of the global namespace. Just skip it without attempting to
-examine its members.
-
The following macros and functions can be used on a @code{NAMESPACE_DECL}:
@ftable @code
The name of the global namespace is @samp{::}, even though in C++ the
global namespace is unnamed. However, you should use comparison with
@code{global_namespace}, rather than @code{DECL_NAME} to determine
-whether or not a namespaces is the global one. An unnamed namespace
+whether or not a namespace is the global one. An unnamed namespace
will have a @code{DECL_NAME} equal to @code{anonymous_namespace_name}.
Within a single translation unit, all unnamed namespaces will have the
same name.
Although most entries on this list will be declarations,
@code{TREE_LIST} nodes may also appear. In this case, the
@code{TREE_VALUE} will be an @code{OVERLOAD}. The value of the
-@code{TREE_PURPOSE} is unspecified; back-ends should ignore this value.
+@code{TREE_PURPOSE} is unspecified; back ends should ignore this value.
As with the other kinds of declarations returned by
@code{cp_namespace_decls}, the @code{TREE_CHAIN} will point to the next
declaration in this list.
@findex CLASSTYPE_DECLARED_CLASS
@findex TYPE_BINFO
@findex BINFO_TYPE
-@findex TREE_VIA_PUBLIC
-@findex TREE_VIA_PROTECTED
-@findex TREE_VIA_PRIVATE
@findex TYPE_FIELDS
@findex TYPE_VFIELD
@findex TYPE_METHODS
list. Given one member, the next can be found by following the
@code{TREE_CHAIN}. You should not depend in any way on the order in
which fields appear on this list. All nodes on this list will be
-@samp{DECL} nodes. A @code{FIELD_DECL} is used to represent a non-static
+@samp{DECL} nodes. A @code{FIELD_DECL} is used to represent a non-static
data member, a @code{VAR_DECL} is used to represent a static data
member, and a @code{TYPE_DECL} is used to represent a type. Note that
the @code{CONST_DECL} for an enumeration constant will appear on this
The @code{TYPE_VFIELD} is a compiler-generated field used to point to
virtual function tables. It may or may not appear on the
-@code{TYPE_FIELDS} list. However, back-ends should handle the
+@code{TYPE_FIELDS} list. However, back ends should handle the
@code{TYPE_VFIELD} just like all the entries on the @code{TYPE_FIELDS}
list.
Every class has an associated @dfn{binfo}, which can be obtained with
@code{TYPE_BINFO}. Binfos are used to represent base-classes. The
binfo given by @code{TYPE_BINFO} is the degenerate case, whereby every
-class is considered to be its own base-class. The base classes for a
-particular binfo can be obtained with @code{BINFO_BASETYPES}. These
-base-classes are themselves binfos. The class type associated with a
-binfo is given by @code{BINFO_TYPE}. It is always the case that
-@code{BINFO_TYPE (TYPE_BINFO (x))} is the same type as @code{x}, up to
-qualifiers. However, it is not always the case that @code{TYPE_BINFO
-(BINFO_TYPE (y))} is always the same binfo as @code{y}. The reason is
-that if @code{y} is a binfo representing a base-class @code{B} of a
-derived class @code{D}, then @code{BINFO_TYPE (y)} will be @code{B}, and
-@code{TYPE_INFO (BINFO_TYPE (y))} will be @code{B} as its own
-base-class, rather than as a base-class of @code{D}.
-
-The @code{BINFO_BASETYPES} is a @code{TREE_VEC} (@pxref{Containers}).
-Base types appear in left-to-right order in this vector. You can tell
-whether or @code{public}, @code{protected}, or @code{private}
-inheritance was used by using the @code{TREE_VIA_PUBLIC},
-@code{TREE_VIA_PROTECTED}, and @code{TREE_VIA_PRIVATE} macros. Each of
-these macros takes a @code{BINFO} and is true if and only if the
-indicated kind of inheritance was used. If @code{TREE_VIA_VIRTUAL}
-holds of a binfo, then its @code{BINFO_TYPE} was inherited from
-virtually.
-
-FIXME: Talk about @code{TYPE_NONCOPIED_PARTS}.
+class is considered to be its own base-class. The base binfos for a
+particular binfo are held in a vector, whose length is obtained with
+@code{BINFO_N_BASE_BINFOS}. The base binfos themselves are obtained
+with @code{BINFO_BASE_BINFO} and @code{BINFO_BASE_ITERATE}. To add a
+new binfo, use @code{BINFO_BASE_APPEND}. The vector of base binfos can
+be obtained with @code{BINFO_BASE_BINFOS}, but normally you do not need
+to use that. The class type associated with a binfo is given by
+@code{BINFO_TYPE}. It is not always the case that @code{BINFO_TYPE
+(TYPE_BINFO (x))}, because of typedefs and qualified types. Neither is
+it the case that @code{TYPE_BINFO (BINFO_TYPE (y))} is the same binfo as
+@code{y}. The reason is that if @code{y} is a binfo representing a
+base-class @code{B} of a derived class @code{D}, then @code{BINFO_TYPE
+(y)} will be @code{B}, and @code{TYPE_BINFO (BINFO_TYPE (y))} will be
+@code{B} as its own base-class, rather than as a base-class of @code{D}.
+
+The access to a base type can be found with @code{BINFO_BASE_ACCESS}.
+This will produce @code{access_public_node}, @code{access_private_node}
+or @code{access_protected_node}. If bases are always public,
+@code{BINFO_BASE_ACCESSES} may be @code{NULL}.
+
+@code{BINFO_VIRTUAL_P} is used to specify whether the binfo is inherited
+virtually or not. The other flags, @code{BINFO_MARKED_P} and
+@code{BINFO_FLAG_1} to @code{BINFO_FLAG_6} can be used for language
+specific use.
The following macros can be used on a tree node representing a class-type.
default constructor.
@item CLASSTYPE_HAS_MUTABLE
-@item TYPE_HAS_MUTABLE_P
+@itemx TYPE_HAS_MUTABLE_P
These predicates hold for a class-type having a mutable data member.
@item CLASSTYPE_NON_POD_P
@item TREE_TYPE
This macro returns the type of the entity declared.
-@item DECL_SOURCE_FILE
+@item TREE_FILENAME
This macro returns the name of the file in which the entity was
declared, as a @code{char*}. For an entity declared implicitly by the
compiler (like @code{__builtin_memcpy}), this will be the string
@code{"<internal>"}.
-@item DECL_SOURCE_LINE
+@item TREE_LINENO
This macro returns the line number at which the entity was declared, as
an @code{int}.
compiler. For example, this predicate will hold of an implicitly
declared member function, or of the @code{TYPE_DECL} implicitly
generated for a class type. Recall that in C++ code like:
-@example
+@smallexample
struct S @{@};
-@end example
+@end smallexample
@noindent
is roughly equivalent to C code like:
-@example
+@smallexample
struct S @{@};
typedef struct S S;
-@end example
+@end smallexample
The implicitly generated @code{typedef} declaration is represented by a
@code{TYPE_DECL} for which @code{DECL_ARTIFICIAL} holds.
you should always use the @code{DECL_SIZE} and @code{DECL_ALIGN} rather
than the @code{TYPE_SIZE} and @code{TYPE_ALIGN} given by the
@code{TREE_TYPE}, since special attributes may have been applied to the
-variable to give it a particular size and alignment. You may use the
+variable to give it a particular size and alignment. You may use the
predicates @code{DECL_THIS_STATIC} or @code{DECL_THIS_EXTERN} to test
whether the storage class specifiers @code{static} or @code{extern} were
used to declare a variable.
@code{INTEGER_CST}. These values are indexed from zero, where zero
indicates the first bit in the object.
-If @code{DECL_C_BIT_FIELD} holds, this field is a bitfield.
+If @code{DECL_C_BIT_FIELD} holds, this field is a bit-field.
@item NAMESPACE_DECL
@xref{Namespaces}.
These nodes are used to represent class, function, and variable (static
data member) templates. The @code{DECL_TEMPLATE_SPECIALIZATIONS} are a
-@code{TREE_LIST}. The @code{TREE_VALUE} of each node in the lst is a
+@code{TREE_LIST}. The @code{TREE_VALUE} of each node in the list is a
@code{TEMPLATE_DECL}s or @code{FUNCTION_DECL}s representing
-specializations (including instantiations) of this template. Back-ends
+specializations (including instantiations) of this template. Back ends
can safely ignore @code{TEMPLATE_DECL}s, but should examine
@code{FUNCTION_DECL} nodes on the specializations list just as they
would ordinary @code{FUNCTION_DECL} nodes.
@item USING_DECL
-Back-ends can safely ignore these nodes.
+Back ends can safely ignore these nodes.
@end table
be @code{NULL_TREE}.
To determine the scope of a function, you can use the
-@code{DECL_REAL_CONTEXT} macro. This macro will return the class
+@code{DECL_CONTEXT} macro. This macro will return the class
(either a @code{RECORD_TYPE} or a @code{UNION_TYPE}) or namespace (a
@code{NAMESPACE_DECL}) of which the function is a member. For a virtual
function, this macro returns the class in which the function was
actually defined, not the base class in which the virtual declaration
-occurred. If a friend function is defined in a class scope, the
-@code{DECL_CLASS_CONTEXT} macro can be used to determine the class in
+occurred.
+
+If a friend function is defined in a class scope, the
+@code{DECL_FRIEND_CONTEXT} macro can be used to determine the class in
which it was defined. For example, in
-@example
+@smallexample
class C @{ friend void f() @{@} @};
-@end example
-the @code{DECL_REAL_CONTEXT} for @code{f} will be the
-@code{global_namespace}, but the @code{DECL_CLASS_CONTEXT} will be the
+@end smallexample
+@noindent
+the @code{DECL_CONTEXT} for @code{f} will be the
+@code{global_namespace}, but the @code{DECL_FRIEND_CONTEXT} will be the
@code{RECORD_TYPE} for @code{C}.
-The @code{DECL_REAL_CONTEXT} and @code{DECL_CLASS_CONTEXT} are not
-available in C; instead you should simply use @code{DECL_CONTEXT}. In C,
-the @code{DECL_CONTEXT} for a function maybe another function. This
-representation indicates that the GNU nested function extension is in
-use. For details on the semantics of nested functions, see the GCC
-Manual. The nested function can refer to local variables in its
+In C, the @code{DECL_CONTEXT} for a function maybe another function.
+This representation indicates that the GNU nested function extension
+is in use. For details on the semantics of nested functions, see the
+GCC Manual. The nested function can refer to local variables in its
containing function. Such references are not explicitly marked in the
-tree structure; back-ends must look at the @code{DECL_CONTEXT} for the
+tree structure; back ends must look at the @code{DECL_CONTEXT} for the
referenced @code{VAR_DECL}. If the @code{DECL_CONTEXT} for the
referenced @code{VAR_DECL} is not the same as the function currently
-being processed, and neither @code{DECL_EXTERNAL} nor @code{DECL_STATIC}
-hold, then the reference is to a local variable in a containing
-function, and the back-end must take appropriate action.
+being processed, and neither @code{DECL_EXTERNAL} nor
+@code{DECL_STATIC} hold, then the reference is to a local variable in
+a containing function, and the back end must take appropriate action.
@menu
* Function Basics:: Function names, linkage, and so forth.
on systems that prefix all identifiers with underscores. The mangled
name is computed in the same way on all platforms; if special processing
is required to deal with the object file format used on a particular
-platform, it is the responsibility of the back-end to perform those
-modifications. (Of course, the back-end should not modify
+platform, it is the responsibility of the back end to perform those
+modifications. (Of course, the back end should not modify
@code{DECL_ASSEMBLER_NAME} itself.)
+Using @code{DECL_ASSEMBLER_NAME} will cause additional memory to be
+allocated (for the mangled name of the entity) so it should be used
+only when emitting assembly code. It should not be used within the
+optimizers to determine whether or not two declarations are the same,
+even though some of the existing optimizers do use it in that way.
+These uses will be removed over time.
+
@item DECL_EXTERNAL
This predicate holds if the function is undefined.
value. (The @code{THUNK_DELTA} is an @code{int}, not an
@code{INTEGER_CST}.)
-Then, if @code{THUNK_VCALL_OFFSET} (an @code{INTEGER_CST}) is non-zero
+Then, if @code{THUNK_VCALL_OFFSET} (an @code{INTEGER_CST}) is nonzero
the adjusted @code{this} pointer must be adjusted again. The complete
calculation is given by the following pseudo-code:
-@example
+@smallexample
this += THUNK_DELTA
if (THUNK_VCALL_OFFSET)
this += (*((ptrdiff_t **) this))[THUNK_VCALL_OFFSET]
-@end example
+@end smallexample
Finally, the thunk should jump to the location given
by @code{DECL_INITIAL}; this will always be an expression for the
@subsection Function Bodies
@cindex function body
@cindex statements
-@tindex ASM_STMT
-@findex ASM_STRING
-@findex ASM_CV_QUAL
-@findex ASM_INPUTS
-@findex ASM_OUTPUTS
-@findex ASM_CLOBBERS
@tindex BREAK_STMT
@tindex CLEANUP_STMT
@findex CLEANUP_DECL
@findex CLEANUP_EXPR
-@tindex COMPOUND_STMT
-@findex COMPOUND_BODY
@tindex CONTINUE_STMT
@tindex DECL_STMT
@findex DECL_STMT_DECL
@findex FOR_COND
@findex FOR_EXPR
@findex FOR_BODY
-@tindex GOTO_STMT
-@findex GOTO_DESTINATION
@tindex HANDLER
@tindex IF_STMT
@findex IF_COND
@findex THEN_CLAUSE
@findex ELSE_CLAUSE
-@tindex LABEL_STMT
-@tindex LABEL_STMT_LABEL
@tindex RETURN_INIT
@tindex RETURN_STMT
@findex RETURN_EXPR
-@tindex SCOPE_STMT
-@findex SCOPE_BEGIN_P
-@findex SCOPE_END_P
-@findex SCOPE_NULLIFIED_P
@tindex SUBOBJECT
@findex SUBOBJECT_CLEANUP
@tindex SWITCH_STMT
@findex WHILE_COND
A function that has a definition in the current translation unit will
-have a non-NULL @code{DECL_INITIAL}. However, back-ends should not make
+have a non-@code{NULL} @code{DECL_INITIAL}. However, back ends should not make
use of the particular value given by @code{DECL_INITIAL}.
The @code{DECL_SAVED_TREE} macro will give the complete body of the
-function. This node will usually be a @code{COMPOUND_STMT} representing
-the outermost block of the function, but it may also be a
-@code{TRY_BLOCK}, a @code{RETURN_INIT}, or any other valid statement.
+function.
@subsubsection Statements
-There are tree nodes corresponding to all of the source-level statement
-constructs. These are enumerated here, together with a list of the
-various macros that can be used to obtain information about them. There
-are a few macros that can be used with all statements:
+There are tree nodes corresponding to all of the source-level
+statement constructs, used within the C and C++ frontends. These are
+enumerated here, together with a list of the various macros that can
+be used to obtain information about them. There are a few macros that
+can be used with all statements:
@ftable @code
-@item STMT_LINENO
-This macro returns the line number for the statement. If the statement
-spans multiple lines, this value will be the number of the first line on
-which the statement occurs. Although we mention @code{CASE_LABEL} below
-as if it were a statement, they do not allow the use of
-@code{STMT_LINENO}. There is no way to obtain the line number for a
-@code{CASE_LABEL}.
-
-Statements do not contain information about
-the file from which they came; that information is implicit in the
-@code{FUNCTION_DECL} from which the statements originate.
-
@item STMT_IS_FULL_EXPR_P
In C++, statements normally constitute ``full expressions''; temporaries
created during a statement are destroyed when the statement is complete.
of statements, connected via their @code{TREE_CHAIN}s. So, you should
always process the statement tree by looping over substatements, like
this:
-@example
+@smallexample
void process_stmt (stmt)
tree stmt;
@{
/* More processing here. */
break;
- ...
+ @dots{}
@}
stmt = TREE_CHAIN (stmt);
@}
@}
-@end example
+@end smallexample
In other words, while the @code{then} clause of an @code{if} statement
in C++ can be only one statement (although that one statement may be a
compound statement), the intermediate representation will sometimes use
several statements chained together.
@table @code
-@item ASM_STMT
+@item ASM_EXPR
Used to represent an inline assembly statement. For an inline assembly
statement like:
-@example
+@smallexample
asm ("mov x, y");
-@end example
+@end smallexample
The @code{ASM_STRING} macro will return a @code{STRING_CST} node for
@code{"mov x, y"}. If the original statement made use of the
extended-assembly syntax, then @code{ASM_OUTPUTS},
@code{ASM_INPUTS}, and @code{ASM_CLOBBERS} will be the outputs, inputs,
and clobbers for the statement, represented as @code{STRING_CST} nodes.
The extended-assembly syntax looks like:
-@example
+@smallexample
asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
-@end example
+@end smallexample
The first string is the @code{ASM_STRING}, containing the instruction
template. The next two strings are the output and inputs, respectively;
this statement has no clobbers. As this example indicates, ``plain''
If the assembly statement is declared @code{volatile}, or if the
statement was not an extended assembly statement, and is therefore
implicitly volatile, then the predicate @code{ASM_VOLATILE_P} will hold
-of the @code{ASM_STMT}.
+of the @code{ASM_EXPR}.
@item BREAK_STMT
Used to represent a @code{break} statement. There are no additional
fields.
-@item CASE_LABEL
+@item CASE_LABEL_EXPR
Use to represent a @code{case} label, range of @code{case} labels, or a
-@code{default} label. If @code{CASE_LOW} is NULL_TREE, then this is a a
-@code{default} label. Otherwise, if @code{CASE_HIGH} is NULL_TREE, then
+@code{default} label. If @code{CASE_LOW} is @code{NULL_TREE}, then this is a
+@code{default} label. Otherwise, if @code{CASE_HIGH} is @code{NULL_TREE}, then
this is an ordinary @code{case} label. In this case, @code{CASE_LOW} is
an expression giving the value of the label. Both @code{CASE_LOW} and
@code{CASE_HIGH} are @code{INTEGER_CST} nodes. These values will have
Otherwise, if both @code{CASE_LOW} and @code{CASE_HIGH} are defined, the
statement is a range of case labels. Such statements originate with the
extension that allows users to write things of the form:
-@example
+@smallexample
case 2 ... 5:
-@end example
+@end smallexample
The first value will be @code{CASE_LOW}, while the second will be
@code{CASE_HIGH}.
Used to represent an action that should take place upon exit from the
enclosing scope. Typically, these actions are calls to destructors for
-local objects, but back-ends cannot rely on this fact. If these nodes
+local objects, but back ends cannot rely on this fact. If these nodes
are in fact representing such destructors, @code{CLEANUP_DECL} will be
the @code{VAR_DECL} destroyed. Otherwise, @code{CLEANUP_DECL} will be
@code{NULL_TREE}. In any case, the @code{CLEANUP_EXPR} is the
should be run in the reverse order of the order in which the associated
@code{CLEANUP_STMT}s were encountered.
-@item COMPOUND_STMT
-
-Used to represent a brace-enclosed block. The first substatement is
-given by @code{COMPOUND_BODY}. Subsequent substatements are found by
-following the @code{TREE_CHAIN} link from one substatement to the next.
-
@item CONTINUE_STMT
Used to represent a @code{continue} statement. There are no additional
return statements, while @code{FOR_COND} and @code{FOR_EXPR} return
expressions.
-@item GOTO_STMT
+@item GOTO_EXPR
-Used to represent a @code{goto} statement. The @code{GOTO_DESTINATION}
-will usually be a @code{LABEL_DECL}. However, if the ``computed
-goto'' extension has been used, the @code{GOTO_DESTINATION} will be an
-arbitrary expression indicating the destination. This expression will
-always have pointer type.
+Used to represent a @code{goto} statement. The @code{GOTO_DESTINATION} will
+usually be a @code{LABEL_DECL}. However, if the ``computed goto'' extension
+has been used, the @code{GOTO_DESTINATION} will be an arbitrary expression
+indicating the destination. This expression will always have pointer type.
@item HANDLER
Used to represent a C++ @code{catch} block. The @code{HANDLER_TYPE}
is the type of exception that will be caught by this handler; it is
-equal (by pointer equality) to @code{CATCH_ALL_TYPE} if this handler
-is for all types. @code{HANDLER_PARMS} is the @code{DECL_STMT} for
-the catch parameter, and @code{HANDLER_BODY} is the
-@code{COMPOUND_STMT} for the block itself.
+equal (by pointer equality) to @code{NULL} if this handler is for all
+types. @code{HANDLER_PARMS} is the @code{DECL_STMT} for the catch
+parameter, and @code{HANDLER_BODY} is the code for the block itself.
@item IF_STMT
expression.
If the condition is a @code{TREE_LIST}, then the @code{TREE_PURPOSE} is
-a statement (usually a @code{DECL_STMT}). Each time the coondition is
+a statement (usually a @code{DECL_STMT}). Each time the condition is
evaluated, the statement should be executed. Then, the
@code{TREE_VALUE} should be used as the conditional expression itself.
This representation is used to handle C++ code like this:
-@example
-if (int i = 7) ...
-@end example
+@smallexample
+if (int i = 7) @dots{}
+@end smallexample
where there is a new local variable (or variables) declared within the
condition.
condition, while the @code{ELSE_CLAUSE} represents the statement given
by the @code{else} condition.
-@item LABEL_STMT
+@item LABEL_EXPR
Used to represent a label. The @code{LABEL_DECL} declared by this
-statement can be obtained with the @code{LABEL_STMT_LABEL} macro. The
+statement can be obtained with the @code{LABEL_EXPR_LABEL} macro. The
@code{IDENTIFIER_NODE} giving the name of the label can be obtained from
the @code{LABEL_DECL} with @code{DECL_NAME}.
If the function uses the G++ ``named return value'' extension, meaning
that the function has been defined like:
-@example
-S f(int) return s @{...@}
-@end example
+@smallexample
+S f(int) return s @{@dots{}@}
+@end smallexample
then there will be a @code{RETURN_INIT}. There is never a named
returned value for a constructor. The first argument to the
@code{RETURN_INIT} is the name of the object returned; the second
Used to represent a @code{return} statement. The @code{RETURN_EXPR} is
the expression returned; it will be @code{NULL_TREE} if the statement
was just
-@example
+@smallexample
return;
-@end example
-
-@item SCOPE_STMT
-
-A scope-statement represents the beginning or end of a scope. If
-@code{SCOPE_BEGIN_P} holds, this statement represents the beginning of a
-scope; if @code{SCOPE_END_P} holds this statement represents the end of
-a scope. On exit from a scope, all cleanups from @code{CLEANUP_STMT}s
-occurring in the scope must be run, in reverse order to the order in
-which they were encountered. If @code{SCOPE_NULLIFIED_P} or
-@code{SCOPE_NO_CLEANUPS_P} holds of the scope, back-ends should behave
-as if the @code{SCOPE_STMT} were not present at all.
+@end smallexample
@item SUBOBJECT
the expression on which the switch is occurring. See the documentation
for an @code{IF_STMT} for more information on the representation used
for the condition. The @code{SWITCH_BODY} is the body of the switch
-statement.
+statement. The @code{SWITCH_TYPE} is the original type of switch
+expression as given in the source, before any compiler conversions.
@item TRY_BLOCK
Used to represent a @code{try} block. The body of the try block is
@code{terminate} must be called.
@item USING_STMT
-Used to represent a @code{using} directive. The namespace is given by
-@code{USING_STMT_NAMESPACE}, which will be a NAMESPACE_DECL. This node
+Used to represent a @code{using} directive. The namespace is given by
+@code{USING_STMT_NAMESPACE}, which will be a NAMESPACE_DECL@. This node
is needed inside template functions, to implement using directives
during instantiation.
@end table
@c ---------------------------------------------------------------------
+@c Attributes
+@c ---------------------------------------------------------------------
+@node Attributes
+@section Attributes in trees
+@cindex attributes
+
+Attributes, as specified using the @code{__attribute__} keyword, are
+represented internally as a @code{TREE_LIST}. The @code{TREE_PURPOSE}
+is the name of the attribute, as an @code{IDENTIFIER_NODE}. The
+@code{TREE_VALUE} is a @code{TREE_LIST} of the arguments of the
+attribute, if any, or @code{NULL_TREE} if there are no arguments; the
+arguments are stored as the @code{TREE_VALUE} of successive entries in
+the list, and may be identifiers or expressions. The @code{TREE_CHAIN}
+of the attribute is the next attribute in a list of attributes applying
+to the same declaration or type, or @code{NULL_TREE} if there are no
+further attributes in the list.
+
+Attributes may be attached to declarations and to types; these
+attributes may be accessed with the following macros. All attributes
+are stored in this way, and many also cause other changes to the
+declaration or type or to other internal compiler data structures.
+
+@deftypefn {Tree Macro} tree DECL_ATTRIBUTES (tree @var{decl})
+This macro returns the attributes on the declaration @var{decl}.
+@end deftypefn
+
+@deftypefn {Tree Macro} tree TYPE_ATTRIBUTES (tree @var{type})
+This macro returns the attributes on the type @var{type}.
+@end deftypefn
+
+@c ---------------------------------------------------------------------
@c Expressions
@c ---------------------------------------------------------------------
@node Expression trees
@section Expressions
@cindex expression
+@findex TREE_TYPE
@findex TREE_OPERAND
@tindex INTEGER_CST
@findex TREE_INT_CST_HIGH
@findex tree_int_cst_equal
@tindex REAL_CST
@tindex COMPLEX_CST
+@tindex VECTOR_CST
@tindex STRING_CST
@findex TREE_STRING_LENGTH
@findex TREE_STRING_POINTER
@findex PTRMEM_CST_MEMBER
@tindex VAR_DECL
@tindex NEGATE_EXPR
+@tindex ABS_EXPR
@tindex BIT_NOT_EXPR
@tindex TRUTH_NOT_EXPR
+@tindex PREDECREMENT_EXPR
+@tindex PREINCREMENT_EXPR
+@tindex POSTDECREMENT_EXPR
+@tindex POSTINCREMENT_EXPR
@tindex ADDR_EXPR
@tindex INDIRECT_REF
@tindex FIX_TRUNC_EXPR
@tindex CONJ_EXPR
@tindex REALPART_EXPR
@tindex IMAGPART_EXPR
+@tindex NON_LVALUE_EXPR
@tindex NOP_EXPR
@tindex CONVERT_EXPR
@tindex THROW_EXPR
@tindex PLUS_EXPR
@tindex MINUS_EXPR
@tindex MULT_EXPR
+@tindex RDIV_EXPR
@tindex TRUNC_DIV_EXPR
+@tindex FLOOR_DIV_EXPR
+@tindex CEIL_DIV_EXPR
+@tindex ROUND_DIV_EXPR
@tindex TRUNC_MOD_EXPR
-@tindex RDIV_EXPR
+@tindex FLOOR_MOD_EXPR
+@tindex CEIL_MOD_EXPR
+@tindex ROUND_MOD_EXPR
+@tindex EXACT_DIV_EXPR
+@tindex ARRAY_REF
+@tindex ARRAY_RANGE_REF
@tindex LT_EXPR
@tindex LE_EXPR
@tindex GT_EXPR
@tindex GE_EXPR
@tindex EQ_EXPR
@tindex NE_EXPR
-@tindex INIT_EXPR
+@tindex ORDERED_EXPR
+@tindex UNORDERED_EXPR
+@tindex UNLT_EXPR
+@tindex UNLE_EXPR
+@tindex UNGT_EXPR
+@tindex UNGE_EXPR
+@tindex UNEQ_EXPR
+@tindex LTGT_EXPR
@tindex MODIFY_EXPR
+@tindex INIT_EXPR
@tindex COMPONENT_REF
@tindex COMPOUND_EXPR
@tindex COND_EXPR
@tindex CALL_EXPR
-@tindex CONSTRUCTOR
@tindex STMT_EXPR
@tindex BIND_EXPR
@tindex LOOP_EXPR
@tindex EXIT_EXPR
@tindex CLEANUP_POINT_EXPR
-@tindex ARRAY_REF
+@tindex CONSTRUCTOR
+@tindex COMPOUND_LITERAL_EXPR
+@tindex SAVE_EXPR
+@tindex TARGET_EXPR
+@tindex AGGR_INIT_EXPR
+@tindex VA_ARG_EXPR
The internal representation for expressions is for the most part quite
straightforward. However, there are a few facts that one must bear in
In what follows, some nodes that one might expect to always have type
@code{bool} are documented to have either integral or boolean type. At
-some point in the future, the C front-end may also make use of this same
+some point in the future, the C front end may also make use of this same
intermediate representation, and at this point these nodes will
certainly have integral type. The previous sentence is not meant to
-imply that the C++ front-end does not or will not give these nodes
+imply that the C++ front end does not or will not give these nodes
integral type.
Below, we list the various kinds of expression nodes. Except where
@code{TREE_OPERAND} macro. For example, to access the first operand to
a binary plus expression @code{expr}, use:
-@example
+@smallexample
TREE_OPERAND (expr, 0)
-@end example
+@end smallexample
@noindent
As this example indicates, the operands are zero-indexed.
constants is obtained with @code{TREE_TYPE}; they are not always of type
@code{int}. In particular, @code{char} constants are represented with
@code{INTEGER_CST} nodes. The value of the integer constant @code{e} is
-given by @example
+given by
+@smallexample
((TREE_INT_CST_HIGH (e) << HOST_BITS_PER_WIDE_INT)
+ TREE_INST_CST_LOW (e))
-@end example
+@end smallexample
@noindent
HOST_BITS_PER_WIDE_INT is at least thirty-two on all platforms. Both
@code{TREE_INT_CST_HIGH} and @code{TREE_INT_CST_LOW} return a
In general, the expression given above will overflow, so it should not
be used to calculate the value of the constant.
-The variable @code{integer_zero_node} is a integer constant with value
+The variable @code{integer_zero_node} is an integer constant with value
zero. Similarly, @code{integer_one_node} is an integer constant with
value one. The @code{size_zero_node} and @code{size_one_node} variables
are analogous, but have type @code{size_t} rather than @code{int}.
@code{TREE_REALPART} and @code{TREE_IMAGPART} return the real and the
imaginary parts respectively.
+@item VECTOR_CST
+These nodes are used to represent vector constants, whose parts are
+constant nodes. Each individual constant node is either an integer or a
+double constant node. The first operand is a @code{TREE_LIST} of the
+constant nodes and is accessed through @code{TREE_VECTOR_CST_ELTS}.
+
@item STRING_CST
These nodes represent string-constants. The @code{TREE_STRING_LENGTH}
returns the length of the string, as an @code{int}. The
present.
For wide string constants, the @code{TREE_STRING_LENGTH} is the number
-of wide characters in the string, and the @code{TREE_STRING_POINTER}
+of bytes in the string, and the @code{TREE_STRING_POINTER}
points to an array of the bytes of the string, as represented on the
target system (that is, as integers in the target endianness). Wide and
non-wide string constants are distinguished only by the @code{TREE_TYPE}
or @code{UNION_TYPE} within which the pointer points), and the
@code{PTRMEM_CST_MEMBER} is the declaration for the pointed to object.
Note that the @code{DECL_CONTEXT} for the @code{PTRMEM_CST_MEMBER} is in
-general different from from the @code{PTRMEM_CST_CLASS}. For example,
+general different from the @code{PTRMEM_CST_CLASS}. For example,
given:
-@example
+@smallexample
struct B @{ int i; @};
struct D : public B @{@};
int D::*dp = &D::i;
-@end example
+@end smallexample
@noindent
The @code{PTRMEM_CST_CLASS} for @code{&D::i} is @code{D}, even though
the @code{DECL_CONTEXT} for the @code{PTRMEM_CST_MEMBER} is @code{B},
integer and floating-point types. The type of negation can be
determined by looking at the type of the expression.
+The behavior of this operation on signed arithmetic overflow is
+controlled by the @code{flag_wrapv} and @code{flag_trapv} variables.
+
+@item ABS_EXPR
+These nodes represent the absolute value of the single operand, for
+both integer and floating-point types. This is typically used to
+implement the @code{abs}, @code{labs} and @code{llabs} builtins for
+integer types, and the @code{fabs}, @code{fabsf} and @code{fabsl}
+builtins for floating point types. The type of abs operation can
+be determined by looking at the type of the expression.
+
+This node is not used for complex types. To represent the modulus
+or complex abs of a complex value, use the @code{BUILT_IN_CABS},
+@code{BUILT_IN_CABSF} or @code{BUILT_IN_CABSL} builtins, as used
+to implement the C99 @code{cabs}, @code{cabsf} and @code{cabsl}
+built-in functions.
+
@item BIT_NOT_EXPR
These nodes represent bitwise complement, and will always have integral
type. The only operand is the value to be complemented.
@item TRUTH_NOT_EXPR
These nodes represent logical negation, and will always have integral
-(or boolean) type. The operand is the value being negated.
+(or boolean) type. The operand is the value being negated. The type
+of the operand and that of the result are always of @code{BOOLEAN_TYPE}
+or @code{INTEGER_TYPE}.
@item PREDECREMENT_EXPR
@itemx PREINCREMENT_EXPR
the complete expression will have a floating-point type.
FIXME: How is the operand supposed to be rounded? Is this dependent on
--mieee?
+@option{-mieee}?
@item COMPLEX_EXPR
These nodes are used to represent complex numbers constructed from two
These nodes represent the conjugate of their operand.
@item REALPART_EXPR
-@item IMAGPART_EXPR
+@itemx IMAGPART_EXPR
These nodes represent respectively the real and the imaginary parts
of complex numbers (their sole argument).
@item NON_LVALUE_EXPR
These nodes indicate that their one and only operand is not an lvalue.
-A back-end can treat these identically to the single operand.
+A back end can treat these identically to the single operand.
@item NOP_EXPR
These nodes are used to represent conversions that do not require any
exception. However, there is one implicit action not represented in
that expression; namely the call to @code{__throw}. This function takes
no arguments. If @code{setjmp}/@code{longjmp} exceptions are used, the
-function @code{__sjthrow} is called instead. The normal GCC back-end
+function @code{__sjthrow} is called instead. The normal GCC back end
uses the function @code{emit_throw} to generate this code; you can
examine this function to see what needs to be done.
shift. Right shift should be treated as arithmetic, i.e., the
high-order bits should be zero-filled when the expression has unsigned
type and filled with the sign bit when the expression has signed type.
+Note that the result is undefined if the second operand is larger
+than the first operand's type size.
+
@item BIT_IOR_EXPR
@itemx BIT_XOR_EXPR
These nodes represent logical and and logical or, respectively. These
operators are not strict; i.e., the second operand is evaluated only if
the value of the expression is not determined by evaluation of the first
-operand. The type of the operands, and the result type, is always of
-boolean or integral type.
+operand. The type of the operands and that of the result are always of
+@code{BOOLEAN_TYPE} or @code{INTEGER_TYPE}.
@item TRUTH_AND_EXPR
@itemx TRUTH_OR_EXPR
@itemx TRUTH_XOR_EXPR
These nodes represent logical and, logical or, and logical exclusive or.
They are strict; both arguments are always evaluated. There are no
-corresponding operators in C or C++, but the front-end will sometimes
+corresponding operators in C or C++, but the front end will sometimes
generate these expressions anyhow, if it can tell that strictness does
-not matter.
+not matter. The type of the operands and that of the result are
+always of @code{BOOLEAN_TYPE} or @code{INTEGER_TYPE}.
@itemx PLUS_EXPR
@itemx MINUS_EXPR
@itemx MULT_EXPR
-@itemx TRUNC_DIV_EXPR
-@itemx TRUNC_MOD_EXPR
-@itemx RDIV_EXPR
These nodes represent various binary arithmetic operations.
Respectively, these operations are addition, subtraction (of the second
-operand from the first), multiplication, integer division, integer
-remainder, and floating-point division. The operands to the first three
-of these may have either integral or floating type, but there will never
-be case in which one operand is of floating type and the other is of
-integral type.
+operand from the first) and multiplication. Their operands may have
+either integral or floating type, but there will never be case in which
+one operand is of floating type and the other is of integral type.
+
+The behavior of these operations on signed arithmetic overflow is
+controlled by the @code{flag_wrapv} and @code{flag_trapv} variables.
+
+@item RDIV_EXPR
+This node represents a floating point division operation.
+
+@item TRUNC_DIV_EXPR
+@itemx FLOOR_DIV_EXPR
+@itemx CEIL_DIV_EXPR
+@itemx ROUND_DIV_EXPR
+These nodes represent integer division operations that return an integer
+result. @code{TRUNC_DIV_EXPR} rounds towards zero, @code{FLOOR_DIV_EXPR}
+rounds towards negative infinity, @code{CEIL_DIV_EXPR} rounds towards
+positive infinity and @code{ROUND_DIV_EXPR} rounds to the closest integer.
+Integer division in C and C++ is truncating, i.e@. @code{TRUNC_DIV_EXPR}.
+
+The behavior of these operations on signed arithmetic overflow, when
+dividing the minimum signed integer by minus one, is controlled by the
+@code{flag_wrapv} and @code{flag_trapv} variables.
+
+@item TRUNC_MOD_EXPR
+@itemx FLOOR_MOD_EXPR
+@itemx CEIL_MOD_EXPR
+@itemx ROUND_MOD_EXPR
+These nodes represent the integer remainder or modulus operation.
+The integer modulus of two operands @code{a} and @code{b} is
+defined as @code{a - (a/b)*b} where the division calculated using
+the corresponding division operator. Hence for @code{TRUNC_MOD_EXPR}
+this definition assumes division using truncation towards zero, i.e@.
+@code{TRUNC_DIV_EXPR}. Integer remainder in C and C++ uses truncating
+division, i.e@. @code{TRUNC_MOD_EXPR}.
-The result of a @code{TRUNC_DIV_EXPR} is always rounded towards zero.
-The @code{TRUNC_MOD_EXPR} of two operands @code{a} and @code{b} is
-always @code{a - a/b} where the division is as if computed by a
-@code{TRUNC_DIV_EXPR}.
+@item EXACT_DIV_EXPR
+The @code{EXACT_DIV_EXPR} code is used to represent integer divisions where
+the numerator is known to be an exact multiple of the denominator. This
+allows the backend to choose between the faster of @code{TRUNC_DIV_EXPR},
+@code{CEIL_DIV_EXPR} and @code{FLOOR_DIV_EXPR} for the current target.
@item ARRAY_REF
These nodes represent array accesses. The first operand is the array;
the second is the index. To calculate the address of the memory
accessed, you must scale the index by the size of the type of the array
elements. The type of these expressions must be the type of a component of
-the array.
+the array. The third and fourth operands are used after gimplification
+to represent the lower bound and component size but should not be used
+directly; call @code{array_ref_low_bound} and @code{array_ref_element_size}
+instead.
@item ARRAY_RANGE_REF
These nodes represent access to a range (or ``slice'') of an array. The
type is the same as that of the first operand. The range of that array
type determines the amount of data these expressions access.
-@item EXACT_DIV_EXPR
-Document.
-
@item LT_EXPR
@itemx LE_EXPR
@itemx GT_EXPR
@itemx GE_EXPR
@itemx EQ_EXPR
@itemx NE_EXPR
-
These nodes represent the less than, less than or equal to, greater
than, greater than or equal to, equal, and not equal comparison
operators. The first and second operand with either be both of integral
type or both of floating type. The result type of these expressions
-will always be of integral or boolean type.
+will always be of integral or boolean type. These operations return
+the result type's zero value for false, and the result type's one value
+for true.
+
+For floating point comparisons, if we honor IEEE NaNs and either operand
+is NaN, then @code{NE_EXPR} always returns true and the remaining operators
+always return false. On some targets, comparisons against an IEEE NaN,
+other than equality and inequality, may generate a floating point exception.
+
+@item ORDERED_EXPR
+@itemx UNORDERED_EXPR
+These nodes represent non-trapping ordered and unordered comparison
+operators. These operations take two floating point operands and
+determine whether they are ordered or unordered relative to each other.
+If either operand is an IEEE NaN, their comparison is defined to be
+unordered, otherwise the comparison is defined to be ordered. The
+result type of these expressions will always be of integral or boolean
+type. These operations return the result type's zero value for false,
+and the result type's one value for true.
+
+@item UNLT_EXPR
+@itemx UNLE_EXPR
+@itemx UNGT_EXPR
+@itemx UNGE_EXPR
+@itemx UNEQ_EXPR
+@itemx LTGT_EXPR
+These nodes represent the unordered comparison operators.
+These operations take two floating point operands and determine whether
+the operands are unordered or are less than, less than or equal to,
+greater than, greater than or equal to, or equal respectively. For
+example, @code{UNLT_EXPR} returns true if either operand is an IEEE
+NaN or the first operand is less than the second. With the possible
+exception of @code{LTGT_EXPR}, all of these operations are guaranteed
+not to generate a floating point exception. The result
+type of these expressions will always be of integral or boolean type.
+These operations return the result type's zero value for false,
+and the result type's one value for true.
@item MODIFY_EXPR
These nodes represent assignment. The left-hand side is the first
other lvalue.
These nodes are used to represent not only assignment with @samp{=} but
-also compount assignments (like @samp{+=}), by reduction to @samp{=}
+also compound assignments (like @samp{+=}), by reduction to @samp{=}
assignment. In other words, the representation for @samp{i += 3} looks
just like that for @samp{i = i + 3}.
@item COMPONENT_REF
These nodes represent non-static data member accesses. The first
operand is the object (rather than a pointer to it); the second operand
-is the @code{FIELD_DECL} for the data member.
+is the @code{FIELD_DECL} for the data member. The third operand represents
+the byte offset of the field, but should not be used directly; call
+@code{component_ref_field_offset} instead.
@item COMPOUND_EXPR
These nodes represent comma-expressions. The first operand is an
@item COND_EXPR
These nodes represent @code{?:} expressions. The first operand
-is of boolean or integral type. If it evaluates to a non-zero value,
+is of boolean or integral type. If it evaluates to a nonzero value,
the second operand should be evaluated, and returned as the value of the
expression. Otherwise, the third operand is evaluated, and returned as
-the value of the expression. As a GNU extension, the middle operand of
-the @code{?:} operator may be omitted in the source, like this:
-
-@example
-x ? : 3
-@end example
-@noindent
-which is equivalent to
-
-@example
-x ? x : 3
-@end example
-
-@noindent
-assuming that @code{x} is an expression without side-effects. However,
-in the case that the first operation causes side effects, the
-side-effects occur only once. Consumers of the internal representation
-do not need to worry about this oddity; the second operand will be
-always be present in the internal representation.
+the value of the expression.
+
+The second operand must have the same type as the entire expression,
+unless it unconditionally throws an exception or calls a noreturn
+function, in which case it should have void type. The same constraints
+apply to the third operand. This allows array bounds checks to be
+represented conveniently as @code{(i >= 0 && i < 10) ? i : abort()}.
+
+As a GNU extension, the C language front-ends allow the second
+operand of the @code{?:} operator may be omitted in the source.
+For example, @code{x ? : 3} is equivalent to @code{x ? x : 3},
+assuming that @code{x} is an expression without side-effects.
+In the tree representation, however, the second operand is always
+present, possibly protected by @code{SAVE_EXPR} if the first
+argument does cause side-effects.
@item CALL_EXPR
These nodes are used to represent calls to functions, including
@item STMT_EXPR
These nodes are used to represent GCC's statement-expression extension.
The statement-expression extension allows code like this:
-@example
+@smallexample
int f() @{ return (@{ int j; j = 3; j + 7; @}); @}
-@end example
+@end smallexample
In other words, an sequence of statements may occur where a single
expression would normally appear. The @code{STMT_EXPR} node represents
such an expression. The @code{STMT_EXPR_STMT} gives the statement
-contained in the expression; this is always a @code{COMPOUND_STMT}. The
-value of the expression is the value of the last sub-statement in the
-@code{COMPOUND_STMT}. More precisely, the value is the value computed
-by the last @code{EXPR_STMT} in the outermost scope of the
-@code{COMPOUND_STMT}. For example, in:
-@example
+contained in the expression. The value of the expression is the value
+of the last sub-statement in the body. More precisely, the value is the
+value computed by the last statement nested inside @code{BIND_EXPR},
+@code{TRY_FINALLY_EXPR}, or @code{TRY_CATCH_EXPR}. For example, in:
+@smallexample
(@{ 3; @})
-@end example
+@end smallexample
the value is @code{3} while in:
-@example
+@smallexample
(@{ if (x) @{ 3; @} @})
-@end example
-(represented by a nested @code{COMPOUND_STMT}), there is no value. If
-the @code{STMT_EXPR} does not yield a value, it's type will be
-@code{void}.
+@end smallexample
+there is no value. If the @code{STMT_EXPR} does not yield a value,
+it's type will be @code{void}.
@item BIND_EXPR
These nodes represent local blocks. The first operand is a list of
-temporary variables, connected via their @code{TREE_CHAIN} field. These
-will never require cleanups. The scope of these variables is just the
-body of the @code{BIND_EXPR}. The body of the @code{BIND_EXPR} is the
+variables, connected via their @code{TREE_CHAIN} field. These will
+never require cleanups. The scope of these variables is just the body
+of the @code{BIND_EXPR}. The body of the @code{BIND_EXPR} is the
second operand.
@item LOOP_EXPR
@item EXIT_EXPR
These nodes represent conditional exits from the nearest enclosing
@code{LOOP_EXPR}. The single operand is the condition; if it is
-non-zero, then the loop should be exited. An @code{EXIT_EXPR} will only
+nonzero, then the loop should be exited. An @code{EXIT_EXPR} will only
appear within a @code{LOOP_EXPR}.
@item CLEANUP_POINT_EXPR
@item CONSTRUCTOR
These nodes represent the brace-enclosed initializers for a structure or
-array. The first operand is reserved for use by the back-end. The
+array. The first operand is reserved for use by the back end. The
second operand is a @code{TREE_LIST}. If the @code{TREE_TYPE} of the
@code{CONSTRUCTOR} is a @code{RECORD_TYPE} or @code{UNION_TYPE}, then
the @code{TREE_PURPOSE} of each node in the @code{TREE_LIST} will be a
@code{FIELD_DECL} and the @code{TREE_VALUE} of each node will be the
-expression used to initialize that field. You should not depend on the
-fields appearing in any particular order, nor should you assume that all
-fields will be represented. Unrepresented fields may be assigned any
-value.
+expression used to initialize that field.
If the @code{TREE_TYPE} of the @code{CONSTRUCTOR} is an
@code{ARRAY_TYPE}, then the @code{TREE_PURPOSE} of each element in the
@code{TREE_PURPOSE} is @code{NULL_TREE}, then the initializer is for the
next available array element.
-Conceptually, before any initialization is done, the entire area of
-storage is initialized to zero.
+In the front end, you should not depend on the fields appearing in any
+particular order. However, in the middle end, fields must appear in
+declaration order. You should not assume that all fields will be
+represented. Unrepresented fields will be set to zero.
+
+@item COMPOUND_LITERAL_EXPR
+@findex COMPOUND_LITERAL_EXPR_DECL_STMT
+@findex COMPOUND_LITERAL_EXPR_DECL
+These nodes represent ISO C99 compound literals. The
+@code{COMPOUND_LITERAL_EXPR_DECL_STMT} is a @code{DECL_STMT}
+containing an anonymous @code{VAR_DECL} for
+the unnamed object represented by the compound literal; the
+@code{DECL_INITIAL} of that @code{VAR_DECL} is a @code{CONSTRUCTOR}
+representing the brace-enclosed list of initializers in the compound
+literal. That anonymous @code{VAR_DECL} can also be accessed directly
+by the @code{COMPOUND_LITERAL_EXPR_DECL} macro.
@item SAVE_EXPR
@item TARGET_EXPR
A @code{TARGET_EXPR} represents a temporary object. The first operand
is a @code{VAR_DECL} for the temporary variable. The second operand is
-the initializer for the temporary. The initializer is evaluated, and
-copied (bitwise) into the temporary.
+the initializer for the temporary. The initializer is evaluated and,
+if non-void, copied (bitwise) into the temporary. If the initializer
+is void, that means that it will perform the initialization itself.
Often, a @code{TARGET_EXPR} occurs on the right-hand side of an
assignment, or as the second operand to a comma-expression which is
@item AGGR_INIT_EXPR
An @code{AGGR_INIT_EXPR} represents the initialization as the return
value of a function call, or as the result of a constructor. An
-@code{AGGR_INIT_EXPR} will only appear as the second operand of a
-@code{TARGET_EXPR}. The first operand to the @code{AGGR_INIT_EXPR} is
-the address of a function to call, just as in a @code{CALL_EXPR}. The
-second operand are the arguments to pass that function, as a
-@code{TREE_LIST}, again in a manner similar to that of a
-@code{CALL_EXPR}. The value of the expression is that returned by the
-function.
+@code{AGGR_INIT_EXPR} will only appear as a full-expression, or as the
+second operand of a @code{TARGET_EXPR}. The first operand to the
+@code{AGGR_INIT_EXPR} is the address of a function to call, just as in
+a @code{CALL_EXPR}. The second operand are the arguments to pass that
+function, as a @code{TREE_LIST}, again in a manner similar to that of
+a @code{CALL_EXPR}.
If @code{AGGR_INIT_VIA_CTOR_P} holds of the @code{AGGR_INIT_EXPR}, then
the initialization is via a constructor call. The address of the third
operand of the @code{AGGR_INIT_EXPR}, which is always a @code{VAR_DECL},
is taken, and this value replaces the first argument in the argument
-list. In this case, the value of the expression is the @code{VAR_DECL}
-given by the third operand to the @code{AGGR_INIT_EXPR}; constructors do
-not return a value.
+list.
+
+In either case, the expression is void.
+
+@item VA_ARG_EXPR
+This node is used to implement support for the C/C++ variable argument-list
+mechanism. It represents expressions like @code{va_arg (ap, type)}.
+Its @code{TREE_TYPE} yields the tree representation for @code{type} and
+its sole argument yields the representation for @code{ap}.
@end table