diff options
Diffstat (limited to 'contrib/gcc/doc/c-tree.texi')
-rw-r--r-- | contrib/gcc/doc/c-tree.texi | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/contrib/gcc/doc/c-tree.texi b/contrib/gcc/doc/c-tree.texi index 35da90a..8f5a5bb 100644 --- a/contrib/gcc/doc/c-tree.texi +++ b/contrib/gcc/doc/c-tree.texi @@ -84,8 +84,8 @@ we will refer to trees in ordinary type, rather than in @code{this 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. @@ -1771,6 +1771,7 @@ This macro returns the attributes on the type @var{type}. @tindex CLEANUP_POINT_EXPR @tindex ARRAY_REF @tindex VTABLE_REF +@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 @@ -2062,7 +2063,7 @@ integral type. 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 +always @code{a - (a/b)*b} where the division is as if computed by a @code{TRUNC_DIV_EXPR}. @item ARRAY_REF @@ -2126,25 +2127,21 @@ These nodes represent @code{?:} expressions. The first operand 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 @@ -2312,4 +2309,10 @@ The first operand is the expression that computes the vtable reference. The second operand is the @code{VAR_DECL} of the vtable. The third operand is an @code{INTEGER_CST} of the byte offset into the vtable. +@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 |