1 /* Perform the semantic phase of parsing, i.e., the process of
2 building tree structure, checking semantic consistency, and
3 building RTL. These routines are used both during actual parsing
4 and during the instantiation of template functions.
6 Copyright (C) 1998, 1999, 2000, 2001, 2002,
7 2003 Free Software Foundation, Inc.
8 Written by Mark Mitchell (mmitchell@usa.net) based on code found
9 formerly in parse.y and pt.c.
11 This file is part of GCC.
13 GCC is free software; you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2, or (at your option)
18 GCC is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with GCC; see the file COPYING. If not, write to the Free
25 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
30 #include "coretypes.h"
34 #include "tree-inline.h"
45 /* There routines provide a modular interface to perform many parsing
46 operations. They may therefore be used during actual parsing, or
47 during template instantiation, which may be regarded as a
48 degenerate form of parsing. Since the current g++ parser is
49 lacking in several respects, and will be reimplemented, we are
50 attempting to move most code that is not directly related to
51 parsing into this file; that will make implementing the new parser
52 much easier since it will be able to make use of these routines. */
54 static tree maybe_convert_cond
PARAMS ((tree
));
55 static tree simplify_aggr_init_exprs_r
PARAMS ((tree
*, int *, void *));
56 static void emit_associated_thunks
PARAMS ((tree
));
57 static void genrtl_try_block
PARAMS ((tree
));
58 static void genrtl_eh_spec_block
PARAMS ((tree
));
59 static void genrtl_handler
PARAMS ((tree
));
60 static void cp_expand_stmt
PARAMS ((tree
));
61 static void genrtl_start_function
PARAMS ((tree
));
62 static void genrtl_finish_function
PARAMS ((tree
));
63 static tree clear_decl_rtl
PARAMS ((tree
*, int *, void *));
65 /* Finish processing the COND, the SUBSTMT condition for STMT. */
67 #define FINISH_COND(COND, STMT, SUBSTMT) \
69 if (last_tree != (STMT)) \
71 RECHAIN_STMTS (STMT, SUBSTMT); \
72 if (!processing_template_decl) \
74 (COND) = build_tree_list (SUBSTMT, COND); \
82 /* Deferred Access Checking Overview
83 ---------------------------------
85 Most C++ expressions and declarations require access checking
86 to be performed during parsing. However, in several cases,
87 this has to be treated differently.
89 For member declarations, access checking has to be deferred
90 until more information about the declaration is known. For
102 When we are parsing the function return type `A::X', we don't
103 really know if this is allowed until we parse the function name.
105 Furthermore, some contexts require that access checking is
106 never performed at all. These include class heads, and template
109 Typical use of access checking functions is described here:
111 1. When we enter a context that requires certain access checking
112 mode, the function `push_deferring_access_checks' is called with
113 DEFERRING argument specifying the desired mode. Access checking
114 may be performed immediately (dk_no_deferred), deferred
115 (dk_deferred), or not performed (dk_no_check).
117 2. When a declaration such as a type, or a variable, is encountered,
118 the function `perform_or_defer_access_check' is called. It
119 maintains a TREE_LIST of all deferred checks.
121 3. The global `current_class_type' or `current_function_decl' is then
122 setup by the parser. `enforce_access' relies on these information
125 4. Upon exiting the context mentioned in step 1,
126 `perform_deferred_access_checks' is called to check all declaration
127 stored in the TREE_LIST. `pop_deferring_access_checks' is then
128 called to restore the previous access checking mode.
130 In case of parsing error, we simply call `pop_deferring_access_checks'
131 without `perform_deferred_access_checks'. */
133 /* Data for deferred access checking. */
134 static GTY(()) deferred_access
*deferred_access_stack
;
135 static GTY(()) deferred_access
*deferred_access_free_list
;
137 /* Save the current deferred access states and start deferred
138 access checking iff DEFER_P is true. */
140 void push_deferring_access_checks (deferring_kind deferring
)
144 /* For context like template instantiation, access checking
145 disabling applies to all nested context. */
146 if (deferred_access_stack
147 && deferred_access_stack
->deferring_access_checks_kind
== dk_no_check
)
148 deferring
= dk_no_check
;
150 /* Recycle previously used free store if available. */
151 if (deferred_access_free_list
)
153 d
= deferred_access_free_list
;
154 deferred_access_free_list
= d
->next
;
157 d
= (deferred_access
*) ggc_alloc (sizeof (deferred_access
));
159 d
->next
= deferred_access_stack
;
160 d
->deferred_access_checks
= NULL_TREE
;
161 d
->deferring_access_checks_kind
= deferring
;
162 deferred_access_stack
= d
;
165 /* Resume deferring access checks again after we stopped doing
168 void resume_deferring_access_checks (void)
170 if (deferred_access_stack
->deferring_access_checks_kind
== dk_no_deferred
)
171 deferred_access_stack
->deferring_access_checks_kind
= dk_deferred
;
174 /* Stop deferring access checks. */
176 void stop_deferring_access_checks (void)
178 if (deferred_access_stack
->deferring_access_checks_kind
== dk_deferred
)
179 deferred_access_stack
->deferring_access_checks_kind
= dk_no_deferred
;
182 /* Discard the current deferred access checks and restore the
185 void pop_deferring_access_checks (void)
187 deferred_access
*d
= deferred_access_stack
;
188 deferred_access_stack
= d
->next
;
190 /* Remove references to access checks TREE_LIST. */
191 d
->deferred_access_checks
= NULL_TREE
;
193 /* Store in free list for later use. */
194 d
->next
= deferred_access_free_list
;
195 deferred_access_free_list
= d
;
198 /* Returns a TREE_LIST representing the deferred checks.
199 The TREE_PURPOSE of each node is the type through which the
200 access occurred; the TREE_VALUE is the declaration named.
203 tree
get_deferred_access_checks (void)
205 return deferred_access_stack
->deferred_access_checks
;
208 /* Take current deferred checks and combine with the
209 previous states if we also defer checks previously.
210 Otherwise perform checks now. */
212 void pop_to_parent_deferring_access_checks (void)
214 tree deferred_check
= get_deferred_access_checks ();
215 deferred_access
*d1
= deferred_access_stack
;
216 deferred_access
*d2
= deferred_access_stack
->next
;
217 deferred_access
*d3
= deferred_access_stack
->next
->next
;
219 /* Temporary swap the order of the top two states, just to make
220 sure the garbage collector will not reclaim the memory during
222 deferred_access_stack
= d2
;
226 for ( ; deferred_check
; deferred_check
= TREE_CHAIN (deferred_check
))
227 /* Perform deferred check if required. */
228 perform_or_defer_access_check (TREE_PURPOSE (deferred_check
),
229 TREE_VALUE (deferred_check
));
231 deferred_access_stack
= d1
;
234 pop_deferring_access_checks ();
237 /* Perform the deferred access checks.
239 After performing the checks, we still have to keep the list
240 `deferred_access_stack->deferred_access_checks' since we may want
241 to check access for them again later in a different context.
248 A::X A::a, x; // No error for `A::a', error for `x'
250 We have to perform deferred access of `A::X', first with `A::a',
253 void perform_deferred_access_checks (void)
256 for (deferred_check
= deferred_access_stack
->deferred_access_checks
;
258 deferred_check
= TREE_CHAIN (deferred_check
))
260 enforce_access (TREE_PURPOSE (deferred_check
),
261 TREE_VALUE (deferred_check
));
264 /* Defer checking the accessibility of DECL, when looked up in
267 void perform_or_defer_access_check (tree class_type
, tree decl
)
271 /* If we are not supposed to defer access checks, just check now. */
272 if (deferred_access_stack
->deferring_access_checks_kind
== dk_no_deferred
)
274 enforce_access (class_type
, decl
);
277 /* Exit if we are in a context that no access checking is performed. */
278 else if (deferred_access_stack
->deferring_access_checks_kind
== dk_no_check
)
281 /* See if we are already going to perform this check. */
282 for (check
= deferred_access_stack
->deferred_access_checks
;
284 check
= TREE_CHAIN (check
))
285 if (TREE_VALUE (check
) == decl
286 && TYPE_P (TREE_PURPOSE (check
))
287 && same_type_p (TREE_PURPOSE (check
), class_type
))
289 /* If not, record the check. */
290 deferred_access_stack
->deferred_access_checks
291 = tree_cons (class_type
, decl
,
292 deferred_access_stack
->deferred_access_checks
);
295 /* Returns nonzero if the current statement is a full expression,
296 i.e. temporaries created during that statement should be destroyed
297 at the end of the statement. */
300 stmts_are_full_exprs_p ()
302 return current_stmt_tree ()->stmts_are_full_exprs_p
;
305 /* Returns the stmt_tree (if any) to which statements are currently
306 being added. If there is no active statement-tree, NULL is
313 ? &cfun
->language
->base
.x_stmt_tree
314 : &scope_chain
->x_stmt_tree
);
317 /* Nonzero if TYPE is an anonymous union or struct type. We have to use a
318 flag for this because "A union for which objects or pointers are
319 declared is not an anonymous union" [class.union]. */
322 anon_aggr_type_p (node
)
325 return ANON_AGGR_TYPE_P (node
);
328 /* Finish a scope. */
333 tree block
= NULL_TREE
;
335 if (stmts_are_full_exprs_p ())
337 tree scope_stmts
= NULL_TREE
;
339 block
= poplevel (kept_level_p (), 1, 0);
340 if (!processing_template_decl
)
342 /* This needs to come after the poplevel so that partial scopes
343 are properly nested. */
344 scope_stmts
= add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0);
347 SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmts
)) = block
;
348 SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmts
)) = block
;
356 /* Begin a new scope. */
359 do_pushlevel (scope_kind sk
)
361 if (stmts_are_full_exprs_p ())
363 if (!processing_template_decl
)
364 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
369 /* Finish a goto-statement. */
372 finish_goto_stmt (destination
)
375 if (TREE_CODE (destination
) == IDENTIFIER_NODE
)
376 destination
= lookup_label (destination
);
378 /* We warn about unused labels with -Wunused. That means we have to
379 mark the used labels as used. */
380 if (TREE_CODE (destination
) == LABEL_DECL
)
381 TREE_USED (destination
) = 1;
383 if (TREE_CODE (destination
) != LABEL_DECL
)
384 /* We don't inline calls to functions with computed gotos.
385 Those functions are typically up to some funny business,
386 and may be depending on the labels being at particular
387 addresses, or some such. */
388 DECL_UNINLINABLE (current_function_decl
) = 1;
390 check_goto (destination
);
392 return add_stmt (build_stmt (GOTO_STMT
, destination
));
395 /* COND is the condition-expression for an if, while, etc.,
396 statement. Convert it to a boolean value, if appropriate. */
399 maybe_convert_cond (cond
)
402 /* Empty conditions remain empty. */
406 /* Wait until we instantiate templates before doing conversion. */
407 if (processing_template_decl
)
410 /* Do the conversion. */
411 cond
= convert_from_reference (cond
);
412 return condition_conversion (cond
);
415 /* Finish an expression-statement, whose EXPRESSION is as indicated. */
418 finish_expr_stmt (expr
)
422 tree expr_type
= NULL_TREE
;;
424 if (expr
!= NULL_TREE
)
426 if (!processing_template_decl
427 && !(stmts_are_full_exprs_p ())
428 && ((TREE_CODE (TREE_TYPE (expr
)) == ARRAY_TYPE
430 || TREE_CODE (TREE_TYPE (expr
)) == FUNCTION_TYPE
))
431 expr
= default_conversion (expr
);
433 /* Remember the type of the expression. */
434 expr_type
= TREE_TYPE (expr
);
436 if (stmts_are_full_exprs_p ())
437 expr
= convert_to_void (expr
, "statement");
439 r
= add_stmt (build_stmt (EXPR_STMT
, expr
));
444 /* This was an expression-statement, so we save the type of the
446 last_expr_type
= expr_type
;
452 /* Begin an if-statement. Returns a newly created IF_STMT if
459 do_pushlevel (sk_block
);
460 r
= build_stmt (IF_STMT
, NULL_TREE
, NULL_TREE
, NULL_TREE
);
465 /* Process the COND of an if-statement, which may be given by
469 finish_if_stmt_cond (cond
, if_stmt
)
473 cond
= maybe_convert_cond (cond
);
474 FINISH_COND (cond
, if_stmt
, IF_COND (if_stmt
));
477 /* Finish the then-clause of an if-statement, which may be given by
481 finish_then_clause (if_stmt
)
484 RECHAIN_STMTS (if_stmt
, THEN_CLAUSE (if_stmt
));
488 /* Begin the else-clause of an if-statement. */
495 /* Finish the else-clause of an if-statement, which may be given by
499 finish_else_clause (if_stmt
)
502 RECHAIN_STMTS (if_stmt
, ELSE_CLAUSE (if_stmt
));
505 /* Finish an if-statement. */
514 /* Begin a while-statement. Returns a newly created WHILE_STMT if
521 r
= build_stmt (WHILE_STMT
, NULL_TREE
, NULL_TREE
);
523 do_pushlevel (sk_block
);
527 /* Process the COND of a while-statement, which may be given by
531 finish_while_stmt_cond (cond
, while_stmt
)
535 cond
= maybe_convert_cond (cond
);
536 if (processing_template_decl
)
537 /* Don't mess with condition decls in a template. */
538 FINISH_COND (cond
, while_stmt
, WHILE_COND (while_stmt
));
539 else if (getdecls () == NULL_TREE
)
540 /* It was a simple condition; install it. */
541 WHILE_COND (while_stmt
) = cond
;
544 /* If there was a declaration in the condition, we can't leave it
548 while (true) { A x = 42; if (!x) break; } */
550 WHILE_COND (while_stmt
) = boolean_true_node
;
552 if_stmt
= begin_if_stmt ();
553 cond
= build_unary_op (TRUTH_NOT_EXPR
, cond
, 0);
554 finish_if_stmt_cond (cond
, if_stmt
);
555 finish_break_stmt ();
556 finish_then_clause (if_stmt
);
561 /* Finish a while-statement, which may be given by WHILE_STMT. */
564 finish_while_stmt (while_stmt
)
568 RECHAIN_STMTS (while_stmt
, WHILE_BODY (while_stmt
));
572 /* Begin a do-statement. Returns a newly created DO_STMT if
578 tree r
= build_stmt (DO_STMT
, NULL_TREE
, NULL_TREE
);
583 /* Finish the body of a do-statement, which may be given by DO_STMT. */
586 finish_do_body (do_stmt
)
589 RECHAIN_STMTS (do_stmt
, DO_BODY (do_stmt
));
592 /* Finish a do-statement, which may be given by DO_STMT, and whose
593 COND is as indicated. */
596 finish_do_stmt (cond
, do_stmt
)
600 cond
= maybe_convert_cond (cond
);
601 DO_COND (do_stmt
) = cond
;
605 /* Finish a return-statement. The EXPRESSION returned, if any, is as
609 finish_return_stmt (expr
)
614 expr
= check_return_expr (expr
);
615 if (!processing_template_decl
)
617 if (DECL_DESTRUCTOR_P (current_function_decl
))
619 /* Similarly, all destructors must run destructors for
620 base-classes before returning. So, all returns in a
621 destructor get sent to the DTOR_LABEL; finish_function emits
622 code to return a value there. */
623 return finish_goto_stmt (dtor_label
);
626 r
= add_stmt (build_stmt (RETURN_STMT
, expr
));
632 /* Begin a for-statement. Returns a new FOR_STMT if appropriate. */
639 r
= build_stmt (FOR_STMT
, NULL_TREE
, NULL_TREE
,
640 NULL_TREE
, NULL_TREE
);
641 NEW_FOR_SCOPE_P (r
) = flag_new_for_scope
> 0;
642 if (NEW_FOR_SCOPE_P (r
))
643 do_pushlevel (sk_for
);
649 /* Finish the for-init-statement of a for-statement, which may be
650 given by FOR_STMT. */
653 finish_for_init_stmt (for_stmt
)
656 if (last_tree
!= for_stmt
)
657 RECHAIN_STMTS (for_stmt
, FOR_INIT_STMT (for_stmt
));
658 do_pushlevel (sk_block
);
661 /* Finish the COND of a for-statement, which may be given by
665 finish_for_cond (cond
, for_stmt
)
669 cond
= maybe_convert_cond (cond
);
670 if (processing_template_decl
)
671 /* Don't mess with condition decls in a template. */
672 FINISH_COND (cond
, for_stmt
, FOR_COND (for_stmt
));
673 else if (getdecls () == NULL_TREE
)
674 /* It was a simple condition; install it. */
675 FOR_COND (for_stmt
) = cond
;
678 /* If there was a declaration in the condition, we can't leave it
680 for (; A x = 42;) { }
682 for (;;) { A x = 42; if (!x) break; } */
684 FOR_COND (for_stmt
) = NULL_TREE
;
686 if_stmt
= begin_if_stmt ();
687 cond
= build_unary_op (TRUTH_NOT_EXPR
, cond
, 0);
688 finish_if_stmt_cond (cond
, if_stmt
);
689 finish_break_stmt ();
690 finish_then_clause (if_stmt
);
695 /* Finish the increment-EXPRESSION in a for-statement, which may be
696 given by FOR_STMT. */
699 finish_for_expr (expr
, for_stmt
)
703 FOR_EXPR (for_stmt
) = expr
;
706 /* Finish the body of a for-statement, which may be given by
707 FOR_STMT. The increment-EXPR for the loop must be
711 finish_for_stmt (for_stmt
)
714 /* Pop the scope for the body of the loop. */
716 RECHAIN_STMTS (for_stmt
, FOR_BODY (for_stmt
));
717 if (NEW_FOR_SCOPE_P (for_stmt
))
722 /* Finish a break-statement. */
727 return add_stmt (build_break_stmt ());
730 /* Finish a continue-statement. */
733 finish_continue_stmt ()
735 return add_stmt (build_continue_stmt ());
738 /* Begin a switch-statement. Returns a new SWITCH_STMT if
745 do_pushlevel (sk_block
);
746 r
= build_stmt (SWITCH_STMT
, NULL_TREE
, NULL_TREE
, NULL_TREE
);
751 /* Finish the cond of a switch-statement. */
754 finish_switch_cond (cond
, switch_stmt
)
758 tree orig_type
= NULL
;
759 if (!processing_template_decl
)
763 /* Convert the condition to an integer or enumeration type. */
764 cond
= build_expr_type_conversion (WANT_INT
| WANT_ENUM
, cond
, true);
765 if (cond
== NULL_TREE
)
767 error ("switch quantity not an integer");
768 cond
= error_mark_node
;
770 orig_type
= TREE_TYPE (cond
);
771 if (cond
!= error_mark_node
)
773 cond
= default_conversion (cond
);
774 cond
= fold (build1 (CLEANUP_POINT_EXPR
, TREE_TYPE (cond
), cond
));
777 if (cond
!= error_mark_node
)
779 index
= get_unwidened (cond
, NULL_TREE
);
780 /* We can't strip a conversion from a signed type to an unsigned,
781 because if we did, int_fits_type_p would do the wrong thing
782 when checking case values for being in range,
783 and it's too hard to do the right thing. */
784 if (TREE_UNSIGNED (TREE_TYPE (cond
))
785 == TREE_UNSIGNED (TREE_TYPE (index
)))
789 FINISH_COND (cond
, switch_stmt
, SWITCH_COND (switch_stmt
));
790 SWITCH_TYPE (switch_stmt
) = orig_type
;
791 push_switch (switch_stmt
);
794 /* Finish the body of a switch-statement, which may be given by
795 SWITCH_STMT. The COND to switch on is indicated. */
798 finish_switch_stmt (switch_stmt
)
801 RECHAIN_STMTS (switch_stmt
, SWITCH_BODY (switch_stmt
));
807 /* Generate the RTL for T, which is a TRY_BLOCK. */
815 expand_eh_region_start ();
816 expand_stmt (TRY_STMTS (t
));
817 expand_eh_region_end_cleanup (TRY_HANDLERS (t
));
821 if (!FN_TRY_BLOCK_P (t
))
822 emit_line_note (input_filename
, input_line
);
824 expand_eh_region_start ();
825 expand_stmt (TRY_STMTS (t
));
827 if (FN_TRY_BLOCK_P (t
))
829 expand_start_all_catch ();
830 in_function_try_handler
= 1;
831 expand_stmt (TRY_HANDLERS (t
));
832 in_function_try_handler
= 0;
833 expand_end_all_catch ();
837 expand_start_all_catch ();
838 expand_stmt (TRY_HANDLERS (t
));
839 expand_end_all_catch ();
844 /* Generate the RTL for T, which is an EH_SPEC_BLOCK. */
847 genrtl_eh_spec_block (t
)
850 expand_eh_region_start ();
851 expand_stmt (EH_SPEC_STMTS (t
));
852 expand_eh_region_end_allowed (EH_SPEC_RAISES (t
),
853 build_call (call_unexpected_node
,
854 tree_cons (NULL_TREE
,
859 /* Begin a try-block. Returns a newly-created TRY_BLOCK if
865 tree r
= build_stmt (TRY_BLOCK
, NULL_TREE
, NULL_TREE
);
870 /* Likewise, for a function-try-block. */
873 begin_function_try_block ()
875 tree r
= build_stmt (TRY_BLOCK
, NULL_TREE
, NULL_TREE
);
876 FN_TRY_BLOCK_P (r
) = 1;
881 /* Finish a try-block, which may be given by TRY_BLOCK. */
884 finish_try_block (try_block
)
887 RECHAIN_STMTS (try_block
, TRY_STMTS (try_block
));
890 /* Finish the body of a cleanup try-block, which may be given by
894 finish_cleanup_try_block (try_block
)
897 RECHAIN_STMTS (try_block
, TRY_STMTS (try_block
));
900 /* Finish an implicitly generated try-block, with a cleanup is given
904 finish_cleanup (cleanup
, try_block
)
908 TRY_HANDLERS (try_block
) = cleanup
;
909 CLEANUP_P (try_block
) = 1;
912 /* Likewise, for a function-try-block. */
915 finish_function_try_block (try_block
)
918 if (TREE_CHAIN (try_block
)
919 && TREE_CODE (TREE_CHAIN (try_block
)) == CTOR_INITIALIZER
)
921 /* Chain the compound statement after the CTOR_INITIALIZER. */
922 TREE_CHAIN (TREE_CHAIN (try_block
)) = last_tree
;
923 /* And make the CTOR_INITIALIZER the body of the try-block. */
924 RECHAIN_STMTS (try_block
, TRY_STMTS (try_block
));
927 RECHAIN_STMTS (try_block
, TRY_STMTS (try_block
));
928 in_function_try_handler
= 1;
931 /* Finish a handler-sequence for a try-block, which may be given by
935 finish_handler_sequence (try_block
)
938 RECHAIN_STMTS (try_block
, TRY_HANDLERS (try_block
));
939 check_handlers (TRY_HANDLERS (try_block
));
942 /* Likewise, for a function-try-block. */
945 finish_function_handler_sequence (try_block
)
948 in_function_try_handler
= 0;
949 RECHAIN_STMTS (try_block
, TRY_HANDLERS (try_block
));
950 check_handlers (TRY_HANDLERS (try_block
));
953 /* Generate the RTL for T, which is a HANDLER. */
959 genrtl_do_pushlevel ();
960 if (!processing_template_decl
)
961 expand_start_catch (HANDLER_TYPE (t
));
962 expand_stmt (HANDLER_BODY (t
));
963 if (!processing_template_decl
)
967 /* Begin a handler. Returns a HANDLER if appropriate. */
973 r
= build_stmt (HANDLER
, NULL_TREE
, NULL_TREE
);
975 /* Create a binding level for the eh_info and the exception object
977 do_pushlevel (sk_catch
);
981 /* Finish the handler-parameters for a handler, which may be given by
982 HANDLER. DECL is the declaration for the catch parameter, or NULL
983 if this is a `catch (...)' clause. */
986 finish_handler_parms (decl
, handler
)
990 tree type
= NULL_TREE
;
991 if (processing_template_decl
)
995 decl
= pushdecl (decl
);
996 decl
= push_template_decl (decl
);
997 add_decl_stmt (decl
);
998 RECHAIN_STMTS (handler
, HANDLER_PARMS (handler
));
999 type
= TREE_TYPE (decl
);
1003 type
= expand_start_catch_block (decl
);
1005 HANDLER_TYPE (handler
) = type
;
1008 /* Finish a handler, which may be given by HANDLER. The BLOCKs are
1009 the return value from the matching call to finish_handler_parms. */
1012 finish_handler (handler
)
1015 if (!processing_template_decl
)
1016 expand_end_catch_block ();
1018 RECHAIN_STMTS (handler
, HANDLER_BODY (handler
));
1021 /* Begin a compound-statement. If HAS_NO_SCOPE is nonzero, the
1022 compound-statement does not define a scope. Returns a new
1023 COMPOUND_STMT if appropriate. */
1026 begin_compound_stmt (has_no_scope
)
1032 r
= build_stmt (COMPOUND_STMT
, NULL_TREE
);
1034 if (last_tree
&& TREE_CODE (last_tree
) == TRY_BLOCK
)
1039 COMPOUND_STMT_NO_SCOPE (r
) = 1;
1041 last_expr_type
= NULL_TREE
;
1044 do_pushlevel (is_try
? sk_try
: sk_block
);
1046 /* Normally, we try hard to keep the BLOCK for a
1047 statement-expression. But, if it's a statement-expression with
1048 a scopeless block, there's nothing to keep, and we don't want
1049 to accidentally keep a block *inside* the scopeless block. */
1050 keep_next_level (0);
1055 /* Finish a compound-statement, which may be given by COMPOUND_STMT.
1056 If HAS_NO_SCOPE is nonzero, the compound statement does not define
1060 finish_compound_stmt (has_no_scope
, compound_stmt
)
1072 RECHAIN_STMTS (compound_stmt
, COMPOUND_BODY (compound_stmt
));
1074 /* When we call finish_stmt we will lose LAST_EXPR_TYPE. But, since
1075 the precise purpose of that variable is store the type of the
1076 last expression statement within the last compound statement, we
1077 preserve the value. */
1085 /* Finish an asm-statement, whose components are a CV_QUALIFIER, a
1086 STRING, some OUTPUT_OPERANDS, some INPUT_OPERANDS, and some
1090 finish_asm_stmt (cv_qualifier
, string
, output_operands
,
1091 input_operands
, clobbers
)
1094 tree output_operands
;
1095 tree input_operands
;
1101 if (cv_qualifier
!= NULL_TREE
1102 && cv_qualifier
!= ridpointers
[(int) RID_VOLATILE
])
1104 warning ("%s qualifier ignored on asm",
1105 IDENTIFIER_POINTER (cv_qualifier
));
1106 cv_qualifier
= NULL_TREE
;
1109 if (!processing_template_decl
)
1115 for (t
= input_operands
; t
; t
= TREE_CHAIN (t
))
1117 tree converted_operand
1118 = decay_conversion (TREE_VALUE (t
));
1120 /* If the type of the operand hasn't been determined (e.g.,
1121 because it involves an overloaded function), then issue
1122 an error message. There's no context available to
1123 resolve the overloading. */
1124 if (TREE_TYPE (converted_operand
) == unknown_type_node
)
1126 error ("type of asm operand `%E' could not be determined",
1128 converted_operand
= error_mark_node
;
1130 TREE_VALUE (t
) = converted_operand
;
1133 ninputs
= list_length (input_operands
);
1134 noutputs
= list_length (output_operands
);
1136 for (i
= 0, t
= output_operands
; t
; t
= TREE_CHAIN (t
), ++i
)
1141 const char *constraint
;
1144 constraint
= TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t
)));
1145 operand
= TREE_VALUE (t
);
1147 if (!parse_output_constraint (&constraint
,
1148 i
, ninputs
, noutputs
,
1153 /* By marking this operand as erroneous, we will not try
1154 to process this operand again in expand_asm_operands. */
1155 TREE_VALUE (t
) = error_mark_node
;
1159 /* If the operand is a DECL that is going to end up in
1160 memory, assume it is addressable. This is a bit more
1161 conservative than it would ideally be; the exact test is
1162 buried deep in expand_asm_operands and depends on the
1163 DECL_RTL for the OPERAND -- which we don't have at this
1165 if (!allows_reg
&& DECL_P (operand
))
1166 cxx_mark_addressable (operand
);
1170 r
= build_stmt (ASM_STMT
, cv_qualifier
, string
,
1171 output_operands
, input_operands
,
1173 return add_stmt (r
);
1176 /* Finish a label with the indicated NAME. */
1179 finish_label_stmt (name
)
1182 tree decl
= define_label (input_filename
, input_line
, name
);
1183 return add_stmt (build_stmt (LABEL_STMT
, decl
));
1186 /* Finish a series of declarations for local labels. G++ allows users
1187 to declare "local" labels, i.e., labels with scope. This extension
1188 is useful when writing code involving statement-expressions. */
1191 finish_label_decl (name
)
1194 tree decl
= declare_local_label (name
);
1195 add_decl_stmt (decl
);
1198 /* When DECL goes out of scope, make sure that CLEANUP is executed. */
1201 finish_decl_cleanup (decl
, cleanup
)
1205 add_stmt (build_stmt (CLEANUP_STMT
, decl
, cleanup
));
1208 /* If the current scope exits with an exception, run CLEANUP. */
1211 finish_eh_cleanup (cleanup
)
1214 tree r
= build_stmt (CLEANUP_STMT
, NULL_TREE
, cleanup
);
1215 CLEANUP_EH_ONLY (r
) = 1;
1219 /* The MEM_INITS is a list of mem-initializers, in reverse of the
1220 order they were written by the user. Each node is as for
1221 emit_mem_initializers. */
1224 finish_mem_initializers (tree mem_inits
)
1226 /* Reorder the MEM_INITS so that they are in the order they appeared
1227 in the source program. */
1228 mem_inits
= nreverse (mem_inits
);
1230 if (processing_template_decl
)
1231 add_stmt (build_min_nt (CTOR_INITIALIZER
, mem_inits
));
1233 emit_mem_initializers (mem_inits
);
1236 /* Returns the stack of SCOPE_STMTs for the current function. */
1239 current_scope_stmt_stack ()
1241 return &cfun
->language
->base
.x_scope_stmt_stack
;
1244 /* Finish a parenthesized expression EXPR. */
1247 finish_parenthesized_expr (expr
)
1250 if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (expr
))))
1251 /* This inhibits warnings in c_common_truthvalue_conversion. */
1252 C_SET_EXP_ORIGINAL_CODE (expr
, ERROR_MARK
);
1254 if (TREE_CODE (expr
) == OFFSET_REF
)
1255 /* [expr.unary.op]/3 The qualified id of a pointer-to-member must not be
1256 enclosed in parentheses. */
1257 PTRMEM_OK_P (expr
) = 0;
1261 /* Finish a reference to a non-static data member (DECL) that is not
1262 preceded by `.' or `->'. */
1265 finish_non_static_data_member (tree decl
, tree qualifying_scope
)
1267 my_friendly_assert (TREE_CODE (decl
) == FIELD_DECL
, 20020909);
1269 if (current_class_ptr
== NULL_TREE
)
1271 if (current_function_decl
1272 && DECL_STATIC_FUNCTION_P (current_function_decl
))
1273 cp_error_at ("invalid use of member `%D' in static member function",
1276 cp_error_at ("invalid use of non-static data member `%D'", decl
);
1277 error ("from this location");
1279 return error_mark_node
;
1281 TREE_USED (current_class_ptr
) = 1;
1282 if (processing_template_decl
)
1283 return build_min (COMPONENT_REF
, TREE_TYPE (decl
),
1284 current_class_ref
, DECL_NAME (decl
));
1287 tree access_type
= current_class_type
;
1288 tree object
= current_class_ref
;
1291 && !DERIVED_FROM_P (context_for_name_lookup (decl
), access_type
))
1293 access_type
= TYPE_CONTEXT (access_type
);
1294 while (access_type
&& DECL_P (access_type
))
1295 access_type
= DECL_CONTEXT (access_type
);
1300 cp_error_at ("object missing in reference to `%D'",
1302 error ("from this location");
1303 return error_mark_node
;
1306 perform_or_defer_access_check (access_type
, decl
);
1308 /* If the data member was named `C::M', convert `*this' to `C'
1310 if (qualifying_scope
)
1312 tree binfo
= NULL_TREE
;
1313 object
= build_scoped_ref (object
, qualifying_scope
,
1317 return build_class_member_access_expr (object
, decl
,
1318 /*access_path=*/NULL_TREE
,
1319 /*preserve_reference=*/false);
1323 /* Begin a statement-expression. The value returned must be passed to
1324 finish_stmt_expr. */
1329 /* If we're outside a function, we won't have a statement-tree to
1330 work with. But, if we see a statement-expression we need to
1332 if (! cfun
&& !last_tree
)
1333 begin_stmt_tree (&scope_chain
->x_saved_tree
);
1335 keep_next_level (1);
1336 /* If we're building a statement tree, then the upcoming compound
1337 statement will be chained onto the tree structure, starting at
1338 last_tree. We return last_tree so that we can later unhook the
1339 compound statement. */
1343 /* Used when beginning a statement-expression outside function scope.
1344 For example, when handling a file-scope initializer, we use this
1348 begin_global_stmt_expr ()
1350 if (! cfun
&& !last_tree
)
1351 begin_stmt_tree (&scope_chain
->x_saved_tree
);
1353 keep_next_level (1);
1355 return last_tree
? last_tree
: expand_start_stmt_expr(/*has_scope=*/1);
1358 /* Finish the STMT_EXPR last begun with begin_global_stmt_expr. */
1361 finish_global_stmt_expr (stmt_expr
)
1364 stmt_expr
= expand_end_stmt_expr (stmt_expr
);
1367 && TREE_CHAIN (scope_chain
->x_saved_tree
) == NULL_TREE
)
1368 finish_stmt_tree (&scope_chain
->x_saved_tree
);
1373 /* Finish a statement-expression. RTL_EXPR should be the value
1374 returned by the previous begin_stmt_expr; EXPR is the
1375 statement-expression. Returns an expression representing the
1376 statement-expression. */
1379 finish_stmt_expr (rtl_expr
)
1384 /* If the last thing in the statement-expression was not an
1385 expression-statement, then it has type `void'. */
1386 if (!last_expr_type
)
1387 last_expr_type
= void_type_node
;
1388 result
= build_min (STMT_EXPR
, last_expr_type
, last_tree
);
1389 TREE_SIDE_EFFECTS (result
) = 1;
1391 /* Remove the compound statement from the tree structure; it is
1392 now saved in the STMT_EXPR. */
1393 last_tree
= rtl_expr
;
1394 TREE_CHAIN (last_tree
) = NULL_TREE
;
1396 /* If we created a statement-tree for this statement-expression,
1399 && TREE_CHAIN (scope_chain
->x_saved_tree
) == NULL_TREE
)
1400 finish_stmt_tree (&scope_chain
->x_saved_tree
);
1405 /* Generate an expression for `FN (ARGS)'.
1407 If DISALLOW_VIRTUAL is true, the call to FN will be not generated
1408 as a virtual call, even if FN is virtual. (This flag is set when
1409 encountering an expression where the function name is explicitly
1410 qualified. For example a call to `X::f' never generates a virtual
1413 Returns code for the call. */
1416 finish_call_expr (tree fn
, tree args
, bool disallow_virtual
)
1418 if (fn
== error_mark_node
|| args
== error_mark_node
)
1419 return error_mark_node
;
1421 if (processing_template_decl
)
1422 return build_nt (CALL_EXPR
, fn
, args
, NULL_TREE
);
1424 /* ARGS should be a list of arguments. */
1425 my_friendly_assert (!args
|| TREE_CODE (args
) == TREE_LIST
,
1428 /* A reference to a member function will appear as an overloaded
1429 function (rather than a BASELINK) if an unqualified name was used
1431 if (!BASELINK_P (fn
) && is_overloaded_fn (fn
))
1435 if (TREE_CODE (fn
) == TEMPLATE_ID_EXPR
)
1436 f
= get_first_fn (TREE_OPERAND (fn
, 0));
1438 f
= get_first_fn (fn
);
1439 if (DECL_FUNCTION_MEMBER_P (f
))
1441 tree type
= currently_open_derived_class (DECL_CONTEXT (f
));
1442 fn
= build_baselink (TYPE_BINFO (type
),
1444 fn
, /*optype=*/NULL_TREE
);
1448 if (BASELINK_P (fn
))
1452 /* A call to a member function. From [over.call.func]:
1454 If the keyword this is in scope and refers to the class of
1455 that member function, or a derived class thereof, then the
1456 function call is transformed into a qualified function call
1457 using (*this) as the postfix-expression to the left of the
1458 . operator.... [Otherwise] a contrived object of type T
1459 becomes the implied object argument.
1461 This paragraph is unclear about this situation:
1463 struct A { void f(); };
1464 struct B : public A {};
1465 struct C : public A { void g() { B::f(); }};
1467 In particular, for `B::f', this paragraph does not make clear
1468 whether "the class of that member function" refers to `A' or
1469 to `B'. We believe it refers to `B'. */
1470 if (current_class_type
1471 && DERIVED_FROM_P (BINFO_TYPE (BASELINK_ACCESS_BINFO (fn
)),
1473 && current_class_ref
)
1474 object
= current_class_ref
;
1477 tree representative_fn
;
1479 representative_fn
= BASELINK_FUNCTIONS (fn
);
1480 if (TREE_CODE (representative_fn
) == TEMPLATE_ID_EXPR
)
1481 representative_fn
= TREE_OPERAND (representative_fn
, 0);
1482 representative_fn
= get_first_fn (representative_fn
);
1483 object
= build_dummy_object (DECL_CONTEXT (representative_fn
));
1486 return build_new_method_call (object
, fn
, args
, NULL_TREE
,
1488 ? LOOKUP_NONVIRTUAL
: 0));
1490 else if (is_overloaded_fn (fn
))
1491 /* A call to a namespace-scope function. */
1492 return build_new_function_call (fn
, args
);
1493 else if (TREE_CODE (fn
) == PSEUDO_DTOR_EXPR
)
1498 error ("arguments to destructor are not allowed");
1499 /* Mark the pseudo-destructor call as having side-effects so
1500 that we do not issue warnings about its use. */
1501 result
= build1 (NOP_EXPR
,
1503 TREE_OPERAND (fn
, 0));
1504 TREE_SIDE_EFFECTS (result
) = 1;
1507 else if (CLASS_TYPE_P (TREE_TYPE (fn
)))
1509 /* If the "function" is really an object of class type, it might
1510 have an overloaded `operator ()'. */
1512 result
= build_new_op (CALL_EXPR
, LOOKUP_NORMAL
, fn
, args
, NULL_TREE
);
1517 /* A call where the function is unknown. */
1518 return build_function_call (fn
, args
);
1521 /* Finish a call to a postfix increment or decrement or EXPR. (Which
1522 is indicated by CODE, which should be POSTINCREMENT_EXPR or
1523 POSTDECREMENT_EXPR.) */
1526 finish_increment_expr (expr
, code
)
1528 enum tree_code code
;
1530 /* If we get an OFFSET_REF, turn it into what it really means (e.g.,
1531 a COMPONENT_REF). This way if we've got, say, a reference to a
1532 static member that's being operated on, we don't end up trying to
1533 find a member operator for the class it's in. */
1535 if (TREE_CODE (expr
) == OFFSET_REF
)
1536 expr
= resolve_offset_ref (expr
);
1537 return build_x_unary_op (code
, expr
);
1540 /* Finish a use of `this'. Returns an expression for `this'. */
1547 if (current_class_ptr
)
1549 result
= current_class_ptr
;
1551 else if (current_function_decl
1552 && DECL_STATIC_FUNCTION_P (current_function_decl
))
1554 error ("`this' is unavailable for static member functions");
1555 result
= error_mark_node
;
1559 if (current_function_decl
)
1560 error ("invalid use of `this' in non-member function");
1562 error ("invalid use of `this' at top level");
1563 result
= error_mark_node
;
1569 /* Finish a member function call using OBJECT and ARGS as arguments to
1570 FN. Returns an expression for the call. */
1573 finish_object_call_expr (fn
, object
, args
)
1578 if (DECL_DECLARES_TYPE_P (fn
))
1580 if (processing_template_decl
)
1581 /* This can happen on code like:
1584 template <class T> void f(T t) {
1588 We just grab the underlying IDENTIFIER. */
1589 fn
= DECL_NAME (fn
);
1592 error ("calling type `%T' like a method", fn
);
1593 return error_mark_node
;
1597 if (processing_template_decl
)
1598 return build_nt (CALL_EXPR
,
1599 build_nt (COMPONENT_REF
, object
, fn
),
1603 return build_method_call (object
, fn
, args
, NULL_TREE
, LOOKUP_NORMAL
);
1605 return build_new_method_call (object
, fn
, args
, NULL_TREE
, LOOKUP_NORMAL
);
1608 /* Finish a qualified member function call using OBJECT and ARGS as
1609 arguments to FN. Returns an expression for the call. */
1612 finish_qualified_object_call_expr (fn
, object
, args
)
1617 return build_scoped_method_call (object
, TREE_OPERAND (fn
, 0),
1618 TREE_OPERAND (fn
, 1), args
);
1621 /* Finish a pseudo-destructor expression. If SCOPE is NULL, the
1622 expression was of the form `OBJECT.~DESTRUCTOR' where DESTRUCTOR is
1623 the TYPE for the type given. If SCOPE is non-NULL, the expression
1624 was of the form `OBJECT.SCOPE::~DESTRUCTOR'. */
1627 finish_pseudo_destructor_expr (object
, scope
, destructor
)
1632 if (destructor
== error_mark_node
)
1633 return error_mark_node
;
1635 my_friendly_assert (TYPE_P (destructor
), 20010905);
1637 if (!processing_template_decl
)
1639 if (scope
== error_mark_node
)
1641 error ("invalid qualifying scope in pseudo-destructor name");
1642 return error_mark_node
;
1645 if (!same_type_p (TREE_TYPE (object
), destructor
))
1647 error ("`%E' is not of type `%T'", object
, destructor
);
1648 return error_mark_node
;
1652 return build (PSEUDO_DTOR_EXPR
, void_type_node
, object
, scope
, destructor
);
1655 /* Finish an expression of the form CODE EXPR. */
1658 finish_unary_op_expr (code
, expr
)
1659 enum tree_code code
;
1662 tree result
= build_x_unary_op (code
, expr
);
1663 /* Inside a template, build_x_unary_op does not fold the
1664 expression. So check whether the result is folded before
1665 setting TREE_NEGATED_INT. */
1666 if (code
== NEGATE_EXPR
&& TREE_CODE (expr
) == INTEGER_CST
1667 && TREE_CODE (result
) == INTEGER_CST
1668 && !TREE_UNSIGNED (TREE_TYPE (result
))
1669 && INT_CST_LT (result
, integer_zero_node
))
1670 TREE_NEGATED_INT (result
) = 1;
1671 overflow_warning (result
);
1675 /* Finish a compound-literal expression. TYPE is the type to which
1676 the INITIALIZER_LIST is being cast. */
1679 finish_compound_literal (type
, initializer_list
)
1681 tree initializer_list
;
1683 tree compound_literal
;
1685 /* Build a CONSTRUCTOR for the INITIALIZER_LIST. */
1686 compound_literal
= build_constructor (NULL_TREE
, initializer_list
);
1687 /* Mark it as a compound-literal. */
1688 TREE_HAS_CONSTRUCTOR (compound_literal
) = 1;
1689 if (processing_template_decl
)
1690 TREE_TYPE (compound_literal
) = type
;
1693 /* Check the initialization. */
1694 compound_literal
= digest_init (type
, compound_literal
, NULL
);
1695 /* If the TYPE was an array type with an unknown bound, then we can
1696 figure out the dimension now. For example, something like:
1700 implies that the array has two elements. */
1701 if (TREE_CODE (type
) == ARRAY_TYPE
&& !COMPLETE_TYPE_P (type
))
1702 complete_array_type (type
, compound_literal
, 1);
1705 return compound_literal
;
1708 /* Return the declaration for the function-name variable indicated by
1712 finish_fname (tree id
)
1716 decl
= fname_decl (C_RID_CODE (id
), id
);
1717 if (processing_template_decl
)
1718 decl
= build_min_nt (LOOKUP_EXPR
, DECL_NAME (decl
));
1722 /* Begin a function definition declared with DECL_SPECS, ATTRIBUTES,
1723 and DECLARATOR. Returns nonzero if the function-declaration is
1727 begin_function_definition (decl_specs
, attributes
, declarator
)
1732 if (!start_function (decl_specs
, declarator
, attributes
, SF_DEFAULT
))
1735 /* The things we're about to see are not directly qualified by any
1736 template headers we've seen thus far. */
1737 reset_specialization ();
1742 /* Finish a translation unit. */
1745 finish_translation_unit ()
1747 /* In case there were missing closebraces,
1748 get us back to the global binding level. */
1750 while (current_namespace
!= global_namespace
)
1753 /* Do file scope __FUNCTION__ et al. */
1754 finish_fname_decls ();
1757 /* Finish a template type parameter, specified as AGGR IDENTIFIER.
1758 Returns the parameter. */
1761 finish_template_type_parm (aggr
, identifier
)
1765 if (aggr
!= class_type_node
)
1767 pedwarn ("template type parameters must use the keyword `class' or `typename'");
1768 aggr
= class_type_node
;
1771 return build_tree_list (aggr
, identifier
);
1774 /* Finish a template template parameter, specified as AGGR IDENTIFIER.
1775 Returns the parameter. */
1778 finish_template_template_parm (aggr
, identifier
)
1782 tree decl
= build_decl (TYPE_DECL
, identifier
, NULL_TREE
);
1783 tree tmpl
= build_lang_decl (TEMPLATE_DECL
, identifier
, NULL_TREE
);
1784 DECL_TEMPLATE_PARMS (tmpl
) = current_template_parms
;
1785 DECL_TEMPLATE_RESULT (tmpl
) = decl
;
1786 DECL_ARTIFICIAL (decl
) = 1;
1787 end_template_decl ();
1789 my_friendly_assert (DECL_TEMPLATE_PARMS (tmpl
), 20010110);
1791 return finish_template_type_parm (aggr
, tmpl
);
1794 /* ARGUMENT is the default-argument value for a template template
1795 parameter. If ARGUMENT is invalid, issue error messages and return
1796 the ERROR_MARK_NODE. Otherwise, ARGUMENT itself is returned. */
1799 check_template_template_default_arg (tree argument
)
1801 if (TREE_CODE (argument
) != TEMPLATE_DECL
1802 && TREE_CODE (argument
) != TEMPLATE_TEMPLATE_PARM
1803 && TREE_CODE (argument
) != TYPE_DECL
1804 && TREE_CODE (argument
) != UNBOUND_CLASS_TEMPLATE
)
1806 error ("invalid default template argument");
1807 return error_mark_node
;
1813 /* Finish a parameter list, indicated by PARMS. If ELLIPSIS is
1814 nonzero, the parameter list was terminated by a `...'. */
1817 finish_parmlist (parms
, ellipsis
)
1823 /* We mark the PARMS as a parmlist so that declarator processing can
1824 disambiguate certain constructs. */
1825 TREE_PARMLIST (parms
) = 1;
1826 /* We do not append void_list_node here, but leave it to grokparms
1828 PARMLIST_ELLIPSIS_P (parms
) = ellipsis
;
1833 /* Begin a class definition, as indicated by T. */
1836 begin_class_definition (t
)
1839 if (t
== error_mark_node
)
1840 return error_mark_node
;
1842 if (processing_template_parmlist
)
1844 error ("definition of `%#T' inside template parameter list", t
);
1845 return error_mark_node
;
1847 /* A non-implicit typename comes from code like:
1849 template <typename T> struct A {
1850 template <typename U> struct A<T>::B ...
1852 This is erroneous. */
1853 else if (TREE_CODE (t
) == TYPENAME_TYPE
)
1855 error ("invalid definition of qualified type `%T'", t
);
1856 t
= error_mark_node
;
1859 if (t
== error_mark_node
|| ! IS_AGGR_TYPE (t
))
1861 t
= make_aggr_type (RECORD_TYPE
);
1862 pushtag (make_anon_name (), t
, 0);
1865 /* If this type was already complete, and we see another definition,
1867 if (COMPLETE_TYPE_P (t
))
1869 error ("redefinition of `%#T'", t
);
1870 cp_error_at ("previous definition of `%#T'", t
);
1871 return error_mark_node
;
1874 /* Update the location of the decl. */
1875 DECL_SOURCE_LOCATION (TYPE_NAME (t
)) = input_location
;
1877 if (TYPE_BEING_DEFINED (t
))
1879 t
= make_aggr_type (TREE_CODE (t
));
1880 pushtag (TYPE_IDENTIFIER (t
), t
, 0);
1882 maybe_process_partial_specialization (t
);
1883 pushclass (t
, true);
1884 TYPE_BEING_DEFINED (t
) = 1;
1885 TYPE_PACKED (t
) = flag_pack_struct
;
1886 /* Reset the interface data, at the earliest possible
1887 moment, as it might have been set via a class foo;
1889 if (! TYPE_ANONYMOUS_P (t
))
1891 CLASSTYPE_INTERFACE_ONLY (t
) = interface_only
;
1892 SET_CLASSTYPE_INTERFACE_UNKNOWN_X
1893 (t
, interface_unknown
);
1895 reset_specialization();
1897 /* Make a declaration for this class in its own scope. */
1898 build_self_reference ();
1903 /* Finish the member declaration given by DECL. */
1906 finish_member_declaration (decl
)
1909 if (decl
== error_mark_node
|| decl
== NULL_TREE
)
1912 if (decl
== void_type_node
)
1913 /* The COMPONENT was a friend, not a member, and so there's
1914 nothing for us to do. */
1917 /* We should see only one DECL at a time. */
1918 my_friendly_assert (TREE_CHAIN (decl
) == NULL_TREE
, 0);
1920 /* Set up access control for DECL. */
1922 = (current_access_specifier
== access_private_node
);
1923 TREE_PROTECTED (decl
)
1924 = (current_access_specifier
== access_protected_node
);
1925 if (TREE_CODE (decl
) == TEMPLATE_DECL
)
1927 TREE_PRIVATE (DECL_TEMPLATE_RESULT (decl
)) = TREE_PRIVATE (decl
);
1928 TREE_PROTECTED (DECL_TEMPLATE_RESULT (decl
)) = TREE_PROTECTED (decl
);
1931 /* Mark the DECL as a member of the current class. */
1932 DECL_CONTEXT (decl
) = current_class_type
;
1936 A C language linkage is ignored for the names of class members
1937 and the member function type of class member functions. */
1938 if (DECL_LANG_SPECIFIC (decl
) && DECL_LANGUAGE (decl
) == lang_c
)
1939 SET_DECL_LANGUAGE (decl
, lang_cplusplus
);
1941 maybe_add_class_template_decl_list (current_class_type
, decl
, /*friend_p=*/0);
1943 /* Put functions on the TYPE_METHODS list and everything else on the
1944 TYPE_FIELDS list. Note that these are built up in reverse order.
1945 We reverse them (to obtain declaration order) in finish_struct. */
1946 if (TREE_CODE (decl
) == FUNCTION_DECL
1947 || DECL_FUNCTION_TEMPLATE_P (decl
))
1949 /* We also need to add this function to the
1950 CLASSTYPE_METHOD_VEC. */
1951 add_method (current_class_type
, decl
, /*error_p=*/0);
1953 TREE_CHAIN (decl
) = TYPE_METHODS (current_class_type
);
1954 TYPE_METHODS (current_class_type
) = decl
;
1958 /* All TYPE_DECLs go at the end of TYPE_FIELDS. Ordinary fields
1959 go at the beginning. The reason is that lookup_field_1
1960 searches the list in order, and we want a field name to
1961 override a type name so that the "struct stat hack" will
1962 work. In particular:
1964 struct S { enum E { }; int E } s;
1967 is valid. In addition, the FIELD_DECLs must be maintained in
1968 declaration order so that class layout works as expected.
1969 However, we don't need that order until class layout, so we
1970 save a little time by putting FIELD_DECLs on in reverse order
1971 here, and then reversing them in finish_struct_1. (We could
1972 also keep a pointer to the correct insertion points in the
1975 if (TREE_CODE (decl
) == TYPE_DECL
)
1976 TYPE_FIELDS (current_class_type
)
1977 = chainon (TYPE_FIELDS (current_class_type
), decl
);
1980 TREE_CHAIN (decl
) = TYPE_FIELDS (current_class_type
);
1981 TYPE_FIELDS (current_class_type
) = decl
;
1984 /* Enter the DECL into the scope of the class. */
1985 if (TREE_CODE (decl
) != USING_DECL
)
1986 pushdecl_class_level (decl
);
1990 /* Finish a class definition T with the indicate ATTRIBUTES. If SEMI,
1991 the definition is immediately followed by a semicolon. Returns the
1995 finish_class_definition (t
, attributes
, semi
, pop_scope_p
)
2001 if (t
== error_mark_node
)
2002 return error_mark_node
;
2004 /* finish_struct nukes this anyway; if finish_exception does too,
2007 note_got_semicolon (t
);
2009 /* If we got any attributes in class_head, xref_tag will stick them in
2010 TREE_TYPE of the type. Grab them now. */
2011 attributes
= chainon (TYPE_ATTRIBUTES (t
), attributes
);
2012 TYPE_ATTRIBUTES (t
) = NULL_TREE
;
2014 if (TREE_CODE (t
) == ENUMERAL_TYPE
)
2018 t
= finish_struct (t
, attributes
);
2020 note_got_semicolon (t
);
2024 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (t
)));
2029 /* Finish processing the declaration of a member class template
2030 TYPES whose template parameters are given by PARMS. */
2033 finish_member_class_template (types
)
2038 /* If there are declared, but undefined, partial specializations
2039 mixed in with the typespecs they will not yet have passed through
2040 maybe_process_partial_specialization, so we do that here. */
2041 for (t
= types
; t
!= NULL_TREE
; t
= TREE_CHAIN (t
))
2042 if (IS_AGGR_TYPE_CODE (TREE_CODE (TREE_VALUE (t
))))
2043 maybe_process_partial_specialization (TREE_VALUE (t
));
2045 note_list_got_semicolon (types
);
2046 grok_x_components (types
);
2047 if (TYPE_CONTEXT (TREE_VALUE (types
)) != current_class_type
)
2048 /* The component was in fact a friend declaration. We avoid
2049 finish_member_template_decl performing certain checks by
2053 finish_member_template_decl (types
);
2055 /* As with other component type declarations, we do
2056 not store the new DECL on the list of
2061 /* Finish processing a complete template declaration. The PARMS are
2062 the template parameters. */
2065 finish_template_decl (parms
)
2069 end_template_decl ();
2071 end_specialization ();
2074 /* Finish processing a template-id (which names a type) of the form
2075 NAME < ARGS >. Return the TYPE_DECL for the type named by the
2076 template-id. If ENTERING_SCOPE is nonzero we are about to enter
2077 the scope of template-id indicated. */
2080 finish_template_type (name
, args
, entering_scope
)
2087 decl
= lookup_template_class (name
, args
,
2088 NULL_TREE
, NULL_TREE
,
2089 entering_scope
, /*complain=*/1);
2090 if (decl
!= error_mark_node
)
2091 decl
= TYPE_STUB_DECL (decl
);
2096 /* Finish processing a BASE_CLASS with the indicated ACCESS_SPECIFIER.
2097 Return a TREE_LIST containing the ACCESS_SPECIFIER and the
2098 BASE_CLASS, or NULL_TREE if an error occurred. The
2099 ACCESS_SPECIFIER is one of
2100 access_{default,public,protected_private}[_virtual]_node.*/
2103 finish_base_specifier (tree base
, tree access
, bool virtual_p
)
2107 if (base
== error_mark_node
)
2109 error ("invalid base-class specification");
2112 else if (! is_aggr_type (base
, 1))
2116 if (cp_type_quals (base
) != 0)
2118 error ("base class `%T' has cv qualifiers", base
);
2119 base
= TYPE_MAIN_VARIANT (base
);
2121 result
= build_tree_list (access
, base
);
2122 TREE_VIA_VIRTUAL (result
) = virtual_p
;
2128 /* Called when multiple declarators are processed. If that is not
2129 premitted in this context, an error is issued. */
2132 check_multiple_declarators ()
2136 In a template-declaration, explicit specialization, or explicit
2137 instantiation the init-declarator-list in the declaration shall
2138 contain at most one declarator.
2140 We don't just use PROCESSING_TEMPLATE_DECL for the first
2141 condition since that would disallow the perfectly valid code,
2142 like `template <class T> struct S { int i, j; };'. */
2143 if (at_function_scope_p ())
2144 /* It's OK to write `template <class T> void f() { int i, j;}'. */
2147 if (PROCESSING_REAL_TEMPLATE_DECL_P ()
2148 || processing_explicit_instantiation
2149 || processing_specialization
)
2150 error ("multiple declarators in template declaration");
2153 /* Implement the __typeof keyword: Return the type of EXPR, suitable for
2154 use as a type-specifier. */
2157 finish_typeof (expr
)
2162 if (type_dependent_expression_p (expr
))
2164 type
= make_aggr_type (TYPEOF_TYPE
);
2165 TYPE_FIELDS (type
) = expr
;
2170 if (TREE_CODE (expr
) == OFFSET_REF
)
2171 expr
= resolve_offset_ref (expr
);
2173 type
= TREE_TYPE (expr
);
2175 if (!type
|| type
== unknown_type_node
)
2177 error ("type of `%E' is unknown", expr
);
2178 return error_mark_node
;
2184 /* Compute the value of the `sizeof' operator. */
2190 return TYPE_P (t
) ? cxx_sizeof (t
) : expr_sizeof (t
);
2193 /* Implement the __alignof keyword: Return the minimum required
2194 alignment of T, measured in bytes. */
2200 if (processing_template_decl
)
2201 return build_min (ALIGNOF_EXPR
, size_type_node
, t
);
2203 return TYPE_P (t
) ? cxx_alignof (t
) : c_alignof_expr (t
);
2206 /* Generate RTL for the statement T, and its substatements, and any
2207 other statements at its nesting level. */
2213 switch (TREE_CODE (t
))
2216 genrtl_try_block (t
);
2220 genrtl_eh_spec_block (t
);
2236 /* Called from expand_body via walk_tree. Replace all AGGR_INIT_EXPRs
2237 will equivalent CALL_EXPRs. */
2240 simplify_aggr_init_exprs_r (tp
, walk_subtrees
, data
)
2242 int *walk_subtrees ATTRIBUTE_UNUSED
;
2243 void *data ATTRIBUTE_UNUSED
;
2245 tree aggr_init_expr
;
2251 enum style_t
{ ctor
, arg
, pcc
} style
;
2253 aggr_init_expr
= *tp
;
2254 /* We don't need to walk into types; there's nothing in a type that
2255 needs simplification. (And, furthermore, there are places we
2256 actively don't want to go. For example, we don't want to wander
2257 into the default arguments for a FUNCTION_DECL that appears in a
2259 if (TYPE_P (aggr_init_expr
))
2264 /* Only AGGR_INIT_EXPRs are interesting. */
2265 else if (TREE_CODE (aggr_init_expr
) != AGGR_INIT_EXPR
)
2268 /* Form an appropriate CALL_EXPR. */
2269 fn
= TREE_OPERAND (aggr_init_expr
, 0);
2270 args
= TREE_OPERAND (aggr_init_expr
, 1);
2271 slot
= TREE_OPERAND (aggr_init_expr
, 2);
2272 type
= TREE_TYPE (aggr_init_expr
);
2274 if (AGGR_INIT_VIA_CTOR_P (aggr_init_expr
))
2276 #ifdef PCC_STATIC_STRUCT_RETURN
2280 else if (TREE_ADDRESSABLE (type
))
2283 /* We shouldn't build an AGGR_INIT_EXPR if we don't need any special
2284 handling. See build_cplus_new. */
2287 if (style
== ctor
|| style
== arg
)
2289 /* Pass the address of the slot. If this is a constructor, we
2290 replace the first argument; otherwise, we tack on a new one. */
2292 args
= TREE_CHAIN (args
);
2294 cxx_mark_addressable (slot
);
2295 args
= tree_cons (NULL_TREE
,
2297 build_pointer_type (TREE_TYPE (slot
)),
2302 call_expr
= build (CALL_EXPR
,
2303 TREE_TYPE (TREE_TYPE (TREE_TYPE (fn
))),
2304 fn
, args
, NULL_TREE
);
2305 TREE_SIDE_EFFECTS (call_expr
) = 1;
2308 /* Tell the backend that we've added our return slot to the argument
2310 CALL_EXPR_HAS_RETURN_SLOT_ADDR (call_expr
) = 1;
2311 else if (style
== pcc
)
2313 /* If we're using the non-reentrant PCC calling convention, then we
2314 need to copy the returned value out of the static buffer into the
2316 push_deferring_access_checks (dk_no_check
);
2317 call_expr
= build_aggr_init (slot
, call_expr
,
2318 DIRECT_BIND
| LOOKUP_ONLYCONVERTING
);
2319 pop_deferring_access_checks ();
2322 /* We want to use the value of the initialized location as the
2324 call_expr
= build (COMPOUND_EXPR
, type
,
2327 /* Replace the AGGR_INIT_EXPR with the CALL_EXPR. */
2328 TREE_CHAIN (call_expr
) = TREE_CHAIN (aggr_init_expr
);
2331 /* Keep iterating. */
2335 /* Emit all thunks to FN that should be emitted when FN is emitted. */
2338 emit_associated_thunks (fn
)
2341 /* When we use vcall offsets, we emit thunks with the virtual
2342 functions to which they thunk. The whole point of vcall offsets
2343 is so that you can know statically the entire set of thunks that
2344 will ever be needed for a given virtual function, thereby
2345 enabling you to output all the thunks with the function itself. */
2346 if (DECL_VIRTUAL_P (fn
))
2350 for (thunk
= DECL_THUNKS (fn
); thunk
; thunk
= TREE_CHAIN (thunk
))
2352 use_thunk (thunk
, /*emit_p=*/1);
2353 if (DECL_RESULT_THUNK_P (thunk
))
2357 for (probe
= DECL_THUNKS (thunk
);
2358 probe
; probe
= TREE_CHAIN (probe
))
2359 use_thunk (probe
, /*emit_p=*/1);
2365 /* Generate RTL for FN. */
2371 location_t saved_loc
;
2372 tree saved_function
;
2374 /* When the parser calls us after finishing the body of a template
2375 function, we don't really want to expand the body. When we're
2376 processing an in-class definition of an inline function,
2377 PROCESSING_TEMPLATE_DECL will no longer be set here, so we have
2378 to look at the function itself. */
2379 if (processing_template_decl
2380 || (DECL_LANG_SPECIFIC (fn
)
2381 && DECL_TEMPLATE_INFO (fn
)
2382 && uses_template_parms (DECL_TI_ARGS (fn
))))
2384 /* Normally, collection only occurs in rest_of_compilation. So,
2385 if we don't collect here, we never collect junk generated
2386 during the processing of templates until we hit a
2387 non-template function. */
2392 /* Replace AGGR_INIT_EXPRs with appropriate CALL_EXPRs. */
2393 walk_tree_without_duplicates (&DECL_SAVED_TREE (fn
),
2394 simplify_aggr_init_exprs_r
,
2397 /* If this is a constructor or destructor body, we have to clone
2399 if (maybe_clone_body (fn
))
2401 /* We don't want to process FN again, so pretend we've written
2402 it out, even though we haven't. */
2403 TREE_ASM_WRITTEN (fn
) = 1;
2407 /* There's no reason to do any of the work here if we're only doing
2408 semantic analysis; this code just generates RTL. */
2409 if (flag_syntax_only
)
2412 /* If possible, avoid generating RTL for this function. Instead,
2413 just record it as an inline function, and wait until end-of-file
2414 to decide whether to write it out or not. */
2415 if (/* We have to generate RTL if it's not an inline function. */
2416 (DECL_INLINE (fn
) || DECL_COMDAT (fn
))
2417 /* Or if we have to emit code for inline functions anyhow. */
2418 && !flag_keep_inline_functions
2419 /* Or if we actually have a reference to the function. */
2420 && !DECL_NEEDED_P (fn
))
2422 /* Set DECL_EXTERNAL so that assemble_external will be called as
2423 necessary. We'll clear it again in finish_file. */
2424 if (!DECL_EXTERNAL (fn
))
2426 DECL_NOT_REALLY_EXTERN (fn
) = 1;
2427 DECL_EXTERNAL (fn
) = 1;
2429 /* Remember this function. In finish_file we'll decide if
2430 we actually need to write this function out. */
2432 /* Let the back-end know that this function exists. */
2433 (*debug_hooks
->deferred_inline_function
) (fn
);
2437 /* Compute the appropriate object-file linkage for inline
2439 if (DECL_DECLARED_INLINE_P (fn
))
2440 import_export_decl (fn
);
2442 /* If FN is external, then there's no point in generating RTL for
2443 it. This situation can arise with an inline function under
2444 `-fexternal-templates'; we instantiate the function, even though
2445 we're not planning on emitting it, in case we get a chance to
2447 if (DECL_EXTERNAL (fn
))
2450 /* Save the current file name and line number. When we expand the
2451 body of the function, we'll set INPUT_LOCATION so that
2452 error-mesages come out in the right places. */
2453 saved_loc
= input_location
;
2454 saved_function
= current_function_decl
;
2455 input_location
= DECL_SOURCE_LOCATION (fn
);
2456 current_function_decl
= fn
;
2458 timevar_push (TV_INTEGRATION
);
2460 /* Optimize the body of the function before expanding it. */
2461 optimize_function (fn
);
2463 timevar_pop (TV_INTEGRATION
);
2464 timevar_push (TV_EXPAND
);
2466 genrtl_start_function (fn
);
2467 current_function_is_thunk
= DECL_THUNK_P (fn
);
2469 /* Expand the body. */
2470 expand_stmt (DECL_SAVED_TREE (fn
));
2472 /* Statements should always be full-expressions at the outermost set
2473 of curly braces for a function. */
2474 my_friendly_assert (stmts_are_full_exprs_p (), 19990831);
2476 /* The outermost statement for a function contains the line number
2477 recorded when we finished processing the function. */
2478 input_line
= STMT_LINENO (DECL_SAVED_TREE (fn
));
2480 /* Generate code for the function. */
2481 genrtl_finish_function (fn
);
2483 /* If possible, obliterate the body of the function so that it can
2484 be garbage collected. */
2485 if (dump_enabled_p (TDI_all
))
2486 /* Keep the body; we're going to dump it. */
2488 else if (DECL_INLINE (fn
) && flag_inline_trees
)
2489 /* We might need the body of this function so that we can expand
2490 it inline somewhere else. */
2493 /* We don't need the body; blow it away. */
2494 DECL_SAVED_TREE (fn
) = NULL_TREE
;
2496 /* And restore the current source position. */
2497 current_function_decl
= saved_function
;
2498 input_location
= saved_loc
;
2499 extract_interface_info ();
2501 timevar_pop (TV_EXPAND
);
2503 /* Emit any thunks that should be emitted at the same time as FN. */
2504 emit_associated_thunks (fn
);
2507 /* Helper function for walk_tree, used by finish_function to override all
2508 the RETURN_STMTs and pertinent CLEANUP_STMTs for the named return
2509 value optimization. */
2512 nullify_returns_r (tp
, walk_subtrees
, data
)
2517 tree nrv
= (tree
) data
;
2519 /* No need to walk into types. There wouldn't be any need to walk into
2520 non-statements, except that we have to consider STMT_EXPRs. */
2523 else if (TREE_CODE (*tp
) == RETURN_STMT
)
2524 RETURN_STMT_EXPR (*tp
) = NULL_TREE
;
2525 else if (TREE_CODE (*tp
) == CLEANUP_STMT
2526 && CLEANUP_DECL (*tp
) == nrv
)
2527 CLEANUP_EH_ONLY (*tp
) = 1;
2529 /* Keep iterating. */
2533 /* Start generating the RTL for FN. */
2536 genrtl_start_function (fn
)
2539 /* Tell everybody what function we're processing. */
2540 current_function_decl
= fn
;
2541 /* Get the RTL machinery going for this function. */
2542 init_function_start (fn
);
2543 /* Let everybody know that we're expanding this function, not doing
2544 semantic analysis. */
2547 /* Even though we're inside a function body, we still don't want to
2548 call expand_expr to calculate the size of a variable-sized array.
2549 We haven't necessarily assigned RTL to all variables yet, so it's
2550 not safe to try to expand expressions involving them. */
2551 immediate_size_expand
= 0;
2552 cfun
->x_dont_save_pending_sizes_p
= 1;
2554 /* Let the user know we're compiling this function. */
2555 announce_function (fn
);
2557 /* Initialize the per-function data. */
2558 my_friendly_assert (!DECL_PENDING_INLINE_P (fn
), 20000911);
2559 if (DECL_SAVED_FUNCTION_DATA (fn
))
2561 /* If we already parsed this function, and we're just expanding it
2562 now, restore saved state. */
2563 *cp_function_chain
= *DECL_SAVED_FUNCTION_DATA (fn
);
2565 /* This function is being processed in whole-function mode; we
2566 already did semantic analysis. */
2567 cfun
->x_whole_function_mode_p
= 1;
2569 /* If we decided that we didn't want to inline this function,
2570 make sure the back-end knows that. */
2571 if (!current_function_cannot_inline
)
2572 current_function_cannot_inline
= cp_function_chain
->cannot_inline
;
2574 /* We don't need the saved data anymore. Unless this is an inline
2575 function; we need the named return value info for
2576 cp_copy_res_decl_for_inlining. */
2577 if (! DECL_INLINE (fn
))
2578 DECL_SAVED_FUNCTION_DATA (fn
) = NULL
;
2581 /* Keep track of how many functions we're presently expanding. */
2584 /* Create a binding level for the parameters. */
2585 expand_function_start (fn
, /*parms_have_cleanups=*/0);
2586 /* If this function is `main'. */
2587 if (DECL_MAIN_P (fn
))
2588 expand_main_function ();
2590 /* Give our named return value the same RTL as our RESULT_DECL. */
2591 if (current_function_return_value
)
2592 COPY_DECL_RTL (DECL_RESULT (fn
), current_function_return_value
);
2595 /* Finish generating the RTL for FN. */
2598 genrtl_finish_function (fn
)
2604 if (write_symbols
!= NO_DEBUG
)
2606 /* Keep this code around in case we later want to control debug info
2607 based on whether a type is "used". (jason 1999-11-11) */
2609 tree ttype
= target_type (fntype
);
2612 if (IS_AGGR_TYPE (ttype
))
2613 /* Let debugger know it should output info for this type. */
2614 note_debug_info_needed (ttype
);
2616 for (parmdecl
= DECL_ARGUMENTS (fndecl
); parmdecl
; parmdecl
= TREE_CHAIN (parmdecl
))
2618 ttype
= target_type (TREE_TYPE (parmdecl
));
2619 if (IS_AGGR_TYPE (ttype
))
2620 /* Let debugger know it should output info for this type. */
2621 note_debug_info_needed (ttype
);
2626 /* Clean house because we will need to reorder insns here. */
2627 do_pending_stack_adjust ();
2629 /* If we have a named return value, we need to force a return so that
2630 the return register is USEd. */
2631 if (DECL_NAME (DECL_RESULT (fn
)))
2632 emit_jump (return_label
);
2634 /* We hard-wired immediate_size_expand to zero in start_function.
2635 Expand_function_end will decrement this variable. So, we set the
2636 variable to one here, so that after the decrement it will remain
2638 immediate_size_expand
= 1;
2640 /* Generate rtl for function exit. */
2641 expand_function_end (input_filename
, input_line
, 0);
2643 /* If this is a nested function (like a template instantiation that
2644 we're compiling in the midst of compiling something else), push a
2645 new GC context. That will keep local variables on the stack from
2646 being collected while we're doing the compilation of this
2648 if (function_depth
> 1)
2649 ggc_push_context ();
2651 /* There's no need to defer outputting this function any more; we
2652 know we want to output it. */
2653 DECL_DEFER_OUTPUT (fn
) = 0;
2655 /* Run the optimizers and output the assembler code for this
2657 rest_of_compilation (fn
);
2659 /* Undo the call to ggc_push_context above. */
2660 if (function_depth
> 1)
2664 /* Keep this code around in case we later want to control debug info
2665 based on whether a type is "used". (jason 1999-11-11) */
2667 if (ctype
&& TREE_ASM_WRITTEN (fn
))
2668 note_debug_info_needed (ctype
);
2671 /* If this function is marked with the constructor attribute, add it
2672 to the list of functions to be called along with constructors
2673 from static duration objects. */
2674 if (DECL_STATIC_CONSTRUCTOR (fn
))
2675 static_ctors
= tree_cons (NULL_TREE
, fn
, static_ctors
);
2677 /* If this function is marked with the destructor attribute, add it
2678 to the list of functions to be called along with destructors from
2679 static duration objects. */
2680 if (DECL_STATIC_DESTRUCTOR (fn
))
2681 static_dtors
= tree_cons (NULL_TREE
, fn
, static_dtors
);
2685 /* In C++, we should never be saving RTL for the function. */
2686 my_friendly_assert (!DECL_SAVED_INSNS (fn
), 20010903);
2688 /* Since we don't need the RTL for this function anymore, stop
2689 pointing to it. That's especially important for LABEL_DECLs,
2690 since you can reach all the instructions in the function from the
2691 CODE_LABEL stored in the DECL_RTL for the LABEL_DECL. Walk the
2692 BLOCK-tree, clearing DECL_RTL for LABEL_DECLs and non-static
2694 walk_tree_without_duplicates (&DECL_SAVED_TREE (fn
),
2698 /* Clear out the RTL for the arguments. */
2699 for (t
= DECL_ARGUMENTS (fn
); t
; t
= TREE_CHAIN (t
))
2701 SET_DECL_RTL (t
, NULL_RTX
);
2702 DECL_INCOMING_RTL (t
) = NULL_RTX
;
2705 if (!(flag_inline_trees
&& DECL_INLINE (fn
)))
2706 /* DECL_INITIAL must remain nonzero so we know this was an
2707 actual function definition. */
2708 DECL_INITIAL (fn
) = error_mark_node
;
2710 /* Let the error reporting routines know that we're outside a
2711 function. For a nested function, this value is used in
2712 pop_cp_function_context and then reset via pop_function_context. */
2713 current_function_decl
= NULL_TREE
;
2716 /* Clear out the DECL_RTL for the non-static variables in BLOCK and
2720 clear_decl_rtl (tp
, walk_subtrees
, data
)
2722 int *walk_subtrees ATTRIBUTE_UNUSED
;
2723 void *data ATTRIBUTE_UNUSED
;
2725 if (nonstatic_local_decl_p (*tp
))
2726 SET_DECL_RTL (*tp
, NULL_RTX
);
2731 /* Perform initialization related to this module. */
2734 init_cp_semantics ()
2736 lang_expand_stmt
= cp_expand_stmt
;
2739 #include "gt-cp-semantics.h"