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 Free Software Foundation, Inc.
7 Written by Mark Mitchell (mmitchell@usa.net) based on code found
8 formerly in parse.y and pt.c.
10 This file is part of GNU CC.
12 GNU CC is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2, or (at your option)
17 GNU CC is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with GNU CC; see the file COPYING. If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
35 /* There routines provide a modular interface to perform many parsing
36 operations. They may therefore be used during actual parsing, or
37 during template instantiation, which may be regarded as a
38 degenerate form of parsing. Since the current g++ parser is
39 lacking in several respects, and will be reimplemented, we are
40 attempting to move most code that is not directly related to
41 parsing into this file; that will make implementing the new parser
42 much easier since it will be able to make use of these routines. */
44 static void expand_stmts PROTO((tree));
45 static void do_pushlevel PROTO((void));
46 static tree do_poplevel PROTO((void));
48 /* Non-zero if we should generate RTL for functions that we process.
49 When this is zero, we just accumulate tree structure, without
50 interacting with the back end. */
53 /* Non-zero if we should treat statements as full expressions. In
54 particular, this variable is no-zero if at the end of a statement
55 we should destroy any temporaries created during that statement.
56 Similarly, if, at the end of a block, we should destroy any local
57 variables in this block. Normally, this variable is non-zero,
58 since those are the normal semantics of C++.
60 However, in order to represent aggregate initialization code as
61 tree structure, we use statement-expressions. The statements
62 within the statement expression should not result in cleanups being
63 run until the entire enclosing statement is complete. */
64 int stmts_are_full_exprs_p = 1;
66 /* The type of the last expression-statement we have seen. This is
67 required because the type of a statement-expression is the type of
68 the last expression statement. */
71 /* When parsing a template, LAST_TREE contains the last statement
72 parsed. These are chained together through the TREE_CHAIN field,
73 but often need to be re-organized since the parse is performed
74 bottom-up. This macro makes LAST_TREE the indicated SUBSTMT of
77 #define RECHAIN_STMTS(stmt, substmt, last) \
80 TREE_CHAIN (stmt) = NULL_TREE; \
84 #define RECHAIN_STMTS_FROM_LAST(stmt, substmt) \
85 RECHAIN_STMTS (stmt, substmt, last_tree)
87 #define RECHAIN_STMTS_FROM_CHAIN(stmt, substmt) \
88 RECHAIN_STMTS (stmt, substmt, TREE_CHAIN (stmt))
90 /* Finish an expression-statement, whose EXPRESSION is as indicated. */
93 finish_expr_stmt (expr)
96 if (expr != NULL_TREE)
98 if (building_stmt_tree ())
99 add_tree (build_min_nt (EXPR_STMT, expr));
102 emit_line_note (input_filename, lineno);
103 /* Do default conversion if safe and possibly important,
104 in case within ({...}). */
105 if ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
107 || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE)
108 expr = default_conversion (expr);
110 if (stmts_are_full_exprs_p)
111 expand_start_target_temps ();
113 cplus_expand_expr_stmt (expr);
115 if (stmts_are_full_exprs_p)
117 expand_end_target_temps ();
125 /* This was an expression-statement, so we save the type of the
127 last_expr_type = expr ? TREE_TYPE (expr) : NULL_TREE;
130 /* Begin an if-statement. Returns a newly created IF_STMT if
138 if (building_stmt_tree ())
140 r = build_min_nt (IF_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
151 /* Process the COND of an if-statement, which may be given by
155 finish_if_stmt_cond (cond, if_stmt)
159 if (building_stmt_tree ())
161 if (last_tree != if_stmt)
162 RECHAIN_STMTS_FROM_LAST (if_stmt, IF_COND (if_stmt));
164 IF_COND (if_stmt) = copy_to_permanent (cond);
168 emit_line_note (input_filename, lineno);
169 expand_start_cond (condition_conversion (cond), 0);
173 /* Finish the then-clause of an if-statement, which may be given by
177 finish_then_clause (if_stmt)
180 if (building_stmt_tree ())
182 RECHAIN_STMTS_FROM_CHAIN (if_stmt,
183 THEN_CLAUSE (if_stmt));
191 /* Begin the else-clause of an if-statement. */
196 if (!building_stmt_tree ())
197 expand_start_else ();
200 /* Finish the else-clause of an if-statement, which may be given by
204 finish_else_clause (if_stmt)
207 if (building_stmt_tree ())
208 RECHAIN_STMTS_FROM_CHAIN (if_stmt, ELSE_CLAUSE (if_stmt));
211 /* Finsh an if-statement. */
216 if (!building_stmt_tree ())
223 /* Begin a while-statement. Returns a newly created WHILE_STMT if
231 if (building_stmt_tree ())
233 r = build_min_nt (WHILE_STMT, NULL_TREE, NULL_TREE);
239 emit_line_note (input_filename, lineno);
240 expand_start_loop (1);
249 /* Process the COND of an if-statement, which may be given by
253 finish_while_stmt_cond (cond, while_stmt)
257 if (building_stmt_tree ())
259 if (last_tree != while_stmt)
260 RECHAIN_STMTS_FROM_LAST (while_stmt, WHILE_COND (while_stmt));
262 TREE_OPERAND (while_stmt, 0) = copy_to_permanent (cond);
266 emit_line_note (input_filename, lineno);
267 expand_exit_loop_if_false (0, condition_conversion (cond));
270 /* If COND wasn't a declaration, clear out the
271 block we made for it and start a new one here so the
272 optimization in expand_end_loop will work. */
273 if (getdecls () == NULL_TREE)
280 /* Finish a while-statement, which may be given by WHILE_STMT. */
283 finish_while_stmt (while_stmt)
288 if (building_stmt_tree ())
289 RECHAIN_STMTS_FROM_CHAIN (while_stmt, WHILE_BODY (while_stmt));
295 /* Begin a do-statement. Returns a newly created DO_STMT if
301 if (building_stmt_tree ())
303 tree r = build_min_nt (DO_STMT, NULL_TREE, NULL_TREE);
310 emit_line_note (input_filename, lineno);
311 expand_start_loop_continue_elsewhere (1);
316 /* Finish the body of a do-statement, which may be given by DO_STMT. */
319 finish_do_body (do_stmt)
322 if (building_stmt_tree ())
323 RECHAIN_STMTS_FROM_CHAIN (do_stmt, DO_BODY (do_stmt));
325 expand_loop_continue_here ();
328 /* Finish a do-statement, which may be given by DO_STMT, and whose
329 COND is as indicated. */
332 finish_do_stmt (cond, do_stmt)
336 if (building_stmt_tree ())
337 DO_COND (do_stmt) = copy_to_permanent (cond);
340 emit_line_note (input_filename, lineno);
341 expand_exit_loop_if_false (0, condition_conversion (cond));
349 /* Finish a return-statement. The EXPRESSION returned, if any, is as
353 finish_return_stmt (expr)
356 if (building_stmt_tree ())
357 add_tree (build_min_nt (RETURN_STMT, expr));
360 emit_line_note (input_filename, lineno);
361 c_expand_return (expr);
367 /* Begin a for-statement. Returns a new FOR_STMT if appropriate. */
374 if (building_stmt_tree ())
376 r = build_min_nt (FOR_STMT, NULL_TREE, NULL_TREE,
377 NULL_TREE, NULL_TREE);
383 if (flag_new_for_scope > 0)
386 note_level_for_for ();
392 /* Finish the for-init-statement of a for-statement, which may be
393 given by FOR_STMT. */
396 finish_for_init_stmt (for_stmt)
399 if (building_stmt_tree ())
401 if (last_tree != for_stmt)
402 RECHAIN_STMTS_FROM_CHAIN (for_stmt, FOR_INIT_STMT (for_stmt));
407 emit_line_note (input_filename, lineno);
408 expand_start_loop_continue_elsewhere (1);
414 /* Finish the COND of a for-statement, which may be given by
418 finish_for_cond (cond, for_stmt)
422 if (building_stmt_tree ())
424 if (last_tree != for_stmt)
425 RECHAIN_STMTS_FROM_LAST (for_stmt, FOR_COND (for_stmt));
427 FOR_COND (for_stmt) = copy_to_permanent (cond);
431 emit_line_note (input_filename, lineno);
433 expand_exit_loop_if_false (0, condition_conversion (cond));
436 /* If the cond wasn't a declaration, clear out the
437 block we made for it and start a new one here so the
438 optimization in expand_end_loop will work. */
439 if (getdecls () == NULL_TREE)
446 /* Finish the increment-EXPRESSION in a for-statement, which may be
447 given by FOR_STMT. */
450 finish_for_expr (expr, for_stmt)
454 if (building_stmt_tree ())
455 FOR_EXPR (for_stmt) = copy_to_permanent (expr);
457 /* Don't let the tree nodes for EXPR be discarded
458 by clear_momentary during the parsing of the next stmt. */
462 /* Finish the body of a for-statement, which may be given by
463 FOR_STMT. The increment-EXPR for the loop must be
467 finish_for_stmt (expr, for_stmt)
471 /* Pop the scope for the body of the loop. */
474 if (building_stmt_tree ())
475 RECHAIN_STMTS_FROM_CHAIN (for_stmt, FOR_BODY (for_stmt));
478 emit_line_note (input_filename, lineno);
479 expand_loop_continue_here ();
481 finish_expr_stmt (expr);
487 if (flag_new_for_scope > 0)
493 /* Finish a break-statement. */
498 emit_line_note (input_filename, lineno);
499 if (building_stmt_tree ())
500 add_tree (build_min_nt (BREAK_STMT));
501 else if ( ! expand_exit_something ())
502 cp_error ("break statement not within loop or switch");
505 /* Finish a continue-statement. */
508 finish_continue_stmt ()
510 emit_line_note (input_filename, lineno);
511 if (building_stmt_tree ())
512 add_tree (build_min_nt (CONTINUE_STMT));
513 else if (! expand_continue_loop (0))
514 cp_error ("continue statement not within a loop");
517 /* Begin a switch-statement. */
525 /* Finish the cond of a switch-statement. Returns a new
526 SWITCH_STMT if appropriate. */
529 finish_switch_cond (cond)
534 if (building_stmt_tree ())
536 r = build_min_nt (SWITCH_STMT, cond, NULL_TREE);
539 else if (cond != error_mark_node)
541 emit_line_note (input_filename, lineno);
542 c_expand_start_case (cond);
547 /* The code is in error, but we don't want expand_end_case to
549 c_expand_start_case (boolean_false_node);
555 /* Don't let the tree nodes for COND be discarded by
556 clear_momentary during the parsing of the next stmt. */
562 /* Finish the body of a switch-statement, which may be given by
563 SWITCH_STMT. The COND to switch on is indicated. */
566 finish_switch_stmt (cond, switch_stmt)
570 if (building_stmt_tree ())
571 RECHAIN_STMTS_FROM_CHAIN (switch_stmt, SWITCH_BODY (switch_stmt));
573 expand_end_case (cond);
580 /* Finish a case-label. */
583 finish_case_label (low_value, high_value)
587 if (building_stmt_tree ())
589 add_tree (build_min_nt (CASE_LABEL, low_value, high_value));
593 do_case (low_value, high_value);
596 /* Finish a goto-statement. */
599 finish_goto_stmt (destination)
602 if (building_stmt_tree ())
603 add_tree (build_min_nt (GOTO_STMT, destination));
606 emit_line_note (input_filename, lineno);
608 if (TREE_CODE (destination) == IDENTIFIER_NODE)
610 tree decl = lookup_label (destination);
611 TREE_USED (decl) = 1;
615 expand_computed_goto (destination);
619 /* Begin a try-block. Returns a newly-created TRY_BLOCK if
625 if (building_stmt_tree ())
627 tree r = build_min_nt (TRY_BLOCK, NULL_TREE,
634 emit_line_note (input_filename, lineno);
635 expand_start_try_stmts ();
640 /* Likewise, for a function-try-block. */
643 begin_function_try_block ()
645 if (building_stmt_tree ())
647 tree r = build_min_nt (TRY_BLOCK, NULL_TREE,
654 if (! current_function_parms_stored)
656 expand_start_early_try_stmts ();
661 /* Finish a try-block, which may be given by TRY_BLOCK. */
664 finish_try_block (try_block)
667 if (building_stmt_tree ())
668 RECHAIN_STMTS_FROM_LAST (try_block, TRY_STMTS (try_block));
670 expand_start_all_catch ();
673 /* Finish an implicitly generated try-block, with a cleanup is given
677 finish_cleanup (cleanup, try_block)
681 if (building_stmt_tree ())
683 TRY_HANDLERS (try_block) = copy_to_permanent (cleanup);
684 CLEANUP_P (try_block) = 1;
687 expand_eh_region_end (protect_with_terminate (cleanup));
690 /* Likewise, for a function-try-block. */
693 finish_function_try_block (try_block)
696 if (building_stmt_tree ())
697 RECHAIN_STMTS_FROM_LAST (try_block, TRY_STMTS (try_block));
700 end_protect_partials ();
701 expand_start_all_catch ();
702 in_function_try_handler = 1;
706 /* Finish a handler-sequence for a try-block, which may be given by
710 finish_handler_sequence (try_block)
713 if (building_stmt_tree ())
714 RECHAIN_STMTS_FROM_CHAIN (try_block, TRY_HANDLERS (try_block));
716 expand_end_all_catch ();
719 /* Likewise, for a function-try-block. */
722 finish_function_handler_sequence (try_block)
725 if (building_stmt_tree ())
726 RECHAIN_STMTS_FROM_CHAIN (try_block, TRY_HANDLERS (try_block));
729 in_function_try_handler = 0;
730 expand_end_all_catch ();
734 /* Begin a handler. Returns a HANDLER if appropriate. */
741 if (building_stmt_tree ())
743 r = build_min_nt (HANDLER, NULL_TREE, NULL_TREE);
754 /* Finish the handler-parameters for a handler, which may be given by
758 finish_handler_parms (handler)
761 if (building_stmt_tree ())
762 RECHAIN_STMTS_FROM_CHAIN (handler, HANDLER_PARMS (handler));
765 /* Finish a handler, which may be given by HANDLER. */
768 finish_handler (handler)
771 if (building_stmt_tree ())
772 RECHAIN_STMTS_FROM_CHAIN (handler, HANDLER_BODY (handler));
774 expand_end_catch_block ();
779 /* Begin a compound-statement. If HAS_NO_SCOPE is non-zero, the
780 compound-statement does not define a scope. Returns a new
781 COMPOUND_STMT if appropriate. */
784 begin_compound_stmt (has_no_scope)
789 if (building_stmt_tree ())
791 r = build_min_nt (COMPOUND_STMT, NULL_TREE);
794 COMPOUND_STMT_NO_SCOPE (r) = 1;
799 last_expr_type = NULL_TREE;
804 /* Normally, we try hard to keep the BLOCK for a
805 statement-expression. But, if it's a statement-expression with
806 a scopeless block, there's nothing to keep, and we don't want
807 to accidentally keep a block *inside* the scopeless block. */
814 /* Finish a compound-statement, which may be given by COMPOUND_STMT.
815 If HAS_NO_SCOPE is non-zero, the compound statement does not define
819 finish_compound_stmt (has_no_scope, compound_stmt)
831 if (building_stmt_tree ())
832 RECHAIN_STMTS_FROM_CHAIN (compound_stmt,
833 COMPOUND_BODY (compound_stmt));
835 /* When we call finish_stmt we will lost LAST_EXPR_TYPE. But, since
836 the precise purpose of that variable is store the type of the
837 last expression statement within the last compound statement, we
838 preserve the value. */
846 /* Finish an asm-statement, whose components are a CV_QUALIFIER, a
847 STRING, some OUTPUT_OPERANDS, some INPUT_OPERANDS, and some
851 finish_asm_stmt (cv_qualifier, string, output_operands,
852 input_operands, clobbers)
855 tree output_operands;
859 if (TREE_CHAIN (string))
861 if (building_stmt_tree ())
862 /* We need to build the combined string on the permanent
863 obstack so that we can use it during instantiations. */
864 push_permanent_obstack ();
866 string = combine_strings (string);
868 if (building_stmt_tree ())
872 if (cv_qualifier != NULL_TREE
873 && cv_qualifier != ridpointers[(int) RID_VOLATILE])
875 cp_warning ("%s qualifier ignored on asm",
876 IDENTIFIER_POINTER (cv_qualifier));
877 cv_qualifier = NULL_TREE;
880 if (building_stmt_tree ())
882 tree r = build_min_nt (ASM_STMT, cv_qualifier, string,
883 output_operands, input_operands,
889 emit_line_note (input_filename, lineno);
890 if (output_operands != NULL_TREE || input_operands != NULL_TREE
891 || clobbers != NULL_TREE)
895 for (t = input_operands; t; t = TREE_CHAIN (t))
896 TREE_VALUE (t) = decay_conversion (TREE_VALUE (t));
898 c_expand_asm_operands (string, output_operands,
901 cv_qualifier != NULL_TREE,
902 input_filename, lineno);
911 /* Finish a label with the indicated NAME. */
914 finish_label_stmt (name)
919 if (building_stmt_tree ())
921 push_permanent_obstack ();
922 decl = build_decl (LABEL_DECL, name, void_type_node);
924 DECL_SOURCE_LINE (decl) = lineno;
925 DECL_SOURCE_FILE (decl) = input_filename;
930 decl = define_label (input_filename, lineno, name);
936 /* Create a declaration statement for the declaration given by the
945 /* We need the type to last until instantiation time. */
946 TREE_TYPE (decl) = copy_to_permanent (TREE_TYPE (decl));
947 decl_stmt = build_min_nt (DECL_STMT, decl);
948 add_tree (decl_stmt);
951 /* We're in a constructor, and have just constructed a a subobject of
952 *THIS. CLEANUP is code to run if an exception is thrown before the
953 end of the current function is reached. */
956 finish_subobject (cleanup)
959 if (building_stmt_tree ())
961 tree r = build_min_nt (SUBOBJECT, cleanup);
965 add_partial_entry (cleanup);
968 /* Bind a name and initialization to the return value of
969 the current function. */
972 finish_named_return_value (return_id, init)
973 tree return_id, init;
975 tree decl = DECL_RESULT (current_function_decl);
978 /* Give this error as many times as there are occurrences,
979 so that users can use Emacs compilation buffers to find
980 and fix all such places. */
981 pedwarn ("ANSI C++ does not permit named return values");
983 if (return_id != NULL_TREE)
985 if (DECL_NAME (decl) == NULL_TREE)
987 DECL_NAME (decl) = return_id;
988 DECL_ASSEMBLER_NAME (decl) = return_id;
992 cp_error ("return identifier `%D' already in place", return_id);
997 /* Can't let this happen for constructors. */
998 if (DECL_CONSTRUCTOR_P (current_function_decl))
1000 error ("can't redefine default return value for constructors");
1004 /* If we have a named return value, put that in our scope as well. */
1005 if (DECL_NAME (decl) != NULL_TREE)
1007 /* Let `cp_finish_decl' know that this initializer is ok. */
1008 DECL_INITIAL (decl) = init;
1011 if (building_stmt_tree ())
1012 add_tree (build_min_nt (RETURN_INIT, return_id,
1013 copy_to_permanent (init)));
1016 cp_finish_decl (decl, init, NULL_TREE, 0, 0);
1017 store_return_init (decl);
1022 /* Cache the value of this class's main virtual function table pointer
1023 in a register variable. This will save one indirection if a
1024 more than one virtual function call is made this function. */
1029 extern tree base_init_expr;
1031 if (base_init_expr == 0
1032 && DECL_CONSTRUCTOR_P (current_function_decl))
1034 if (building_stmt_tree ())
1035 add_tree (build_min_nt
1037 current_member_init_list, current_base_init_list));
1039 emit_base_init (current_class_type);
1042 /* Always keep the BLOCK node associated with the outermost pair of
1043 curley braces of a function. These are needed for correct
1044 operation of dwarfout.c. */
1045 keep_next_level (1);
1048 /* Begin a new scope. */
1053 if (!building_stmt_tree ())
1055 emit_line_note (input_filename, lineno);
1059 if (stmts_are_full_exprs_p)
1061 if (!building_stmt_tree () && stmts_are_full_exprs_p)
1062 expand_start_bindings (0);
1065 /* Finish a scope. */
1072 if (!building_stmt_tree () && stmts_are_full_exprs_p)
1073 expand_end_bindings (getdecls (), kept_level_p (), 0);
1074 if (stmts_are_full_exprs_p)
1075 t = poplevel (kept_level_p (), 1, 0);
1082 /* Finish a parenthesized expression EXPR. */
1085 finish_parenthesized_expr (expr)
1088 if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (expr))))
1089 /* This inhibits warnings in truthvalue_conversion. */
1090 C_SET_EXP_ORIGINAL_CODE (expr, ERROR_MARK);
1095 /* Begin a statement-expression. The value returned must be passed to
1096 finish_stmt_expr. */
1101 keep_next_level (1);
1102 /* If we're building a statement tree, then the upcoming compound
1103 statement will be chained onto the tree structure, starting at
1104 last_tree. We return last_tree so that we can later unhook the
1105 compound statement. */
1106 return building_stmt_tree () ? last_tree : expand_start_stmt_expr();
1109 /* Finish a statement-expression. RTL_EXPR should be the value
1110 returned by the previous begin_stmt_expr; EXPR is the
1111 statement-expression. Returns an expression representing the
1112 statement-expression. */
1115 finish_stmt_expr (rtl_expr, expr)
1121 if (!building_stmt_tree ())
1123 rtl_expr = expand_end_stmt_expr (rtl_expr);
1124 /* The statements have side effects, so the group does. */
1125 TREE_SIDE_EFFECTS (rtl_expr) = 1;
1128 if (building_stmt_tree ())
1130 /* If the last thing in the statement-expression was not an
1131 expression-statement, then it has type `void'. */
1132 if (!last_expr_type)
1133 last_expr_type = void_type_node;
1134 result = build_min (STMT_EXPR, last_expr_type, last_tree);
1135 TREE_SIDE_EFFECTS (result) = 1;
1137 /* Remove the compound statement from the tree structure; it is
1138 now saved in the STMT_EXPR. */
1139 last_tree = rtl_expr;
1140 TREE_CHAIN (last_tree) = NULL_TREE;
1142 else if (expr && TREE_CODE (expr) == BLOCK)
1144 result = build (BIND_EXPR, TREE_TYPE (rtl_expr),
1145 NULL_TREE, rtl_expr, expr);
1146 delete_block (expr);
1151 if (expr && TREE_CODE (expr) == BLOCK)
1152 /* Remove the block from the tree at this point. It gets put back
1153 at the proper place when the STMT_EXPR or BIND_EXPR is
1155 delete_block (expr);
1160 /* Finish a call to FN with ARGS. Returns a representation of the
1164 finish_call_expr (fn, args, koenig)
1173 if (TREE_CODE (fn) == BIT_NOT_EXPR)
1174 fn = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND (fn, 0));
1175 else if (TREE_CODE (fn) != TEMPLATE_ID_EXPR)
1176 fn = do_identifier (fn, 2, args);
1178 result = build_x_function_call (fn, args, current_class_ref);
1180 if (TREE_CODE (result) == CALL_EXPR
1181 && (! TREE_TYPE (result)
1182 || TREE_CODE (TREE_TYPE (result)) != VOID_TYPE))
1183 result = require_complete_type (result);
1188 /* Finish a call to a postfix increment or decrement or EXPR. (Which
1189 is indicated by CODE, which should be POSTINCREMENT_EXPR or
1190 POSTDECREMENT_EXPR.) */
1193 finish_increment_expr (expr, code)
1195 enum tree_code code;
1197 /* If we get an OFFSET_REF, turn it into what it really means (e.g.,
1198 a COMPONENT_REF). This way if we've got, say, a reference to a
1199 static member that's being operated on, we don't end up trying to
1200 find a member operator for the class it's in. */
1202 if (TREE_CODE (expr) == OFFSET_REF)
1203 expr = resolve_offset_ref (expr);
1204 return build_x_unary_op (code, expr);
1207 /* Finish a use of `this'. Returns an expression for `this'. */
1214 if (current_class_ptr)
1216 #ifdef WARNING_ABOUT_CCD
1217 TREE_USED (current_class_ptr) = 1;
1219 result = current_class_ptr;
1221 else if (current_function_decl
1222 && DECL_STATIC_FUNCTION_P (current_function_decl))
1224 error ("`this' is unavailable for static member functions");
1225 result = error_mark_node;
1229 if (current_function_decl)
1230 error ("invalid use of `this' in non-member function");
1232 error ("invalid use of `this' at top level");
1233 result = error_mark_node;
1239 /* Finish a member function call using OBJECT and ARGS as arguments to
1240 FN. Returns an expression for the call. */
1243 finish_object_call_expr (fn, object, args)
1249 /* This is a future direction of this code, but because
1250 build_x_function_call cannot always undo what is done in
1251 build_component_ref entirely yet, we cannot do this. */
1253 tree real_fn = build_component_ref (object, fn, NULL_TREE, 1);
1254 return finish_call_expr (real_fn, args);
1256 if (TREE_CODE (fn) == TYPE_DECL)
1258 if (processing_template_decl)
1259 /* This can happen on code like:
1262 template <class T> void f(T t) {
1266 We just grab the underlying IDENTIFIER. */
1267 fn = DECL_NAME (fn);
1270 cp_error ("calling type `%T' like a method", fn);
1271 return error_mark_node;
1275 return build_method_call (object, fn, args, NULL_TREE, LOOKUP_NORMAL);
1279 /* Finish a qualified member function call using OBJECT and ARGS as
1280 arguments to FN. Returns an expressino for the call. */
1283 finish_qualified_object_call_expr (fn, object, args)
1288 return build_scoped_method_call (object, TREE_OPERAND (fn, 0),
1289 TREE_OPERAND (fn, 1), args);
1292 /* Finish a pseudo-destructor call expression of OBJECT, with SCOPE
1293 being the scope, if any, of DESTRUCTOR. Returns an expression for
1297 finish_pseudo_destructor_call_expr (object, scope, destructor)
1302 if (processing_template_decl)
1303 return build_min_nt (PSEUDO_DTOR_EXPR, object, scope, destructor);
1305 if (scope && scope != destructor)
1306 cp_error ("destructor specifier `%T::~%T()' must have matching names",
1309 if ((scope == NULL_TREE || IDENTIFIER_GLOBAL_VALUE (destructor))
1310 && (TREE_CODE (TREE_TYPE (object)) !=
1311 TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (destructor)))))
1312 cp_error ("`%E' is not of type `%T'", object, destructor);
1314 return cp_convert (void_type_node, object);
1317 /* Finish a call to a globally qualified member function FN using
1318 ARGS. Returns an expression for the call. */
1321 finish_qualified_call_expr (fn, args)
1325 if (processing_template_decl)
1326 return build_min_nt (CALL_EXPR, copy_to_permanent (fn), args,
1329 return build_member_call (TREE_OPERAND (fn, 0),
1330 TREE_OPERAND (fn, 1),
1334 /* Finish an expression taking the address of LABEL. Returns an
1335 expression for the address. */
1338 finish_label_address_expr (label)
1343 label = lookup_label (label);
1344 if (label == NULL_TREE)
1345 result = null_pointer_node;
1348 TREE_USED (label) = 1;
1349 result = build1 (ADDR_EXPR, ptr_type_node, label);
1350 TREE_CONSTANT (result) = 1;
1356 /* Finish an expression of the form CODE EXPR. */
1359 finish_unary_op_expr (code, expr)
1360 enum tree_code code;
1363 tree result = build_x_unary_op (code, expr);
1364 if (code == NEGATE_EXPR && TREE_CODE (expr) == INTEGER_CST)
1365 TREE_NEGATED_INT (result) = 1;
1366 overflow_warning (result);
1370 /* Finish an id-expression. */
1373 finish_id_expr (expr)
1376 if (TREE_CODE (expr) == IDENTIFIER_NODE)
1377 expr = do_identifier (expr, 1, NULL_TREE);
1382 /* Begin a new-placement. */
1385 begin_new_placement ()
1387 /* The arguments to a placement new might be passed to a
1388 deallocation function, in the event that the allocation throws an
1389 exception. Since we don't expand exception handlers until the
1390 end of a function, we must make sure the arguments stay around
1392 return suspend_momentary ();
1395 /* Finish a new-placement. The ARGS are the placement arguments. The
1396 COOKIE is the value returned by the previous call to
1397 begin_new_placement. */
1400 finish_new_placement (args, cookie)
1404 resume_momentary (cookie);
1408 /* Begin a function defniition declared with DECL_SPECS and
1409 DECLARATOR. Returns non-zero if the function-declaration is
1413 begin_function_definition (decl_specs, declarator)
1419 split_specs_attrs (decl_specs, &specs, &attrs);
1420 if (!start_function (specs, declarator, attrs, 0))
1423 reinit_parse_for_function ();
1424 /* The things we're about to see are not directly qualified by any
1425 template headers we've seen thus far. */
1426 reset_specialization ();
1431 /* Begin a constructor declarator of the form `SCOPE::NAME'. Returns
1435 begin_constructor_declarator (scope, name)
1439 tree result = build_parse_node (SCOPE_REF, scope, name);
1440 enter_scope_of (result);
1444 /* Finish an init-declarator. Returns a DECL. */
1447 finish_declarator (declarator, declspecs, attributes,
1448 prefix_attributes, initialized)
1452 tree prefix_attributes;
1455 return start_decl (declarator, declspecs, initialized, attributes,
1459 /* Finish a translation unit. */
1462 finish_translation_unit ()
1464 /* In case there were missing closebraces,
1465 get us back to the global binding level. */
1466 while (! toplevel_bindings_p ())
1468 while (current_namespace != global_namespace)
1473 /* Finish a template type parameter, specified as AGGR IDENTIFIER.
1474 Returns the parameter. */
1477 finish_template_type_parm (aggr, identifier)
1481 if (aggr != class_type_node)
1483 pedwarn ("template type parameters must use the keyword `class' or `typename'");
1484 aggr = class_type_node;
1487 return build_tree_list (aggr, identifier);
1490 /* Finish a template template parameter, specified as AGGR IDENTIFIER.
1491 Returns the parameter. */
1494 finish_template_template_parm (aggr, identifier)
1498 tree decl = build_decl (TYPE_DECL, identifier, NULL_TREE);
1499 tree tmpl = build_lang_decl (TEMPLATE_DECL, identifier, NULL_TREE);
1500 DECL_TEMPLATE_PARMS (tmpl) = current_template_parms;
1501 DECL_TEMPLATE_RESULT (tmpl) = decl;
1502 SET_DECL_ARTIFICIAL (decl);
1503 end_template_decl ();
1505 return finish_template_type_parm (aggr, tmpl);
1508 /* Finish a parameter list, indicated by PARMS. If ELLIPSIS is
1509 non-zero, the parameter list was terminated by a `...'. */
1512 finish_parmlist (parms, ellipsis)
1517 chainon (parms, void_list_node);
1518 /* We mark the PARMS as a parmlist so that declarator processing can
1519 disambiguate certain constructs. */
1520 if (parms != NULL_TREE)
1521 TREE_PARMLIST (parms) = 1;
1526 /* Begin a class definition, as indicated by T. */
1529 begin_class_definition (t)
1532 push_permanent_obstack ();
1534 if (t == error_mark_node
1535 || ! IS_AGGR_TYPE (t))
1537 t = make_lang_type (RECORD_TYPE);
1538 pushtag (make_anon_name (), t, 0);
1541 /* In a definition of a member class template, we will get here with an
1542 implicit typename, a TYPENAME_TYPE with a type. */
1543 if (TREE_CODE (t) == TYPENAME_TYPE)
1546 /* If we generated a partial instantiation of this type, but now
1547 we're seeing a real definition, we're actually looking at a
1548 partial specialization. Consider:
1550 template <class T, class U>
1556 template <class T, class U>
1559 typename X<Y<T, U> >::A a;
1562 template <class T, class U>
1567 We have to undo the effects of the previous partial
1569 if (PARTIAL_INSTANTIATION_P (t))
1573 /* Unfortunately, when we're not in pedantic mode, we
1574 attempt to actually fill in some of the fields of the
1575 partial instantiation, in order to support the implicit
1576 typename extension. Clear those fields now, in
1577 preparation for the definition here. The fields cleared
1578 here must match those set in instantiate_class_template.
1579 Look for a comment mentioning begin_class_definition
1581 TYPE_BINFO_BASETYPES (t) = NULL_TREE;
1582 TYPE_FIELDS (t) = NULL_TREE;
1583 TYPE_METHODS (t) = NULL_TREE;
1584 CLASSTYPE_TAGS (t) = NULL_TREE;
1585 TYPE_SIZE (t) = NULL_TREE;
1588 /* This isn't a partial instantiation any more. */
1589 PARTIAL_INSTANTIATION_P (t) = 0;
1591 /* If this type was already complete, and we see another definition,
1593 else if (TYPE_SIZE (t))
1594 duplicate_tag_error (t);
1596 /* Update the location of the decl. */
1597 DECL_SOURCE_FILE (TYPE_NAME (t)) = input_filename;
1598 DECL_SOURCE_LINE (TYPE_NAME (t)) = lineno;
1600 if (TYPE_BEING_DEFINED (t))
1602 t = make_lang_type (TREE_CODE (t));
1603 pushtag (TYPE_IDENTIFIER (t), t, 0);
1605 maybe_process_partial_specialization (t);
1607 TYPE_BEING_DEFINED (t) = 1;
1608 /* Reset the interface data, at the earliest possible
1609 moment, as it might have been set via a class foo;
1612 tree name = TYPE_IDENTIFIER (t);
1614 if (! ANON_AGGRNAME_P (name))
1616 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
1617 SET_CLASSTYPE_INTERFACE_UNKNOWN_X
1618 (t, interface_unknown);
1621 /* Only leave this bit clear if we know this
1622 class is part of an interface-only specification. */
1623 if (! CLASSTYPE_INTERFACE_KNOWN (t)
1624 || ! CLASSTYPE_INTERFACE_ONLY (t))
1625 CLASSTYPE_VTABLE_NEEDS_WRITING (t) = 1;
1628 tmp = TYPE_IDENTIFIER ($<ttype>0);
1629 if (tmp && IDENTIFIER_TEMPLATE (tmp))
1630 overload_template_name (tmp, 1);
1632 reset_specialization();
1634 /* In case this is a local class within a template
1635 function, we save the current tree structure so
1636 that we can get it back later. */
1639 /* Make a declaration for this class in its own scope. */
1640 build_self_reference ();
1645 /* Finish the member declaration given by DECL. */
1648 finish_member_declaration (decl)
1651 if (decl == error_mark_node || decl == NULL_TREE)
1654 if (decl == void_type_node)
1655 /* The COMPONENT was a friend, not a member, and so there's
1656 nothing for us to do. */
1659 /* We should see only one DECL at a time. */
1660 my_friendly_assert (TREE_CHAIN (decl) == NULL_TREE, 0);
1662 /* Set up access control for DECL. */
1664 = (current_access_specifier == access_private_node);
1665 TREE_PROTECTED (decl)
1666 = (current_access_specifier == access_protected_node);
1667 if (TREE_CODE (decl) == TEMPLATE_DECL)
1669 TREE_PRIVATE (DECL_RESULT (decl)) = TREE_PRIVATE (decl);
1670 TREE_PROTECTED (DECL_RESULT (decl)) = TREE_PROTECTED (decl);
1673 /* Mark the DECL as a member of the current class. */
1674 if (TREE_CODE (decl) == FUNCTION_DECL
1675 || DECL_FUNCTION_TEMPLATE_P (decl))
1676 /* Historically, DECL_CONTEXT was not set for a FUNCTION_DECL in
1677 finish_struct. Presumably it is already set as the function is
1678 parsed. Perhaps DECL_CLASS_CONTEXT is already set, too? */
1679 DECL_CLASS_CONTEXT (decl) = current_class_type;
1681 DECL_CONTEXT (decl) = current_class_type;
1683 /* Put functions on the TYPE_METHODS list and everything else on the
1684 TYPE_FIELDS list. Note that these are built up in reverse order.
1685 We reverse them (to obtain declaration order) in finish_struct. */
1686 if (TREE_CODE (decl) == FUNCTION_DECL
1687 || DECL_FUNCTION_TEMPLATE_P (decl))
1689 /* We also need to add this function to the
1690 CLASSTYPE_METHOD_VEC. */
1691 add_method (current_class_type, 0, decl);
1693 TREE_CHAIN (decl) = TYPE_METHODS (current_class_type);
1694 TYPE_METHODS (current_class_type) = decl;
1698 /* All TYPE_DECLs go at the end of TYPE_FIELDS. Ordinary fields
1699 go at the beginning. The reason is that lookup_field_1
1700 searches the list in order, and we want a field name to
1701 override a type name so that the "struct stat hack" will
1702 work. In particular:
1704 struct S { enum E { }; int E } s;
1707 is legal. In addition, the FIELD_DECLs must be maintained in
1708 declaration order so that class layout works as expected.
1709 However, we don't need that order until class layout, so we
1710 save a little time by putting FIELD_DECLs on in reverse order
1711 here, and then reversing them in finish_struct_1. (We could
1712 also keep a pointer to the correct insertion points in the
1715 if (TREE_CODE (decl) == TYPE_DECL)
1716 TYPE_FIELDS (current_class_type)
1717 = chainon (TYPE_FIELDS (current_class_type), decl);
1720 TREE_CHAIN (decl) = TYPE_FIELDS (current_class_type);
1721 TYPE_FIELDS (current_class_type) = decl;
1724 /* Enter the DECL into the scope of the class. */
1725 if (TREE_CODE (decl) != USING_DECL)
1726 pushdecl_class_level (decl);
1730 /* Finish a class definition T with the indicate ATTRIBUTES. If SEMI,
1731 the definition is immediately followed by a semicolon. Returns the
1735 finish_class_definition (t, attributes, semi, pop_scope_p)
1741 /* finish_struct nukes this anyway; if finish_exception does too,
1744 note_got_semicolon (t);
1746 /* If we got any attributes in class_head, xref_tag will stick them in
1747 TREE_TYPE of the type. Grab them now. */
1748 attributes = chainon (TREE_TYPE (t), attributes);
1749 TREE_TYPE (t) = NULL_TREE;
1751 if (TREE_CODE (t) == ENUMERAL_TYPE)
1755 t = finish_struct (t, attributes);
1757 note_got_semicolon (t);
1763 check_for_missing_semicolon (t);
1765 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (t)));
1766 if (current_scope () == current_function_decl)
1767 do_pending_defargs ();
1772 /* Finish processing the default argument expressions cached during
1773 the processing of a class definition. */
1776 begin_inline_definitions ()
1779 && current_scope () == current_function_decl)
1780 do_pending_inlines ();
1783 /* Finish processing the inline function definitions cached during the
1784 processing of a class definition. */
1787 finish_inline_definitions ()
1789 if (current_class_type == NULL_TREE)
1790 clear_inline_text_obstack ();
1792 /* Undo the begin_tree in begin_class_definition. */
1796 /* Finish processing the declaration of a member class template
1797 TYPES whose template parameters are given by PARMS. */
1800 finish_member_class_template (types)
1805 /* If there are declared, but undefined, partial specializations
1806 mixed in with the typespecs they will not yet have passed through
1807 maybe_process_partial_specialization, so we do that here. */
1808 for (t = types; t != NULL_TREE; t = TREE_CHAIN (t))
1809 if (IS_AGGR_TYPE_CODE (TREE_CODE (TREE_VALUE (t))))
1810 maybe_process_partial_specialization (TREE_VALUE (t));
1812 note_list_got_semicolon (types);
1813 grok_x_components (types);
1814 if (TYPE_CONTEXT (TREE_VALUE (types)) != current_class_type)
1815 /* The component was in fact a friend declaration. We avoid
1816 finish_member_template_decl performing certain checks by
1820 finish_member_template_decl (types);
1822 /* As with other component type declarations, we do
1823 not store the new DECL on the list of
1828 /* Finish processsing a complete template declaration. The PARMS are
1829 the template parameters. */
1832 finish_template_decl (parms)
1836 end_template_decl ();
1838 end_specialization ();
1841 /* Finish processing a a template-id (which names a type) of the form
1842 NAME < ARGS >. Return the TYPE_DECL for the type named by the
1843 template-id. If ENTERING_SCOPE is non-zero we are about to enter
1844 the scope of template-id indicated. */
1847 finish_template_type (name, args, entering_scope)
1854 decl = lookup_template_class (name, args,
1855 NULL_TREE, NULL_TREE, entering_scope);
1856 if (decl != error_mark_node)
1857 decl = TYPE_STUB_DECL (decl);
1862 /* SR is a SCOPE_REF node. Enter the scope of SR, whether it is a
1863 namespace scope or a class scope. */
1869 tree scope = TREE_OPERAND (sr, 0);
1871 if (TREE_CODE (scope) == NAMESPACE_DECL)
1873 push_decl_namespace (scope);
1874 TREE_COMPLEXITY (sr) = -1;
1876 else if (scope != current_class_type)
1878 if (TREE_CODE (scope) == TYPENAME_TYPE)
1880 /* In a declarator for a template class member, the scope will
1881 get here as an implicit typename, a TYPENAME_TYPE with a type. */
1882 scope = TREE_TYPE (scope);
1883 TREE_OPERAND (sr, 0) = scope;
1885 push_nested_class (scope, 3);
1886 TREE_COMPLEXITY (sr) = current_class_depth;
1890 /* Finish processing a BASE_CLASS with the indicated ACCESS_SPECIFIER.
1891 Return a TREE_LIST containing the ACCESS_SPECIFIER and the
1892 BASE_CLASS, or NULL_TREE if an error occurred. The
1893 ACCESSS_SPECIFIER is one of
1894 access_{default,public,protected_private}[_virtual]_node.*/
1897 finish_base_specifier (access_specifier, base_class)
1898 tree access_specifier;
1904 if (base_class == NULL_TREE)
1906 error ("invalid base class");
1907 type = error_mark_node;
1910 type = TREE_TYPE (base_class);
1912 if (! is_aggr_type (type, 1))
1915 result = build_tree_list (access_specifier, type);
1920 /* Called when multiple declarators are processed. If that is not
1921 premitted in this context, an error is issued. */
1924 check_multiple_declarators ()
1928 In a template-declaration, explicit specialization, or explicit
1929 instantiation the init-declarator-list in the declaration shall
1930 contain at most one declarator.
1932 We don't just use PROCESSING_TEMPLATE_DECL for the first
1933 condition since that would disallow the perfectly legal code,
1934 like `template <class T> struct S { int i, j; };'. */
1935 tree scope = current_scope ();
1937 if (scope && TREE_CODE (scope) == FUNCTION_DECL)
1938 /* It's OK to write `template <class T> void f() { int i, j;}'. */
1941 if (PROCESSING_REAL_TEMPLATE_DECL_P ()
1942 || processing_explicit_instantiation
1943 || processing_specialization)
1944 cp_error ("multiple declarators in template declaration");
1948 finish_typeof (expr)
1951 if (processing_template_decl)
1955 push_permanent_obstack ();
1956 t = make_lang_type (TYPEOF_TYPE);
1957 TYPE_FIELDS (t) = expr;
1963 return TREE_TYPE (expr);
1966 /* Create an empty statement tree for FN. */
1969 begin_stmt_tree (fn)
1972 /* We create a trivial EXPR_STMT so that last_tree is never NULL in
1973 what follows. We remove the extraneous statement in
1974 finish_stmt_tree. */
1975 DECL_SAVED_TREE (fn) = build_nt (EXPR_STMT, void_zero_node);
1976 last_tree = DECL_SAVED_TREE (fn);
1977 last_expr_type = NULL_TREE;
1980 /* Finish the statement tree for FN. */
1983 finish_stmt_tree (fn)
1986 DECL_SAVED_TREE (fn) = TREE_CHAIN (DECL_SAVED_TREE (fn));
1989 /* Generate RTL for the chain of statements T. */
2002 /* Generate RTL for the statement T, and its substatements. */
2008 if (t == NULL_TREE || t == error_mark_node)
2011 switch (TREE_CODE (t))
2014 lineno = STMT_LINENO (t);
2015 finish_return_stmt (RETURN_EXPR (t));
2019 lineno = STMT_LINENO (t);
2020 finish_expr_stmt (EXPR_STMT_EXPR (t));
2026 int i = suspend_momentary ();
2028 lineno = STMT_LINENO (t);
2029 emit_line_note (input_filename, lineno);
2030 decl = DECL_STMT_DECL (t);
2031 /* We need to clear DECL_CONTEXT so that maybe_push_decl
2032 will push it into the current scope. */
2033 if (DECL_CONTEXT (decl) == current_function_decl)
2034 DECL_CONTEXT (decl) = NULL_TREE;
2035 /* If we marked this variable as dead when we processed it
2036 before, we must undo that now. The variable has been
2038 if (TREE_CODE (decl) == VAR_DECL)
2039 DECL_DEAD_FOR_LOCAL (decl) = 0;
2040 maybe_push_decl (decl);
2041 cp_finish_decl (decl, DECL_INITIAL (decl), NULL_TREE, 0, 0);
2042 resume_momentary (i);
2050 lineno = STMT_LINENO (t);
2052 for (tmp = FOR_INIT_STMT (t); tmp; tmp = TREE_CHAIN (tmp))
2054 finish_for_init_stmt (NULL_TREE);
2055 finish_for_cond (FOR_COND (t), NULL_TREE);
2057 finish_for_expr (tmp, NULL_TREE);
2058 expand_stmt (FOR_BODY (t));
2059 finish_for_stmt (tmp, NULL_TREE);
2065 lineno = STMT_LINENO (t);
2066 begin_while_stmt ();
2067 finish_while_stmt_cond (WHILE_COND (t), NULL_TREE);
2068 expand_stmt (WHILE_BODY (t));
2069 finish_while_stmt (NULL_TREE);
2075 lineno = STMT_LINENO (t);
2077 expand_stmt (DO_BODY (t));
2078 finish_do_body (NULL_TREE);
2079 finish_do_stmt (DO_COND (t), NULL_TREE);
2084 lineno = STMT_LINENO (t);
2086 finish_if_stmt_cond (IF_COND (t), NULL_TREE);
2087 if (THEN_CLAUSE (t))
2089 expand_stmt (THEN_CLAUSE (t));
2090 finish_then_clause (NULL_TREE);
2092 if (ELSE_CLAUSE (t))
2094 begin_else_clause ();
2095 expand_stmt (ELSE_CLAUSE (t));
2096 finish_else_clause (NULL_TREE);
2102 lineno = STMT_LINENO (t);
2103 begin_compound_stmt (COMPOUND_STMT_NO_SCOPE (t));
2104 expand_stmts (COMPOUND_BODY (t));
2105 return finish_compound_stmt (COMPOUND_STMT_NO_SCOPE (t),
2109 lineno = STMT_LINENO (t);
2110 finish_break_stmt ();
2114 lineno = STMT_LINENO (t);
2115 finish_continue_stmt ();
2119 lineno = STMT_LINENO (t);
2120 begin_switch_stmt ();
2121 finish_switch_cond (SWITCH_COND (t));
2122 if (TREE_OPERAND (t, 1))
2123 expand_stmt (SWITCH_BODY (t));
2124 finish_switch_stmt (SWITCH_COND (t), NULL_TREE);
2128 finish_case_label (CASE_LOW (t), CASE_HIGH (t));
2132 t = define_label (DECL_SOURCE_FILE (t), DECL_SOURCE_LINE (t),
2139 lineno = STMT_LINENO (t);
2140 finish_goto_stmt (GOTO_DESTINATION (t));
2144 lineno = STMT_LINENO (t);
2145 finish_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t), ASM_OUTPUTS
2146 (t), ASM_INPUTS (t), ASM_CLOBBERS (t));
2150 lineno = STMT_LINENO (t);
2153 expand_eh_region_start ();
2154 expand_stmt (TRY_STMTS (t));
2155 finish_cleanup (TRY_HANDLERS (t), NULL_TREE);
2160 expand_stmt (TRY_STMTS (t));
2161 finish_try_block (NULL_TREE);
2162 expand_stmts (TRY_HANDLERS (t));
2163 finish_handler_sequence (NULL_TREE);
2168 lineno = STMT_LINENO (t);
2170 if (HANDLER_PARMS (t))
2172 tree d = HANDLER_PARMS (t);
2173 expand_start_catch_block (TREE_OPERAND (d, 1),
2174 TREE_OPERAND (d, 0));
2177 expand_start_catch_block (NULL_TREE, NULL_TREE);
2178 finish_handler_parms (NULL_TREE);
2179 expand_stmt (HANDLER_BODY (t));
2180 finish_handler (NULL_TREE);
2184 lineno = STMT_LINENO (t);
2185 finish_subobject (SUBOBJECT_CLEANUP (t));
2189 my_friendly_abort (19990810);
2196 /* Generate RTL for FN. */
2202 int saved_expanding_p;
2207 /* Remember whether we're already processing a function definition
2208 so that we can tell finish_function. */
2209 nested = in_function_p ();
2211 /* Let the compiler know that now is the time to really generate
2213 saved_expanding_p = expanding_p;
2216 start_function (NULL_TREE, fn, NULL_TREE, 1);
2217 store_parm_decls ();
2219 /* There are a few things that we do not handle recursively. For
2220 example, a function try-block is handled differently from an
2221 ordinary try-block, so we must handle it here. */
2222 t = DECL_SAVED_TREE (fn);
2223 try_block = NULL_TREE;
2224 if (t && TREE_CODE (t) == TRY_BLOCK)
2227 begin_function_try_block ();
2228 t = TRY_STMTS (try_block);
2231 if (t && TREE_CODE (t) == RETURN_INIT)
2233 /* Clear this out so that finish_named_return_value can set it
2235 DECL_NAME (DECL_RESULT (fn)) = NULL_TREE;
2236 finish_named_return_value (TREE_OPERAND (t, 0), TREE_OPERAND (t, 1));
2240 if (t && TREE_CODE (t) == CTOR_INITIALIZER)
2242 current_member_init_list = TREE_OPERAND (t, 0);
2243 current_base_init_list = TREE_OPERAND (t, 1);
2247 /* If this is a constructor, we need to initialize our members and
2251 /* Expand the body. */
2254 /* If there was a function try-block, expand the handlers. */
2257 finish_function_try_block (NULL_TREE);
2259 tree handler = TRY_HANDLERS (try_block);
2260 for (; handler; handler = TREE_CHAIN (handler))
2261 expand_stmt (handler);
2263 finish_function_handler_sequence (NULL_TREE);
2266 finish_function (lineno, 0, nested);
2268 /* Restore EXPANDING_P. */
2269 expanding_p = saved_expanding_p;