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 do_pushlevel PROTO((void));
45 static tree do_poplevel PROTO((void));
46 static void finish_expr_stmt_real PROTO((tree, int));
47 static tree expand_cond PROTO((tree));
49 /* When parsing a template, LAST_TREE contains the last statement
50 parsed. These are chained together through the TREE_CHAIN field,
51 but often need to be re-organized since the parse is performed
52 bottom-up. This macro makes LAST_TREE the indicated SUBSTMT of
55 #define RECHAIN_STMTS(stmt, substmt) \
57 substmt = TREE_CHAIN (stmt); \
58 TREE_CHAIN (stmt) = NULL_TREE; \
62 /* Finish processing the COND, the SUBSTMT condition for STMT. */
64 #define FINISH_COND(cond, stmt, substmt) \
66 if (last_tree != stmt) \
67 RECHAIN_STMTS (stmt, substmt); \
72 /* T is a statement. Add it to the statement-tree. */
78 /* Add T to the statement-tree. */
79 last_tree = TREE_CHAIN (last_tree) = t;
81 /* When we expand a statement-tree, we must know whether or not the
82 statements are full-expresions. We record that fact here. */
83 if (building_stmt_tree ())
84 STMT_IS_FULL_EXPR_P (last_tree) = stmts_are_full_exprs_p;
87 /* Finish an expression-statement, whose EXPRESSION is as indicated.
88 If ASSIGNED_THIS is non-zero, then this statement just assigned to
89 the `this' pointer. */
92 finish_expr_stmt_real (expr, assigned_this)
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 (!stmts_are_full_exprs_p &&
106 ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
108 || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE))
109 expr = default_conversion (expr);
111 if (stmts_are_full_exprs_p)
112 expand_start_target_temps ();
114 cplus_expand_expr_stmt (expr);
116 if (stmts_are_full_exprs_p)
118 expand_end_target_temps ();
124 /* If this statement assigned to the `this' pointer, record that
125 fact for finish_stmt. */
127 current_function_just_assigned_this = 1;
131 /* This was an expression-statement, so we save the type of the
133 last_expr_type = expr ? TREE_TYPE (expr) : NULL_TREE;
136 /* Like finish_expr_stmt_real, but ASSIGNS_THIS is always zero. */
139 finish_expr_stmt (expr)
142 finish_expr_stmt_real (expr, /*assigns_this=*/0);
145 /* Begin an if-statement. Returns a newly created IF_STMT if
153 if (building_stmt_tree ())
155 r = build_min_nt (IF_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
166 /* Process the COND of an if-statement, which may be given by
170 finish_if_stmt_cond (cond, if_stmt)
174 if (building_stmt_tree ())
175 FINISH_COND (cond, if_stmt, IF_COND (if_stmt));
178 emit_line_note (input_filename, lineno);
179 expand_start_cond (condition_conversion (cond), 0);
183 /* Finish the then-clause of an if-statement, which may be given by
187 finish_then_clause (if_stmt)
190 if (building_stmt_tree ())
192 RECHAIN_STMTS (if_stmt, THEN_CLAUSE (if_stmt));
200 /* Begin the else-clause of an if-statement. */
205 if (!building_stmt_tree ())
206 expand_start_else ();
209 /* Finish the else-clause of an if-statement, which may be given by
213 finish_else_clause (if_stmt)
216 if (building_stmt_tree ())
217 RECHAIN_STMTS (if_stmt, ELSE_CLAUSE (if_stmt));
220 /* Finsh an if-statement. */
225 if (!building_stmt_tree ())
232 /* Begin a while-statement. Returns a newly created WHILE_STMT if
240 if (building_stmt_tree ())
242 r = build_min_nt (WHILE_STMT, NULL_TREE, NULL_TREE);
248 emit_line_note (input_filename, lineno);
249 expand_start_loop (1);
258 /* Process the COND of an if-statement, which may be given by
262 finish_while_stmt_cond (cond, while_stmt)
266 if (building_stmt_tree ())
267 FINISH_COND (cond, while_stmt, WHILE_COND (while_stmt));
270 emit_line_note (input_filename, lineno);
271 expand_exit_loop_if_false (0, condition_conversion (cond));
274 /* If COND wasn't a declaration, clear out the
275 block we made for it and start a new one here so the
276 optimization in expand_end_loop will work. */
277 if (getdecls () == NULL_TREE)
284 /* Finish a while-statement, which may be given by WHILE_STMT. */
287 finish_while_stmt (while_stmt)
292 if (building_stmt_tree ())
293 RECHAIN_STMTS (while_stmt, WHILE_BODY (while_stmt));
299 /* Begin a do-statement. Returns a newly created DO_STMT if
305 if (building_stmt_tree ())
307 tree r = build_min_nt (DO_STMT, NULL_TREE, NULL_TREE);
314 emit_line_note (input_filename, lineno);
315 expand_start_loop_continue_elsewhere (1);
320 /* Finish the body of a do-statement, which may be given by DO_STMT. */
323 finish_do_body (do_stmt)
326 if (building_stmt_tree ())
327 RECHAIN_STMTS (do_stmt, DO_BODY (do_stmt));
329 expand_loop_continue_here ();
332 /* Finish a do-statement, which may be given by DO_STMT, and whose
333 COND is as indicated. */
336 finish_do_stmt (cond, do_stmt)
340 if (building_stmt_tree ())
341 DO_COND (do_stmt) = cond;
344 emit_line_note (input_filename, lineno);
345 expand_exit_loop_if_false (0, condition_conversion (cond));
353 /* Finish a return-statement. The EXPRESSION returned, if any, is as
357 finish_return_stmt (expr)
360 if (building_stmt_tree ())
361 add_tree (build_min_nt (RETURN_STMT, expr));
364 emit_line_note (input_filename, lineno);
365 c_expand_return (expr);
371 /* Begin a for-statement. Returns a new FOR_STMT if appropriate. */
378 if (building_stmt_tree ())
380 r = build_min_nt (FOR_STMT, NULL_TREE, NULL_TREE,
381 NULL_TREE, NULL_TREE);
387 if (flag_new_for_scope > 0)
390 note_level_for_for ();
396 /* Finish the for-init-statement of a for-statement, which may be
397 given by FOR_STMT. */
400 finish_for_init_stmt (for_stmt)
403 if (building_stmt_tree ())
405 if (last_tree != for_stmt)
406 RECHAIN_STMTS (for_stmt, FOR_INIT_STMT (for_stmt));
411 emit_line_note (input_filename, lineno);
412 expand_start_loop_continue_elsewhere (1);
418 /* Finish the COND of a for-statement, which may be given by
422 finish_for_cond (cond, for_stmt)
426 if (building_stmt_tree ())
427 FINISH_COND (cond, for_stmt, FOR_COND (for_stmt));
430 emit_line_note (input_filename, lineno);
432 expand_exit_loop_if_false (0, condition_conversion (cond));
435 /* If the cond wasn't a declaration, clear out the
436 block we made for it and start a new one here so the
437 optimization in expand_end_loop will work. */
438 if (getdecls () == NULL_TREE)
445 /* Finish the increment-EXPRESSION in a for-statement, which may be
446 given by FOR_STMT. */
449 finish_for_expr (expr, for_stmt)
453 if (building_stmt_tree ())
454 FOR_EXPR (for_stmt) = expr;
456 /* Don't let the tree nodes for EXPR be discarded
457 by clear_momentary during the parsing of the next stmt. */
461 /* Finish the body of a for-statement, which may be given by
462 FOR_STMT. The increment-EXPR for the loop must be
466 finish_for_stmt (expr, for_stmt)
470 /* Pop the scope for the body of the loop. */
473 if (building_stmt_tree ())
474 RECHAIN_STMTS (for_stmt, FOR_BODY (for_stmt));
477 emit_line_note (input_filename, lineno);
478 expand_loop_continue_here ();
480 finish_expr_stmt (expr);
486 if (flag_new_for_scope > 0)
492 /* Finish a break-statement. */
497 emit_line_note (input_filename, lineno);
498 if (building_stmt_tree ())
499 add_tree (build_min_nt (BREAK_STMT));
500 else if ( ! expand_exit_something ())
501 cp_error ("break statement not within loop or switch");
504 /* Finish a continue-statement. */
507 finish_continue_stmt ()
509 emit_line_note (input_filename, lineno);
510 if (building_stmt_tree ())
511 add_tree (build_min_nt (CONTINUE_STMT));
512 else if (! expand_continue_loop (0))
513 cp_error ("continue statement not within a loop");
516 /* Begin a switch-statement. Returns a new SWITCH_STMT if
524 if (building_stmt_tree ())
526 r = build_min_nt (SWITCH_STMT, NULL_TREE, NULL_TREE);
537 /* Finish the cond of a switch-statement. */
540 finish_switch_cond (cond, switch_stmt)
544 if (building_stmt_tree ())
545 FINISH_COND (cond, switch_stmt, SWITCH_COND (switch_stmt));
546 else if (cond != error_mark_node)
548 emit_line_note (input_filename, lineno);
549 c_expand_start_case (cond);
552 /* The code is in error, but we don't want expand_end_case to
554 c_expand_start_case (boolean_false_node);
558 /* Don't let the tree nodes for COND be discarded by
559 clear_momentary during the parsing of the next stmt. */
563 /* Finish the body of a switch-statement, which may be given by
564 SWITCH_STMT. The COND to switch on is indicated. */
567 finish_switch_stmt (cond, switch_stmt)
571 if (building_stmt_tree ())
572 RECHAIN_STMTS (switch_stmt, SWITCH_BODY (switch_stmt));
574 expand_end_case (cond);
581 /* Finish a case-label. */
584 finish_case_label (low_value, high_value)
588 if (building_stmt_tree ())
590 add_tree (build_min_nt (CASE_LABEL, low_value, high_value));
594 do_case (low_value, high_value);
597 /* Finish a goto-statement. */
600 finish_goto_stmt (destination)
603 if (TREE_CODE (destination) == IDENTIFIER_NODE)
604 destination = lookup_label (destination);
606 if (building_stmt_tree ())
607 add_tree (build_min_nt (GOTO_STMT, destination));
610 emit_line_note (input_filename, lineno);
612 if (TREE_CODE (destination) == LABEL_DECL)
614 TREE_USED (destination) = 1;
615 expand_goto (destination);
618 expand_computed_goto (destination);
622 /* Begin a try-block. Returns a newly-created TRY_BLOCK if
628 if (building_stmt_tree ())
630 tree r = build_min_nt (TRY_BLOCK, NULL_TREE,
637 emit_line_note (input_filename, lineno);
638 expand_start_try_stmts ();
643 /* Likewise, for a function-try-block. */
646 begin_function_try_block ()
648 if (building_stmt_tree ())
650 tree r = build_min_nt (TRY_BLOCK, NULL_TREE,
652 FN_TRY_BLOCK_P (r) = 1;
658 if (! current_function_parms_stored)
660 expand_start_early_try_stmts ();
665 /* Finish a try-block, which may be given by TRY_BLOCK. */
668 finish_try_block (try_block)
671 if (building_stmt_tree ())
672 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
674 expand_start_all_catch ();
677 /* Finish the body of a cleanup try-block, which may be given by
681 finish_cleanup_try_block (try_block)
684 if (building_stmt_tree ())
685 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
688 /* Finish an implicitly generated try-block, with a cleanup is given
692 finish_cleanup (cleanup, try_block)
696 if (building_stmt_tree ())
698 TRY_HANDLERS (try_block) = cleanup;
699 CLEANUP_P (try_block) = 1;
702 expand_eh_region_end (protect_with_terminate (cleanup));
705 /* Likewise, for a function-try-block. */
708 finish_function_try_block (try_block)
711 if (building_stmt_tree ())
713 if (TREE_CHAIN (try_block)
714 && TREE_CODE (TREE_CHAIN (try_block)) == CTOR_INITIALIZER)
716 /* Chain the compound statement after the CTOR_INITIALIZER. */
717 TREE_CHAIN (TREE_CHAIN (try_block)) = last_tree;
718 /* And make the CTOR_INITIALIZER the body of the try-block. */
719 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
722 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
726 end_protect_partials ();
727 expand_start_all_catch ();
728 in_function_try_handler = 1;
732 /* Finish a handler-sequence for a try-block, which may be given by
736 finish_handler_sequence (try_block)
739 if (building_stmt_tree ())
740 RECHAIN_STMTS (try_block, TRY_HANDLERS (try_block));
742 expand_end_all_catch ();
745 /* Likewise, for a function-try-block. */
748 finish_function_handler_sequence (try_block)
751 if (building_stmt_tree ())
752 RECHAIN_STMTS (try_block, TRY_HANDLERS (try_block));
755 in_function_try_handler = 0;
756 expand_end_all_catch ();
760 /* Begin a handler. Returns a HANDLER if appropriate. */
767 if (building_stmt_tree ())
769 r = build_min_nt (HANDLER, NULL_TREE, NULL_TREE);
780 /* Finish the handler-parameters for a handler, which may be given by
784 finish_handler_parms (handler)
787 if (building_stmt_tree ())
788 RECHAIN_STMTS (handler, HANDLER_PARMS (handler));
791 /* Finish a handler, which may be given by HANDLER. */
794 finish_handler (handler)
797 if (building_stmt_tree ())
798 RECHAIN_STMTS (handler, HANDLER_BODY (handler));
800 expand_end_catch_block ();
805 /* Begin a compound-statement. If HAS_NO_SCOPE is non-zero, the
806 compound-statement does not define a scope. Returns a new
807 COMPOUND_STMT if appropriate. */
810 begin_compound_stmt (has_no_scope)
815 if (building_stmt_tree ())
817 r = build_min_nt (COMPOUND_STMT, NULL_TREE);
820 COMPOUND_STMT_NO_SCOPE (r) = 1;
825 last_expr_type = NULL_TREE;
830 /* Normally, we try hard to keep the BLOCK for a
831 statement-expression. But, if it's a statement-expression with
832 a scopeless block, there's nothing to keep, and we don't want
833 to accidentally keep a block *inside* the scopeless block. */
840 /* Finish a compound-statement, which may be given by COMPOUND_STMT.
841 If HAS_NO_SCOPE is non-zero, the compound statement does not define
845 finish_compound_stmt (has_no_scope, compound_stmt)
857 if (building_stmt_tree ())
858 RECHAIN_STMTS (compound_stmt, COMPOUND_BODY (compound_stmt));
860 /* When we call finish_stmt we will lose LAST_EXPR_TYPE. But, since
861 the precise purpose of that variable is store the type of the
862 last expression statement within the last compound statement, we
863 preserve the value. */
871 /* Finish an asm-statement, whose components are a CV_QUALIFIER, a
872 STRING, some OUTPUT_OPERANDS, some INPUT_OPERANDS, and some
876 finish_asm_stmt (cv_qualifier, string, output_operands,
877 input_operands, clobbers)
880 tree output_operands;
884 if (TREE_CHAIN (string))
886 if (building_stmt_tree ())
887 /* We need to build the combined string on the permanent
888 obstack so that we can use it during instantiations. */
889 push_permanent_obstack ();
891 string = combine_strings (string);
893 if (building_stmt_tree ())
897 if (cv_qualifier != NULL_TREE
898 && cv_qualifier != ridpointers[(int) RID_VOLATILE])
900 cp_warning ("%s qualifier ignored on asm",
901 IDENTIFIER_POINTER (cv_qualifier));
902 cv_qualifier = NULL_TREE;
905 if (building_stmt_tree ())
907 tree r = build_min_nt (ASM_STMT, cv_qualifier, string,
908 output_operands, input_operands,
914 emit_line_note (input_filename, lineno);
915 if (output_operands != NULL_TREE || input_operands != NULL_TREE
916 || clobbers != NULL_TREE)
920 for (t = input_operands; t; t = TREE_CHAIN (t))
921 TREE_VALUE (t) = decay_conversion (TREE_VALUE (t));
923 c_expand_asm_operands (string, output_operands,
926 cv_qualifier != NULL_TREE,
927 input_filename, lineno);
936 /* Finish a label with the indicated NAME. */
939 finish_label_stmt (name)
942 tree decl = define_label (input_filename, lineno, name);
944 if (building_stmt_tree ())
945 add_tree (build_min_nt (LABEL_STMT, decl));
950 /* Finish a series of declarations for local labels. G++ allows users
951 to declare "local" labels, i.e., labels with scope. This extension
952 is useful when writing code involving statement-expressions. */
955 finish_label_decl (name)
958 tree decl = declare_local_label (name);
959 if (building_stmt_tree ())
960 add_decl_stmt (decl);
963 /* Create a declaration statement for the declaration given by the
972 /* We need the type to last until instantiation time. */
973 decl_stmt = build_min_nt (DECL_STMT, decl);
974 add_tree (decl_stmt);
977 /* We're in a constructor, and have just constructed a a subobject of
978 *THIS. CLEANUP is code to run if an exception is thrown before the
979 end of the current function is reached. */
982 finish_subobject (cleanup)
985 if (building_stmt_tree ())
987 tree r = build_min_nt (SUBOBJECT, cleanup);
991 add_partial_entry (cleanup);
994 /* Bind a name and initialization to the return value of
995 the current function. */
998 finish_named_return_value (return_id, init)
999 tree return_id, init;
1001 tree decl = DECL_RESULT (current_function_decl);
1004 /* Give this error as many times as there are occurrences,
1005 so that users can use Emacs compilation buffers to find
1006 and fix all such places. */
1007 pedwarn ("ANSI C++ does not permit named return values");
1009 if (return_id != NULL_TREE)
1011 if (DECL_NAME (decl) == NULL_TREE)
1013 DECL_NAME (decl) = return_id;
1014 DECL_ASSEMBLER_NAME (decl) = return_id;
1018 cp_error ("return identifier `%D' already in place", return_id);
1023 /* Can't let this happen for constructors. */
1024 if (DECL_CONSTRUCTOR_P (current_function_decl))
1026 error ("can't redefine default return value for constructors");
1030 /* If we have a named return value, put that in our scope as well. */
1031 if (DECL_NAME (decl) != NULL_TREE)
1033 /* Let `cp_finish_decl' know that this initializer is ok. */
1034 DECL_INITIAL (decl) = init;
1037 if (building_stmt_tree ())
1038 add_tree (build_min_nt (RETURN_INIT, return_id, init));
1041 cp_finish_decl (decl, init, NULL_TREE, 0, 0);
1042 store_return_init (decl);
1047 /* Cache the value of this class's main virtual function table pointer
1048 in a register variable. This will save one indirection if a
1049 more than one virtual function call is made this function. */
1054 if (base_init_expr == 0
1055 && DECL_CONSTRUCTOR_P (current_function_decl))
1057 if (building_stmt_tree ())
1058 add_tree (build_min_nt
1060 current_member_init_list, current_base_init_list));
1062 emit_base_init (current_class_type);
1065 /* Always keep the BLOCK node associated with the outermost pair of
1066 curley braces of a function. These are needed for correct
1067 operation of dwarfout.c. */
1068 keep_next_level (1);
1071 /* Begin a new scope. */
1076 if (!building_stmt_tree ())
1078 emit_line_note (input_filename, lineno);
1082 if (stmts_are_full_exprs_p)
1084 if (!building_stmt_tree () && stmts_are_full_exprs_p)
1085 expand_start_bindings (0);
1088 /* Finish a scope. */
1095 if (!building_stmt_tree () && stmts_are_full_exprs_p)
1096 expand_end_bindings (getdecls (), kept_level_p (), 0);
1097 if (stmts_are_full_exprs_p)
1098 t = poplevel (kept_level_p (), 1, 0);
1105 /* Finish a parenthesized expression EXPR. */
1108 finish_parenthesized_expr (expr)
1111 if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (expr))))
1112 /* This inhibits warnings in truthvalue_conversion. */
1113 C_SET_EXP_ORIGINAL_CODE (expr, ERROR_MARK);
1118 /* Begin a statement-expression. The value returned must be passed to
1119 finish_stmt_expr. */
1124 keep_next_level (1);
1125 /* If we're building a statement tree, then the upcoming compound
1126 statement will be chained onto the tree structure, starting at
1127 last_tree. We return last_tree so that we can later unhook the
1128 compound statement. */
1129 return building_stmt_tree () ? last_tree : expand_start_stmt_expr();
1132 /* Finish a statement-expression. RTL_EXPR should be the value
1133 returned by the previous begin_stmt_expr; EXPR is the
1134 statement-expression. Returns an expression representing the
1135 statement-expression. */
1138 finish_stmt_expr (rtl_expr, expr)
1144 if (!building_stmt_tree ())
1146 rtl_expr = expand_end_stmt_expr (rtl_expr);
1147 /* The statements have side effects, so the group does. */
1148 TREE_SIDE_EFFECTS (rtl_expr) = 1;
1151 if (building_stmt_tree ())
1153 /* If the last thing in the statement-expression was not an
1154 expression-statement, then it has type `void'. */
1155 if (!last_expr_type)
1156 last_expr_type = void_type_node;
1157 result = build_min (STMT_EXPR, last_expr_type, last_tree);
1158 TREE_SIDE_EFFECTS (result) = 1;
1160 /* Remove the compound statement from the tree structure; it is
1161 now saved in the STMT_EXPR. */
1162 last_tree = rtl_expr;
1163 TREE_CHAIN (last_tree) = NULL_TREE;
1165 else if (expr && TREE_CODE (expr) == BLOCK)
1167 result = build (BIND_EXPR, TREE_TYPE (rtl_expr),
1168 NULL_TREE, rtl_expr, expr);
1169 delete_block (expr);
1174 if (expr && TREE_CODE (expr) == BLOCK)
1175 /* Remove the block from the tree at this point. It gets put back
1176 at the proper place when the STMT_EXPR or BIND_EXPR is
1178 delete_block (expr);
1183 /* Finish a call to FN with ARGS. Returns a representation of the
1187 finish_call_expr (fn, args, koenig)
1196 if (TREE_CODE (fn) == BIT_NOT_EXPR)
1197 fn = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND (fn, 0));
1198 else if (TREE_CODE (fn) != TEMPLATE_ID_EXPR)
1199 fn = do_identifier (fn, 2, args);
1201 result = build_x_function_call (fn, args, current_class_ref);
1203 if (TREE_CODE (result) == CALL_EXPR
1204 && (! TREE_TYPE (result)
1205 || TREE_CODE (TREE_TYPE (result)) != VOID_TYPE))
1206 result = require_complete_type (result);
1211 /* Finish a call to a postfix increment or decrement or EXPR. (Which
1212 is indicated by CODE, which should be POSTINCREMENT_EXPR or
1213 POSTDECREMENT_EXPR.) */
1216 finish_increment_expr (expr, code)
1218 enum tree_code code;
1220 /* If we get an OFFSET_REF, turn it into what it really means (e.g.,
1221 a COMPONENT_REF). This way if we've got, say, a reference to a
1222 static member that's being operated on, we don't end up trying to
1223 find a member operator for the class it's in. */
1225 if (TREE_CODE (expr) == OFFSET_REF)
1226 expr = resolve_offset_ref (expr);
1227 return build_x_unary_op (code, expr);
1230 /* Finish a use of `this'. Returns an expression for `this'. */
1237 if (current_class_ptr)
1239 #ifdef WARNING_ABOUT_CCD
1240 TREE_USED (current_class_ptr) = 1;
1242 result = current_class_ptr;
1244 else if (current_function_decl
1245 && DECL_STATIC_FUNCTION_P (current_function_decl))
1247 error ("`this' is unavailable for static member functions");
1248 result = error_mark_node;
1252 if (current_function_decl)
1253 error ("invalid use of `this' in non-member function");
1255 error ("invalid use of `this' at top level");
1256 result = error_mark_node;
1262 /* Finish a member function call using OBJECT and ARGS as arguments to
1263 FN. Returns an expression for the call. */
1266 finish_object_call_expr (fn, object, args)
1272 /* This is a future direction of this code, but because
1273 build_x_function_call cannot always undo what is done in
1274 build_component_ref entirely yet, we cannot do this. */
1276 tree real_fn = build_component_ref (object, fn, NULL_TREE, 1);
1277 return finish_call_expr (real_fn, args);
1279 if (TREE_CODE (fn) == TYPE_DECL)
1281 if (processing_template_decl)
1282 /* This can happen on code like:
1285 template <class T> void f(T t) {
1289 We just grab the underlying IDENTIFIER. */
1290 fn = DECL_NAME (fn);
1293 cp_error ("calling type `%T' like a method", fn);
1294 return error_mark_node;
1298 return build_method_call (object, fn, args, NULL_TREE, LOOKUP_NORMAL);
1302 /* Finish a qualified member function call using OBJECT and ARGS as
1303 arguments to FN. Returns an expressino for the call. */
1306 finish_qualified_object_call_expr (fn, object, args)
1311 return build_scoped_method_call (object, TREE_OPERAND (fn, 0),
1312 TREE_OPERAND (fn, 1), args);
1315 /* Finish a pseudo-destructor call expression of OBJECT, with SCOPE
1316 being the scope, if any, of DESTRUCTOR. Returns an expression for
1320 finish_pseudo_destructor_call_expr (object, scope, destructor)
1325 if (processing_template_decl)
1326 return build_min_nt (PSEUDO_DTOR_EXPR, object, scope, destructor);
1328 if (scope && scope != destructor)
1329 cp_error ("destructor specifier `%T::~%T()' must have matching names",
1332 if ((scope == NULL_TREE || IDENTIFIER_GLOBAL_VALUE (destructor))
1333 && (TREE_CODE (TREE_TYPE (object)) !=
1334 TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (destructor)))))
1335 cp_error ("`%E' is not of type `%T'", object, destructor);
1337 return cp_convert (void_type_node, object);
1340 /* Finish a call to a globally qualified member function FN using
1341 ARGS. Returns an expression for the call. */
1344 finish_qualified_call_expr (fn, args)
1348 if (processing_template_decl)
1349 return build_min_nt (CALL_EXPR, fn, args, NULL_TREE);
1351 return build_member_call (TREE_OPERAND (fn, 0),
1352 TREE_OPERAND (fn, 1),
1356 /* Finish an expression taking the address of LABEL. Returns an
1357 expression for the address. */
1360 finish_label_address_expr (label)
1365 label = lookup_label (label);
1366 if (label == NULL_TREE)
1367 result = null_pointer_node;
1370 TREE_USED (label) = 1;
1371 result = build1 (ADDR_EXPR, ptr_type_node, label);
1372 TREE_CONSTANT (result) = 1;
1378 /* Finish an expression of the form CODE EXPR. */
1381 finish_unary_op_expr (code, expr)
1382 enum tree_code code;
1385 tree result = build_x_unary_op (code, expr);
1386 if (code == NEGATE_EXPR && TREE_CODE (expr) == INTEGER_CST)
1387 TREE_NEGATED_INT (result) = 1;
1388 overflow_warning (result);
1392 /* Finish an id-expression. */
1395 finish_id_expr (expr)
1398 if (TREE_CODE (expr) == IDENTIFIER_NODE)
1399 expr = do_identifier (expr, 1, NULL_TREE);
1404 /* Begin a new-placement. */
1407 begin_new_placement ()
1409 /* The arguments to a placement new might be passed to a
1410 deallocation function, in the event that the allocation throws an
1411 exception. Since we don't expand exception handlers until the
1412 end of a function, we must make sure the arguments stay around
1414 return suspend_momentary ();
1417 /* Finish a new-placement. The ARGS are the placement arguments. The
1418 COOKIE is the value returned by the previous call to
1419 begin_new_placement. */
1422 finish_new_placement (args, cookie)
1426 resume_momentary (cookie);
1430 /* Begin a function defniition declared with DECL_SPECS and
1431 DECLARATOR. Returns non-zero if the function-declaration is
1435 begin_function_definition (decl_specs, declarator)
1441 split_specs_attrs (decl_specs, &specs, &attrs);
1442 if (!start_function (specs, declarator, attrs, SF_DEFAULT))
1445 reinit_parse_for_function ();
1446 /* The things we're about to see are not directly qualified by any
1447 template headers we've seen thus far. */
1448 reset_specialization ();
1453 /* Begin a constructor declarator of the form `SCOPE::NAME'. Returns
1457 begin_constructor_declarator (scope, name)
1461 tree result = build_parse_node (SCOPE_REF, scope, name);
1462 enter_scope_of (result);
1466 /* Finish an init-declarator. Returns a DECL. */
1469 finish_declarator (declarator, declspecs, attributes,
1470 prefix_attributes, initialized)
1474 tree prefix_attributes;
1477 return start_decl (declarator, declspecs, initialized, attributes,
1481 /* Finish a translation unit. */
1484 finish_translation_unit ()
1486 /* In case there were missing closebraces,
1487 get us back to the global binding level. */
1488 while (! toplevel_bindings_p ())
1490 while (current_namespace != global_namespace)
1495 /* Finish a template type parameter, specified as AGGR IDENTIFIER.
1496 Returns the parameter. */
1499 finish_template_type_parm (aggr, identifier)
1503 if (aggr != class_type_node)
1505 pedwarn ("template type parameters must use the keyword `class' or `typename'");
1506 aggr = class_type_node;
1509 return build_tree_list (aggr, identifier);
1512 /* Finish a template template parameter, specified as AGGR IDENTIFIER.
1513 Returns the parameter. */
1516 finish_template_template_parm (aggr, identifier)
1520 tree decl = build_decl (TYPE_DECL, identifier, NULL_TREE);
1521 tree tmpl = build_lang_decl (TEMPLATE_DECL, identifier, NULL_TREE);
1522 DECL_TEMPLATE_PARMS (tmpl) = current_template_parms;
1523 DECL_TEMPLATE_RESULT (tmpl) = decl;
1524 SET_DECL_ARTIFICIAL (decl);
1525 end_template_decl ();
1527 return finish_template_type_parm (aggr, tmpl);
1530 /* Finish a parameter list, indicated by PARMS. If ELLIPSIS is
1531 non-zero, the parameter list was terminated by a `...'. */
1534 finish_parmlist (parms, ellipsis)
1539 chainon (parms, void_list_node);
1540 /* We mark the PARMS as a parmlist so that declarator processing can
1541 disambiguate certain constructs. */
1542 if (parms != NULL_TREE)
1543 TREE_PARMLIST (parms) = 1;
1548 /* Begin a class definition, as indicated by T. */
1551 begin_class_definition (t)
1554 push_permanent_obstack ();
1556 if (t == error_mark_node
1557 || ! IS_AGGR_TYPE (t))
1559 t = make_lang_type (RECORD_TYPE);
1560 pushtag (make_anon_name (), t, 0);
1563 /* In a definition of a member class template, we will get here with an
1564 implicit typename, a TYPENAME_TYPE with a type. */
1565 if (TREE_CODE (t) == TYPENAME_TYPE)
1568 /* If we generated a partial instantiation of this type, but now
1569 we're seeing a real definition, we're actually looking at a
1570 partial specialization. Consider:
1572 template <class T, class U>
1578 template <class T, class U>
1581 typename X<Y<T, U> >::A a;
1584 template <class T, class U>
1589 We have to undo the effects of the previous partial
1591 if (PARTIAL_INSTANTIATION_P (t))
1595 /* Unfortunately, when we're not in pedantic mode, we
1596 attempt to actually fill in some of the fields of the
1597 partial instantiation, in order to support the implicit
1598 typename extension. Clear those fields now, in
1599 preparation for the definition here. The fields cleared
1600 here must match those set in instantiate_class_template.
1601 Look for a comment mentioning begin_class_definition
1603 TYPE_BINFO_BASETYPES (t) = NULL_TREE;
1604 TYPE_FIELDS (t) = NULL_TREE;
1605 TYPE_METHODS (t) = NULL_TREE;
1606 CLASSTYPE_TAGS (t) = NULL_TREE;
1607 TYPE_SIZE (t) = NULL_TREE;
1610 /* This isn't a partial instantiation any more. */
1611 PARTIAL_INSTANTIATION_P (t) = 0;
1613 /* If this type was already complete, and we see another definition,
1615 else if (TYPE_SIZE (t))
1616 duplicate_tag_error (t);
1618 /* Update the location of the decl. */
1619 DECL_SOURCE_FILE (TYPE_NAME (t)) = input_filename;
1620 DECL_SOURCE_LINE (TYPE_NAME (t)) = lineno;
1622 if (TYPE_BEING_DEFINED (t))
1624 t = make_lang_type (TREE_CODE (t));
1625 pushtag (TYPE_IDENTIFIER (t), t, 0);
1627 maybe_process_partial_specialization (t);
1629 TYPE_BEING_DEFINED (t) = 1;
1630 /* Reset the interface data, at the earliest possible
1631 moment, as it might have been set via a class foo;
1634 tree name = TYPE_IDENTIFIER (t);
1636 if (! ANON_AGGRNAME_P (name))
1638 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
1639 SET_CLASSTYPE_INTERFACE_UNKNOWN_X
1640 (t, interface_unknown);
1643 /* Only leave this bit clear if we know this
1644 class is part of an interface-only specification. */
1645 if (! CLASSTYPE_INTERFACE_KNOWN (t)
1646 || ! CLASSTYPE_INTERFACE_ONLY (t))
1647 CLASSTYPE_VTABLE_NEEDS_WRITING (t) = 1;
1650 tmp = TYPE_IDENTIFIER ($<ttype>0);
1651 if (tmp && IDENTIFIER_TEMPLATE (tmp))
1652 overload_template_name (tmp, 1);
1654 reset_specialization();
1656 /* In case this is a local class within a template
1657 function, we save the current tree structure so
1658 that we can get it back later. */
1661 /* Make a declaration for this class in its own scope. */
1662 build_self_reference ();
1667 /* Finish the member declaration given by DECL. */
1670 finish_member_declaration (decl)
1673 if (decl == error_mark_node || decl == NULL_TREE)
1676 if (decl == void_type_node)
1677 /* The COMPONENT was a friend, not a member, and so there's
1678 nothing for us to do. */
1681 /* We should see only one DECL at a time. */
1682 my_friendly_assert (TREE_CHAIN (decl) == NULL_TREE, 0);
1684 /* Set up access control for DECL. */
1686 = (current_access_specifier == access_private_node);
1687 TREE_PROTECTED (decl)
1688 = (current_access_specifier == access_protected_node);
1689 if (TREE_CODE (decl) == TEMPLATE_DECL)
1691 TREE_PRIVATE (DECL_RESULT (decl)) = TREE_PRIVATE (decl);
1692 TREE_PROTECTED (DECL_RESULT (decl)) = TREE_PROTECTED (decl);
1695 /* Mark the DECL as a member of the current class. */
1696 if (TREE_CODE (decl) == FUNCTION_DECL
1697 || DECL_FUNCTION_TEMPLATE_P (decl))
1698 /* Historically, DECL_CONTEXT was not set for a FUNCTION_DECL in
1699 finish_struct. Presumably it is already set as the function is
1700 parsed. Perhaps DECL_CLASS_CONTEXT is already set, too? */
1701 DECL_CLASS_CONTEXT (decl) = current_class_type;
1703 DECL_CONTEXT (decl) = current_class_type;
1705 /* Put functions on the TYPE_METHODS list and everything else on the
1706 TYPE_FIELDS list. Note that these are built up in reverse order.
1707 We reverse them (to obtain declaration order) in finish_struct. */
1708 if (TREE_CODE (decl) == FUNCTION_DECL
1709 || DECL_FUNCTION_TEMPLATE_P (decl))
1711 /* We also need to add this function to the
1712 CLASSTYPE_METHOD_VEC. */
1713 add_method (current_class_type, 0, decl);
1715 TREE_CHAIN (decl) = TYPE_METHODS (current_class_type);
1716 TYPE_METHODS (current_class_type) = decl;
1720 /* All TYPE_DECLs go at the end of TYPE_FIELDS. Ordinary fields
1721 go at the beginning. The reason is that lookup_field_1
1722 searches the list in order, and we want a field name to
1723 override a type name so that the "struct stat hack" will
1724 work. In particular:
1726 struct S { enum E { }; int E } s;
1729 is legal. In addition, the FIELD_DECLs must be maintained in
1730 declaration order so that class layout works as expected.
1731 However, we don't need that order until class layout, so we
1732 save a little time by putting FIELD_DECLs on in reverse order
1733 here, and then reversing them in finish_struct_1. (We could
1734 also keep a pointer to the correct insertion points in the
1737 if (TREE_CODE (decl) == TYPE_DECL)
1738 TYPE_FIELDS (current_class_type)
1739 = chainon (TYPE_FIELDS (current_class_type), decl);
1742 TREE_CHAIN (decl) = TYPE_FIELDS (current_class_type);
1743 TYPE_FIELDS (current_class_type) = decl;
1746 /* Enter the DECL into the scope of the class. */
1747 if (TREE_CODE (decl) != USING_DECL)
1748 pushdecl_class_level (decl);
1752 /* Finish a class definition T with the indicate ATTRIBUTES. If SEMI,
1753 the definition is immediately followed by a semicolon. Returns the
1757 finish_class_definition (t, attributes, semi, pop_scope_p)
1763 /* finish_struct nukes this anyway; if finish_exception does too,
1766 note_got_semicolon (t);
1768 /* If we got any attributes in class_head, xref_tag will stick them in
1769 TREE_TYPE of the type. Grab them now. */
1770 attributes = chainon (TREE_TYPE (t), attributes);
1771 TREE_TYPE (t) = NULL_TREE;
1773 if (TREE_CODE (t) == ENUMERAL_TYPE)
1777 t = finish_struct (t, attributes);
1779 note_got_semicolon (t);
1785 check_for_missing_semicolon (t);
1787 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (t)));
1788 if (current_scope () == current_function_decl)
1789 do_pending_defargs ();
1794 /* Finish processing the default argument expressions cached during
1795 the processing of a class definition. */
1798 begin_inline_definitions ()
1801 && current_scope () == current_function_decl)
1802 do_pending_inlines ();
1805 /* Finish processing the inline function definitions cached during the
1806 processing of a class definition. */
1809 finish_inline_definitions ()
1811 if (current_class_type == NULL_TREE)
1812 clear_inline_text_obstack ();
1814 /* Undo the begin_tree in begin_class_definition. */
1818 /* Finish processing the declaration of a member class template
1819 TYPES whose template parameters are given by PARMS. */
1822 finish_member_class_template (types)
1827 /* If there are declared, but undefined, partial specializations
1828 mixed in with the typespecs they will not yet have passed through
1829 maybe_process_partial_specialization, so we do that here. */
1830 for (t = types; t != NULL_TREE; t = TREE_CHAIN (t))
1831 if (IS_AGGR_TYPE_CODE (TREE_CODE (TREE_VALUE (t))))
1832 maybe_process_partial_specialization (TREE_VALUE (t));
1834 note_list_got_semicolon (types);
1835 grok_x_components (types);
1836 if (TYPE_CONTEXT (TREE_VALUE (types)) != current_class_type)
1837 /* The component was in fact a friend declaration. We avoid
1838 finish_member_template_decl performing certain checks by
1842 finish_member_template_decl (types);
1844 /* As with other component type declarations, we do
1845 not store the new DECL on the list of
1850 /* Finish processsing a complete template declaration. The PARMS are
1851 the template parameters. */
1854 finish_template_decl (parms)
1858 end_template_decl ();
1860 end_specialization ();
1863 /* Finish processing a a template-id (which names a type) of the form
1864 NAME < ARGS >. Return the TYPE_DECL for the type named by the
1865 template-id. If ENTERING_SCOPE is non-zero we are about to enter
1866 the scope of template-id indicated. */
1869 finish_template_type (name, args, entering_scope)
1876 decl = lookup_template_class (name, args,
1877 NULL_TREE, NULL_TREE, entering_scope);
1878 if (decl != error_mark_node)
1879 decl = TYPE_STUB_DECL (decl);
1884 /* SR is a SCOPE_REF node. Enter the scope of SR, whether it is a
1885 namespace scope or a class scope. */
1891 tree scope = TREE_OPERAND (sr, 0);
1893 if (TREE_CODE (scope) == NAMESPACE_DECL)
1895 push_decl_namespace (scope);
1896 TREE_COMPLEXITY (sr) = -1;
1898 else if (scope != current_class_type)
1900 if (TREE_CODE (scope) == TYPENAME_TYPE)
1902 /* In a declarator for a template class member, the scope will
1903 get here as an implicit typename, a TYPENAME_TYPE with a type. */
1904 scope = TREE_TYPE (scope);
1905 TREE_OPERAND (sr, 0) = scope;
1907 push_nested_class (scope, 3);
1908 TREE_COMPLEXITY (sr) = current_class_depth;
1912 /* Finish processing a BASE_CLASS with the indicated ACCESS_SPECIFIER.
1913 Return a TREE_LIST containing the ACCESS_SPECIFIER and the
1914 BASE_CLASS, or NULL_TREE if an error occurred. The
1915 ACCESSS_SPECIFIER is one of
1916 access_{default,public,protected_private}[_virtual]_node.*/
1919 finish_base_specifier (access_specifier, base_class)
1920 tree access_specifier;
1926 if (base_class == NULL_TREE)
1928 error ("invalid base class");
1929 type = error_mark_node;
1932 type = TREE_TYPE (base_class);
1934 if (! is_aggr_type (type, 1))
1937 result = build_tree_list (access_specifier, type);
1942 /* Called when multiple declarators are processed. If that is not
1943 premitted in this context, an error is issued. */
1946 check_multiple_declarators ()
1950 In a template-declaration, explicit specialization, or explicit
1951 instantiation the init-declarator-list in the declaration shall
1952 contain at most one declarator.
1954 We don't just use PROCESSING_TEMPLATE_DECL for the first
1955 condition since that would disallow the perfectly legal code,
1956 like `template <class T> struct S { int i, j; };'. */
1957 tree scope = current_scope ();
1959 if (scope && TREE_CODE (scope) == FUNCTION_DECL)
1960 /* It's OK to write `template <class T> void f() { int i, j;}'. */
1963 if (PROCESSING_REAL_TEMPLATE_DECL_P ()
1964 || processing_explicit_instantiation
1965 || processing_specialization)
1966 cp_error ("multiple declarators in template declaration");
1970 finish_typeof (expr)
1973 if (processing_template_decl)
1977 push_permanent_obstack ();
1978 t = make_lang_type (TYPEOF_TYPE);
1979 TYPE_FIELDS (t) = expr;
1985 return TREE_TYPE (expr);
1988 /* Create an empty statement tree for FN. */
1991 begin_stmt_tree (fn)
1994 /* We create a trivial EXPR_STMT so that last_tree is never NULL in
1995 what follows. We remove the extraneous statement in
1996 finish_stmt_tree. */
1997 DECL_SAVED_TREE (fn) = build_nt (EXPR_STMT, void_zero_node);
1998 last_tree = DECL_SAVED_TREE (fn);
1999 last_expr_type = NULL_TREE;
2002 /* Finish the statement tree for FN. */
2005 finish_stmt_tree (fn)
2010 /* Remove the fake extra statement added in begin_stmt_tree. */
2011 stmt = TREE_CHAIN (DECL_SAVED_TREE (fn));
2012 DECL_SAVED_TREE (fn) = stmt;
2014 /* The line-number recorded in the outermost statement in a function
2015 is the line number of the end of the function. */
2016 STMT_LINENO (stmt) = lineno;
2017 STMT_LINENO_FOR_FN_P (stmt) = 1;
2020 /* We're about to expand T, a statement. Set up appropriate context
2021 for the substitution. */
2027 if (!STMT_LINENO_FOR_FN_P (t))
2028 lineno = STMT_LINENO (t);
2029 stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t);
2032 /* Some statements, like for-statements or if-statements, require a
2033 condition. This condition can be a declaration. If T is such a
2034 declaration it is processed, and an expression appropriate to use
2035 as the condition is returned. Otherwise, T itself is returned. */
2041 if (t && TREE_CODE (t) == DECL_STMT)
2044 return convert_from_reference (DECL_STMT_DECL (t));
2050 /* Generate RTL for the statement T, and its substatements, and any
2051 other statements at its nesting level. */
2059 while (t && t != error_mark_node)
2061 int saved_stmts_are_full_exprs_p;
2063 /* Assume we'll have nothing to return. */
2066 /* Set up context appropriately for handling this statement. */
2067 saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p;
2070 switch (TREE_CODE (t))
2073 finish_return_stmt (RETURN_EXPR (t));
2077 finish_expr_stmt_real (EXPR_STMT_EXPR (t),
2078 EXPR_STMT_ASSIGNS_THIS (t));
2084 int i = suspend_momentary ();
2086 emit_line_note (input_filename, lineno);
2087 decl = DECL_STMT_DECL (t);
2088 if (TREE_CODE (decl) == LABEL_DECL)
2089 finish_label_decl (DECL_NAME (decl));
2092 /* If we marked this variable as dead when we processed it
2093 before, we must undo that now. The variable has been
2095 if (TREE_CODE (decl) == VAR_DECL)
2096 DECL_DEAD_FOR_LOCAL (decl) = 0;
2097 /* We need to clear DECL_CONTEXT so that maybe_push_decl
2098 will push it into the current scope. */
2099 if (DECL_CONTEXT (decl) == current_function_decl)
2101 DECL_CONTEXT (decl) = NULL_TREE;
2102 maybe_push_decl (decl);
2104 /* If this is a declaration for an automatic local
2105 variable, initialize it. Note that we might also see a
2106 declaration for a namespace-scope object (declared with
2107 `extern') or an object with static storage duration
2108 (declared with `static'). We don't have to handle the
2109 initialization of those objects here; the former can
2110 never be a definition (only a declaration), and the
2111 latter is handled in finish_file. */
2112 if (TREE_CODE (decl) == VAR_DECL
2113 && !TREE_STATIC (decl)
2114 && !DECL_EXTERNAL (decl))
2116 /* Support the old for-scope rules for backwards
2118 maybe_inject_for_scope_var (decl);
2119 /* Let the back-end know about this variable. */
2120 initialize_local_var (decl, DECL_INITIAL (decl), 0);
2123 resume_momentary (i);
2132 expand_stmt (FOR_INIT_STMT (t));
2133 finish_for_init_stmt (NULL_TREE);
2134 finish_for_cond (expand_cond (FOR_COND (t)), NULL_TREE);
2136 finish_for_expr (tmp, NULL_TREE);
2137 expand_stmt (FOR_BODY (t));
2138 finish_for_stmt (tmp, NULL_TREE);
2144 begin_while_stmt ();
2145 finish_while_stmt_cond (expand_cond (WHILE_COND (t)), NULL_TREE);
2146 expand_stmt (WHILE_BODY (t));
2147 finish_while_stmt (NULL_TREE);
2154 expand_stmt (DO_BODY (t));
2155 finish_do_body (NULL_TREE);
2156 finish_do_stmt (DO_COND (t), NULL_TREE);
2162 finish_if_stmt_cond (expand_cond (IF_COND (t)), NULL_TREE);
2163 if (THEN_CLAUSE (t))
2165 expand_stmt (THEN_CLAUSE (t));
2166 finish_then_clause (NULL_TREE);
2168 if (ELSE_CLAUSE (t))
2170 begin_else_clause ();
2171 expand_stmt (ELSE_CLAUSE (t));
2172 finish_else_clause (NULL_TREE);
2178 begin_compound_stmt (COMPOUND_STMT_NO_SCOPE (t));
2179 expand_stmt (COMPOUND_BODY (t));
2180 rval = finish_compound_stmt (COMPOUND_STMT_NO_SCOPE (t),
2185 finish_break_stmt ();
2189 finish_continue_stmt ();
2196 begin_switch_stmt ();
2197 cond = expand_cond (SWITCH_COND (t));
2198 finish_switch_cond (cond, NULL_TREE);
2199 expand_stmt (SWITCH_BODY (t));
2200 finish_switch_stmt (cond, NULL_TREE);
2205 finish_case_label (CASE_LOW (t), CASE_HIGH (t));
2209 finish_label_stmt (DECL_NAME (LABEL_STMT_LABEL (t)));
2213 if (TREE_CODE (GOTO_DESTINATION (t)) == LABEL_DECL)
2214 finish_goto_stmt (DECL_NAME (GOTO_DESTINATION (t)));
2216 finish_goto_stmt (GOTO_DESTINATION (t));
2220 finish_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t), ASM_OUTPUTS
2221 (t), ASM_INPUTS (t), ASM_CLOBBERS (t));
2227 expand_eh_region_start ();
2228 expand_stmt (TRY_STMTS (t));
2229 finish_cleanup_try_block (NULL_TREE);
2230 finish_cleanup (TRY_HANDLERS (t), NULL_TREE);
2235 expand_stmt (TRY_STMTS (t));
2236 finish_try_block (NULL_TREE);
2237 expand_stmt (TRY_HANDLERS (t));
2238 finish_handler_sequence (NULL_TREE);
2244 if (HANDLER_PARMS (t))
2245 expand_start_catch_block (DECL_STMT_DECL (HANDLER_PARMS (t)));
2247 expand_start_catch_block (NULL_TREE);
2248 finish_handler_parms (NULL_TREE);
2249 expand_stmt (HANDLER_BODY (t));
2250 finish_handler (NULL_TREE);
2254 finish_subobject (SUBOBJECT_CLEANUP (t));
2258 my_friendly_abort (19990810);
2262 /* Restore saved state. */
2263 stmts_are_full_exprs_p = saved_stmts_are_full_exprs_p;
2265 /* Go on to the next statement in this scope. */
2272 /* Generate RTL for FN. */
2279 char *saved_input_filename;
2283 /* When the parser calls us after finishing the body of a template
2284 function, we don't really want to expand the body. When we're
2285 processing an in-class definition of an inline function,
2286 PROCESSING_TEMPLATE_DECL will no longer be set here, so we have
2287 to look at the function itself. */
2288 if (processing_template_decl
2289 || (DECL_LANG_SPECIFIC (fn)
2290 && DECL_TEMPLATE_INFO (fn)
2291 && uses_template_parms (DECL_TI_ARGS (fn))))
2294 /* Save the current file name and line number. When we expand the
2295 body of the funciton, we'll set LINENO and INPUT_FILENAME so that
2296 error-mesages come out in the right places. */
2297 saved_lineno = lineno;
2298 saved_input_filename = input_filename;
2299 lineno = DECL_SOURCE_LINE (fn);
2300 input_filename = DECL_SOURCE_FILE (fn);
2302 start_function (NULL_TREE, fn, NULL_TREE, SF_PRE_PARSED | SF_EXPAND);
2303 store_parm_decls ();
2305 /* There are a few things that we do not handle recursively. For
2306 example, a function try-block is handled differently from an
2307 ordinary try-block, so we must handle it here. */
2308 t = DECL_SAVED_TREE (fn);
2309 try_block = NULL_TREE;
2310 if (t && TREE_CODE (t) == TRY_BLOCK)
2313 begin_function_try_block ();
2314 t = TRY_STMTS (try_block);
2317 if (t && TREE_CODE (t) == RETURN_INIT)
2319 /* Clear this out so that finish_named_return_value can set it
2321 DECL_NAME (DECL_RESULT (fn)) = NULL_TREE;
2322 finish_named_return_value (TREE_OPERAND (t, 0), TREE_OPERAND (t, 1));
2326 if (t && TREE_CODE (t) == CTOR_INITIALIZER)
2328 current_member_init_list = TREE_OPERAND (t, 0);
2329 current_base_init_list = TREE_OPERAND (t, 1);
2333 /* If this is a constructor, we need to initialize our members and
2337 /* Expand the body. */
2340 /* If there was a function try-block, expand the handlers. */
2343 finish_function_try_block (NULL_TREE);
2344 expand_stmt (TRY_HANDLERS (try_block));
2345 finish_function_handler_sequence (NULL_TREE);
2348 /* Statements should always be full-expressions at the outermost set
2349 of curly braces for a function. */
2350 my_friendly_assert (stmts_are_full_exprs_p, 19990831);
2352 /* The outermost statement for a function contains the line number
2353 recorded when we finished processing the function. */
2354 lineno = STMT_LINENO (DECL_SAVED_TREE (fn));
2356 /* Generate code for the function. */
2357 finish_function (lineno, 0);
2359 /* And restore the current source position. */
2360 lineno = saved_lineno;
2361 input_filename = saved_input_filename;