1 /* Perform the semantic phase of parsing, i.e., the process of
2 building tree structure, checking semantic consistency, and
3 building RTL. These routines are used both during actual parsing
4 and during the instantiation of template functions.
6 Copyright (C) 1998, 1999, 2000 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
40 /* There routines provide a modular interface to perform many parsing
41 operations. They may therefore be used during actual parsing, or
42 during template instantiation, which may be regarded as a
43 degenerate form of parsing. Since the current g++ parser is
44 lacking in several respects, and will be reimplemented, we are
45 attempting to move most code that is not directly related to
46 parsing into this file; that will make implementing the new parser
47 much easier since it will be able to make use of these routines. */
49 static tree expand_cond PARAMS ((tree));
50 static tree maybe_convert_cond PARAMS ((tree));
51 static tree simplify_aggr_init_exprs_r PARAMS ((tree *, int *, void *));
52 static void deferred_type_access_control PARAMS ((void));
54 /* Record the fact that STMT was the last statement added to the
57 #define SET_LAST_STMT(stmt) \
58 (current_stmt_tree->x_last_stmt = (stmt))
60 /* When parsing a template, LAST_TREE contains the last statement
61 parsed. These are chained together through the TREE_CHAIN field,
62 but often need to be re-organized since the parse is performed
63 bottom-up. This macro makes LAST_TREE the indicated SUBSTMT of
66 #define RECHAIN_STMTS(stmt, substmt) \
68 substmt = TREE_CHAIN (stmt); \
69 TREE_CHAIN (stmt) = NULL_TREE; \
70 SET_LAST_STMT (stmt); \
73 /* Finish processing the COND, the SUBSTMT condition for STMT. */
75 #define FINISH_COND(cond, stmt, substmt) \
77 if (last_tree != stmt) \
79 RECHAIN_STMTS (stmt, substmt); \
80 if (!processing_template_decl) \
82 cond = build_tree_list (substmt, cond); \
95 tree block = NULL_TREE;
97 if (stmts_are_full_exprs_p)
101 if (!processing_template_decl)
102 scope_stmts = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0);
104 block = poplevel (kept_level_p (), 1, 0);
105 if (block && !processing_template_decl)
107 SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmts)) = block;
108 SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmts)) = block;
115 /* Begin a new scope. */
120 if (stmts_are_full_exprs_p)
123 if (!processing_template_decl)
124 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
128 /* Helper for generating the RTL at the end of a scope. */
131 genrtl_do_poplevel ()
133 tree block = NULL_TREE;
135 if (stmts_are_full_exprs_p)
138 scope_stmts = NULL_TREE;
140 block = poplevel (kept_level_p (), 1, 0);
141 if (block && !processing_template_decl)
143 SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmts)) = block;
144 SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmts)) = block;
151 /* Helper for generating the RTL at the beginning of a scope. */
154 genrtl_do_pushlevel ()
156 emit_line_note (input_filename, lineno);
159 if (stmts_are_full_exprs_p)
161 pushlevel (0); // Try to get rid of me.
162 if (!cfun->x_whole_function_mode_p)
163 my_friendly_abort (19991129);
167 /* Helper for generating the RTL. */
170 genrtl_clear_out_block ()
172 /* If COND wasn't a declaration, clear out the
173 block we made for it and start a new one here so the
174 optimization in expand_end_loop will work. */
175 if (getdecls () == NULL_TREE)
177 genrtl_do_poplevel ();
178 genrtl_do_pushlevel ();
182 /* T is a statement. Add it to the statement-tree. */
188 /* Add T to the statement-tree. */
189 TREE_CHAIN (last_tree) = t;
191 /* When we expand a statement-tree, we must know whether or not the
192 statements are full-expresions. We record that fact here. */
193 STMT_IS_FULL_EXPR_P (last_tree) = stmts_are_full_exprs_p;
196 /* Finish a goto-statement. */
199 finish_goto_stmt (destination)
202 if (TREE_CODE (destination) == IDENTIFIER_NODE)
203 destination = lookup_label (destination);
205 /* We warn about unused labels with -Wunused. That means we have to
206 mark the used labels as used. */
207 if (TREE_CODE (destination) == LABEL_DECL)
208 TREE_USED (destination) = 1;
210 if (TREE_CODE (destination) != LABEL_DECL)
211 /* We don't inline calls to functions with computed gotos.
212 Those functions are typically up to some funny business,
213 and may be depending on the labels being at particular
214 addresses, or some such. */
215 DECL_UNINLINABLE (current_function_decl) = 1;
217 check_goto (destination);
219 add_tree (build_min_nt (GOTO_STMT, destination));
222 /* Generate the RTL for DESTINATION, which is a GOTO_STMT. */
225 genrtl_goto_stmt (destination)
228 if (TREE_CODE (destination) == IDENTIFIER_NODE)
229 destination = lookup_label (destination);
231 /* We warn about unused labels with -Wunused. That means we have to
232 mark the used labels as used. */
233 if (TREE_CODE (destination) == LABEL_DECL)
234 TREE_USED (destination) = 1;
236 emit_line_note (input_filename, lineno);
238 if (TREE_CODE (destination) == LABEL_DECL)
240 label_rtx (destination);
241 expand_goto (destination);
244 expand_computed_goto (destination);
247 /* COND is the condition-expression for an if, while, etc.,
248 statement. Convert it to a boolean value, if appropriate. */
251 maybe_convert_cond (cond)
254 /* Empty conditions remain empty. */
258 /* Wait until we instantiate templates before doing conversion. */
259 if (processing_template_decl)
262 /* Do the conversion. */
263 cond = convert_from_reference (cond);
264 return condition_conversion (cond);
267 /* Finish an expression-statement, whose EXPRESSION is as indicated. */
270 finish_expr_stmt (expr)
273 if (expr != NULL_TREE)
275 if (!processing_template_decl
276 && !stmts_are_full_exprs_p
277 && ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
279 || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE))
280 expr = default_conversion (expr);
282 if (stmts_are_full_exprs_p)
283 expr = convert_to_void (expr, "statement");
285 if (!processing_template_decl)
286 expr = break_out_cleanups (expr);
288 add_tree (build_min_nt (EXPR_STMT, expr));
293 /* This was an expression-statement, so we save the type of the
295 last_expr_type = expr ? TREE_TYPE (expr) : NULL_TREE;
298 /* Generate the RTL for EXPR, which is an EXPR_STMT. */
301 genrtl_expr_stmt (expr)
304 if (expr != NULL_TREE)
306 emit_line_note (input_filename, lineno);
308 if (stmts_are_full_exprs_p)
309 expand_start_target_temps ();
311 cplus_expand_expr_stmt (expr);
313 if (stmts_are_full_exprs_p)
314 expand_end_target_temps ();
319 /* This was an expression-statement, so we save the type of the
321 last_expr_type = expr ? TREE_TYPE (expr) : NULL_TREE;
324 /* Generate the RTL for T, which is a DECL_STMT. */
331 emit_line_note (input_filename, lineno);
332 decl = DECL_STMT_DECL (t);
333 /* If this is a declaration for an automatic local
334 variable, initialize it. Note that we might also see a
335 declaration for a namespace-scope object (declared with
336 `extern'). We don't have to handle the initialization
337 of those objects here; they can only be declarations,
338 rather than definitions. */
339 if (TREE_CODE (decl) == VAR_DECL
340 && !TREE_STATIC (decl)
341 && !DECL_EXTERNAL (decl))
343 /* Let the back-end know about this variable. */
344 if (!ANON_AGGR_TYPE_P (TREE_TYPE (decl)))
345 emit_local_var (decl);
347 expand_anon_union_decl (decl, NULL_TREE,
348 DECL_ANON_UNION_ELEMS (decl));
350 else if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
352 if (DECL_ARTIFICIAL (decl) && ! TREE_USED (decl))
353 /* Do not emit unused decls. This is not just an
354 optimization. We really do not want to emit
355 __PRETTY_FUNCTION__ etc, if they're never used. */
356 DECL_IGNORED_P (decl) = 1;
358 make_rtl_for_local_static (decl);
362 /* Generate the RTL for T, which is an IF_STMT. */
369 genrtl_do_pushlevel ();
370 cond = maybe_convert_cond (expand_cond (IF_COND (t)));
371 emit_line_note (input_filename, lineno);
372 expand_start_cond (cond, 0);
374 expand_stmt (THEN_CLAUSE (t));
377 expand_start_else ();
378 expand_stmt (ELSE_CLAUSE (t));
381 genrtl_do_poplevel ();
385 /* Begin an if-statement. Returns a newly created IF_STMT if
393 r = build_min_nt (IF_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
398 /* Process the COND of an if-statement, which may be given by
402 finish_if_stmt_cond (cond, if_stmt)
406 cond = maybe_convert_cond (cond);
407 FINISH_COND (cond, if_stmt, IF_COND (if_stmt));
410 /* Finish the then-clause of an if-statement, which may be given by
414 finish_then_clause (if_stmt)
417 RECHAIN_STMTS (if_stmt, THEN_CLAUSE (if_stmt));
418 SET_LAST_STMT (if_stmt);
422 /* Begin the else-clause of an if-statement. */
429 /* Finish the else-clause of an if-statement, which may be given by
433 finish_else_clause (if_stmt)
436 RECHAIN_STMTS (if_stmt, ELSE_CLAUSE (if_stmt));
439 /* Finsh an if-statement. */
451 /* If COND wasn't a declaration, clear out the
452 block we made for it and start a new one here so the
453 optimization in expand_end_loop will work. */
454 if (getdecls () == NULL_TREE)
461 /* Generate the RTL for T, which is a WHILE_STMT. */
464 genrtl_while_stmt (t)
469 emit_line_note (input_filename, lineno);
470 expand_start_loop (1);
471 genrtl_do_pushlevel ();
473 cond = maybe_convert_cond (expand_cond (WHILE_COND (t)));
474 emit_line_note (input_filename, lineno);
475 expand_exit_loop_if_false (0, cond);
476 genrtl_clear_out_block ();
478 expand_stmt (WHILE_BODY (t));
480 genrtl_do_poplevel ();
485 /* Begin a while-statement. Returns a newly created WHILE_STMT if
492 r = build_min_nt (WHILE_STMT, NULL_TREE, NULL_TREE);
498 /* Process the COND of a while-statement, which may be given by
502 finish_while_stmt_cond (cond, while_stmt)
506 cond = maybe_convert_cond (cond);
507 FINISH_COND (cond, while_stmt, WHILE_COND (while_stmt));
511 /* Finish a while-statement, which may be given by WHILE_STMT. */
514 finish_while_stmt (while_stmt)
518 RECHAIN_STMTS (while_stmt, WHILE_BODY (while_stmt));
522 /* Generate the RTL for T, which is a DO_STMT. */
530 emit_line_note (input_filename, lineno);
531 expand_start_loop_continue_elsewhere (1);
533 expand_stmt (DO_BODY (t));
535 expand_loop_continue_here ();
537 cond = maybe_convert_cond (DO_COND (t));
538 emit_line_note (input_filename, lineno);
539 expand_exit_loop_if_false (0, cond);
544 /* Begin a do-statement. Returns a newly created DO_STMT if
550 tree r = build_min_nt (DO_STMT, NULL_TREE, NULL_TREE);
555 /* Finish the body of a do-statement, which may be given by DO_STMT. */
558 finish_do_body (do_stmt)
561 RECHAIN_STMTS (do_stmt, DO_BODY (do_stmt));
564 /* Finish a do-statement, which may be given by DO_STMT, and whose
565 COND is as indicated. */
568 finish_do_stmt (cond, do_stmt)
572 cond = maybe_convert_cond (cond);
573 DO_COND (do_stmt) = cond;
577 /* Generate the RTL for EXPR, which is a RETURN_STMT. */
580 genrtl_return_stmt (expr)
583 emit_line_note (input_filename, lineno);
584 c_expand_return (expr);
588 /* Finish a return-statement. The EXPRESSION returned, if any, is as
592 finish_return_stmt (expr)
595 if (!processing_template_decl)
596 expr = check_return_expr (expr);
597 if (!processing_template_decl)
599 if (DECL_CONSTRUCTOR_P (current_function_decl) && ctor_label)
601 /* Even returns without a value in a constructor must return
602 `this'. We accomplish this by sending all returns in a
603 constructor to the CTOR_LABEL; finish_function emits code to
604 return a value there. When we finally generate the real
605 return statement, CTOR_LABEL is no longer set, and we fall
606 through into the normal return-processing code below. */
607 finish_goto_stmt (ctor_label);
610 else if (DECL_DESTRUCTOR_P (current_function_decl))
612 /* Similarly, all destructors must run destructors for
613 base-classes before returning. So, all returns in a
614 destructor get sent to the DTOR_LABEL; finsh_function emits
615 code to return a value there. */
616 finish_goto_stmt (dtor_label);
620 add_tree (build_min_nt (RETURN_STMT, expr));
624 /* Generate the RTL for T, which is a FOR_STMT. */
632 if (flag_new_for_scope > 0)
634 genrtl_do_pushlevel ();
635 note_level_for_for ();
638 expand_stmt (FOR_INIT_STMT (t));
641 emit_line_note (input_filename, lineno);
642 expand_start_loop_continue_elsewhere (1);
643 genrtl_do_pushlevel ();
644 cond = maybe_convert_cond (expand_cond (FOR_COND (t)));
645 emit_line_note (input_filename, lineno);
647 expand_exit_loop_if_false (0, cond);
648 genrtl_clear_out_block ();
651 expand_stmt (FOR_BODY (t));
653 /* Pop the scope for the body of the loop. */
654 genrtl_do_poplevel ();
655 emit_line_note (input_filename, lineno);
656 expand_loop_continue_here ();
658 genrtl_expr_stmt (tmp);
660 if (flag_new_for_scope > 0)
661 genrtl_do_poplevel ();
665 /* Begin a for-statement. Returns a new FOR_STMT if appropriate. */
672 r = build_min_nt (FOR_STMT, NULL_TREE, NULL_TREE,
673 NULL_TREE, NULL_TREE);
676 if (flag_new_for_scope > 0)
679 note_level_for_for ();
685 /* Finish the for-init-statement of a for-statement, which may be
686 given by FOR_STMT. */
689 finish_for_init_stmt (for_stmt)
692 if (last_tree != for_stmt)
693 RECHAIN_STMTS (for_stmt, FOR_INIT_STMT (for_stmt));
697 /* Finish the COND of a for-statement, which may be given by
701 finish_for_cond (cond, for_stmt)
705 cond = maybe_convert_cond (cond);
706 FINISH_COND (cond, for_stmt, FOR_COND (for_stmt));
710 /* Finish the increment-EXPRESSION in a for-statement, which may be
711 given by FOR_STMT. */
714 finish_for_expr (expr, for_stmt)
718 FOR_EXPR (for_stmt) = expr;
721 /* Finish the body of a for-statement, which may be given by
722 FOR_STMT. The increment-EXPR for the loop must be
726 finish_for_stmt (for_stmt)
729 /* Pop the scope for the body of the loop. */
731 RECHAIN_STMTS (for_stmt, FOR_BODY (for_stmt));
732 if (flag_new_for_scope > 0)
737 /* Generate the RTL for a BREAK_STMT. */
742 emit_line_note (input_filename, lineno);
743 if ( ! expand_exit_something ())
744 cp_error ("break statement not within loop or switch");
747 /* Finish a break-statement. */
752 emit_line_note (input_filename, lineno);
753 add_tree (build_min_nt (BREAK_STMT));
756 /* Generate the RTL for a CONTINUE_STMT. */
759 genrtl_continue_stmt ()
761 emit_line_note (input_filename, lineno);
762 if (! expand_continue_loop (0))
763 cp_error ("continue statement not within a loop");
766 /* Finish a continue-statement. */
769 finish_continue_stmt ()
771 emit_line_note (input_filename, lineno);
772 add_tree (build_min_nt (CONTINUE_STMT));
775 /* Generate the RTL for T, which is a SCOPE_STMT. */
778 genrtl_scope_stmt (t)
781 if (!SCOPE_NO_CLEANUPS_P (t))
783 if (SCOPE_BEGIN_P (t))
784 expand_start_bindings_and_block (2 * SCOPE_NULLIFIED_P (t),
785 SCOPE_STMT_BLOCK (t));
786 else if (SCOPE_END_P (t))
787 expand_end_bindings (NULL_TREE, !SCOPE_NULLIFIED_P (t), 0);
789 else if (!SCOPE_NULLIFIED_P (t))
791 rtx note = emit_note (NULL,
793 ? NOTE_INSN_BLOCK_BEG
794 : NOTE_INSN_BLOCK_END));
795 NOTE_BLOCK (note) = SCOPE_STMT_BLOCK (t);
799 /* Generate the RTL for T, which is a SWITCH_STMT. */
802 genrtl_switch_stmt (t)
806 genrtl_do_pushlevel ();
808 cond = expand_cond (SWITCH_COND (t));
809 if (cond != error_mark_node)
811 emit_line_note (input_filename, lineno);
812 c_expand_start_case (cond);
815 /* The code is in error, but we don't want expand_end_case to
817 c_expand_start_case (boolean_false_node);
821 expand_stmt (SWITCH_BODY (t));
823 expand_end_case (cond);
825 genrtl_do_poplevel ();
829 /* Begin a switch-statement. Returns a new SWITCH_STMT if
836 r = build_min_nt (SWITCH_STMT, NULL_TREE, NULL_TREE);
842 /* Finish the cond of a switch-statement. */
845 finish_switch_cond (cond, switch_stmt)
849 if (!processing_template_decl)
851 /* Convert the condition to an integer or enumeration type. */
852 cond = build_expr_type_conversion (WANT_INT | WANT_ENUM, cond, 1);
853 if (cond == NULL_TREE)
855 error ("switch quantity not an integer");
856 cond = error_mark_node;
858 if (cond != error_mark_node)
863 cond = default_conversion (cond);
864 type = TREE_TYPE (cond);
865 idx = get_unwidened (cond, 0);
866 /* We can't strip a conversion from a signed type to an unsigned,
867 because if we did, int_fits_type_p would do the wrong thing
868 when checking case values for being in range,
869 and it's too hard to do the right thing. */
870 if (TREE_UNSIGNED (TREE_TYPE (cond))
871 == TREE_UNSIGNED (TREE_TYPE (idx)))
874 cond = fold (build1 (CLEANUP_POINT_EXPR, type, cond));
877 FINISH_COND (cond, switch_stmt, SWITCH_COND (switch_stmt));
881 /* Finish the body of a switch-statement, which may be given by
882 SWITCH_STMT. The COND to switch on is indicated. */
885 finish_switch_stmt (switch_stmt)
888 RECHAIN_STMTS (switch_stmt, SWITCH_BODY (switch_stmt));
894 /* Generate the RTL for a CASE_LABEL. */
897 genrtl_case_label (low_value, high_value)
901 do_case (low_value, high_value);
904 /* Finish a case-label. */
907 finish_case_label (low_value, high_value)
911 /* Add a representation for the case label to the statement
913 add_tree (build_min_nt (CASE_LABEL, low_value, high_value));
914 /* And warn about crossing initializations, etc. */
915 if (!processing_template_decl)
916 define_case_label ();
919 /* Generate the RTL for T, which is a TRY_BLOCK. */
921 void genrtl_try_block (t)
926 expand_eh_region_start ();
927 expand_stmt (TRY_STMTS (t));
928 expand_eh_region_end (protect_with_terminate (TRY_HANDLERS (t)));
932 if (FN_TRY_BLOCK_P (t)) {
933 if (! current_function_parms_stored)
935 expand_start_early_try_stmts ();
938 emit_line_note (input_filename, lineno);
939 expand_start_try_stmts ();
942 expand_stmt (TRY_STMTS (t));
944 if (FN_TRY_BLOCK_P (t))
946 end_protect_partials ();
947 expand_start_all_catch ();
948 in_function_try_handler = 1;
949 expand_stmt (TRY_HANDLERS (t));
950 in_function_try_handler = 0;
951 expand_end_all_catch ();
955 expand_start_all_catch ();
956 expand_stmt (TRY_HANDLERS (t));
957 expand_end_all_catch ();
962 /* Begin a try-block. Returns a newly-created TRY_BLOCK if
968 tree r = build_min_nt (TRY_BLOCK, NULL_TREE, NULL_TREE);
973 /* Likewise, for a function-try-block. */
976 begin_function_try_block ()
978 tree r = build_min_nt (TRY_BLOCK, NULL_TREE, NULL_TREE);
979 FN_TRY_BLOCK_P (r) = 1;
984 /* Finish a try-block, which may be given by TRY_BLOCK. */
987 finish_try_block (try_block)
990 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
993 /* Finish the body of a cleanup try-block, which may be given by
997 finish_cleanup_try_block (try_block)
1000 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
1003 /* Finish an implicitly generated try-block, with a cleanup is given
1007 finish_cleanup (cleanup, try_block)
1011 TRY_HANDLERS (try_block) = cleanup;
1012 CLEANUP_P (try_block) = 1;
1015 /* Likewise, for a function-try-block. */
1018 finish_function_try_block (try_block)
1021 if (TREE_CHAIN (try_block)
1022 && TREE_CODE (TREE_CHAIN (try_block)) == CTOR_INITIALIZER)
1024 /* Chain the compound statement after the CTOR_INITIALIZER. */
1025 TREE_CHAIN (TREE_CHAIN (try_block)) = last_tree;
1026 /* And make the CTOR_INITIALIZER the body of the try-block. */
1027 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
1030 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
1031 in_function_try_handler = 1;
1034 /* Finish a handler-sequence for a try-block, which may be given by
1038 finish_handler_sequence (try_block)
1041 RECHAIN_STMTS (try_block, TRY_HANDLERS (try_block));
1042 check_handlers (TRY_HANDLERS (try_block));
1045 /* Likewise, for a function-try-block. */
1048 finish_function_handler_sequence (try_block)
1051 in_function_try_handler = 0;
1052 RECHAIN_STMTS (try_block, TRY_HANDLERS (try_block));
1053 check_handlers (TRY_HANDLERS (try_block));
1056 /* Generate the RTL for T, which is a HANDLER. */
1062 genrtl_do_pushlevel ();
1063 expand_stmt (HANDLER_BODY (t));
1064 if (!processing_template_decl)
1066 /* Fall to outside the try statement when done executing
1067 handler and we fall off end of handler. This is jump
1068 Lresume in the documentation. */
1069 expand_goto (top_label_entry (&caught_return_label_stack));
1070 end_catch_handler ();
1073 genrtl_do_poplevel ();
1076 /* Begin a handler. Returns a HANDLER if appropriate. */
1082 r = build_min_nt (HANDLER, NULL_TREE, NULL_TREE);
1088 /* Finish the handler-parameters for a handler, which may be given by
1089 HANDLER. DECL is the declaration for the catch parameter, or NULL
1090 if this is a `catch (...)' clause. */
1093 finish_handler_parms (decl, handler)
1097 tree blocks = NULL_TREE;
1099 if (processing_template_decl)
1103 decl = pushdecl (decl);
1104 decl = push_template_decl (decl);
1105 add_decl_stmt (decl);
1106 RECHAIN_STMTS (handler, HANDLER_PARMS (handler));
1110 blocks = expand_start_catch_block (decl);
1113 TREE_TYPE (handler) = TREE_TYPE (decl);
1118 /* Generate the RTL for a CATCH_BLOCK. */
1121 genrtl_catch_block (type)
1124 start_catch_handler (type);
1127 /* Note the beginning of a handler for TYPE. This function is called
1128 at the point to which control should be transferred when an
1129 appropriately-typed exception is thrown. */
1132 begin_catch_block (type)
1135 add_tree (build (START_CATCH_STMT, type));
1138 /* Finish a handler, which may be given by HANDLER. The BLOCKs are
1139 the return value from the matching call to finish_handler_parms. */
1142 finish_handler (blocks, handler)
1146 if (!processing_template_decl)
1147 expand_end_catch_block (blocks);
1149 RECHAIN_STMTS (handler, HANDLER_BODY (handler));
1152 /* Generate the RTL for T, which is a CTOR_STMT. */
1155 genrtl_ctor_stmt (t)
1158 if (CTOR_BEGIN_P (t))
1159 begin_protect_partials ();
1161 /* After this point, any exceptions will cause the
1162 destructor to be executed, so we no longer need to worry
1163 about destroying the various subobjects ourselves. */
1164 end_protect_partials ();
1167 /* Generate the RTL for the start of a COMPOUND_STMT. */
1169 tree genrtl_begin_compound_stmt (has_no_scope)
1177 last_expr_type = NULL_TREE;
1181 genrtl_do_pushlevel ();
1183 note_level_for_eh ();
1186 /* Normally, we try hard to keep the BLOCK for a
1187 statement-expression. But, if it's a statement-expression with
1188 a scopeless block, there's nothing to keep, and we don't want
1189 to accidentally keep a block *inside* the scopeless block. */
1190 keep_next_level (0);
1192 /* If this is the outermost block of the function, declare the
1193 variables __FUNCTION__, __PRETTY_FUNCTION__, and so forth. */
1195 && !current_function_name_declared
1198 current_function_name_declared = 1;
1199 declare_function_name ();
1205 /* Generate the RTL for the end of a COMPOUND_STMT. */
1207 tree genrtl_finish_compound_stmt (has_no_scope)
1214 r = genrtl_do_poplevel ();
1218 /* When we call finish_stmt we will lose LAST_EXPR_TYPE. But, since
1219 the precise purpose of that variable is store the type of the
1220 last expression statement within the last compound statement, we
1221 preserve the value. */
1229 /* Generate the RTL for T, which is a COMPOUND_STMT. */
1232 genrtl_compound_stmt (t)
1235 genrtl_begin_compound_stmt (COMPOUND_STMT_NO_SCOPE (t));
1236 expand_stmt (COMPOUND_BODY (t));
1237 return (genrtl_finish_compound_stmt (COMPOUND_STMT_NO_SCOPE (t)));
1240 /* Begin a compound-statement. If HAS_NO_SCOPE is non-zero, the
1241 compound-statement does not define a scope. Returns a new
1242 COMPOUND_STMT if appropriate. */
1245 begin_compound_stmt (has_no_scope)
1251 r = build_min_nt (COMPOUND_STMT, NULL_TREE);
1253 if (last_tree && TREE_CODE (last_tree) == TRY_BLOCK)
1258 COMPOUND_STMT_NO_SCOPE (r) = 1;
1260 last_expr_type = NULL_TREE;
1266 note_level_for_eh ();
1269 /* Normally, we try hard to keep the BLOCK for a
1270 statement-expression. But, if it's a statement-expression with
1271 a scopeless block, there's nothing to keep, and we don't want
1272 to accidentally keep a block *inside* the scopeless block. */
1273 keep_next_level (0);
1275 /* If this is the outermost block of the function, declare the
1276 variables __FUNCTION__, __PRETTY_FUNCTION__, and so forth. */
1278 && !current_function_name_declared
1281 current_function_name_declared = 1;
1282 declare_function_name ();
1288 /* Finish a compound-statement, which may be given by COMPOUND_STMT.
1289 If HAS_NO_SCOPE is non-zero, the compound statement does not define
1293 finish_compound_stmt (has_no_scope, compound_stmt)
1305 RECHAIN_STMTS (compound_stmt, COMPOUND_BODY (compound_stmt));
1307 /* When we call finish_stmt we will lose LAST_EXPR_TYPE. But, since
1308 the precise purpose of that variable is store the type of the
1309 last expression statement within the last compound statement, we
1310 preserve the value. */
1318 /* Generate the RTL for an ASM_STMT. */
1321 genrtl_asm_stmt (cv_qualifier, string, output_operands,
1322 input_operands, clobbers)
1325 tree output_operands;
1326 tree input_operands;
1329 if (TREE_CHAIN (string))
1330 string = combine_strings (string);
1332 if (cv_qualifier != NULL_TREE
1333 && cv_qualifier != ridpointers[(int) RID_VOLATILE])
1335 cp_warning ("%s qualifier ignored on asm",
1336 IDENTIFIER_POINTER (cv_qualifier));
1337 cv_qualifier = NULL_TREE;
1340 emit_line_note (input_filename, lineno);
1341 if (output_operands != NULL_TREE || input_operands != NULL_TREE
1342 || clobbers != NULL_TREE)
1346 for (t = input_operands; t; t = TREE_CHAIN (t))
1347 TREE_VALUE (t) = decay_conversion (TREE_VALUE (t));
1349 c_expand_asm_operands (string, output_operands,
1352 cv_qualifier != NULL_TREE,
1353 input_filename, lineno);
1356 expand_asm (string);
1361 /* Finish an asm-statement, whose components are a CV_QUALIFIER, a
1362 STRING, some OUTPUT_OPERANDS, some INPUT_OPERANDS, and some
1366 finish_asm_stmt (cv_qualifier, string, output_operands,
1367 input_operands, clobbers)
1370 tree output_operands;
1371 tree input_operands;
1375 if (TREE_CHAIN (string))
1376 string = combine_strings (string);
1378 if (cv_qualifier != NULL_TREE
1379 && cv_qualifier != ridpointers[(int) RID_VOLATILE])
1381 cp_warning ("%s qualifier ignored on asm",
1382 IDENTIFIER_POINTER (cv_qualifier));
1383 cv_qualifier = NULL_TREE;
1386 r = build_min_nt (ASM_STMT, cv_qualifier, string,
1387 output_operands, input_operands,
1392 /* Finish a label with the indicated NAME. */
1395 finish_label_stmt (name)
1398 tree decl = define_label (input_filename, lineno, name);
1399 add_tree (build_min_nt (LABEL_STMT, decl));
1402 /* Finish a series of declarations for local labels. G++ allows users
1403 to declare "local" labels, i.e., labels with scope. This extension
1404 is useful when writing code involving statement-expressions. */
1407 finish_label_decl (name)
1410 tree decl = declare_local_label (name);
1411 add_decl_stmt (decl);
1414 /* Create a declaration statement for the declaration given by the
1418 add_decl_stmt (decl)
1423 /* We need the type to last until instantiation time. */
1424 decl_stmt = build_min_nt (DECL_STMT, decl);
1425 add_tree (decl_stmt);
1428 /* Generate the RTL for a SUBOBJECT. */
1431 genrtl_subobject (cleanup)
1434 add_partial_entry (cleanup);
1437 /* We're in a constructor, and have just constructed a a subobject of
1438 *THIS. CLEANUP is code to run if an exception is thrown before the
1439 end of the current function is reached. */
1442 finish_subobject (cleanup)
1445 tree r = build_min_nt (SUBOBJECT, cleanup);
1449 /* Generate the RTL for a DECL_CLEANUP. */
1452 genrtl_decl_cleanup (decl, cleanup)
1456 if (!decl || (DECL_SIZE (decl) && TREE_TYPE (decl) != error_mark_node))
1457 expand_decl_cleanup (decl, cleanup);
1460 /* When DECL goes out of scope, make sure that CLEANUP is executed. */
1463 finish_decl_cleanup (decl, cleanup)
1467 add_tree (build_min_nt (CLEANUP_STMT, decl, cleanup));
1470 /* Generate the RTL for a RETURN_INIT. */
1473 genrtl_named_return_value (return_id, init)
1474 tree return_id, init;
1477 /* Clear this out so that finish_named_return_value can set it
1479 DECL_NAME (DECL_RESULT (current_function_decl)) = NULL_TREE;
1481 decl = DECL_RESULT (current_function_decl);
1483 /* Give this error as many times as there are occurrences,
1484 so that users can use Emacs compilation buffers to find
1485 and fix all such places. */
1486 pedwarn ("ISO C++ does not permit named return values");
1488 if (return_id != NULL_TREE)
1490 if (DECL_NAME (decl) == NULL_TREE)
1492 DECL_NAME (decl) = return_id;
1493 DECL_ASSEMBLER_NAME (decl) = return_id;
1497 cp_error ("return identifier `%D' already in place", return_id);
1502 /* Can't let this happen for constructors. */
1503 if (DECL_CONSTRUCTOR_P (current_function_decl))
1505 error ("can't redefine default return value for constructors");
1509 /* If we have a named return value, put that in our scope as well. */
1510 if (DECL_NAME (decl) != NULL_TREE)
1512 /* Let `cp_finish_decl' know that this initializer is ok. */
1513 DECL_INITIAL (decl) = init;
1514 cp_finish_decl (decl, init, NULL_TREE, 0);
1515 store_return_init (decl);
1518 /* Don't use tree-inlining for functions with named return values.
1519 That doesn't work properly because we don't do any translation of
1520 the RETURN_INITs when they are copied. */
1521 DECL_UNINLINABLE (current_function_decl) = 1;
1524 /* Bind a name and initialization to the return value of
1525 the current function. */
1528 finish_named_return_value (return_id, init)
1529 tree return_id, init;
1531 tree decl = DECL_RESULT (current_function_decl);
1534 /* Give this error as many times as there are occurrences,
1535 so that users can use Emacs compilation buffers to find
1536 and fix all such places. */
1537 pedwarn ("ISO C++ does not permit named return values");
1539 if (return_id != NULL_TREE)
1541 if (DECL_NAME (decl) == NULL_TREE)
1543 DECL_NAME (decl) = return_id;
1544 DECL_ASSEMBLER_NAME (decl) = return_id;
1548 cp_error ("return identifier `%D' already in place", return_id);
1553 /* Can't let this happen for constructors. */
1554 if (DECL_CONSTRUCTOR_P (current_function_decl))
1556 error ("can't redefine default return value for constructors");
1560 /* If we have a named return value, put that in our scope as well. */
1561 if (DECL_NAME (decl) != NULL_TREE)
1563 /* Let `cp_finish_decl' know that this initializer is ok. */
1564 DECL_INITIAL (decl) = init;
1565 if (doing_semantic_analysis_p ())
1567 add_tree (build_min_nt (RETURN_INIT, return_id, init));
1570 /* Don't use tree-inlining for functions with named return values.
1571 That doesn't work properly because we don't do any translation of
1572 the RETURN_INITs when they are copied. */
1573 DECL_UNINLINABLE (current_function_decl) = 1;
1576 /* The INIT_LIST is a list of mem-initializers, in the order they were
1577 written by the user. The TREE_VALUE of each node is a list of
1578 initializers for a particular subobject. The TREE_PURPOSE is a
1579 FIELD_DECL is the initializer is for a non-static data member, and
1580 a class type if the initializer is for a base class. */
1583 finish_mem_initializers (init_list)
1586 tree member_init_list;
1587 tree base_init_list;
1588 tree last_base_warned_about;
1592 member_init_list = NULL_TREE;
1593 base_init_list = NULL_TREE;
1594 last_base_warned_about = NULL_TREE;
1596 for (init = init_list; init; init = next)
1598 next = TREE_CHAIN (init);
1599 if (TREE_CODE (TREE_PURPOSE (init)) == FIELD_DECL)
1601 TREE_CHAIN (init) = member_init_list;
1602 member_init_list = init;
1604 /* We're running through the initializers from right to left
1605 as we process them here. So, if we see a data member
1606 initializer after we see a base initializer, that
1607 actually means that the base initializer preceeded the
1608 data member initializer. */
1609 if (warn_reorder && last_base_warned_about != base_init_list)
1613 for (base = base_init_list;
1614 base != last_base_warned_about;
1615 base = TREE_CHAIN (base))
1617 cp_warning ("base initializer for `%T'",
1618 TREE_PURPOSE (base));
1619 warning (" will be re-ordered to precede member initializations");
1622 last_base_warned_about = base_init_list;
1627 TREE_CHAIN (init) = base_init_list;
1628 base_init_list = init;
1632 setup_vtbl_ptr (member_init_list, base_init_list);
1635 /* Cache the value of this class's main virtual function table pointer
1636 in a register variable. This will save one indirection if a
1637 more than one virtual function call is made this function. */
1640 setup_vtbl_ptr (member_init_list, base_init_list)
1641 tree member_init_list;
1642 tree base_init_list;
1644 my_friendly_assert (doing_semantic_analysis_p (), 19990919);
1646 /* If we've already done this, there's no need to do it again. */
1650 if (DECL_CONSTRUCTOR_P (current_function_decl))
1652 if (processing_template_decl)
1653 add_tree (build_min_nt
1655 member_init_list, base_init_list));
1660 /* Mark the beginning of the constructor. */
1661 ctor_stmt = build_min_nt (CTOR_STMT);
1662 CTOR_BEGIN_P (ctor_stmt) = 1;
1663 add_tree (ctor_stmt);
1665 /* And actually initialize the base-classes and members. */
1666 emit_base_init (member_init_list, base_init_list);
1669 else if (DECL_DESTRUCTOR_P (current_function_decl)
1670 && !processing_template_decl)
1676 /* If the dtor is empty, and we know there is not any possible
1677 way we could use any vtable entries, before they are possibly
1678 set by a base class dtor, we don't have to setup the vtables,
1679 as we know that any base class dtor will set up any vtables
1680 it needs. We avoid MI, because one base class dtor can do a
1681 virtual dispatch to an overridden function that would need to
1682 have a non-related vtable set up, we cannot avoid setting up
1683 vtables in that case. We could change this to see if there
1684 is just one vtable. */
1685 if_stmt = begin_if_stmt ();
1687 /* If it is not safe to avoid setting up the vtables, then
1688 someone will change the condition to be boolean_true_node.
1689 (Actually, for now, we do not have code to set the condition
1690 appropriately, so we just assume that we always need to
1691 initialize the vtables.) */
1692 finish_if_stmt_cond (boolean_true_node, if_stmt);
1693 current_vcalls_possible_p = &IF_COND (if_stmt);
1695 /* Don't declare __PRETTY_FUNCTION__ and friends here when we
1696 open the block for the if-body. */
1697 saved_cfnd = current_function_name_declared;
1698 current_function_name_declared = 1;
1699 compound_stmt = begin_compound_stmt (/*has_no_scope=*/0);
1700 current_function_name_declared = saved_cfnd;
1702 /* Make all virtual function table pointers in non-virtual base
1703 classes point to CURRENT_CLASS_TYPE's virtual function
1705 initialize_vtbl_ptrs (current_class_ptr);
1707 finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
1708 finish_then_clause (if_stmt);
1712 /* Always keep the BLOCK node associated with the outermost pair of
1713 curly braces of a function. These are needed for correct
1714 operation of dwarfout.c. */
1715 keep_next_level (1);
1717 /* The virtual function tables are set up now. */
1722 /* Add a scope-statement to the statement-tree. BEGIN_P indicates
1723 whether this statements opens or closes a scope. PARTIAL_P is true
1724 for a partial scope, i.e, the scope that begins after a label when
1725 an object that needs a cleanup is created. If BEGIN_P is nonzero,
1726 returns a new TREE_LIST representing the top of the SCOPE_STMT
1727 stack. The TREE_PURPOSE is the new SCOPE_STMT. If BEGIN_P is
1728 zero, returns a TREE_LIST whose TREE_VALUE is the new SCOPE_STMT,
1729 and whose TREE_PURPOSE is the matching SCOPE_STMT iwth
1730 SCOPE_BEGIN_P set. */
1733 add_scope_stmt (begin_p, partial_p)
1740 /* Build the statement. */
1741 ss = build_min_nt (SCOPE_STMT, NULL_TREE);
1742 SCOPE_BEGIN_P (ss) = begin_p;
1743 SCOPE_PARTIAL_P (ss) = partial_p;
1745 /* Keep the scope stack up to date. */
1748 current_scope_stmt_stack
1749 = tree_cons (ss, NULL_TREE, current_scope_stmt_stack);
1750 top = current_scope_stmt_stack;
1754 top = current_scope_stmt_stack;
1755 TREE_VALUE (top) = ss;
1756 current_scope_stmt_stack = TREE_CHAIN (top);
1759 /* Add the new statement to the statement-tree. */
1765 /* Finish a parenthesized expression EXPR. */
1768 finish_parenthesized_expr (expr)
1771 if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (expr))))
1772 /* This inhibits warnings in truthvalue_conversion. */
1773 C_SET_EXP_ORIGINAL_CODE (expr, ERROR_MARK);
1778 /* The last_tree will be NULL_TREE when entering this function. Unlike
1779 the other genrtl functions, in this function, that state can change
1780 hence the check at the end as in the original version of
1781 begin_stmt_expr. Generate the RTL for the start of a STMT_EXPR. */
1783 genrtl_begin_stmt_expr ()
1785 if (! cfun && !last_tree)
1786 begin_stmt_tree (&scope_chain->x_saved_tree);
1788 keep_next_level (1);
1790 return (last_tree != NULL_TREE) ? last_tree : expand_start_stmt_expr();
1793 /* Begin a statement-expression. The value returned must be passed to
1794 finish_stmt_expr. */
1799 /* If we're outside a function, we won't have a statement-tree to
1800 work with. But, if we see a statement-expression we need to
1802 if (! cfun && !last_tree)
1803 begin_stmt_tree (&scope_chain->x_saved_tree);
1805 keep_next_level (1);
1806 /* If we're building a statement tree, then the upcoming compound
1807 statement will be chained onto the tree structure, starting at
1808 last_tree. We return last_tree so that we can later unhook the
1809 compound statement. */
1813 /* Generate the RTL for the end of the STMT_EXPR. */
1816 genrtl_finish_stmt_expr (rtl_expr)
1821 rtl_expr = expand_end_stmt_expr (rtl_expr);
1825 && TREE_CHAIN (scope_chain->x_saved_tree) == NULL_TREE)
1826 finish_stmt_tree (&scope_chain->x_saved_tree);
1831 /* Finish a statement-expression. RTL_EXPR should be the value
1832 returned by the previous begin_stmt_expr; EXPR is the
1833 statement-expression. Returns an expression representing the
1834 statement-expression. */
1837 finish_stmt_expr (rtl_expr)
1842 /* If the last thing in the statement-expression was not an
1843 expression-statement, then it has type `void'. */
1844 if (!last_expr_type)
1845 last_expr_type = void_type_node;
1846 result = build_min (STMT_EXPR, last_expr_type, last_tree);
1847 TREE_SIDE_EFFECTS (result) = 1;
1849 /* Remove the compound statement from the tree structure; it is
1850 now saved in the STMT_EXPR. */
1851 SET_LAST_STMT (rtl_expr);
1852 TREE_CHAIN (last_tree) = NULL_TREE;
1854 /* If we created a statement-tree for this statement-expression,
1857 && TREE_CHAIN (scope_chain->x_saved_tree) == NULL_TREE)
1858 finish_stmt_tree (&scope_chain->x_saved_tree);
1863 /* Finish a call to FN with ARGS. Returns a representation of the
1867 finish_call_expr (fn, args, koenig)
1876 if (TREE_CODE (fn) == BIT_NOT_EXPR)
1877 fn = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND (fn, 0));
1878 else if (TREE_CODE (fn) != TEMPLATE_ID_EXPR)
1879 fn = do_identifier (fn, 2, args);
1881 result = build_x_function_call (fn, args, current_class_ref);
1883 if (TREE_CODE (result) == CALL_EXPR
1884 && (! TREE_TYPE (result)
1885 || TREE_CODE (TREE_TYPE (result)) != VOID_TYPE))
1886 result = require_complete_type (result);
1891 /* Finish a call to a postfix increment or decrement or EXPR. (Which
1892 is indicated by CODE, which should be POSTINCREMENT_EXPR or
1893 POSTDECREMENT_EXPR.) */
1896 finish_increment_expr (expr, code)
1898 enum tree_code code;
1900 /* If we get an OFFSET_REF, turn it into what it really means (e.g.,
1901 a COMPONENT_REF). This way if we've got, say, a reference to a
1902 static member that's being operated on, we don't end up trying to
1903 find a member operator for the class it's in. */
1905 if (TREE_CODE (expr) == OFFSET_REF)
1906 expr = resolve_offset_ref (expr);
1907 return build_x_unary_op (code, expr);
1910 /* Finish a use of `this'. Returns an expression for `this'. */
1917 if (current_class_ptr)
1919 #ifdef WARNING_ABOUT_CCD
1920 TREE_USED (current_class_ptr) = 1;
1922 result = current_class_ptr;
1924 else if (current_function_decl
1925 && DECL_STATIC_FUNCTION_P (current_function_decl))
1927 error ("`this' is unavailable for static member functions");
1928 result = error_mark_node;
1932 if (current_function_decl)
1933 error ("invalid use of `this' in non-member function");
1935 error ("invalid use of `this' at top level");
1936 result = error_mark_node;
1942 /* Finish a member function call using OBJECT and ARGS as arguments to
1943 FN. Returns an expression for the call. */
1946 finish_object_call_expr (fn, object, args)
1952 /* This is a future direction of this code, but because
1953 build_x_function_call cannot always undo what is done in
1954 build_component_ref entirely yet, we cannot do this. */
1956 tree real_fn = build_component_ref (object, fn, NULL_TREE, 1);
1957 return finish_call_expr (real_fn, args);
1959 if (DECL_DECLARES_TYPE_P (fn))
1961 if (processing_template_decl)
1962 /* This can happen on code like:
1965 template <class T> void f(T t) {
1969 We just grab the underlying IDENTIFIER. */
1970 fn = DECL_NAME (fn);
1973 cp_error ("calling type `%T' like a method", fn);
1974 return error_mark_node;
1978 return build_method_call (object, fn, args, NULL_TREE, LOOKUP_NORMAL);
1982 /* Finish a qualified member function call using OBJECT and ARGS as
1983 arguments to FN. Returns an expressino for the call. */
1986 finish_qualified_object_call_expr (fn, object, args)
1991 return build_scoped_method_call (object, TREE_OPERAND (fn, 0),
1992 TREE_OPERAND (fn, 1), args);
1995 /* Finish a pseudo-destructor call expression of OBJECT, with SCOPE
1996 being the scope, if any, of DESTRUCTOR. Returns an expression for
2000 finish_pseudo_destructor_call_expr (object, scope, destructor)
2005 if (processing_template_decl)
2006 return build_min_nt (PSEUDO_DTOR_EXPR, object, scope, destructor);
2008 if (scope && scope != destructor)
2009 cp_error ("destructor specifier `%T::~%T()' must have matching names",
2012 if ((scope == NULL_TREE || IDENTIFIER_GLOBAL_VALUE (destructor))
2013 && (TREE_CODE (TREE_TYPE (object)) !=
2014 TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (destructor)))))
2015 cp_error ("`%E' is not of type `%T'", object, destructor);
2017 return cp_convert (void_type_node, object);
2020 /* Finish a call to a globally qualified member function FN using
2021 ARGS. Returns an expression for the call. */
2024 finish_qualified_call_expr (fn, args)
2028 if (processing_template_decl)
2029 return build_min_nt (CALL_EXPR, fn, args, NULL_TREE);
2031 return build_member_call (TREE_OPERAND (fn, 0),
2032 TREE_OPERAND (fn, 1),
2036 /* Finish an expression taking the address of LABEL. Returns an
2037 expression for the address. */
2040 finish_label_address_expr (label)
2045 label = lookup_label (label);
2046 if (label == NULL_TREE)
2047 result = null_pointer_node;
2050 TREE_USED (label) = 1;
2051 result = build1 (ADDR_EXPR, ptr_type_node, label);
2052 TREE_CONSTANT (result) = 1;
2053 /* This function cannot be inlined. All jumps to the addressed
2054 label should wind up at the same point. */
2055 DECL_UNINLINABLE (current_function_decl) = 1;
2061 /* Finish an expression of the form CODE EXPR. */
2064 finish_unary_op_expr (code, expr)
2065 enum tree_code code;
2068 tree result = build_x_unary_op (code, expr);
2069 /* Inside a template, build_x_unary_op does not fold the
2070 expression. So check whether the result is folded before
2071 setting TREE_NEGATED_INT. */
2072 if (code == NEGATE_EXPR && TREE_CODE (expr) == INTEGER_CST
2073 && TREE_CODE (result) == INTEGER_CST
2074 && !TREE_UNSIGNED (TREE_TYPE (result))
2075 && INT_CST_LT (result, integer_zero_node))
2076 TREE_NEGATED_INT (result) = 1;
2077 overflow_warning (result);
2081 /* Finish an id-expression. */
2084 finish_id_expr (expr)
2087 if (TREE_CODE (expr) == IDENTIFIER_NODE)
2088 expr = do_identifier (expr, 1, NULL_TREE);
2093 static tree current_type_lookups;
2095 /* Perform deferred access control for types used in the type of a
2099 deferred_type_access_control ()
2101 tree lookup = type_lookups;
2103 if (lookup == error_mark_node)
2106 for (; lookup; lookup = TREE_CHAIN (lookup))
2107 enforce_access (TREE_PURPOSE (lookup), TREE_VALUE (lookup));
2111 decl_type_access_control (decl)
2116 if (type_lookups == error_mark_node)
2119 save_fn = current_function_decl;
2121 if (decl && TREE_CODE (decl) == FUNCTION_DECL)
2122 current_function_decl = decl;
2124 deferred_type_access_control ();
2126 current_function_decl = save_fn;
2128 /* Now strip away the checks for the current declarator; they were
2129 added to type_lookups after typed_declspecs saved the copy that
2130 ended up in current_type_lookups. */
2131 type_lookups = current_type_lookups;
2135 save_type_access_control (lookups)
2138 current_type_lookups = lookups;
2141 /* Begin a function definition declared with DECL_SPECS and
2142 DECLARATOR. Returns non-zero if the function-declaration is
2146 begin_function_definition (decl_specs, declarator)
2153 split_specs_attrs (decl_specs, &specs, &attrs);
2154 if (!start_function (specs, declarator, attrs, SF_DEFAULT))
2157 deferred_type_access_control ();
2158 type_lookups = error_mark_node;
2160 /* The things we're about to see are not directly qualified by any
2161 template headers we've seen thus far. */
2162 reset_specialization ();
2167 /* Begin a constructor declarator of the form `SCOPE::NAME'. Returns
2171 begin_constructor_declarator (scope, name)
2175 tree result = build_parse_node (SCOPE_REF, scope, name);
2176 enter_scope_of (result);
2180 /* Finish an init-declarator. Returns a DECL. */
2183 finish_declarator (declarator, declspecs, attributes,
2184 prefix_attributes, initialized)
2188 tree prefix_attributes;
2191 return start_decl (declarator, declspecs, initialized, attributes,
2195 /* Finish a translation unit. */
2198 finish_translation_unit ()
2200 /* In case there were missing closebraces,
2201 get us back to the global binding level. */
2203 while (current_namespace != global_namespace)
2208 /* Finish a template type parameter, specified as AGGR IDENTIFIER.
2209 Returns the parameter. */
2212 finish_template_type_parm (aggr, identifier)
2216 if (aggr != class_type_node)
2218 pedwarn ("template type parameters must use the keyword `class' or `typename'");
2219 aggr = class_type_node;
2222 return build_tree_list (aggr, identifier);
2225 /* Finish a template template parameter, specified as AGGR IDENTIFIER.
2226 Returns the parameter. */
2229 finish_template_template_parm (aggr, identifier)
2233 tree decl = build_decl (TYPE_DECL, identifier, NULL_TREE);
2234 tree tmpl = build_lang_decl (TEMPLATE_DECL, identifier, NULL_TREE);
2235 DECL_TEMPLATE_PARMS (tmpl) = current_template_parms;
2236 DECL_TEMPLATE_RESULT (tmpl) = decl;
2237 SET_DECL_ARTIFICIAL (decl);
2238 end_template_decl ();
2240 return finish_template_type_parm (aggr, tmpl);
2243 /* Finish a parameter list, indicated by PARMS. If ELLIPSIS is
2244 non-zero, the parameter list was terminated by a `...'. */
2247 finish_parmlist (parms, ellipsis)
2252 chainon (parms, void_list_node);
2253 /* We mark the PARMS as a parmlist so that declarator processing can
2254 disambiguate certain constructs. */
2255 if (parms != NULL_TREE)
2256 TREE_PARMLIST (parms) = 1;
2261 /* Begin a class definition, as indicated by T. */
2264 begin_class_definition (t)
2267 if (t == error_mark_node
2268 || ! IS_AGGR_TYPE (t))
2270 t = make_aggr_type (RECORD_TYPE);
2271 pushtag (make_anon_name (), t, 0);
2274 /* In a definition of a member class template, we will get here with an
2275 implicit typename, a TYPENAME_TYPE with a type. */
2276 if (TREE_CODE (t) == TYPENAME_TYPE)
2279 /* If we generated a partial instantiation of this type, but now
2280 we're seeing a real definition, we're actually looking at a
2281 partial specialization. Consider:
2283 template <class T, class U>
2289 template <class T, class U>
2292 typename X<Y<T, U> >::A a;
2295 template <class T, class U>
2300 We have to undo the effects of the previous partial
2302 if (PARTIAL_INSTANTIATION_P (t))
2306 /* Unfortunately, when we're not in pedantic mode, we
2307 attempt to actually fill in some of the fields of the
2308 partial instantiation, in order to support the implicit
2309 typename extension. Clear those fields now, in
2310 preparation for the definition here. The fields cleared
2311 here must match those set in instantiate_class_template.
2312 Look for a comment mentioning begin_class_definition
2314 TYPE_BINFO_BASETYPES (t) = NULL_TREE;
2315 TYPE_FIELDS (t) = NULL_TREE;
2316 TYPE_METHODS (t) = NULL_TREE;
2317 CLASSTYPE_TAGS (t) = NULL_TREE;
2318 TYPE_SIZE (t) = NULL_TREE;
2321 /* This isn't a partial instantiation any more. */
2322 PARTIAL_INSTANTIATION_P (t) = 0;
2324 /* If this type was already complete, and we see another definition,
2326 else if (COMPLETE_TYPE_P (t))
2327 duplicate_tag_error (t);
2329 /* Update the location of the decl. */
2330 DECL_SOURCE_FILE (TYPE_NAME (t)) = input_filename;
2331 DECL_SOURCE_LINE (TYPE_NAME (t)) = lineno;
2333 if (TYPE_BEING_DEFINED (t))
2335 t = make_aggr_type (TREE_CODE (t));
2336 pushtag (TYPE_IDENTIFIER (t), t, 0);
2338 maybe_process_partial_specialization (t);
2340 TYPE_BEING_DEFINED (t) = 1;
2341 TYPE_PACKED (t) = flag_pack_struct;
2342 /* Reset the interface data, at the earliest possible
2343 moment, as it might have been set via a class foo;
2346 tree name = TYPE_IDENTIFIER (t);
2348 if (! ANON_AGGRNAME_P (name))
2350 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
2351 SET_CLASSTYPE_INTERFACE_UNKNOWN_X
2352 (t, interface_unknown);
2355 /* Only leave this bit clear if we know this
2356 class is part of an interface-only specification. */
2357 if (! CLASSTYPE_INTERFACE_KNOWN (t)
2358 || ! CLASSTYPE_INTERFACE_ONLY (t))
2359 CLASSTYPE_VTABLE_NEEDS_WRITING (t) = 1;
2361 reset_specialization();
2363 /* Make a declaration for this class in its own scope. */
2364 build_self_reference ();
2369 /* Finish the member declaration given by DECL. */
2372 finish_member_declaration (decl)
2375 if (decl == error_mark_node || decl == NULL_TREE)
2378 if (decl == void_type_node)
2379 /* The COMPONENT was a friend, not a member, and so there's
2380 nothing for us to do. */
2383 /* We should see only one DECL at a time. */
2384 my_friendly_assert (TREE_CHAIN (decl) == NULL_TREE, 0);
2386 /* Set up access control for DECL. */
2388 = (current_access_specifier == access_private_node);
2389 TREE_PROTECTED (decl)
2390 = (current_access_specifier == access_protected_node);
2391 if (TREE_CODE (decl) == TEMPLATE_DECL)
2393 TREE_PRIVATE (DECL_TEMPLATE_RESULT (decl)) = TREE_PRIVATE (decl);
2394 TREE_PROTECTED (DECL_TEMPLATE_RESULT (decl)) = TREE_PROTECTED (decl);
2397 /* Mark the DECL as a member of the current class. */
2398 DECL_CONTEXT (decl) = current_class_type;
2402 A C language linkage is ignored for the names of class members
2403 and the member function type of class member functions. */
2404 if (DECL_LANG_SPECIFIC (decl) && DECL_LANGUAGE (decl) == lang_c)
2405 DECL_LANGUAGE (decl) = lang_cplusplus;
2407 /* Put functions on the TYPE_METHODS list and everything else on the
2408 TYPE_FIELDS list. Note that these are built up in reverse order.
2409 We reverse them (to obtain declaration order) in finish_struct. */
2410 if (TREE_CODE (decl) == FUNCTION_DECL
2411 || DECL_FUNCTION_TEMPLATE_P (decl))
2413 /* We also need to add this function to the
2414 CLASSTYPE_METHOD_VEC. */
2415 add_method (current_class_type, 0, decl);
2417 TREE_CHAIN (decl) = TYPE_METHODS (current_class_type);
2418 TYPE_METHODS (current_class_type) = decl;
2422 /* All TYPE_DECLs go at the end of TYPE_FIELDS. Ordinary fields
2423 go at the beginning. The reason is that lookup_field_1
2424 searches the list in order, and we want a field name to
2425 override a type name so that the "struct stat hack" will
2426 work. In particular:
2428 struct S { enum E { }; int E } s;
2431 is legal. In addition, the FIELD_DECLs must be maintained in
2432 declaration order so that class layout works as expected.
2433 However, we don't need that order until class layout, so we
2434 save a little time by putting FIELD_DECLs on in reverse order
2435 here, and then reversing them in finish_struct_1. (We could
2436 also keep a pointer to the correct insertion points in the
2439 if (TREE_CODE (decl) == TYPE_DECL)
2440 TYPE_FIELDS (current_class_type)
2441 = chainon (TYPE_FIELDS (current_class_type), decl);
2444 TREE_CHAIN (decl) = TYPE_FIELDS (current_class_type);
2445 TYPE_FIELDS (current_class_type) = decl;
2448 /* Enter the DECL into the scope of the class. */
2449 if (TREE_CODE (decl) != USING_DECL)
2450 pushdecl_class_level (decl);
2454 /* Finish a class definition T with the indicate ATTRIBUTES. If SEMI,
2455 the definition is immediately followed by a semicolon. Returns the
2459 finish_class_definition (t, attributes, semi, pop_scope_p)
2465 /* finish_struct nukes this anyway; if finish_exception does too,
2468 note_got_semicolon (t);
2470 /* If we got any attributes in class_head, xref_tag will stick them in
2471 TREE_TYPE of the type. Grab them now. */
2472 attributes = chainon (TREE_TYPE (t), attributes);
2473 TREE_TYPE (t) = NULL_TREE;
2475 if (TREE_CODE (t) == ENUMERAL_TYPE)
2479 t = finish_struct (t, attributes);
2481 note_got_semicolon (t);
2485 check_for_missing_semicolon (t);
2487 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (t)));
2488 if (current_scope () == current_function_decl)
2489 do_pending_defargs ();
2494 /* Finish processing the default argument expressions cached during
2495 the processing of a class definition. */
2498 begin_inline_definitions ()
2501 && current_scope () == current_function_decl)
2502 do_pending_inlines ();
2505 /* Finish processing the inline function definitions cached during the
2506 processing of a class definition. */
2509 finish_inline_definitions ()
2511 if (current_class_type == NULL_TREE)
2512 clear_inline_text_obstack ();
2515 /* Finish processing the declaration of a member class template
2516 TYPES whose template parameters are given by PARMS. */
2519 finish_member_class_template (types)
2524 /* If there are declared, but undefined, partial specializations
2525 mixed in with the typespecs they will not yet have passed through
2526 maybe_process_partial_specialization, so we do that here. */
2527 for (t = types; t != NULL_TREE; t = TREE_CHAIN (t))
2528 if (IS_AGGR_TYPE_CODE (TREE_CODE (TREE_VALUE (t))))
2529 maybe_process_partial_specialization (TREE_VALUE (t));
2531 note_list_got_semicolon (types);
2532 grok_x_components (types);
2533 if (TYPE_CONTEXT (TREE_VALUE (types)) != current_class_type)
2534 /* The component was in fact a friend declaration. We avoid
2535 finish_member_template_decl performing certain checks by
2539 finish_member_template_decl (types);
2541 /* As with other component type declarations, we do
2542 not store the new DECL on the list of
2547 /* Finish processsing a complete template declaration. The PARMS are
2548 the template parameters. */
2551 finish_template_decl (parms)
2555 end_template_decl ();
2557 end_specialization ();
2560 /* Finish processing a a template-id (which names a type) of the form
2561 NAME < ARGS >. Return the TYPE_DECL for the type named by the
2562 template-id. If ENTERING_SCOPE is non-zero we are about to enter
2563 the scope of template-id indicated. */
2566 finish_template_type (name, args, entering_scope)
2573 decl = lookup_template_class (name, args,
2574 NULL_TREE, NULL_TREE, entering_scope);
2575 if (decl != error_mark_node)
2576 decl = TYPE_STUB_DECL (decl);
2581 /* SR is a SCOPE_REF node. Enter the scope of SR, whether it is a
2582 namespace scope or a class scope. */
2588 tree scope = TREE_OPERAND (sr, 0);
2590 if (TREE_CODE (scope) == NAMESPACE_DECL)
2592 push_decl_namespace (scope);
2593 TREE_COMPLEXITY (sr) = -1;
2595 else if (scope != current_class_type)
2597 if (TREE_CODE (scope) == TYPENAME_TYPE)
2599 /* In a declarator for a template class member, the scope will
2600 get here as an implicit typename, a TYPENAME_TYPE with a type. */
2601 scope = TREE_TYPE (scope);
2602 TREE_OPERAND (sr, 0) = scope;
2604 push_nested_class (scope, 3);
2605 TREE_COMPLEXITY (sr) = current_class_depth;
2609 /* Finish processing a BASE_CLASS with the indicated ACCESS_SPECIFIER.
2610 Return a TREE_LIST containing the ACCESS_SPECIFIER and the
2611 BASE_CLASS, or NULL_TREE if an error occurred. The
2612 ACCESSS_SPECIFIER is one of
2613 access_{default,public,protected_private}[_virtual]_node.*/
2616 finish_base_specifier (access_specifier, base_class)
2617 tree access_specifier;
2623 if (base_class == NULL_TREE)
2625 error ("invalid base class");
2626 type = error_mark_node;
2629 type = TREE_TYPE (base_class);
2631 if (! is_aggr_type (type, 1))
2634 result = build_tree_list (access_specifier, type);
2639 /* Called when multiple declarators are processed. If that is not
2640 premitted in this context, an error is issued. */
2643 check_multiple_declarators ()
2647 In a template-declaration, explicit specialization, or explicit
2648 instantiation the init-declarator-list in the declaration shall
2649 contain at most one declarator.
2651 We don't just use PROCESSING_TEMPLATE_DECL for the first
2652 condition since that would disallow the perfectly legal code,
2653 like `template <class T> struct S { int i, j; };'. */
2654 tree scope = current_scope ();
2656 if (scope && TREE_CODE (scope) == FUNCTION_DECL)
2657 /* It's OK to write `template <class T> void f() { int i, j;}'. */
2660 if (PROCESSING_REAL_TEMPLATE_DECL_P ()
2661 || processing_explicit_instantiation
2662 || processing_specialization)
2663 cp_error ("multiple declarators in template declaration");
2667 finish_typeof (expr)
2670 if (processing_template_decl)
2674 t = make_aggr_type (TYPEOF_TYPE);
2675 TYPE_FIELDS (t) = expr;
2680 return TREE_TYPE (expr);
2683 /* Create an empty statement tree rooted at T. */
2689 /* We create a trivial EXPR_STMT so that last_tree is never NULL in
2690 what follows. We remove the extraneous statement in
2691 finish_stmt_tree. */
2692 *t = build_nt (EXPR_STMT, void_zero_node);
2694 last_expr_type = NULL_TREE;
2697 /* Finish the statement tree rooted at T. */
2700 finish_stmt_tree (t)
2705 /* Remove the fake extra statement added in begin_stmt_tree. */
2706 stmt = TREE_CHAIN (*t);
2708 SET_LAST_STMT (NULL_TREE);
2712 /* The line-number recorded in the outermost statement in a function
2713 is the line number of the end of the function. */
2714 STMT_LINENO (stmt) = lineno;
2715 STMT_LINENO_FOR_FN_P (stmt) = 1;
2719 /* We're about to expand T, a statement. Set up appropriate context
2720 for the substitution. */
2726 if (!STMT_LINENO_FOR_FN_P (t))
2727 lineno = STMT_LINENO (t);
2728 stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t);
2731 /* Some statements, like for-statements or if-statements, require a
2732 condition. This condition can be a declaration. If T is such a
2733 declaration it is processed, and an expression appropriate to use
2734 as the condition is returned. Otherwise, T itself is returned. */
2740 if (t && TREE_CODE (t) == TREE_LIST)
2742 expand_stmt (TREE_PURPOSE (t));
2743 return TREE_VALUE (t);
2749 /* Generate RTL for the statement T, and its substatements, and any
2750 other statements at its nesting level. */
2756 tree rval = NULL_TREE;
2758 while (t && t != error_mark_node)
2760 int saved_stmts_are_full_exprs_p;
2762 /* Assume we'll have nothing to return. */
2765 /* Set up context appropriately for handling this statement. */
2766 saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p;
2769 switch (TREE_CODE (t))
2772 genrtl_return_stmt (RETURN_EXPR (t));
2776 genrtl_expr_stmt (EXPR_STMT_EXPR (t));
2780 genrtl_decl_stmt (t);
2784 genrtl_decl_cleanup (CLEANUP_DECL (t), CLEANUP_EXPR (t));
2787 case START_CATCH_STMT:
2788 genrtl_catch_block (TREE_TYPE (t));
2792 genrtl_ctor_stmt (t);
2796 genrtl_for_stmt (t);
2800 genrtl_while_stmt (t);
2812 rval = genrtl_compound_stmt (t);
2816 genrtl_break_stmt ();
2820 genrtl_continue_stmt ();
2824 genrtl_switch_stmt (t);
2828 genrtl_case_label (CASE_LOW (t), CASE_HIGH (t));
2832 expand_label (LABEL_STMT_LABEL (t));
2836 genrtl_goto_stmt (GOTO_DESTINATION (t));
2840 genrtl_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t),
2841 ASM_OUTPUTS (t), ASM_INPUTS (t), ASM_CLOBBERS (t));
2845 genrtl_try_block (t);
2853 genrtl_subobject (SUBOBJECT_CLEANUP (t));
2857 genrtl_scope_stmt (t);
2861 genrtl_named_return_value (TREE_OPERAND (t, 0),
2862 TREE_OPERAND (t, 1));
2866 my_friendly_abort (19990810);
2870 /* Restore saved state. */
2871 stmts_are_full_exprs_p = saved_stmts_are_full_exprs_p;
2873 /* Go on to the next statement in this scope. */
2880 /* Called from expand_body via walk_tree. Replace all AGGR_INIT_EXPRs
2881 will equivalent CALL_EXPRs. */
2884 simplify_aggr_init_exprs_r (tp, walk_subtrees, data)
2886 int *walk_subtrees ATTRIBUTE_UNUSED;
2887 void *data ATTRIBUTE_UNUSED;
2889 tree aggr_init_expr;
2896 int copy_from_buffer_p;
2898 aggr_init_expr = *tp;
2899 /* We don't need to walk into types; there's nothing in a type that
2900 needs simplification. (And, furthermore, there are places we
2901 actively don't want to go. For example, we don't want to wander
2902 into the default arguments for a FUNCTION_DECL that appears in a
2904 if (TYPE_P (aggr_init_expr))
2909 /* Only AGGR_INIT_EXPRs are interesting. */
2910 else if (TREE_CODE (aggr_init_expr) != AGGR_INIT_EXPR)
2913 /* Form an appropriate CALL_EXPR. */
2914 fn = TREE_OPERAND (aggr_init_expr, 0);
2915 args = TREE_OPERAND (aggr_init_expr, 1);
2916 slot = TREE_OPERAND (aggr_init_expr, 2);
2917 type = TREE_TYPE (aggr_init_expr);
2919 if (AGGR_INIT_VIA_CTOR_P (aggr_init_expr))
2921 /* Replace the first argument with the address of the third
2922 argument to the AGGR_INIT_EXPR. */
2923 call_type = build_pointer_type (type);
2924 mark_addressable (slot);
2925 args = tree_cons (NULL_TREE, build1 (ADDR_EXPR, call_type, slot),
2928 call_expr = build (CALL_EXPR, call_type, fn, args, NULL_TREE);
2929 TREE_SIDE_EFFECTS (call_expr) = 1;
2931 /* If we're using the non-reentrant PCC calling convention, then we
2932 need to copy the returned value out of the static buffer into the
2934 copy_from_buffer_p = 0;
2935 #ifdef PCC_STATIC_STRUCT_RETURN
2936 if (!AGGR_INIT_VIA_CTOR_P (aggr_init_expr) && aggregate_value_p (type))
2940 flag_access_control = 0;
2941 call_expr = build_aggr_init (slot, call_expr, LOOKUP_ONLYCONVERTING);
2942 flag_access_control = old_ac;
2943 copy_from_buffer_p = 1;
2947 /* If this AGGR_INIT_EXPR indicates the value returned by a
2948 function, then we want to use the value of the initialized
2949 location as the result. */
2950 if (AGGR_INIT_VIA_CTOR_P (aggr_init_expr) || copy_from_buffer_p)
2952 call_expr = build (COMPOUND_EXPR, type,
2954 TREE_SIDE_EFFECTS (call_expr) = 1;
2957 /* Replace the AGGR_INIT_EXPR with the CALL_EXPR. */
2958 TREE_CHAIN (call_expr) = TREE_CHAIN (aggr_init_expr);
2961 /* Keep iterating. */
2965 /* Generate RTL for FN. */
2972 const char *saved_input_filename;
2974 /* When the parser calls us after finishing the body of a template
2975 function, we don't really want to expand the body. When we're
2976 processing an in-class definition of an inline function,
2977 PROCESSING_TEMPLATE_DECL will no longer be set here, so we have
2978 to look at the function itself. */
2979 if (processing_template_decl
2980 || (DECL_LANG_SPECIFIC (fn)
2981 && DECL_TEMPLATE_INFO (fn)
2982 && uses_template_parms (DECL_TI_ARGS (fn))))
2984 /* Normally, collection only occurs in rest_of_compilation. So,
2985 if we don't collect here, we never collect junk generated
2986 during the processing of templates until we hit a
2987 non-template function. */
2992 /* Replace AGGR_INIT_EXPRs with appropriate CALL_EXPRs. */
2993 walk_tree (&DECL_SAVED_TREE (fn), simplify_aggr_init_exprs_r, NULL);
2995 /* If this is a constructor or destructor body, we have to clone it
2996 under the new ABI. */
2997 if (maybe_clone_body (fn))
2999 /* We don't want to process FN again, so pretend we've written
3000 it out, even though we haven't. */
3001 TREE_ASM_WRITTEN (fn) = 1;
3005 /* There's no reason to do any of the work here if we're only doing
3006 semantic analysis; this code just generates RTL. */
3007 if (flag_syntax_only)
3010 /* If possible, avoid generating RTL for this function. Instead,
3011 just record it as an inline function, and wait until end-of-file
3012 to decide whether to write it out or not. */
3013 if (/* We have to generate RTL if it's not an inline function. */
3014 (DECL_INLINE (fn) || DECL_COMDAT (fn))
3015 /* Or if we have to keep all inline functions anyhow. */
3016 && !flag_keep_inline_functions
3017 /* Or if we actually have a reference to the function. */
3018 && !DECL_NEEDED_P (fn)
3019 /* Or if this is a nested function. */
3020 && !decl_function_context (fn))
3022 /* Give the function RTL now so that we can assign it to a
3023 function pointer, etc. */
3024 make_function_rtl (fn);
3025 /* Set DECL_EXTERNAL so that assemble_external will be called as
3026 necessary. We'll clear it again in finish_file. */
3027 if (!DECL_EXTERNAL (fn))
3029 DECL_NOT_REALLY_EXTERN (fn) = 1;
3030 DECL_EXTERNAL (fn) = 1;
3032 /* Remember this function. In finish_file we'll decide if
3033 we actually need to write this function out. */
3035 /* Let the back-end know that this funtion exists. */
3036 note_deferral_of_defined_inline_function (fn);
3040 timevar_push (TV_INTEGRATION);
3042 /* Optimize the body of the function before expanding it. */
3043 optimize_function (fn);
3045 timevar_pop (TV_INTEGRATION);
3046 timevar_push (TV_EXPAND);
3048 /* Save the current file name and line number. When we expand the
3049 body of the function, we'll set LINENO and INPUT_FILENAME so that
3050 error-mesages come out in the right places. */
3051 saved_lineno = lineno;
3052 saved_input_filename = input_filename;
3053 lineno = DECL_SOURCE_LINE (fn);
3054 input_filename = DECL_SOURCE_FILE (fn);
3056 start_function (NULL_TREE, fn, NULL_TREE, SF_PRE_PARSED | SF_EXPAND);
3057 store_parm_decls ();
3058 current_function_is_thunk = DECL_THUNK_P (fn);
3060 /* We don't need to redeclare __FUNCTION__, __PRETTY_FUNCTION__, or
3061 any of the other magic variables we set up when starting a
3063 current_function_name_declared = 1;
3065 /* Expand the body. */
3066 expand_stmt (DECL_SAVED_TREE (fn));
3068 /* Statements should always be full-expressions at the outermost set
3069 of curly braces for a function. */
3070 my_friendly_assert (stmts_are_full_exprs_p, 19990831);
3072 /* The outermost statement for a function contains the line number
3073 recorded when we finished processing the function. */
3074 lineno = STMT_LINENO (DECL_SAVED_TREE (fn));
3076 /* Generate code for the function. */
3077 finish_function (0);
3079 /* If possible, obliterate the body of the function so that it can
3080 be garbage collected. */
3081 if (flag_dump_translation_unit)
3082 /* Keep the body; we're going to dump it. */
3084 else if (DECL_INLINE (fn) && flag_inline_trees)
3085 /* We might need the body of this function so that we can expand
3086 it inline somewhere else. */
3089 /* We don't need the body; blow it away. */
3090 DECL_SAVED_TREE (fn) = NULL_TREE;
3092 /* And restore the current source position. */
3093 lineno = saved_lineno;
3094 input_filename = saved_input_filename;
3096 timevar_pop (TV_EXPAND);