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 (TREE_CODE (destination) == IDENTIFIER_NODE)
603 destination = lookup_label (destination);
605 if (building_stmt_tree ())
606 add_tree (build_min_nt (GOTO_STMT, destination));
609 emit_line_note (input_filename, lineno);
611 if (TREE_CODE (destination) == LABEL_DECL)
613 TREE_USED (destination) = 1;
614 expand_goto (destination);
617 expand_computed_goto (destination);
621 /* Begin a try-block. Returns a newly-created TRY_BLOCK if
627 if (building_stmt_tree ())
629 tree r = build_min_nt (TRY_BLOCK, NULL_TREE,
636 emit_line_note (input_filename, lineno);
637 expand_start_try_stmts ();
642 /* Likewise, for a function-try-block. */
645 begin_function_try_block ()
647 if (building_stmt_tree ())
649 tree r = build_min_nt (TRY_BLOCK, NULL_TREE,
656 if (! current_function_parms_stored)
658 expand_start_early_try_stmts ();
663 /* Finish a try-block, which may be given by TRY_BLOCK. */
666 finish_try_block (try_block)
669 if (building_stmt_tree ())
670 RECHAIN_STMTS_FROM_LAST (try_block, TRY_STMTS (try_block));
672 expand_start_all_catch ();
675 /* Finish an implicitly generated try-block, with a cleanup is given
679 finish_cleanup (cleanup, try_block)
683 if (building_stmt_tree ())
685 TRY_HANDLERS (try_block) = copy_to_permanent (cleanup);
686 CLEANUP_P (try_block) = 1;
689 expand_eh_region_end (protect_with_terminate (cleanup));
692 /* Likewise, for a function-try-block. */
695 finish_function_try_block (try_block)
698 if (building_stmt_tree ())
699 RECHAIN_STMTS_FROM_LAST (try_block, TRY_STMTS (try_block));
702 end_protect_partials ();
703 expand_start_all_catch ();
704 in_function_try_handler = 1;
708 /* Finish a handler-sequence for a try-block, which may be given by
712 finish_handler_sequence (try_block)
715 if (building_stmt_tree ())
716 RECHAIN_STMTS_FROM_CHAIN (try_block, TRY_HANDLERS (try_block));
718 expand_end_all_catch ();
721 /* Likewise, for a function-try-block. */
724 finish_function_handler_sequence (try_block)
727 if (building_stmt_tree ())
728 RECHAIN_STMTS_FROM_CHAIN (try_block, TRY_HANDLERS (try_block));
731 in_function_try_handler = 0;
732 expand_end_all_catch ();
736 /* Begin a handler. Returns a HANDLER if appropriate. */
743 if (building_stmt_tree ())
745 r = build_min_nt (HANDLER, NULL_TREE, NULL_TREE);
756 /* Finish the handler-parameters for a handler, which may be given by
760 finish_handler_parms (handler)
763 if (building_stmt_tree ())
764 RECHAIN_STMTS_FROM_CHAIN (handler, HANDLER_PARMS (handler));
767 /* Finish a handler, which may be given by HANDLER. */
770 finish_handler (handler)
773 if (building_stmt_tree ())
774 RECHAIN_STMTS_FROM_CHAIN (handler, HANDLER_BODY (handler));
776 expand_end_catch_block ();
781 /* Begin a compound-statement. If HAS_NO_SCOPE is non-zero, the
782 compound-statement does not define a scope. Returns a new
783 COMPOUND_STMT if appropriate. */
786 begin_compound_stmt (has_no_scope)
791 if (building_stmt_tree ())
793 r = build_min_nt (COMPOUND_STMT, NULL_TREE);
796 COMPOUND_STMT_NO_SCOPE (r) = 1;
801 last_expr_type = NULL_TREE;
806 /* Normally, we try hard to keep the BLOCK for a
807 statement-expression. But, if it's a statement-expression with
808 a scopeless block, there's nothing to keep, and we don't want
809 to accidentally keep a block *inside* the scopeless block. */
816 /* Finish a compound-statement, which may be given by COMPOUND_STMT.
817 If HAS_NO_SCOPE is non-zero, the compound statement does not define
821 finish_compound_stmt (has_no_scope, compound_stmt)
833 if (building_stmt_tree ())
834 RECHAIN_STMTS_FROM_CHAIN (compound_stmt,
835 COMPOUND_BODY (compound_stmt));
837 /* When we call finish_stmt we will lost LAST_EXPR_TYPE. But, since
838 the precise purpose of that variable is store the type of the
839 last expression statement within the last compound statement, we
840 preserve the value. */
848 /* Finish an asm-statement, whose components are a CV_QUALIFIER, a
849 STRING, some OUTPUT_OPERANDS, some INPUT_OPERANDS, and some
853 finish_asm_stmt (cv_qualifier, string, output_operands,
854 input_operands, clobbers)
857 tree output_operands;
861 if (TREE_CHAIN (string))
863 if (building_stmt_tree ())
864 /* We need to build the combined string on the permanent
865 obstack so that we can use it during instantiations. */
866 push_permanent_obstack ();
868 string = combine_strings (string);
870 if (building_stmt_tree ())
874 if (cv_qualifier != NULL_TREE
875 && cv_qualifier != ridpointers[(int) RID_VOLATILE])
877 cp_warning ("%s qualifier ignored on asm",
878 IDENTIFIER_POINTER (cv_qualifier));
879 cv_qualifier = NULL_TREE;
882 if (building_stmt_tree ())
884 tree r = build_min_nt (ASM_STMT, cv_qualifier, string,
885 output_operands, input_operands,
891 emit_line_note (input_filename, lineno);
892 if (output_operands != NULL_TREE || input_operands != NULL_TREE
893 || clobbers != NULL_TREE)
897 for (t = input_operands; t; t = TREE_CHAIN (t))
898 TREE_VALUE (t) = decay_conversion (TREE_VALUE (t));
900 c_expand_asm_operands (string, output_operands,
903 cv_qualifier != NULL_TREE,
904 input_filename, lineno);
913 /* Finish a label with the indicated NAME. */
916 finish_label_stmt (name)
919 tree decl = define_label (input_filename, lineno, name);
921 if (building_stmt_tree ())
922 add_tree (build_min_nt (LABEL_STMT, decl));
927 /* Finish a series of declarations for local labels. G++ allows users
928 to declare "local" labels, i.e., labels with scope. This extension
929 is useful when writing code involving statement-expressions. */
932 finish_label_decl (name)
935 tree decl = declare_local_label (name);
936 if (building_stmt_tree ())
937 add_decl_stmt (decl);
940 /* Create a declaration statement for the declaration given by the
949 /* We need the type to last until instantiation time. */
950 TREE_TYPE (decl) = copy_to_permanent (TREE_TYPE (decl));
951 decl_stmt = build_min_nt (DECL_STMT, decl);
952 add_tree (decl_stmt);
955 /* We're in a constructor, and have just constructed a a subobject of
956 *THIS. CLEANUP is code to run if an exception is thrown before the
957 end of the current function is reached. */
960 finish_subobject (cleanup)
963 if (building_stmt_tree ())
965 tree r = build_min_nt (SUBOBJECT, cleanup);
969 add_partial_entry (cleanup);
972 /* Bind a name and initialization to the return value of
973 the current function. */
976 finish_named_return_value (return_id, init)
977 tree return_id, init;
979 tree decl = DECL_RESULT (current_function_decl);
982 /* Give this error as many times as there are occurrences,
983 so that users can use Emacs compilation buffers to find
984 and fix all such places. */
985 pedwarn ("ANSI C++ does not permit named return values");
987 if (return_id != NULL_TREE)
989 if (DECL_NAME (decl) == NULL_TREE)
991 DECL_NAME (decl) = return_id;
992 DECL_ASSEMBLER_NAME (decl) = return_id;
996 cp_error ("return identifier `%D' already in place", return_id);
1001 /* Can't let this happen for constructors. */
1002 if (DECL_CONSTRUCTOR_P (current_function_decl))
1004 error ("can't redefine default return value for constructors");
1008 /* If we have a named return value, put that in our scope as well. */
1009 if (DECL_NAME (decl) != NULL_TREE)
1011 /* Let `cp_finish_decl' know that this initializer is ok. */
1012 DECL_INITIAL (decl) = init;
1015 if (building_stmt_tree ())
1016 add_tree (build_min_nt (RETURN_INIT, return_id,
1017 copy_to_permanent (init)));
1020 cp_finish_decl (decl, init, NULL_TREE, 0, 0);
1021 store_return_init (decl);
1026 /* Cache the value of this class's main virtual function table pointer
1027 in a register variable. This will save one indirection if a
1028 more than one virtual function call is made this function. */
1033 extern tree base_init_expr;
1035 if (base_init_expr == 0
1036 && DECL_CONSTRUCTOR_P (current_function_decl))
1038 if (building_stmt_tree ())
1039 add_tree (build_min_nt
1041 current_member_init_list, current_base_init_list));
1043 emit_base_init (current_class_type);
1046 /* Always keep the BLOCK node associated with the outermost pair of
1047 curley braces of a function. These are needed for correct
1048 operation of dwarfout.c. */
1049 keep_next_level (1);
1052 /* Begin a new scope. */
1057 if (!building_stmt_tree ())
1059 emit_line_note (input_filename, lineno);
1063 if (stmts_are_full_exprs_p)
1065 if (!building_stmt_tree () && stmts_are_full_exprs_p)
1066 expand_start_bindings (0);
1069 /* Finish a scope. */
1076 if (!building_stmt_tree () && stmts_are_full_exprs_p)
1077 expand_end_bindings (getdecls (), kept_level_p (), 0);
1078 if (stmts_are_full_exprs_p)
1079 t = poplevel (kept_level_p (), 1, 0);
1086 /* Finish a parenthesized expression EXPR. */
1089 finish_parenthesized_expr (expr)
1092 if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (expr))))
1093 /* This inhibits warnings in truthvalue_conversion. */
1094 C_SET_EXP_ORIGINAL_CODE (expr, ERROR_MARK);
1099 /* Begin a statement-expression. The value returned must be passed to
1100 finish_stmt_expr. */
1105 keep_next_level (1);
1106 /* If we're building a statement tree, then the upcoming compound
1107 statement will be chained onto the tree structure, starting at
1108 last_tree. We return last_tree so that we can later unhook the
1109 compound statement. */
1110 return building_stmt_tree () ? last_tree : expand_start_stmt_expr();
1113 /* Finish a statement-expression. RTL_EXPR should be the value
1114 returned by the previous begin_stmt_expr; EXPR is the
1115 statement-expression. Returns an expression representing the
1116 statement-expression. */
1119 finish_stmt_expr (rtl_expr, expr)
1125 if (!building_stmt_tree ())
1127 rtl_expr = expand_end_stmt_expr (rtl_expr);
1128 /* The statements have side effects, so the group does. */
1129 TREE_SIDE_EFFECTS (rtl_expr) = 1;
1132 if (building_stmt_tree ())
1134 /* If the last thing in the statement-expression was not an
1135 expression-statement, then it has type `void'. */
1136 if (!last_expr_type)
1137 last_expr_type = void_type_node;
1138 result = build_min (STMT_EXPR, last_expr_type, last_tree);
1139 TREE_SIDE_EFFECTS (result) = 1;
1141 /* Remove the compound statement from the tree structure; it is
1142 now saved in the STMT_EXPR. */
1143 last_tree = rtl_expr;
1144 TREE_CHAIN (last_tree) = NULL_TREE;
1146 else if (expr && TREE_CODE (expr) == BLOCK)
1148 result = build (BIND_EXPR, TREE_TYPE (rtl_expr),
1149 NULL_TREE, rtl_expr, expr);
1150 delete_block (expr);
1155 if (expr && TREE_CODE (expr) == BLOCK)
1156 /* Remove the block from the tree at this point. It gets put back
1157 at the proper place when the STMT_EXPR or BIND_EXPR is
1159 delete_block (expr);
1164 /* Finish a call to FN with ARGS. Returns a representation of the
1168 finish_call_expr (fn, args, koenig)
1177 if (TREE_CODE (fn) == BIT_NOT_EXPR)
1178 fn = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND (fn, 0));
1179 else if (TREE_CODE (fn) != TEMPLATE_ID_EXPR)
1180 fn = do_identifier (fn, 2, args);
1182 result = build_x_function_call (fn, args, current_class_ref);
1184 if (TREE_CODE (result) == CALL_EXPR
1185 && (! TREE_TYPE (result)
1186 || TREE_CODE (TREE_TYPE (result)) != VOID_TYPE))
1187 result = require_complete_type (result);
1192 /* Finish a call to a postfix increment or decrement or EXPR. (Which
1193 is indicated by CODE, which should be POSTINCREMENT_EXPR or
1194 POSTDECREMENT_EXPR.) */
1197 finish_increment_expr (expr, code)
1199 enum tree_code code;
1201 /* If we get an OFFSET_REF, turn it into what it really means (e.g.,
1202 a COMPONENT_REF). This way if we've got, say, a reference to a
1203 static member that's being operated on, we don't end up trying to
1204 find a member operator for the class it's in. */
1206 if (TREE_CODE (expr) == OFFSET_REF)
1207 expr = resolve_offset_ref (expr);
1208 return build_x_unary_op (code, expr);
1211 /* Finish a use of `this'. Returns an expression for `this'. */
1218 if (current_class_ptr)
1220 #ifdef WARNING_ABOUT_CCD
1221 TREE_USED (current_class_ptr) = 1;
1223 result = current_class_ptr;
1225 else if (current_function_decl
1226 && DECL_STATIC_FUNCTION_P (current_function_decl))
1228 error ("`this' is unavailable for static member functions");
1229 result = error_mark_node;
1233 if (current_function_decl)
1234 error ("invalid use of `this' in non-member function");
1236 error ("invalid use of `this' at top level");
1237 result = error_mark_node;
1243 /* Finish a member function call using OBJECT and ARGS as arguments to
1244 FN. Returns an expression for the call. */
1247 finish_object_call_expr (fn, object, args)
1253 /* This is a future direction of this code, but because
1254 build_x_function_call cannot always undo what is done in
1255 build_component_ref entirely yet, we cannot do this. */
1257 tree real_fn = build_component_ref (object, fn, NULL_TREE, 1);
1258 return finish_call_expr (real_fn, args);
1260 if (TREE_CODE (fn) == TYPE_DECL)
1262 if (processing_template_decl)
1263 /* This can happen on code like:
1266 template <class T> void f(T t) {
1270 We just grab the underlying IDENTIFIER. */
1271 fn = DECL_NAME (fn);
1274 cp_error ("calling type `%T' like a method", fn);
1275 return error_mark_node;
1279 return build_method_call (object, fn, args, NULL_TREE, LOOKUP_NORMAL);
1283 /* Finish a qualified member function call using OBJECT and ARGS as
1284 arguments to FN. Returns an expressino for the call. */
1287 finish_qualified_object_call_expr (fn, object, args)
1292 return build_scoped_method_call (object, TREE_OPERAND (fn, 0),
1293 TREE_OPERAND (fn, 1), args);
1296 /* Finish a pseudo-destructor call expression of OBJECT, with SCOPE
1297 being the scope, if any, of DESTRUCTOR. Returns an expression for
1301 finish_pseudo_destructor_call_expr (object, scope, destructor)
1306 if (processing_template_decl)
1307 return build_min_nt (PSEUDO_DTOR_EXPR, object, scope, destructor);
1309 if (scope && scope != destructor)
1310 cp_error ("destructor specifier `%T::~%T()' must have matching names",
1313 if ((scope == NULL_TREE || IDENTIFIER_GLOBAL_VALUE (destructor))
1314 && (TREE_CODE (TREE_TYPE (object)) !=
1315 TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (destructor)))))
1316 cp_error ("`%E' is not of type `%T'", object, destructor);
1318 return cp_convert (void_type_node, object);
1321 /* Finish a call to a globally qualified member function FN using
1322 ARGS. Returns an expression for the call. */
1325 finish_qualified_call_expr (fn, args)
1329 if (processing_template_decl)
1330 return build_min_nt (CALL_EXPR, copy_to_permanent (fn), args,
1333 return build_member_call (TREE_OPERAND (fn, 0),
1334 TREE_OPERAND (fn, 1),
1338 /* Finish an expression taking the address of LABEL. Returns an
1339 expression for the address. */
1342 finish_label_address_expr (label)
1347 label = lookup_label (label);
1348 if (label == NULL_TREE)
1349 result = null_pointer_node;
1352 TREE_USED (label) = 1;
1353 result = build1 (ADDR_EXPR, ptr_type_node, label);
1354 TREE_CONSTANT (result) = 1;
1360 /* Finish an expression of the form CODE EXPR. */
1363 finish_unary_op_expr (code, expr)
1364 enum tree_code code;
1367 tree result = build_x_unary_op (code, expr);
1368 if (code == NEGATE_EXPR && TREE_CODE (expr) == INTEGER_CST)
1369 TREE_NEGATED_INT (result) = 1;
1370 overflow_warning (result);
1374 /* Finish an id-expression. */
1377 finish_id_expr (expr)
1380 if (TREE_CODE (expr) == IDENTIFIER_NODE)
1381 expr = do_identifier (expr, 1, NULL_TREE);
1386 /* Begin a new-placement. */
1389 begin_new_placement ()
1391 /* The arguments to a placement new might be passed to a
1392 deallocation function, in the event that the allocation throws an
1393 exception. Since we don't expand exception handlers until the
1394 end of a function, we must make sure the arguments stay around
1396 return suspend_momentary ();
1399 /* Finish a new-placement. The ARGS are the placement arguments. The
1400 COOKIE is the value returned by the previous call to
1401 begin_new_placement. */
1404 finish_new_placement (args, cookie)
1408 resume_momentary (cookie);
1412 /* Begin a function defniition declared with DECL_SPECS and
1413 DECLARATOR. Returns non-zero if the function-declaration is
1417 begin_function_definition (decl_specs, declarator)
1423 split_specs_attrs (decl_specs, &specs, &attrs);
1424 if (!start_function (specs, declarator, attrs, 0))
1427 reinit_parse_for_function ();
1428 /* The things we're about to see are not directly qualified by any
1429 template headers we've seen thus far. */
1430 reset_specialization ();
1435 /* Begin a constructor declarator of the form `SCOPE::NAME'. Returns
1439 begin_constructor_declarator (scope, name)
1443 tree result = build_parse_node (SCOPE_REF, scope, name);
1444 enter_scope_of (result);
1448 /* Finish an init-declarator. Returns a DECL. */
1451 finish_declarator (declarator, declspecs, attributes,
1452 prefix_attributes, initialized)
1456 tree prefix_attributes;
1459 return start_decl (declarator, declspecs, initialized, attributes,
1463 /* Finish a translation unit. */
1466 finish_translation_unit ()
1468 /* In case there were missing closebraces,
1469 get us back to the global binding level. */
1470 while (! toplevel_bindings_p ())
1472 while (current_namespace != global_namespace)
1477 /* Finish a template type parameter, specified as AGGR IDENTIFIER.
1478 Returns the parameter. */
1481 finish_template_type_parm (aggr, identifier)
1485 if (aggr != class_type_node)
1487 pedwarn ("template type parameters must use the keyword `class' or `typename'");
1488 aggr = class_type_node;
1491 return build_tree_list (aggr, identifier);
1494 /* Finish a template template parameter, specified as AGGR IDENTIFIER.
1495 Returns the parameter. */
1498 finish_template_template_parm (aggr, identifier)
1502 tree decl = build_decl (TYPE_DECL, identifier, NULL_TREE);
1503 tree tmpl = build_lang_decl (TEMPLATE_DECL, identifier, NULL_TREE);
1504 DECL_TEMPLATE_PARMS (tmpl) = current_template_parms;
1505 DECL_TEMPLATE_RESULT (tmpl) = decl;
1506 SET_DECL_ARTIFICIAL (decl);
1507 end_template_decl ();
1509 return finish_template_type_parm (aggr, tmpl);
1512 /* Finish a parameter list, indicated by PARMS. If ELLIPSIS is
1513 non-zero, the parameter list was terminated by a `...'. */
1516 finish_parmlist (parms, ellipsis)
1521 chainon (parms, void_list_node);
1522 /* We mark the PARMS as a parmlist so that declarator processing can
1523 disambiguate certain constructs. */
1524 if (parms != NULL_TREE)
1525 TREE_PARMLIST (parms) = 1;
1530 /* Begin a class definition, as indicated by T. */
1533 begin_class_definition (t)
1536 push_permanent_obstack ();
1538 if (t == error_mark_node
1539 || ! IS_AGGR_TYPE (t))
1541 t = make_lang_type (RECORD_TYPE);
1542 pushtag (make_anon_name (), t, 0);
1545 /* In a definition of a member class template, we will get here with an
1546 implicit typename, a TYPENAME_TYPE with a type. */
1547 if (TREE_CODE (t) == TYPENAME_TYPE)
1550 /* If we generated a partial instantiation of this type, but now
1551 we're seeing a real definition, we're actually looking at a
1552 partial specialization. Consider:
1554 template <class T, class U>
1560 template <class T, class U>
1563 typename X<Y<T, U> >::A a;
1566 template <class T, class U>
1571 We have to undo the effects of the previous partial
1573 if (PARTIAL_INSTANTIATION_P (t))
1577 /* Unfortunately, when we're not in pedantic mode, we
1578 attempt to actually fill in some of the fields of the
1579 partial instantiation, in order to support the implicit
1580 typename extension. Clear those fields now, in
1581 preparation for the definition here. The fields cleared
1582 here must match those set in instantiate_class_template.
1583 Look for a comment mentioning begin_class_definition
1585 TYPE_BINFO_BASETYPES (t) = NULL_TREE;
1586 TYPE_FIELDS (t) = NULL_TREE;
1587 TYPE_METHODS (t) = NULL_TREE;
1588 CLASSTYPE_TAGS (t) = NULL_TREE;
1589 TYPE_SIZE (t) = NULL_TREE;
1592 /* This isn't a partial instantiation any more. */
1593 PARTIAL_INSTANTIATION_P (t) = 0;
1595 /* If this type was already complete, and we see another definition,
1597 else if (TYPE_SIZE (t))
1598 duplicate_tag_error (t);
1600 /* Update the location of the decl. */
1601 DECL_SOURCE_FILE (TYPE_NAME (t)) = input_filename;
1602 DECL_SOURCE_LINE (TYPE_NAME (t)) = lineno;
1604 if (TYPE_BEING_DEFINED (t))
1606 t = make_lang_type (TREE_CODE (t));
1607 pushtag (TYPE_IDENTIFIER (t), t, 0);
1609 maybe_process_partial_specialization (t);
1611 TYPE_BEING_DEFINED (t) = 1;
1612 /* Reset the interface data, at the earliest possible
1613 moment, as it might have been set via a class foo;
1616 tree name = TYPE_IDENTIFIER (t);
1618 if (! ANON_AGGRNAME_P (name))
1620 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
1621 SET_CLASSTYPE_INTERFACE_UNKNOWN_X
1622 (t, interface_unknown);
1625 /* Only leave this bit clear if we know this
1626 class is part of an interface-only specification. */
1627 if (! CLASSTYPE_INTERFACE_KNOWN (t)
1628 || ! CLASSTYPE_INTERFACE_ONLY (t))
1629 CLASSTYPE_VTABLE_NEEDS_WRITING (t) = 1;
1632 tmp = TYPE_IDENTIFIER ($<ttype>0);
1633 if (tmp && IDENTIFIER_TEMPLATE (tmp))
1634 overload_template_name (tmp, 1);
1636 reset_specialization();
1638 /* In case this is a local class within a template
1639 function, we save the current tree structure so
1640 that we can get it back later. */
1643 /* Make a declaration for this class in its own scope. */
1644 build_self_reference ();
1649 /* Finish the member declaration given by DECL. */
1652 finish_member_declaration (decl)
1655 if (decl == error_mark_node || decl == NULL_TREE)
1658 if (decl == void_type_node)
1659 /* The COMPONENT was a friend, not a member, and so there's
1660 nothing for us to do. */
1663 /* We should see only one DECL at a time. */
1664 my_friendly_assert (TREE_CHAIN (decl) == NULL_TREE, 0);
1666 /* Set up access control for DECL. */
1668 = (current_access_specifier == access_private_node);
1669 TREE_PROTECTED (decl)
1670 = (current_access_specifier == access_protected_node);
1671 if (TREE_CODE (decl) == TEMPLATE_DECL)
1673 TREE_PRIVATE (DECL_RESULT (decl)) = TREE_PRIVATE (decl);
1674 TREE_PROTECTED (DECL_RESULT (decl)) = TREE_PROTECTED (decl);
1677 /* Mark the DECL as a member of the current class. */
1678 if (TREE_CODE (decl) == FUNCTION_DECL
1679 || DECL_FUNCTION_TEMPLATE_P (decl))
1680 /* Historically, DECL_CONTEXT was not set for a FUNCTION_DECL in
1681 finish_struct. Presumably it is already set as the function is
1682 parsed. Perhaps DECL_CLASS_CONTEXT is already set, too? */
1683 DECL_CLASS_CONTEXT (decl) = current_class_type;
1685 DECL_CONTEXT (decl) = current_class_type;
1687 /* Put functions on the TYPE_METHODS list and everything else on the
1688 TYPE_FIELDS list. Note that these are built up in reverse order.
1689 We reverse them (to obtain declaration order) in finish_struct. */
1690 if (TREE_CODE (decl) == FUNCTION_DECL
1691 || DECL_FUNCTION_TEMPLATE_P (decl))
1693 /* We also need to add this function to the
1694 CLASSTYPE_METHOD_VEC. */
1695 add_method (current_class_type, 0, decl);
1697 TREE_CHAIN (decl) = TYPE_METHODS (current_class_type);
1698 TYPE_METHODS (current_class_type) = decl;
1702 /* All TYPE_DECLs go at the end of TYPE_FIELDS. Ordinary fields
1703 go at the beginning. The reason is that lookup_field_1
1704 searches the list in order, and we want a field name to
1705 override a type name so that the "struct stat hack" will
1706 work. In particular:
1708 struct S { enum E { }; int E } s;
1711 is legal. In addition, the FIELD_DECLs must be maintained in
1712 declaration order so that class layout works as expected.
1713 However, we don't need that order until class layout, so we
1714 save a little time by putting FIELD_DECLs on in reverse order
1715 here, and then reversing them in finish_struct_1. (We could
1716 also keep a pointer to the correct insertion points in the
1719 if (TREE_CODE (decl) == TYPE_DECL)
1720 TYPE_FIELDS (current_class_type)
1721 = chainon (TYPE_FIELDS (current_class_type), decl);
1724 TREE_CHAIN (decl) = TYPE_FIELDS (current_class_type);
1725 TYPE_FIELDS (current_class_type) = decl;
1728 /* Enter the DECL into the scope of the class. */
1729 if (TREE_CODE (decl) != USING_DECL)
1730 pushdecl_class_level (decl);
1734 /* Finish a class definition T with the indicate ATTRIBUTES. If SEMI,
1735 the definition is immediately followed by a semicolon. Returns the
1739 finish_class_definition (t, attributes, semi, pop_scope_p)
1745 /* finish_struct nukes this anyway; if finish_exception does too,
1748 note_got_semicolon (t);
1750 /* If we got any attributes in class_head, xref_tag will stick them in
1751 TREE_TYPE of the type. Grab them now. */
1752 attributes = chainon (TREE_TYPE (t), attributes);
1753 TREE_TYPE (t) = NULL_TREE;
1755 if (TREE_CODE (t) == ENUMERAL_TYPE)
1759 t = finish_struct (t, attributes);
1761 note_got_semicolon (t);
1767 check_for_missing_semicolon (t);
1769 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (t)));
1770 if (current_scope () == current_function_decl)
1771 do_pending_defargs ();
1776 /* Finish processing the default argument expressions cached during
1777 the processing of a class definition. */
1780 begin_inline_definitions ()
1783 && current_scope () == current_function_decl)
1784 do_pending_inlines ();
1787 /* Finish processing the inline function definitions cached during the
1788 processing of a class definition. */
1791 finish_inline_definitions ()
1793 if (current_class_type == NULL_TREE)
1794 clear_inline_text_obstack ();
1796 /* Undo the begin_tree in begin_class_definition. */
1800 /* Finish processing the declaration of a member class template
1801 TYPES whose template parameters are given by PARMS. */
1804 finish_member_class_template (types)
1809 /* If there are declared, but undefined, partial specializations
1810 mixed in with the typespecs they will not yet have passed through
1811 maybe_process_partial_specialization, so we do that here. */
1812 for (t = types; t != NULL_TREE; t = TREE_CHAIN (t))
1813 if (IS_AGGR_TYPE_CODE (TREE_CODE (TREE_VALUE (t))))
1814 maybe_process_partial_specialization (TREE_VALUE (t));
1816 note_list_got_semicolon (types);
1817 grok_x_components (types);
1818 if (TYPE_CONTEXT (TREE_VALUE (types)) != current_class_type)
1819 /* The component was in fact a friend declaration. We avoid
1820 finish_member_template_decl performing certain checks by
1824 finish_member_template_decl (types);
1826 /* As with other component type declarations, we do
1827 not store the new DECL on the list of
1832 /* Finish processsing a complete template declaration. The PARMS are
1833 the template parameters. */
1836 finish_template_decl (parms)
1840 end_template_decl ();
1842 end_specialization ();
1845 /* Finish processing a a template-id (which names a type) of the form
1846 NAME < ARGS >. Return the TYPE_DECL for the type named by the
1847 template-id. If ENTERING_SCOPE is non-zero we are about to enter
1848 the scope of template-id indicated. */
1851 finish_template_type (name, args, entering_scope)
1858 decl = lookup_template_class (name, args,
1859 NULL_TREE, NULL_TREE, entering_scope);
1860 if (decl != error_mark_node)
1861 decl = TYPE_STUB_DECL (decl);
1866 /* SR is a SCOPE_REF node. Enter the scope of SR, whether it is a
1867 namespace scope or a class scope. */
1873 tree scope = TREE_OPERAND (sr, 0);
1875 if (TREE_CODE (scope) == NAMESPACE_DECL)
1877 push_decl_namespace (scope);
1878 TREE_COMPLEXITY (sr) = -1;
1880 else if (scope != current_class_type)
1882 if (TREE_CODE (scope) == TYPENAME_TYPE)
1884 /* In a declarator for a template class member, the scope will
1885 get here as an implicit typename, a TYPENAME_TYPE with a type. */
1886 scope = TREE_TYPE (scope);
1887 TREE_OPERAND (sr, 0) = scope;
1889 push_nested_class (scope, 3);
1890 TREE_COMPLEXITY (sr) = current_class_depth;
1894 /* Finish processing a BASE_CLASS with the indicated ACCESS_SPECIFIER.
1895 Return a TREE_LIST containing the ACCESS_SPECIFIER and the
1896 BASE_CLASS, or NULL_TREE if an error occurred. The
1897 ACCESSS_SPECIFIER is one of
1898 access_{default,public,protected_private}[_virtual]_node.*/
1901 finish_base_specifier (access_specifier, base_class)
1902 tree access_specifier;
1908 if (base_class == NULL_TREE)
1910 error ("invalid base class");
1911 type = error_mark_node;
1914 type = TREE_TYPE (base_class);
1916 if (! is_aggr_type (type, 1))
1919 result = build_tree_list (access_specifier, type);
1924 /* Called when multiple declarators are processed. If that is not
1925 premitted in this context, an error is issued. */
1928 check_multiple_declarators ()
1932 In a template-declaration, explicit specialization, or explicit
1933 instantiation the init-declarator-list in the declaration shall
1934 contain at most one declarator.
1936 We don't just use PROCESSING_TEMPLATE_DECL for the first
1937 condition since that would disallow the perfectly legal code,
1938 like `template <class T> struct S { int i, j; };'. */
1939 tree scope = current_scope ();
1941 if (scope && TREE_CODE (scope) == FUNCTION_DECL)
1942 /* It's OK to write `template <class T> void f() { int i, j;}'. */
1945 if (PROCESSING_REAL_TEMPLATE_DECL_P ()
1946 || processing_explicit_instantiation
1947 || processing_specialization)
1948 cp_error ("multiple declarators in template declaration");
1952 finish_typeof (expr)
1955 if (processing_template_decl)
1959 push_permanent_obstack ();
1960 t = make_lang_type (TYPEOF_TYPE);
1961 TYPE_FIELDS (t) = expr;
1967 return TREE_TYPE (expr);
1970 /* Create an empty statement tree for FN. */
1973 begin_stmt_tree (fn)
1976 /* We create a trivial EXPR_STMT so that last_tree is never NULL in
1977 what follows. We remove the extraneous statement in
1978 finish_stmt_tree. */
1979 DECL_SAVED_TREE (fn) = build_nt (EXPR_STMT, void_zero_node);
1980 last_tree = DECL_SAVED_TREE (fn);
1981 last_expr_type = NULL_TREE;
1984 /* Finish the statement tree for FN. */
1987 finish_stmt_tree (fn)
1990 DECL_SAVED_TREE (fn) = TREE_CHAIN (DECL_SAVED_TREE (fn));
1993 /* Generate RTL for the chain of statements T. */
2006 /* Generate RTL for the statement T, and its substatements. */
2012 if (t == NULL_TREE || t == error_mark_node)
2015 switch (TREE_CODE (t))
2018 lineno = STMT_LINENO (t);
2019 finish_return_stmt (RETURN_EXPR (t));
2023 lineno = STMT_LINENO (t);
2024 finish_expr_stmt (EXPR_STMT_EXPR (t));
2030 int i = suspend_momentary ();
2032 lineno = STMT_LINENO (t);
2033 emit_line_note (input_filename, lineno);
2034 decl = DECL_STMT_DECL (t);
2035 if (TREE_CODE (decl) == LABEL_DECL)
2036 finish_label_decl (DECL_NAME (decl));
2039 /* We need to clear DECL_CONTEXT so that maybe_push_decl
2040 will push it into the current scope. */
2041 if (DECL_CONTEXT (decl) == current_function_decl)
2042 DECL_CONTEXT (decl) = NULL_TREE;
2043 /* If we marked this variable as dead when we processed it
2044 before, we must undo that now. The variable has been
2046 if (TREE_CODE (decl) == VAR_DECL)
2047 DECL_DEAD_FOR_LOCAL (decl) = 0;
2048 maybe_push_decl (decl);
2049 cp_finish_decl (decl, DECL_INITIAL (decl), NULL_TREE, 0, 0);
2051 resume_momentary (i);
2059 lineno = STMT_LINENO (t);
2061 for (tmp = FOR_INIT_STMT (t); tmp; tmp = TREE_CHAIN (tmp))
2063 finish_for_init_stmt (NULL_TREE);
2064 finish_for_cond (FOR_COND (t), NULL_TREE);
2066 finish_for_expr (tmp, NULL_TREE);
2067 expand_stmt (FOR_BODY (t));
2068 finish_for_stmt (tmp, NULL_TREE);
2074 lineno = STMT_LINENO (t);
2075 begin_while_stmt ();
2076 finish_while_stmt_cond (WHILE_COND (t), NULL_TREE);
2077 expand_stmt (WHILE_BODY (t));
2078 finish_while_stmt (NULL_TREE);
2084 lineno = STMT_LINENO (t);
2086 expand_stmt (DO_BODY (t));
2087 finish_do_body (NULL_TREE);
2088 finish_do_stmt (DO_COND (t), NULL_TREE);
2093 lineno = STMT_LINENO (t);
2095 finish_if_stmt_cond (IF_COND (t), NULL_TREE);
2096 if (THEN_CLAUSE (t))
2098 expand_stmt (THEN_CLAUSE (t));
2099 finish_then_clause (NULL_TREE);
2101 if (ELSE_CLAUSE (t))
2103 begin_else_clause ();
2104 expand_stmt (ELSE_CLAUSE (t));
2105 finish_else_clause (NULL_TREE);
2111 lineno = STMT_LINENO (t);
2112 begin_compound_stmt (COMPOUND_STMT_NO_SCOPE (t));
2113 expand_stmts (COMPOUND_BODY (t));
2114 return finish_compound_stmt (COMPOUND_STMT_NO_SCOPE (t),
2118 lineno = STMT_LINENO (t);
2119 finish_break_stmt ();
2123 lineno = STMT_LINENO (t);
2124 finish_continue_stmt ();
2128 lineno = STMT_LINENO (t);
2129 begin_switch_stmt ();
2130 finish_switch_cond (SWITCH_COND (t));
2131 if (TREE_OPERAND (t, 1))
2132 expand_stmt (SWITCH_BODY (t));
2133 finish_switch_stmt (SWITCH_COND (t), NULL_TREE);
2137 finish_case_label (CASE_LOW (t), CASE_HIGH (t));
2141 lineno = STMT_LINENO (t);
2142 finish_label_stmt (DECL_NAME (LABEL_STMT_LABEL (t)));
2146 lineno = STMT_LINENO (t);
2147 if (TREE_CODE (GOTO_DESTINATION (t)) == LABEL_DECL)
2148 finish_goto_stmt (DECL_NAME (GOTO_DESTINATION (t)));
2150 finish_goto_stmt (GOTO_DESTINATION (t));
2154 lineno = STMT_LINENO (t);
2155 finish_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t), ASM_OUTPUTS
2156 (t), ASM_INPUTS (t), ASM_CLOBBERS (t));
2160 lineno = STMT_LINENO (t);
2163 expand_eh_region_start ();
2164 expand_stmt (TRY_STMTS (t));
2165 finish_cleanup (TRY_HANDLERS (t), NULL_TREE);
2170 expand_stmt (TRY_STMTS (t));
2171 finish_try_block (NULL_TREE);
2172 expand_stmts (TRY_HANDLERS (t));
2173 finish_handler_sequence (NULL_TREE);
2178 lineno = STMT_LINENO (t);
2180 if (HANDLER_PARMS (t))
2182 tree d = HANDLER_PARMS (t);
2183 expand_start_catch_block (TREE_OPERAND (d, 1),
2184 TREE_OPERAND (d, 0));
2187 expand_start_catch_block (NULL_TREE, NULL_TREE);
2188 finish_handler_parms (NULL_TREE);
2189 expand_stmt (HANDLER_BODY (t));
2190 finish_handler (NULL_TREE);
2194 lineno = STMT_LINENO (t);
2195 finish_subobject (SUBOBJECT_CLEANUP (t));
2199 my_friendly_abort (19990810);
2206 /* Generate RTL for FN. */
2212 int saved_expanding_p;
2217 /* Remember whether we're already processing a function definition
2218 so that we can tell finish_function. */
2219 nested = in_function_p ();
2221 /* Let the compiler know that now is the time to really generate
2223 saved_expanding_p = expanding_p;
2226 start_function (NULL_TREE, fn, NULL_TREE, 1);
2227 store_parm_decls ();
2229 /* There are a few things that we do not handle recursively. For
2230 example, a function try-block is handled differently from an
2231 ordinary try-block, so we must handle it here. */
2232 t = DECL_SAVED_TREE (fn);
2233 try_block = NULL_TREE;
2234 if (t && TREE_CODE (t) == TRY_BLOCK)
2237 begin_function_try_block ();
2238 t = TRY_STMTS (try_block);
2241 if (t && TREE_CODE (t) == RETURN_INIT)
2243 /* Clear this out so that finish_named_return_value can set it
2245 DECL_NAME (DECL_RESULT (fn)) = NULL_TREE;
2246 finish_named_return_value (TREE_OPERAND (t, 0), TREE_OPERAND (t, 1));
2250 if (t && TREE_CODE (t) == CTOR_INITIALIZER)
2252 current_member_init_list = TREE_OPERAND (t, 0);
2253 current_base_init_list = TREE_OPERAND (t, 1);
2257 /* If this is a constructor, we need to initialize our members and
2261 /* Expand the body. */
2264 /* If there was a function try-block, expand the handlers. */
2267 finish_function_try_block (NULL_TREE);
2269 tree handler = TRY_HANDLERS (try_block);
2270 for (; handler; handler = TREE_CHAIN (handler))
2271 expand_stmt (handler);
2273 finish_function_handler_sequence (NULL_TREE);
2276 finish_function (lineno, 0, nested);
2278 /* Restore EXPANDING_P. */
2279 expanding_p = saved_expanding_p;