OSDN Git Service

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