summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/doc/c-tree.texi
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/gcc/doc/c-tree.texi')
-rw-r--r--contrib/gcc/doc/c-tree.texi162
1 files changed, 91 insertions, 71 deletions
diff --git a/contrib/gcc/doc/c-tree.texi b/contrib/gcc/doc/c-tree.texi
index fbc90fa3..d1afe65 100644
--- a/contrib/gcc/doc/c-tree.texi
+++ b/contrib/gcc/doc/c-tree.texi
@@ -1,4 +1,4 @@
-@c Copyright (c) 1999, 2000, 2001, 2002, 2003 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.
@@ -98,24 +98,24 @@ Many macros behave as predicates. Many, although not all, of these
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 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.
@@ -124,7 +124,7 @@ functions described here. In particular, no guarantee is given that the
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
@@ -555,11 +555,9 @@ 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
@@ -790,7 +788,7 @@ This predicate holds whenever its argument represents a class-type with
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
@@ -873,15 +871,15 @@ This predicate holds if the declaration was implicitly generated by the
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.
@@ -1021,34 +1019,35 @@ will always return the function itself, and @code{OVL_NEXT} will always
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
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.
@@ -1379,7 +1378,7 @@ the expression has been omitted. A substatement may in fact be a list
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;
@{
@@ -1398,7 +1397,7 @@ void process_stmt (stmt)
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
@@ -1409,18 +1408,18 @@ several statements chained together.
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''
@@ -1452,9 +1451,9 @@ the same type as the condition expression in the switch statement.
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}.
@@ -1547,10 +1546,10 @@ This is used for branch prediction.
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{COMPOUND_STMT} for the
+block itself.
@item IF_STMT
@@ -1563,9 +1562,9 @@ 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
+@smallexample
if (int i = 7) @dots{}
-@end example
+@end smallexample
where there is a new local variable (or variables) declared within the
condition.
@@ -1585,9 +1584,9 @@ 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
+@smallexample
S f(int) return s @{@dots{}@}
-@end example
+@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
@@ -1602,9 +1601,9 @@ constructed in the place where the object will be returned.
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
+@end smallexample
@item SCOPE_STMT
@@ -1721,6 +1720,7 @@ This macro returns the attributes on the type @var{type}.
@findex PTRMEM_CST_MEMBER
@tindex VAR_DECL
@tindex NEGATE_EXPR
+@tindex ABS_EXPR
@tindex BIT_NOT_EXPR
@tindex TRUTH_NOT_EXPR
@tindex ADDR_EXPR
@@ -1803,9 +1803,9 @@ noted otherwise, the operands to an expression are accessed using the
@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.
@@ -1819,10 +1819,11 @@ These nodes represent integer constants. Note that the type of these
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
@@ -1893,11 +1894,11 @@ or @code{UNION_TYPE} within which the pointer points), and the
Note that the @code{DECL_CONTEXT} for the @code{PTRMEM_CST_MEMBER} is in
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},
@@ -1913,6 +1914,23 @@ These nodes represent unary negation of the single operand, for both
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.
@@ -1974,7 +1992,7 @@ real part and the second operand is the imaginary part.
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).
@@ -2066,6 +2084,9 @@ The @code{TRUNC_MOD_EXPR} of two operands @code{a} and @code{b} is
always @code{a - (a/b)*b} where the division is as if computed by a
@code{TRUNC_DIV_EXPR}.
+The behavior of these operations on signed arithmetic overflow is
+controlled by the @code{flag_wrapv} and @code{flag_trapv} variables.
+
@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
@@ -2161,9 +2182,9 @@ sites.
@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
@@ -2172,13 +2193,13 @@ 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
+@smallexample
(@{ 3; @})
-@end example
+@end smallexample
the value is @code{3} while in:
-@example
+@smallexample
(@{ if (x) @{ 3; @} @})
-@end example
+@end smallexample
(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}.
@@ -2214,10 +2235,7 @@ 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
@@ -2227,8 +2245,10 @@ again, the @code{TREE_VALUE} is the corresponding initializer. If 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
OpenPOWER on IntegriCloud