]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/cp/semantics.c
decl.c (init_decl_processing): Reenable inlining on trees.
[thirdparty/gcc.git] / gcc / cp / semantics.c
CommitLineData
ad321293
MM
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.
5
4c571114 6 Copyright (C) 1998, 1999 Free Software Foundation, Inc.
ad321293
MM
7 Written by Mark Mitchell (mmitchell@usa.net) based on code found
8 formerly in parse.y and pt.c.
9
10 This file is part of GNU CC.
11
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)
15 any later version.
16
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.
21
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
25 02111-1307, USA. */
26
27#include "config.h"
8d052bc7 28#include "system.h"
ad321293
MM
29#include "tree.h"
30#include "cp-tree.h"
31#include "except.h"
32#include "lex.h"
12027a89 33#include "toplev.h"
84df082b 34#include "flags.h"
d658cd4c 35#include "ggc.h"
d9b2d9da 36#include "rtl.h"
ad321293
MM
37
38/* There routines provide a modular interface to perform many parsing
39 operations. They may therefore be used during actual parsing, or
40 during template instantiation, which may be regarded as a
41 degenerate form of parsing. Since the current g++ parser is
42 lacking in several respects, and will be reimplemented, we are
43 attempting to move most code that is not directly related to
44 parsing into this file; that will make implementing the new parser
45 much easier since it will be able to make use of these routines. */
46
527f0080 47static tree expand_cond PROTO((tree));
ed5511d9 48static tree maybe_convert_cond PROTO((tree));
558475f0 49
6f80451c
MM
50/* Record the fact that STMT was the last statement added to the
51 statement tree. */
52
53#define SET_LAST_STMT(stmt) \
54 (current_stmt_tree->x_last_stmt = (stmt))
55
ad321293
MM
56/* When parsing a template, LAST_TREE contains the last statement
57 parsed. These are chained together through the TREE_CHAIN field,
58 but often need to be re-organized since the parse is performed
59 bottom-up. This macro makes LAST_TREE the indicated SUBSTMT of
60 STMT. */
61
cb39191d
MM
62#define RECHAIN_STMTS(stmt, substmt) \
63 do { \
64 substmt = TREE_CHAIN (stmt); \
65 TREE_CHAIN (stmt) = NULL_TREE; \
6f80451c 66 SET_LAST_STMT (stmt); \
ad321293
MM
67 } while (0)
68
527f0080
MM
69/* Finish processing the COND, the SUBSTMT condition for STMT. */
70
ed5511d9
MM
71#define FINISH_COND(cond, stmt, substmt) \
72 do { \
73 if (last_tree != stmt) \
74 { \
75 RECHAIN_STMTS (stmt, substmt); \
76 if (!processing_template_decl) \
77 { \
78 cond = build_tree_list (substmt, cond); \
79 substmt = cond; \
80 } \
81 } \
82 else \
83 substmt = cond; \
527f0080
MM
84 } while (0)
85
a7e4cfa0 86/* T is a statement. Add it to the statement-tree. */
ad321293 87
a7e4cfa0
MM
88void
89add_tree (t)
90 tree t;
91{
92 /* Add T to the statement-tree. */
6f80451c
MM
93 TREE_CHAIN (last_tree) = t;
94 SET_LAST_STMT (t);
a7e4cfa0
MM
95
96 /* When we expand a statement-tree, we must know whether or not the
97 statements are full-expresions. We record that fact here. */
98 if (building_stmt_tree ())
99 STMT_IS_FULL_EXPR_P (last_tree) = stmts_are_full_exprs_p;
100}
101
ed5511d9
MM
102/* COND is the condition-expression for an if, while, etc.,
103 statement. Convert it to a boolean value, if appropriate. */
104
105static tree
106maybe_convert_cond (cond)
107 tree cond;
108{
109 /* Empty conditions remain empty. */
110 if (!cond)
111 return NULL_TREE;
112
113 /* Wait until we instantiate templates before doing conversion. */
114 if (processing_template_decl)
115 return cond;
116
117 /* Do the conversion. */
118 cond = convert_from_reference (cond);
119 return condition_conversion (cond);
120}
121
9bfadf57 122/* Finish an expression-statement, whose EXPRESSION is as indicated. */
a7e4cfa0 123
9bfadf57
MM
124void
125finish_expr_stmt (expr)
ad321293
MM
126 tree expr;
127{
ce4a0391 128 if (expr != NULL_TREE)
ad321293 129 {
558475f0 130 if (building_stmt_tree ())
ce4a0391 131 {
ce4a0391
MM
132 /* Do default conversion if safe and possibly important,
133 in case within ({...}). */
364460b6
MM
134 if (!processing_template_decl
135 && !stmts_are_full_exprs_p
136 && ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
137 && lvalue_p (expr))
138 || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE))
ce4a0391 139 expr = default_conversion (expr);
f1dedc31 140
364460b6
MM
141 if (!processing_template_decl)
142 expr = break_out_cleanups (expr);
143
144 add_tree (build_min_nt (EXPR_STMT, expr));
145 }
146 else
147 {
148 emit_line_note (input_filename, lineno);
149
f1dedc31
MM
150 if (stmts_are_full_exprs_p)
151 expand_start_target_temps ();
152
558475f0 153 cplus_expand_expr_stmt (expr);
558475f0 154
f1dedc31 155 if (stmts_are_full_exprs_p)
f31c0a32 156 expand_end_target_temps ();
f1dedc31 157 }
ad321293 158 }
ce4a0391 159
ad321293 160 finish_stmt ();
558475f0
MM
161
162 /* This was an expression-statement, so we save the type of the
163 expression. */
164 last_expr_type = expr ? TREE_TYPE (expr) : NULL_TREE;
ad321293
MM
165}
166
167/* Begin an if-statement. Returns a newly created IF_STMT if
168 appropriate. */
169
170tree
171begin_if_stmt ()
172{
173 tree r;
174
9bfadf57
MM
175 do_pushlevel ();
176
558475f0 177 if (building_stmt_tree ())
ad321293
MM
178 {
179 r = build_min_nt (IF_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
180 add_tree (r);
181 }
182 else
183 r = NULL_TREE;
184
ad321293
MM
185 return r;
186}
187
188/* Process the COND of an if-statement, which may be given by
189 IF_STMT. */
190
191void
192finish_if_stmt_cond (cond, if_stmt)
193 tree cond;
194 tree if_stmt;
195{
ed5511d9
MM
196 cond = maybe_convert_cond (cond);
197
558475f0 198 if (building_stmt_tree ())
a7e4cfa0 199 FINISH_COND (cond, if_stmt, IF_COND (if_stmt));
ad321293
MM
200 else
201 {
202 emit_line_note (input_filename, lineno);
ed5511d9 203 expand_start_cond (cond, 0);
ad321293
MM
204 }
205}
206
207/* Finish the then-clause of an if-statement, which may be given by
208 IF_STMT. */
209
210tree
211finish_then_clause (if_stmt)
212 tree if_stmt;
213{
558475f0 214 if (building_stmt_tree ())
ad321293 215 {
cb39191d 216 RECHAIN_STMTS (if_stmt, THEN_CLAUSE (if_stmt));
6f80451c 217 SET_LAST_STMT (if_stmt);
ad321293
MM
218 return if_stmt;
219 }
220 else
221 return NULL_TREE;
222}
223
224/* Begin the else-clause of an if-statement. */
225
226void
227begin_else_clause ()
228{
558475f0 229 if (!building_stmt_tree ())
ad321293
MM
230 expand_start_else ();
231}
232
233/* Finish the else-clause of an if-statement, which may be given by
234 IF_STMT. */
235
236void
237finish_else_clause (if_stmt)
238 tree if_stmt;
239{
558475f0 240 if (building_stmt_tree ())
cb39191d 241 RECHAIN_STMTS (if_stmt, ELSE_CLAUSE (if_stmt));
ad321293
MM
242}
243
244/* Finsh an if-statement. */
245
246void
247finish_if_stmt ()
248{
558475f0 249 if (!building_stmt_tree ())
ad321293
MM
250 expand_end_cond ();
251
252 do_poplevel ();
253 finish_stmt ();
254}
255
256/* Begin a while-statement. Returns a newly created WHILE_STMT if
257 appropriate. */
258
259tree
260begin_while_stmt ()
261{
262 tree r;
263
558475f0 264 if (building_stmt_tree ())
ad321293
MM
265 {
266 r = build_min_nt (WHILE_STMT, NULL_TREE, NULL_TREE);
267 add_tree (r);
268 }
269 else
270 {
271 emit_nop ();
272 emit_line_note (input_filename, lineno);
273 expand_start_loop (1);
274 r = NULL_TREE;
275 }
276
277 do_pushlevel ();
278
279 return r;
280}
281
282/* Process the COND of an if-statement, which may be given by
283 WHILE_STMT. */
284
285void
286finish_while_stmt_cond (cond, while_stmt)
287 tree cond;
288 tree while_stmt;
289{
ed5511d9
MM
290 cond = maybe_convert_cond (cond);
291
558475f0 292 if (building_stmt_tree ())
a7e4cfa0 293 FINISH_COND (cond, while_stmt, WHILE_COND (while_stmt));
ad321293
MM
294 else
295 {
296 emit_line_note (input_filename, lineno);
ed5511d9 297 expand_exit_loop_if_false (0, cond);
ad321293
MM
298 }
299
300 /* If COND wasn't a declaration, clear out the
301 block we made for it and start a new one here so the
302 optimization in expand_end_loop will work. */
303 if (getdecls () == NULL_TREE)
304 {
305 do_poplevel ();
306 do_pushlevel ();
307 }
308}
309
310/* Finish a while-statement, which may be given by WHILE_STMT. */
311
312void
313finish_while_stmt (while_stmt)
314 tree while_stmt;
315{
316 do_poplevel ();
317
558475f0 318 if (building_stmt_tree ())
cb39191d 319 RECHAIN_STMTS (while_stmt, WHILE_BODY (while_stmt));
ad321293
MM
320 else
321 expand_end_loop ();
322 finish_stmt ();
323}
324
325/* Begin a do-statement. Returns a newly created DO_STMT if
326 appropriate. */
327
328tree
329begin_do_stmt ()
330{
558475f0 331 if (building_stmt_tree ())
ad321293
MM
332 {
333 tree r = build_min_nt (DO_STMT, NULL_TREE, NULL_TREE);
334 add_tree (r);
335 return r;
336 }
337 else
338 {
339 emit_nop ();
340 emit_line_note (input_filename, lineno);
341 expand_start_loop_continue_elsewhere (1);
342 return NULL_TREE;
343 }
344}
345
346/* Finish the body of a do-statement, which may be given by DO_STMT. */
347
348void
349finish_do_body (do_stmt)
350 tree do_stmt;
351{
558475f0 352 if (building_stmt_tree ())
cb39191d 353 RECHAIN_STMTS (do_stmt, DO_BODY (do_stmt));
ad321293
MM
354 else
355 expand_loop_continue_here ();
356}
357
358/* Finish a do-statement, which may be given by DO_STMT, and whose
359 COND is as indicated. */
360
361void
362finish_do_stmt (cond, do_stmt)
363 tree cond;
364 tree do_stmt;
365{
ed5511d9
MM
366 cond = maybe_convert_cond (cond);
367
558475f0 368 if (building_stmt_tree ())
2a1e9fdd 369 DO_COND (do_stmt) = cond;
ad321293
MM
370 else
371 {
372 emit_line_note (input_filename, lineno);
ed5511d9 373 expand_exit_loop_if_false (0, cond);
ad321293
MM
374 expand_end_loop ();
375 }
376
ad321293
MM
377 finish_stmt ();
378}
379
380/* Finish a return-statement. The EXPRESSION returned, if any, is as
381 indicated. */
382
383void
384finish_return_stmt (expr)
385 tree expr;
386{
efee38a9
MM
387 if (doing_semantic_analysis_p () && !processing_template_decl)
388 expr = check_return_expr (expr);
389
390 if (doing_semantic_analysis_p () && !processing_template_decl)
391 {
392 if (DECL_CONSTRUCTOR_P (current_function_decl) && ctor_label)
393 {
394 /* Even returns without a value in a constructor must return
395 `this'. We accomplish this by sending all returns in a
396 constructor to the CTOR_LABEL; finish_function emits code to
397 return a value there. When we finally generate the real
398 return statement, CTOR_LABEL is no longer set, and we fall
399 through into the normal return-processing code below. */
400 finish_goto_stmt (ctor_label);
401 return;
402 }
403 else if (DECL_DESTRUCTOR_P (current_function_decl))
404 {
405 /* Similarly, all destructors must run destructors for
406 base-classes before returning. So, all returns in a
407 destructor get sent to the DTOR_LABEL; finsh_function emits
408 code to return a value there. */
409 finish_goto_stmt (dtor_label);
410 return;
411 }
412 }
413
558475f0
MM
414 if (building_stmt_tree ())
415 add_tree (build_min_nt (RETURN_STMT, expr));
416 else
417 {
418 emit_line_note (input_filename, lineno);
419 c_expand_return (expr);
420 }
421
ad321293
MM
422 finish_stmt ();
423}
424
425/* Begin a for-statement. Returns a new FOR_STMT if appropriate. */
426
427tree
428begin_for_stmt ()
429{
430 tree r;
431
558475f0 432 if (building_stmt_tree ())
ad321293
MM
433 {
434 r = build_min_nt (FOR_STMT, NULL_TREE, NULL_TREE,
435 NULL_TREE, NULL_TREE);
436 add_tree (r);
437 }
438 else
439 r = NULL_TREE;
440
441 if (flag_new_for_scope > 0)
442 {
443 do_pushlevel ();
444 note_level_for_for ();
445 }
446
447 return r;
448}
449
450/* Finish the for-init-statement of a for-statement, which may be
451 given by FOR_STMT. */
452
453void
454finish_for_init_stmt (for_stmt)
455 tree for_stmt;
456{
558475f0 457 if (building_stmt_tree ())
ad321293
MM
458 {
459 if (last_tree != for_stmt)
cb39191d 460 RECHAIN_STMTS (for_stmt, FOR_INIT_STMT (for_stmt));
ad321293
MM
461 }
462 else
463 {
464 emit_nop ();
465 emit_line_note (input_filename, lineno);
466 expand_start_loop_continue_elsewhere (1);
467 }
468
469 do_pushlevel ();
470}
471
472/* Finish the COND of a for-statement, which may be given by
473 FOR_STMT. */
474
475void
476finish_for_cond (cond, for_stmt)
477 tree cond;
478 tree for_stmt;
479{
ed5511d9
MM
480 cond = maybe_convert_cond (cond);
481
558475f0 482 if (building_stmt_tree ())
a7e4cfa0 483 FINISH_COND (cond, for_stmt, FOR_COND (for_stmt));
ad321293
MM
484 else
485 {
486 emit_line_note (input_filename, lineno);
1dcf683e 487 if (cond)
ed5511d9 488 expand_exit_loop_if_false (0, cond);
ad321293
MM
489 }
490
491 /* If the cond wasn't a declaration, clear out the
492 block we made for it and start a new one here so the
493 optimization in expand_end_loop will work. */
494 if (getdecls () == NULL_TREE)
495 {
496 do_poplevel ();
497 do_pushlevel ();
498 }
499}
500
501/* Finish the increment-EXPRESSION in a for-statement, which may be
502 given by FOR_STMT. */
503
504void
505finish_for_expr (expr, for_stmt)
506 tree expr;
507 tree for_stmt;
508{
558475f0 509 if (building_stmt_tree ())
2a1e9fdd 510 FOR_EXPR (for_stmt) = expr;
ad321293
MM
511}
512
513/* Finish the body of a for-statement, which may be given by
514 FOR_STMT. The increment-EXPR for the loop must be
515 provided. */
516
517void
518finish_for_stmt (expr, for_stmt)
519 tree expr;
520 tree for_stmt;
521{
522 /* Pop the scope for the body of the loop. */
523 do_poplevel ();
524
558475f0 525 if (building_stmt_tree ())
cb39191d 526 RECHAIN_STMTS (for_stmt, FOR_BODY (for_stmt));
ad321293
MM
527 else
528 {
529 emit_line_note (input_filename, lineno);
530 expand_loop_continue_here ();
531 if (expr)
f1dedc31 532 finish_expr_stmt (expr);
ad321293
MM
533 expand_end_loop ();
534 }
535
ad321293
MM
536 if (flag_new_for_scope > 0)
537 do_poplevel ();
538
539 finish_stmt ();
540}
541
542/* Finish a break-statement. */
543
544void
545finish_break_stmt ()
546{
547 emit_line_note (input_filename, lineno);
558475f0 548 if (building_stmt_tree ())
ad321293
MM
549 add_tree (build_min_nt (BREAK_STMT));
550 else if ( ! expand_exit_something ())
8251199e 551 cp_error ("break statement not within loop or switch");
ad321293
MM
552}
553
554/* Finish a continue-statement. */
555
556void
557finish_continue_stmt ()
558{
559 emit_line_note (input_filename, lineno);
558475f0 560 if (building_stmt_tree ())
ad321293
MM
561 add_tree (build_min_nt (CONTINUE_STMT));
562 else if (! expand_continue_loop (0))
8251199e 563 cp_error ("continue statement not within a loop");
ad321293
MM
564}
565
527f0080
MM
566/* Begin a switch-statement. Returns a new SWITCH_STMT if
567 appropriate. */
ad321293 568
527f0080 569tree
ad321293
MM
570begin_switch_stmt ()
571{
527f0080
MM
572 tree r;
573
574 if (building_stmt_tree ())
575 {
576 r = build_min_nt (SWITCH_STMT, NULL_TREE, NULL_TREE);
577 add_tree (r);
578 }
579 else
580 r = NULL_TREE;
581
ad321293 582 do_pushlevel ();
527f0080
MM
583
584 return r;
ad321293
MM
585}
586
527f0080 587/* Finish the cond of a switch-statement. */
ad321293 588
527f0080
MM
589void
590finish_switch_cond (cond, switch_stmt)
ad321293 591 tree cond;
527f0080 592 tree switch_stmt;
ad321293 593{
558475f0 594 if (building_stmt_tree ())
373eb3b3
MM
595 {
596 if (!processing_template_decl)
597 {
598 /* Convert the condition to an integer or enumeration type. */
599 cond = build_expr_type_conversion (WANT_INT | WANT_ENUM, cond, 1);
600 if (cond == NULL_TREE)
601 {
602 error ("switch quantity not an integer");
603 cond = error_mark_node;
604 }
605 if (cond != error_mark_node)
606 {
607 tree idx;
608 tree type;
609
610 cond = default_conversion (cond);
611 type = TREE_TYPE (cond);
612 idx = get_unwidened (cond, 0);
613 /* We can't strip a conversion from a signed type to an unsigned,
614 because if we did, int_fits_type_p would do the wrong thing
615 when checking case values for being in range,
616 and it's too hard to do the right thing. */
617 if (TREE_UNSIGNED (TREE_TYPE (cond))
618 == TREE_UNSIGNED (TREE_TYPE (idx)))
619 cond = idx;
620
621 cond = fold (build1 (CLEANUP_POINT_EXPR, type, cond));
622 }
623 }
624 FINISH_COND (cond, switch_stmt, SWITCH_COND (switch_stmt));
625 }
0db982be 626 else if (cond != error_mark_node)
ad321293
MM
627 {
628 emit_line_note (input_filename, lineno);
629 c_expand_start_case (cond);
ad321293 630 }
0db982be 631 else
527f0080
MM
632 /* The code is in error, but we don't want expand_end_case to
633 crash. */
634 c_expand_start_case (boolean_false_node);
0db982be 635
ad321293 636 push_switch ();
ad321293
MM
637}
638
639/* Finish the body of a switch-statement, which may be given by
640 SWITCH_STMT. The COND to switch on is indicated. */
641
642void
643finish_switch_stmt (cond, switch_stmt)
644 tree cond;
645 tree switch_stmt;
646{
558475f0 647 if (building_stmt_tree ())
cb39191d 648 RECHAIN_STMTS (switch_stmt, SWITCH_BODY (switch_stmt));
ad321293
MM
649 else
650 expand_end_case (cond);
ad321293
MM
651 pop_switch ();
652 do_poplevel ();
653 finish_stmt ();
654}
655
656/* Finish a case-label. */
657
658void
659finish_case_label (low_value, high_value)
660 tree low_value;
661 tree high_value;
662{
558475f0
MM
663 if (building_stmt_tree ())
664 {
b35d4555
MM
665 /* Add a representation for the case label to the statement
666 tree. */
558475f0 667 add_tree (build_min_nt (CASE_LABEL, low_value, high_value));
b35d4555
MM
668 /* And warn about crossing initializations, etc. */
669 if (!processing_template_decl)
670 define_case_label ();
558475f0
MM
671 return;
672 }
673
ad321293
MM
674 do_case (low_value, high_value);
675}
676
ad321293
MM
677/* Finish a goto-statement. */
678
679void
680finish_goto_stmt (destination)
681 tree destination;
682{
3fa56191
MM
683 if (TREE_CODE (destination) == IDENTIFIER_NODE)
684 destination = lookup_label (destination);
685
88848bde
MM
686 /* We warn about unused labels with -Wunused. That means we have to
687 mark the used labels as used. */
688 if (TREE_CODE (destination) == LABEL_DECL)
689 TREE_USED (destination) = 1;
690
558475f0 691 if (building_stmt_tree ())
46e8c075
MM
692 {
693 if (TREE_CODE (destination) != LABEL_DECL)
694 /* We don't inline calls to functions with computed gotos.
695 Those functions are typically up to some funny business,
696 and may be depending on the labels being at particular
697 addresses, or some such. */
698 DECL_UNINLINABLE (current_function_decl) = 1;
699
700 add_tree (build_min_nt (GOTO_STMT, destination));
701 }
ad321293
MM
702 else
703 {
704 emit_line_note (input_filename, lineno);
705
3fa56191 706 if (TREE_CODE (destination) == LABEL_DECL)
ad321293 707 {
b35d4555 708 label_rtx (destination);
3fa56191 709 expand_goto (destination);
ad321293
MM
710 }
711 else
712 expand_computed_goto (destination);
713 }
714}
715
716/* Begin a try-block. Returns a newly-created TRY_BLOCK if
717 appropriate. */
718
719tree
720begin_try_block ()
721{
558475f0 722 if (building_stmt_tree ())
ad321293
MM
723 {
724 tree r = build_min_nt (TRY_BLOCK, NULL_TREE,
725 NULL_TREE);
726 add_tree (r);
727 return r;
728 }
729 else
730 {
731 emit_line_note (input_filename, lineno);
732 expand_start_try_stmts ();
733 return NULL_TREE;
734 }
735}
736
0dde4175
JM
737/* Likewise, for a function-try-block. */
738
739tree
740begin_function_try_block ()
741{
558475f0 742 if (building_stmt_tree ())
0dde4175
JM
743 {
744 tree r = build_min_nt (TRY_BLOCK, NULL_TREE,
745 NULL_TREE);
62409b39 746 FN_TRY_BLOCK_P (r) = 1;
0dde4175
JM
747 add_tree (r);
748 return r;
749 }
750 else
751 {
752 if (! current_function_parms_stored)
753 store_parm_decls ();
754 expand_start_early_try_stmts ();
755 return NULL_TREE;
756 }
757}
758
ad321293
MM
759/* Finish a try-block, which may be given by TRY_BLOCK. */
760
761void
762finish_try_block (try_block)
763 tree try_block;
764{
558475f0 765 if (building_stmt_tree ())
cb39191d 766 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
ad321293 767 else
558475f0 768 expand_start_all_catch ();
ad321293
MM
769}
770
efa8eda3
MM
771/* Finish the body of a cleanup try-block, which may be given by
772 TRY_BLOCK. */
773
62409b39
MM
774void
775finish_cleanup_try_block (try_block)
776 tree try_block;
777{
778 if (building_stmt_tree ())
779 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
780}
781
f1dedc31
MM
782/* Finish an implicitly generated try-block, with a cleanup is given
783 by CLEANUP. */
784
785void
786finish_cleanup (cleanup, try_block)
787 tree cleanup;
788 tree try_block;
789{
790 if (building_stmt_tree ())
791 {
2a1e9fdd 792 TRY_HANDLERS (try_block) = cleanup;
f1dedc31
MM
793 CLEANUP_P (try_block) = 1;
794 }
795 else
796 expand_eh_region_end (protect_with_terminate (cleanup));
797}
798
0dde4175
JM
799/* Likewise, for a function-try-block. */
800
801void
802finish_function_try_block (try_block)
f1dedc31 803 tree try_block;
0dde4175 804{
558475f0 805 if (building_stmt_tree ())
62409b39
MM
806 {
807 if (TREE_CHAIN (try_block)
808 && TREE_CODE (TREE_CHAIN (try_block)) == CTOR_INITIALIZER)
809 {
810 /* Chain the compound statement after the CTOR_INITIALIZER. */
811 TREE_CHAIN (TREE_CHAIN (try_block)) = last_tree;
812 /* And make the CTOR_INITIALIZER the body of the try-block. */
813 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
814 }
815 else
816 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
817 }
0dde4175
JM
818 else
819 {
820 end_protect_partials ();
821 expand_start_all_catch ();
0dde4175 822 }
b35d4555
MM
823
824 in_function_try_handler = 1;
0dde4175
JM
825}
826
ad321293
MM
827/* Finish a handler-sequence for a try-block, which may be given by
828 TRY_BLOCK. */
829
830void
831finish_handler_sequence (try_block)
832 tree try_block;
833{
558475f0 834 if (building_stmt_tree ())
cb39191d 835 RECHAIN_STMTS (try_block, TRY_HANDLERS (try_block));
ad321293 836 else
f1dedc31 837 expand_end_all_catch ();
ad321293
MM
838}
839
0dde4175
JM
840/* Likewise, for a function-try-block. */
841
842void
843finish_function_handler_sequence (try_block)
844 tree try_block;
845{
b35d4555
MM
846 in_function_try_handler = 0;
847
558475f0 848 if (building_stmt_tree ())
cb39191d 849 RECHAIN_STMTS (try_block, TRY_HANDLERS (try_block));
0dde4175 850 else
b35d4555 851 expand_end_all_catch ();
0dde4175
JM
852}
853
ad321293
MM
854/* Begin a handler. Returns a HANDLER if appropriate. */
855
856tree
857begin_handler ()
858{
859 tree r;
860
558475f0 861 if (building_stmt_tree ())
ad321293
MM
862 {
863 r = build_min_nt (HANDLER, NULL_TREE, NULL_TREE);
864 add_tree (r);
865 }
866 else
867 r = NULL_TREE;
868
869 do_pushlevel ();
870
871 return r;
872}
873
874/* Finish the handler-parameters for a handler, which may be given by
b35d4555
MM
875 HANDLER. DECL is the declaration for the catch parameter, or NULL
876 if this is a `catch (...)' clause. */
ad321293 877
b35d4555
MM
878tree
879finish_handler_parms (decl, handler)
880 tree decl;
ad321293 881 tree handler;
b35d4555
MM
882{
883 tree blocks = NULL_TREE;
884
885 if (processing_template_decl)
886 {
887 if (decl)
888 {
889 decl = pushdecl (decl);
890 decl = push_template_decl (decl);
891 add_decl_stmt (decl);
892 RECHAIN_STMTS (handler, HANDLER_PARMS (handler));
893 }
894 }
895 else if (building_stmt_tree ())
896 blocks = expand_start_catch_block (decl);
897
898 return blocks;
899}
900
901/* Note the beginning of a handler for TYPE. This function is called
902 at the point to which control should be transferred when an
903 appropriately-typed exception is thrown. */
904
905void
906begin_catch_block (type)
907 tree type;
ad321293 908{
558475f0 909 if (building_stmt_tree ())
b35d4555
MM
910 add_tree (build (START_CATCH_STMT, type));
911 else
912 start_catch_handler (type);
ad321293
MM
913}
914
b35d4555
MM
915/* Finish a handler, which may be given by HANDLER. The BLOCKs are
916 the return value from the matching call to finish_handler_parms. */
ad321293
MM
917
918void
b35d4555
MM
919finish_handler (blocks, handler)
920 tree blocks;
ad321293
MM
921 tree handler;
922{
b35d4555
MM
923 if (!processing_template_decl)
924 {
925 if (building_stmt_tree ())
926 expand_end_catch_block (blocks);
927
928 if (!building_stmt_tree ())
929 {
930 /* Fall to outside the try statement when done executing
931 handler and we fall off end of handler. This is jump
932 Lresume in the documentation. */
933 expand_goto (top_label_entry (&caught_return_label_stack));
934 end_catch_handler ();
935 }
936 }
937
13e8cf82
MM
938 do_poplevel ();
939
558475f0 940 if (building_stmt_tree ())
cb39191d 941 RECHAIN_STMTS (handler, HANDLER_BODY (handler));
ad321293
MM
942}
943
944/* Begin a compound-statement. If HAS_NO_SCOPE is non-zero, the
945 compound-statement does not define a scope. Returns a new
946 COMPOUND_STMT if appropriate. */
947
948tree
949begin_compound_stmt (has_no_scope)
950 int has_no_scope;
951{
952 tree r;
953
558475f0 954 if (building_stmt_tree ())
ad321293
MM
955 {
956 r = build_min_nt (COMPOUND_STMT, NULL_TREE);
957 add_tree (r);
958 if (has_no_scope)
959 COMPOUND_STMT_NO_SCOPE (r) = 1;
960 }
961 else
962 r = NULL_TREE;
963
558475f0
MM
964 last_expr_type = NULL_TREE;
965
ad321293
MM
966 if (!has_no_scope)
967 do_pushlevel ();
f1dedc31
MM
968 else
969 /* Normally, we try hard to keep the BLOCK for a
970 statement-expression. But, if it's a statement-expression with
971 a scopeless block, there's nothing to keep, and we don't want
972 to accidentally keep a block *inside* the scopeless block. */
973 keep_next_level (0);
ad321293 974
24bef158
MM
975 /* If this is the outermost block of the function, declare the
976 variables __FUNCTION__, __PRETTY_FUNCTION__, and so forth. */
6f80451c
MM
977 if (current_function
978 && !current_function_name_declared
9bfadf57 979 && !has_no_scope)
24bef158 980 {
f9817201
MM
981 /* When we get callbacks from the middle-end, we need to know
982 we're in the midst of declaring these variables. */
983 current_function_name_declared = 2;
984 /* Actually insert the declarations. */
24bef158 985 declare_function_name ();
f9817201 986 /* And now just remember that we're all done. */
24bef158
MM
987 current_function_name_declared = 1;
988 }
989
ad321293
MM
990 return r;
991}
992
993
994/* Finish a compound-statement, which may be given by COMPOUND_STMT.
995 If HAS_NO_SCOPE is non-zero, the compound statement does not define
996 a scope. */
997
998tree
999finish_compound_stmt (has_no_scope, compound_stmt)
1000 int has_no_scope;
1001 tree compound_stmt;
1002{
1003 tree r;
558475f0 1004 tree t;
ad321293
MM
1005
1006 if (!has_no_scope)
1007 r = do_poplevel ();
1008 else
1009 r = NULL_TREE;
1010
558475f0 1011 if (building_stmt_tree ())
cb39191d 1012 RECHAIN_STMTS (compound_stmt, COMPOUND_BODY (compound_stmt));
ad321293 1013
cb39191d 1014 /* When we call finish_stmt we will lose LAST_EXPR_TYPE. But, since
558475f0
MM
1015 the precise purpose of that variable is store the type of the
1016 last expression statement within the last compound statement, we
1017 preserve the value. */
1018 t = last_expr_type;
ad321293 1019 finish_stmt ();
558475f0 1020 last_expr_type = t;
ad321293
MM
1021
1022 return r;
1023}
1024
1025/* Finish an asm-statement, whose components are a CV_QUALIFIER, a
1026 STRING, some OUTPUT_OPERANDS, some INPUT_OPERANDS, and some
1027 CLOBBERS. */
1028
1029void
1030finish_asm_stmt (cv_qualifier, string, output_operands,
3ebc5c52 1031 input_operands, clobbers)
ad321293
MM
1032 tree cv_qualifier;
1033 tree string;
1034 tree output_operands;
1035 tree input_operands;
1036 tree clobbers;
1037{
1038 if (TREE_CHAIN (string))
cd9f6678 1039 string = combine_strings (string);
ad321293 1040
f71f87f9
MM
1041 if (cv_qualifier != NULL_TREE
1042 && cv_qualifier != ridpointers[(int) RID_VOLATILE])
1043 {
1044 cp_warning ("%s qualifier ignored on asm",
1045 IDENTIFIER_POINTER (cv_qualifier));
1046 cv_qualifier = NULL_TREE;
1047 }
1048
558475f0 1049 if (building_stmt_tree ())
ad321293
MM
1050 {
1051 tree r = build_min_nt (ASM_STMT, cv_qualifier, string,
1052 output_operands, input_operands,
1053 clobbers);
1054 add_tree (r);
1055 }
1056 else
1057 {
1058 emit_line_note (input_filename, lineno);
6e9438cf
AG
1059 if (output_operands != NULL_TREE || input_operands != NULL_TREE
1060 || clobbers != NULL_TREE)
1061 {
7dc5bd62
MM
1062 tree t;
1063
7dc5bd62
MM
1064 for (t = input_operands; t; t = TREE_CHAIN (t))
1065 TREE_VALUE (t) = decay_conversion (TREE_VALUE (t));
1066
6e9438cf
AG
1067 c_expand_asm_operands (string, output_operands,
1068 input_operands,
1069 clobbers,
f71f87f9 1070 cv_qualifier != NULL_TREE,
6e9438cf
AG
1071 input_filename, lineno);
1072 }
1073 else
f71f87f9 1074 expand_asm (string);
a64c757e 1075
ad321293
MM
1076 finish_stmt ();
1077 }
1078}
b4c4a9ec 1079
f01b0acb
MM
1080/* Finish a label with the indicated NAME. */
1081
1082void
1083finish_label_stmt (name)
1084 tree name;
1085{
3fa56191 1086 tree decl = define_label (input_filename, lineno, name);
f01b0acb 1087
558475f0 1088 if (building_stmt_tree ())
acef433b 1089 add_tree (build_min_nt (LABEL_STMT, decl));
3fa56191
MM
1090 else if (decl)
1091 expand_label (decl);
f01b0acb
MM
1092}
1093
acef433b
MM
1094/* Finish a series of declarations for local labels. G++ allows users
1095 to declare "local" labels, i.e., labels with scope. This extension
1096 is useful when writing code involving statement-expressions. */
1097
1098void
1099finish_label_decl (name)
1100 tree name;
1101{
1102 tree decl = declare_local_label (name);
1103 if (building_stmt_tree ())
1104 add_decl_stmt (decl);
1105}
1106
9188c363
MM
1107/* Create a declaration statement for the declaration given by the
1108 DECL. */
1109
1110void
1111add_decl_stmt (decl)
1112 tree decl;
1113{
1114 tree decl_stmt;
1115
1116 /* We need the type to last until instantiation time. */
9188c363
MM
1117 decl_stmt = build_min_nt (DECL_STMT, decl);
1118 add_tree (decl_stmt);
1119}
1120
f1dedc31
MM
1121/* We're in a constructor, and have just constructed a a subobject of
1122 *THIS. CLEANUP is code to run if an exception is thrown before the
1123 end of the current function is reached. */
1124
1125void
1126finish_subobject (cleanup)
1127 tree cleanup;
1128{
1129 if (building_stmt_tree ())
1130 {
1131 tree r = build_min_nt (SUBOBJECT, cleanup);
1132 add_tree (r);
1133 }
1134 else
1135 add_partial_entry (cleanup);
1136}
1137
24bef158
MM
1138/* When DECL goes out of scope, make sure that CLEANUP is executed. */
1139
1140void
1141finish_decl_cleanup (decl, cleanup)
1142 tree decl;
1143 tree cleanup;
1144{
1145 if (building_stmt_tree ())
1146 add_tree (build_min_nt (CLEANUP_STMT, decl, cleanup));
b35d4555
MM
1147 else if (!decl
1148 || (DECL_SIZE (decl) && TREE_TYPE (decl) != error_mark_node))
24bef158
MM
1149 expand_decl_cleanup (decl, cleanup);
1150}
1151
558475f0
MM
1152/* Bind a name and initialization to the return value of
1153 the current function. */
1154
1155void
1156finish_named_return_value (return_id, init)
1157 tree return_id, init;
1158{
1159 tree decl = DECL_RESULT (current_function_decl);
1160
1161 if (pedantic)
1162 /* Give this error as many times as there are occurrences,
1163 so that users can use Emacs compilation buffers to find
1164 and fix all such places. */
1165 pedwarn ("ANSI C++ does not permit named return values");
1166
1167 if (return_id != NULL_TREE)
1168 {
1169 if (DECL_NAME (decl) == NULL_TREE)
1170 {
1171 DECL_NAME (decl) = return_id;
1172 DECL_ASSEMBLER_NAME (decl) = return_id;
1173 }
1174 else
1175 {
1176 cp_error ("return identifier `%D' already in place", return_id);
1177 return;
1178 }
1179 }
1180
1181 /* Can't let this happen for constructors. */
1182 if (DECL_CONSTRUCTOR_P (current_function_decl))
1183 {
1184 error ("can't redefine default return value for constructors");
1185 return;
1186 }
1187
1188 /* If we have a named return value, put that in our scope as well. */
1189 if (DECL_NAME (decl) != NULL_TREE)
1190 {
1191 /* Let `cp_finish_decl' know that this initializer is ok. */
1192 DECL_INITIAL (decl) = init;
b35d4555
MM
1193 if (doing_semantic_analysis_p ())
1194 pushdecl (decl);
558475f0
MM
1195
1196 if (building_stmt_tree ())
2a1e9fdd 1197 add_tree (build_min_nt (RETURN_INIT, return_id, init));
558475f0
MM
1198 else
1199 {
cd9f6678 1200 cp_finish_decl (decl, init, NULL_TREE, 0);
558475f0
MM
1201 store_return_init (decl);
1202 }
1203 }
1204}
1205
1206/* Cache the value of this class's main virtual function table pointer
1207 in a register variable. This will save one indirection if a
1208 more than one virtual function call is made this function. */
1209
1210void
1211setup_vtbl_ptr ()
1212{
9bfadf57
MM
1213 my_friendly_assert (doing_semantic_analysis_p (), 19990919);
1214
1215 /* If we've already done this, there's no need to do it again. */
1216 if (vtbls_set_up_p)
1217 return;
1218
1219 if (DECL_CONSTRUCTOR_P (current_function_decl))
558475f0 1220 {
9bfadf57 1221 if (processing_template_decl)
558475f0
MM
1222 add_tree (build_min_nt
1223 (CTOR_INITIALIZER,
1224 current_member_init_list, current_base_init_list));
1225 else
46e8c075
MM
1226 {
1227 tree ctor_stmt;
1228
1229 /* Mark the beginning of the constructor. */
1230 ctor_stmt = build_min_nt (CTOR_STMT);
1231 CTOR_BEGIN_P (ctor_stmt) = 1;
1232 add_tree (ctor_stmt);
1233
1234 /* And actually initialize the base-classes and members. */
1235 finish_expr_stmt (emit_base_init (current_class_type));
1236 }
9bfadf57
MM
1237 }
1238 else if (DECL_DESTRUCTOR_P (current_function_decl)
1239 && !processing_template_decl)
1240 {
1241 tree binfo = TYPE_BINFO (current_class_type);
1242 tree if_stmt;
1243 tree compound_stmt;
f9817201 1244 int saved_cfnd;
9bfadf57
MM
1245
1246 /* If the dtor is empty, and we know there is not possible way we
1247 could use any vtable entries, before they are possibly set by
1248 a base class dtor, we don't have to setup the vtables, as we
1249 know that any base class dtoring will set up any vtables it
1250 needs. We avoid MI, because one base class dtor can do a
1251 virtual dispatch to an overridden function that would need to
1252 have a non-related vtable set up, we cannot avoid setting up
1253 vtables in that case. We could change this to see if there is
1254 just one vtable. */
1255 if_stmt = begin_if_stmt ();
1256
1257 /* If it is not safe to avoid setting up the vtables, then
1258 someone will change the condition to be boolean_true_node.
1259 (Actually, for now, we do not have code to set the condition
f9817201 1260 appropriately, so we just assume that we always need to
9bfadf57
MM
1261 initialize the vtables.) */
1262 finish_if_stmt_cond (boolean_true_node, if_stmt);
1263 current_vcalls_possible_p = &IF_COND (if_stmt);
f9817201
MM
1264
1265 /* Don't declare __PRETTY_FUNCTION__ and friends here when we
1266 open the block for the if-body. */
1267 saved_cfnd = current_function_name_declared;
1268 current_function_name_declared = 1;
9bfadf57 1269 compound_stmt = begin_compound_stmt (/*has_no_scope=*/0);
f9817201 1270 current_function_name_declared = saved_cfnd;
9bfadf57
MM
1271
1272 /* Make all virtual function table pointers in non-virtual base
1273 classes point to CURRENT_CLASS_TYPE's virtual function
1274 tables. */
1275 expand_direct_vtbls_init (binfo, binfo, 1, 0, current_class_ptr);
1276
1277 if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
1278 expand_indirect_vtbls_init (binfo, current_class_ref,
1279 current_class_ptr);
1280
1281 finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
1282 finish_then_clause (if_stmt);
1283 finish_if_stmt ();
558475f0 1284 }
f1dedc31
MM
1285
1286 /* Always keep the BLOCK node associated with the outermost pair of
9bfadf57 1287 curly braces of a function. These are needed for correct
f1dedc31
MM
1288 operation of dwarfout.c. */
1289 keep_next_level (1);
9bfadf57
MM
1290
1291 /* The virtual function tables are set up now. */
1292 vtbls_set_up_p = 1;
558475f0
MM
1293}
1294
8f471b0d
MM
1295/* Add a scope-statement to the statement-tree. BEGIN_P indicates
1296 whether this statements opens or closes a scope. PARTIAL_P is true
1297 for a partial scope, i.e, the scope that begins after a label when
d9b2d9da
MM
1298 an object that needs a cleanup is created. If BEGIN_P is nonzero,
1299 returns a new TREE_LIST representing the top of the SCOPE_STMT
1300 stack. The TREE_PURPOSE is the new SCOPE_STMT. If BEGIN_P is
1301 zero, returns a TREE_LIST whose TREE_VALUE is the new SCOPE_STMT,
1302 and whose TREE_PURPOSE is the matching SCOPE_STMT iwth
1303 SCOPE_BEGIN_P set. */
8f471b0d 1304
d9b2d9da 1305tree
8f471b0d
MM
1306add_scope_stmt (begin_p, partial_p)
1307 int begin_p;
1308 int partial_p;
1309{
1310 tree ss;
d9b2d9da 1311 tree top;
8f471b0d
MM
1312
1313 /* Build the statement. */
d9b2d9da 1314 ss = build_min_nt (SCOPE_STMT, NULL_TREE);
8f471b0d
MM
1315 SCOPE_BEGIN_P (ss) = begin_p;
1316 SCOPE_PARTIAL_P (ss) = partial_p;
1317
8f471b0d
MM
1318 /* Keep the scope stack up to date. */
1319 if (begin_p)
d9b2d9da
MM
1320 {
1321 current_scope_stmt_stack
1322 = tree_cons (ss, NULL_TREE, current_scope_stmt_stack);
1323 top = current_scope_stmt_stack;
1324 }
8f471b0d 1325 else
d9b2d9da
MM
1326 {
1327 top = current_scope_stmt_stack;
1328 TREE_VALUE (top) = ss;
1329 current_scope_stmt_stack = TREE_CHAIN (top);
1330 }
8f471b0d
MM
1331
1332 /* Add the new statement to the statement-tree. */
1333 add_tree (ss);
d9b2d9da
MM
1334
1335 return top;
8f471b0d
MM
1336}
1337
558475f0
MM
1338/* Begin a new scope. */
1339
b35d4555 1340void
558475f0
MM
1341do_pushlevel ()
1342{
1343 if (!building_stmt_tree ())
1344 {
1345 emit_line_note (input_filename, lineno);
1346 clear_last_expr ();
1347 }
f1dedc31 1348 if (stmts_are_full_exprs_p)
b35d4555
MM
1349 {
1350 pushlevel (0);
1351 if (!building_stmt_tree ()
1352 && !current_function->x_whole_function_mode_p)
d9b2d9da
MM
1353 my_friendly_abort (19991129);
1354
1355 if (building_stmt_tree () && !processing_template_decl)
8f471b0d 1356 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
b35d4555 1357 }
f1dedc31 1358}
558475f0
MM
1359
1360/* Finish a scope. */
1361
b35d4555 1362tree
558475f0
MM
1363do_poplevel ()
1364{
d9b2d9da 1365 tree block = NULL_TREE;
558475f0 1366
f1dedc31 1367 if (stmts_are_full_exprs_p)
b35d4555 1368 {
d9b2d9da 1369 tree scope_stmts;
d9b2d9da
MM
1370
1371 if (building_stmt_tree () && !processing_template_decl)
1372 scope_stmts = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0);
1373 else
1374 scope_stmts = NULL_TREE;
1375
1376 block = poplevel (kept_level_p (), 1, 0);
1377 if (block && !processing_template_decl)
b35d4555 1378 {
d9b2d9da
MM
1379 SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmts)) = block;
1380 SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmts)) = block;
b35d4555 1381 }
b35d4555 1382 }
d9b2d9da
MM
1383
1384 return block;
558475f0
MM
1385}
1386
b4c4a9ec
MM
1387/* Finish a parenthesized expression EXPR. */
1388
1389tree
1390finish_parenthesized_expr (expr)
1391 tree expr;
1392{
1393 if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (expr))))
1394 /* This inhibits warnings in truthvalue_conversion. */
1395 C_SET_EXP_ORIGINAL_CODE (expr, ERROR_MARK);
1396
1397 return expr;
1398}
1399
b69b1501
MM
1400/* Begin a statement-expression. The value returned must be passed to
1401 finish_stmt_expr. */
b4c4a9ec
MM
1402
1403tree
1404begin_stmt_expr ()
1405{
6f80451c
MM
1406 /* If we're outside a function, we won't have a statement-tree to
1407 work with. But, if we see a statement-expression we need to
1408 create one. */
1409 if (!current_function && !last_tree)
1410 begin_stmt_tree (&scope_chain->x_saved_tree);
1411
f1dedc31 1412 keep_next_level (1);
558475f0 1413 /* If we're building a statement tree, then the upcoming compound
b69b1501
MM
1414 statement will be chained onto the tree structure, starting at
1415 last_tree. We return last_tree so that we can later unhook the
1416 compound statement. */
558475f0 1417 return building_stmt_tree () ? last_tree : expand_start_stmt_expr();
b4c4a9ec
MM
1418}
1419
1420/* Finish a statement-expression. RTL_EXPR should be the value
1421 returned by the previous begin_stmt_expr; EXPR is the
1422 statement-expression. Returns an expression representing the
1423 statement-expression. */
1424
1425tree
5ba57b55 1426finish_stmt_expr (rtl_expr)
b4c4a9ec 1427 tree rtl_expr;
b4c4a9ec
MM
1428{
1429 tree result;
1430
558475f0 1431 if (!building_stmt_tree ())
c557501d 1432 rtl_expr = expand_end_stmt_expr (rtl_expr);
b4c4a9ec 1433
558475f0 1434 if (building_stmt_tree ())
b69b1501 1435 {
f1dedc31
MM
1436 /* If the last thing in the statement-expression was not an
1437 expression-statement, then it has type `void'. */
1438 if (!last_expr_type)
1439 last_expr_type = void_type_node;
1440 result = build_min (STMT_EXPR, last_expr_type, last_tree);
1441 TREE_SIDE_EFFECTS (result) = 1;
1442
b69b1501 1443 /* Remove the compound statement from the tree structure; it is
558475f0 1444 now saved in the STMT_EXPR. */
6f80451c 1445 SET_LAST_STMT (rtl_expr);
b69b1501
MM
1446 TREE_CHAIN (last_tree) = NULL_TREE;
1447 }
5ba57b55 1448 else
f1dedc31
MM
1449 result = rtl_expr;
1450
6f80451c
MM
1451 /* If we created a statement-tree for this statement-expression,
1452 remove it now. */
1453 if (!current_function
1454 && TREE_CHAIN (scope_chain->x_saved_tree) == NULL_TREE)
1455 finish_stmt_tree (&scope_chain->x_saved_tree);
1456
b4c4a9ec
MM
1457 return result;
1458}
1459
1460/* Finish a call to FN with ARGS. Returns a representation of the
1461 call. */
1462
1463tree
a759e627 1464finish_call_expr (fn, args, koenig)
b4c4a9ec
MM
1465 tree fn;
1466 tree args;
a759e627 1467 int koenig;
b4c4a9ec 1468{
a759e627
ML
1469 tree result;
1470
1471 if (koenig)
03d82991
JM
1472 {
1473 if (TREE_CODE (fn) == BIT_NOT_EXPR)
1474 fn = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND (fn, 0));
1475 else if (TREE_CODE (fn) != TEMPLATE_ID_EXPR)
e13a4123 1476 fn = do_identifier (fn, 2, args);
03d82991 1477 }
a759e627 1478 result = build_x_function_call (fn, args, current_class_ref);
b4c4a9ec
MM
1479
1480 if (TREE_CODE (result) == CALL_EXPR
66543169
NS
1481 && (! TREE_TYPE (result)
1482 || TREE_CODE (TREE_TYPE (result)) != VOID_TYPE))
b4c4a9ec
MM
1483 result = require_complete_type (result);
1484
1485 return result;
1486}
1487
1488/* Finish a call to a postfix increment or decrement or EXPR. (Which
1489 is indicated by CODE, which should be POSTINCREMENT_EXPR or
1490 POSTDECREMENT_EXPR.) */
1491
1492tree
1493finish_increment_expr (expr, code)
1494 tree expr;
1495 enum tree_code code;
1496{
1497 /* If we get an OFFSET_REF, turn it into what it really means (e.g.,
1498 a COMPONENT_REF). This way if we've got, say, a reference to a
1499 static member that's being operated on, we don't end up trying to
1500 find a member operator for the class it's in. */
1501
1502 if (TREE_CODE (expr) == OFFSET_REF)
1503 expr = resolve_offset_ref (expr);
1504 return build_x_unary_op (code, expr);
1505}
1506
1507/* Finish a use of `this'. Returns an expression for `this'. */
1508
1509tree
1510finish_this_expr ()
1511{
1512 tree result;
1513
1514 if (current_class_ptr)
1515 {
1516#ifdef WARNING_ABOUT_CCD
1517 TREE_USED (current_class_ptr) = 1;
1518#endif
1519 result = current_class_ptr;
1520 }
1521 else if (current_function_decl
1522 && DECL_STATIC_FUNCTION_P (current_function_decl))
1523 {
8251199e 1524 error ("`this' is unavailable for static member functions");
b4c4a9ec
MM
1525 result = error_mark_node;
1526 }
1527 else
1528 {
1529 if (current_function_decl)
8251199e 1530 error ("invalid use of `this' in non-member function");
b4c4a9ec 1531 else
8251199e 1532 error ("invalid use of `this' at top level");
b4c4a9ec
MM
1533 result = error_mark_node;
1534 }
1535
1536 return result;
1537}
1538
1539/* Finish a member function call using OBJECT and ARGS as arguments to
1540 FN. Returns an expression for the call. */
1541
1542tree
1543finish_object_call_expr (fn, object, args)
1544 tree fn;
1545 tree object;
1546 tree args;
1547{
1548#if 0
1549 /* This is a future direction of this code, but because
1550 build_x_function_call cannot always undo what is done in
1551 build_component_ref entirely yet, we cannot do this. */
1552
1553 tree real_fn = build_component_ref (object, fn, NULL_TREE, 1);
1554 return finish_call_expr (real_fn, args);
1555#else
c219b878 1556 if (DECL_DECLARES_TYPE_P (fn))
c68c56f7
MM
1557 {
1558 if (processing_template_decl)
1559 /* This can happen on code like:
1560
1561 class X;
1562 template <class T> void f(T t) {
1563 t.X();
1564 }
1565
1566 We just grab the underlying IDENTIFIER. */
1567 fn = DECL_NAME (fn);
1568 else
1569 {
8251199e 1570 cp_error ("calling type `%T' like a method", fn);
c68c56f7
MM
1571 return error_mark_node;
1572 }
1573 }
1574
b4c4a9ec
MM
1575 return build_method_call (object, fn, args, NULL_TREE, LOOKUP_NORMAL);
1576#endif
1577}
1578
1579/* Finish a qualified member function call using OBJECT and ARGS as
1580 arguments to FN. Returns an expressino for the call. */
1581
1582tree
1583finish_qualified_object_call_expr (fn, object, args)
1584 tree fn;
1585 tree object;
1586 tree args;
1587{
6eabb241
MM
1588 return build_scoped_method_call (object, TREE_OPERAND (fn, 0),
1589 TREE_OPERAND (fn, 1), args);
b4c4a9ec
MM
1590}
1591
1592/* Finish a pseudo-destructor call expression of OBJECT, with SCOPE
1593 being the scope, if any, of DESTRUCTOR. Returns an expression for
1594 the call. */
1595
1596tree
1597finish_pseudo_destructor_call_expr (object, scope, destructor)
1598 tree object;
1599 tree scope;
1600 tree destructor;
1601{
40242ccf
MM
1602 if (processing_template_decl)
1603 return build_min_nt (PSEUDO_DTOR_EXPR, object, scope, destructor);
1604
b4c4a9ec 1605 if (scope && scope != destructor)
8251199e 1606 cp_error ("destructor specifier `%T::~%T()' must have matching names",
b4c4a9ec
MM
1607 scope, destructor);
1608
1609 if ((scope == NULL_TREE || IDENTIFIER_GLOBAL_VALUE (destructor))
1610 && (TREE_CODE (TREE_TYPE (object)) !=
1611 TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (destructor)))))
8251199e 1612 cp_error ("`%E' is not of type `%T'", object, destructor);
b4c4a9ec
MM
1613
1614 return cp_convert (void_type_node, object);
1615}
1616
1617/* Finish a call to a globally qualified member function FN using
1618 ARGS. Returns an expression for the call. */
1619
1620tree
75d587eb 1621finish_qualified_call_expr (fn, args)
b4c4a9ec
MM
1622 tree fn;
1623 tree args;
1624{
1625 if (processing_template_decl)
2a1e9fdd 1626 return build_min_nt (CALL_EXPR, fn, args, NULL_TREE);
b4c4a9ec
MM
1627 else
1628 return build_member_call (TREE_OPERAND (fn, 0),
1629 TREE_OPERAND (fn, 1),
1630 args);
1631}
1632
1633/* Finish an expression taking the address of LABEL. Returns an
1634 expression for the address. */
1635
1636tree
1637finish_label_address_expr (label)
1638 tree label;
1639{
1640 tree result;
1641
1642 label = lookup_label (label);
1643 if (label == NULL_TREE)
1644 result = null_pointer_node;
1645 else
1646 {
1647 TREE_USED (label) = 1;
1648 result = build1 (ADDR_EXPR, ptr_type_node, label);
1649 TREE_CONSTANT (result) = 1;
46e8c075
MM
1650 /* This function cannot be inlined. All jumps to the addressed
1651 label should wind up at the same point. */
1652 DECL_UNINLINABLE (current_function_decl) = 1;
b4c4a9ec
MM
1653 }
1654
1655 return result;
1656}
1657
ce4a0391
MM
1658/* Finish an expression of the form CODE EXPR. */
1659
1660tree
1661finish_unary_op_expr (code, expr)
1662 enum tree_code code;
1663 tree expr;
1664{
1665 tree result = build_x_unary_op (code, expr);
7c355bca
ML
1666 /* Inside a template, build_x_unary_op does not fold the
1667 expression. So check whether the result is folded before
1668 setting TREE_NEGATED_INT. */
1669 if (code == NEGATE_EXPR && TREE_CODE (expr) == INTEGER_CST
88b4335f
NS
1670 && TREE_CODE (result) == INTEGER_CST
1671 && !TREE_UNSIGNED (TREE_TYPE (result))
1672 && INT_CST_LT (result, integer_zero_node))
ce4a0391
MM
1673 TREE_NEGATED_INT (result) = 1;
1674 overflow_warning (result);
1675 return result;
1676}
1677
1678/* Finish an id-expression. */
1679
1680tree
1681finish_id_expr (expr)
1682 tree expr;
1683{
1684 if (TREE_CODE (expr) == IDENTIFIER_NODE)
a759e627 1685 expr = do_identifier (expr, 1, NULL_TREE);
ce4a0391
MM
1686
1687 return expr;
1688}
1689
b4c4a9ec
MM
1690/* Begin a function defniition declared with DECL_SPECS and
1691 DECLARATOR. Returns non-zero if the function-declaration is
1692 legal. */
1693
1694int
1695begin_function_definition (decl_specs, declarator)
1696 tree decl_specs;
1697 tree declarator;
1698{
1699 tree specs;
1700 tree attrs;
1701 split_specs_attrs (decl_specs, &specs, &attrs);
a8f73d4b 1702 if (!start_function (specs, declarator, attrs, SF_DEFAULT))
b4c4a9ec
MM
1703 return 0;
1704
1705 reinit_parse_for_function ();
39c01e4c
MM
1706 /* The things we're about to see are not directly qualified by any
1707 template headers we've seen thus far. */
1708 reset_specialization ();
1709
b4c4a9ec
MM
1710 return 1;
1711}
1712
1713/* Begin a constructor declarator of the form `SCOPE::NAME'. Returns
1714 a SCOPE_REF. */
1715
1716tree
1717begin_constructor_declarator (scope, name)
1718 tree scope;
1719 tree name;
1720{
1721 tree result = build_parse_node (SCOPE_REF, scope, name);
830fcda8 1722 enter_scope_of (result);
b4c4a9ec
MM
1723 return result;
1724}
1725
ce4a0391
MM
1726/* Finish an init-declarator. Returns a DECL. */
1727
1728tree
1729finish_declarator (declarator, declspecs, attributes,
1730 prefix_attributes, initialized)
1731 tree declarator;
1732 tree declspecs;
1733 tree attributes;
1734 tree prefix_attributes;
1735 int initialized;
1736{
1737 return start_decl (declarator, declspecs, initialized, attributes,
1738 prefix_attributes);
1739}
1740
8014a339 1741/* Finish a translation unit. */
ce4a0391
MM
1742
1743void
1744finish_translation_unit ()
1745{
1746 /* In case there were missing closebraces,
1747 get us back to the global binding level. */
273a708f 1748 pop_everything ();
ce4a0391
MM
1749 while (current_namespace != global_namespace)
1750 pop_namespace ();
1751 finish_file ();
1752}
1753
b4c4a9ec
MM
1754/* Finish a template type parameter, specified as AGGR IDENTIFIER.
1755 Returns the parameter. */
1756
1757tree
1758finish_template_type_parm (aggr, identifier)
1759 tree aggr;
1760 tree identifier;
1761{
6eabb241 1762 if (aggr != class_type_node)
b4c4a9ec 1763 {
8251199e 1764 pedwarn ("template type parameters must use the keyword `class' or `typename'");
b4c4a9ec
MM
1765 aggr = class_type_node;
1766 }
1767
1768 return build_tree_list (aggr, identifier);
1769}
1770
1771/* Finish a template template parameter, specified as AGGR IDENTIFIER.
1772 Returns the parameter. */
1773
1774tree
1775finish_template_template_parm (aggr, identifier)
1776 tree aggr;
1777 tree identifier;
1778{
1779 tree decl = build_decl (TYPE_DECL, identifier, NULL_TREE);
1780 tree tmpl = build_lang_decl (TEMPLATE_DECL, identifier, NULL_TREE);
1781 DECL_TEMPLATE_PARMS (tmpl) = current_template_parms;
1782 DECL_TEMPLATE_RESULT (tmpl) = decl;
1783 SET_DECL_ARTIFICIAL (decl);
1784 end_template_decl ();
1785
1786 return finish_template_type_parm (aggr, tmpl);
1787}
ce4a0391
MM
1788
1789/* Finish a parameter list, indicated by PARMS. If ELLIPSIS is
1790 non-zero, the parameter list was terminated by a `...'. */
1791
1792tree
1793finish_parmlist (parms, ellipsis)
1794 tree parms;
1795 int ellipsis;
1796{
1797 if (!ellipsis)
1798 chainon (parms, void_list_node);
1799 /* We mark the PARMS as a parmlist so that declarator processing can
1800 disambiguate certain constructs. */
1801 if (parms != NULL_TREE)
1802 TREE_PARMLIST (parms) = 1;
1803
1804 return parms;
1805}
1806
1807/* Begin a class definition, as indicated by T. */
1808
1809tree
1810begin_class_definition (t)
1811 tree t;
1812{
ce4a0391
MM
1813 if (t == error_mark_node
1814 || ! IS_AGGR_TYPE (t))
1815 {
830fcda8 1816 t = make_lang_type (RECORD_TYPE);
ce4a0391
MM
1817 pushtag (make_anon_name (), t, 0);
1818 }
830fcda8
JM
1819
1820 /* In a definition of a member class template, we will get here with an
1821 implicit typename, a TYPENAME_TYPE with a type. */
1822 if (TREE_CODE (t) == TYPENAME_TYPE)
1823 t = TREE_TYPE (t);
4c571114
MM
1824
1825 /* If we generated a partial instantiation of this type, but now
1826 we're seeing a real definition, we're actually looking at a
1827 partial specialization. Consider:
1828
1829 template <class T, class U>
1830 struct Y {};
1831
1832 template <class T>
1833 struct X {};
1834
1835 template <class T, class U>
1836 void f()
1837 {
1838 typename X<Y<T, U> >::A a;
1839 }
1840
1841 template <class T, class U>
1842 struct X<Y<T, U> >
1843 {
1844 };
1845
1846 We have to undo the effects of the previous partial
1847 instantiation. */
1848 if (PARTIAL_INSTANTIATION_P (t))
1849 {
1850 if (!pedantic)
1851 {
1852 /* Unfortunately, when we're not in pedantic mode, we
1853 attempt to actually fill in some of the fields of the
1854 partial instantiation, in order to support the implicit
1855 typename extension. Clear those fields now, in
1856 preparation for the definition here. The fields cleared
1857 here must match those set in instantiate_class_template.
1858 Look for a comment mentioning begin_class_definition
1859 there. */
1860 TYPE_BINFO_BASETYPES (t) = NULL_TREE;
1861 TYPE_FIELDS (t) = NULL_TREE;
1862 TYPE_METHODS (t) = NULL_TREE;
1863 CLASSTYPE_TAGS (t) = NULL_TREE;
1864 TYPE_SIZE (t) = NULL_TREE;
1865 }
830fcda8 1866
4c571114
MM
1867 /* This isn't a partial instantiation any more. */
1868 PARTIAL_INSTANTIATION_P (t) = 0;
1869 }
1870 /* If this type was already complete, and we see another definition,
1871 that's an error. */
1872 else if (TYPE_SIZE (t))
ce4a0391 1873 duplicate_tag_error (t);
4c571114 1874
b4f70b3d
NS
1875 /* Update the location of the decl. */
1876 DECL_SOURCE_FILE (TYPE_NAME (t)) = input_filename;
1877 DECL_SOURCE_LINE (TYPE_NAME (t)) = lineno;
1878
4c571114 1879 if (TYPE_BEING_DEFINED (t))
ce4a0391
MM
1880 {
1881 t = make_lang_type (TREE_CODE (t));
1882 pushtag (TYPE_IDENTIFIER (t), t, 0);
ce4a0391 1883 }
ff350acd 1884 maybe_process_partial_specialization (t);
8f032717 1885 pushclass (t, 1);
ce4a0391 1886 TYPE_BEING_DEFINED (t) = 1;
ce4a0391
MM
1887 /* Reset the interface data, at the earliest possible
1888 moment, as it might have been set via a class foo;
1889 before. */
6eabb241
MM
1890 {
1891 tree name = TYPE_IDENTIFIER (t);
1892
1893 if (! ANON_AGGRNAME_P (name))
1894 {
1895 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
1896 SET_CLASSTYPE_INTERFACE_UNKNOWN_X
1897 (t, interface_unknown);
1898 }
1899
1900 /* Only leave this bit clear if we know this
1901 class is part of an interface-only specification. */
1902 if (! CLASSTYPE_INTERFACE_KNOWN (t)
1903 || ! CLASSTYPE_INTERFACE_ONLY (t))
1904 CLASSTYPE_VTABLE_NEEDS_WRITING (t) = 1;
1905 }
ce4a0391 1906#if 0
830fcda8
JM
1907 tmp = TYPE_IDENTIFIER ($<ttype>0);
1908 if (tmp && IDENTIFIER_TEMPLATE (tmp))
1909 overload_template_name (tmp, 1);
ce4a0391
MM
1910#endif
1911 reset_specialization();
1912
b7975aed
MM
1913 /* Make a declaration for this class in its own scope. */
1914 build_self_reference ();
1915
830fcda8 1916 return t;
ce4a0391
MM
1917}
1918
61a127b3
MM
1919/* Finish the member declaration given by DECL. */
1920
1921void
1922finish_member_declaration (decl)
1923 tree decl;
1924{
1925 if (decl == error_mark_node || decl == NULL_TREE)
1926 return;
1927
1928 if (decl == void_type_node)
1929 /* The COMPONENT was a friend, not a member, and so there's
1930 nothing for us to do. */
1931 return;
1932
1933 /* We should see only one DECL at a time. */
1934 my_friendly_assert (TREE_CHAIN (decl) == NULL_TREE, 0);
1935
1936 /* Set up access control for DECL. */
1937 TREE_PRIVATE (decl)
1938 = (current_access_specifier == access_private_node);
1939 TREE_PROTECTED (decl)
1940 = (current_access_specifier == access_protected_node);
1941 if (TREE_CODE (decl) == TEMPLATE_DECL)
1942 {
1943 TREE_PRIVATE (DECL_RESULT (decl)) = TREE_PRIVATE (decl);
1944 TREE_PROTECTED (DECL_RESULT (decl)) = TREE_PROTECTED (decl);
1945 }
1946
1947 /* Mark the DECL as a member of the current class. */
1948 if (TREE_CODE (decl) == FUNCTION_DECL
1949 || DECL_FUNCTION_TEMPLATE_P (decl))
1950 /* Historically, DECL_CONTEXT was not set for a FUNCTION_DECL in
1951 finish_struct. Presumably it is already set as the function is
1952 parsed. Perhaps DECL_CLASS_CONTEXT is already set, too? */
1953 DECL_CLASS_CONTEXT (decl) = current_class_type;
61a127b3
MM
1954 else
1955 DECL_CONTEXT (decl) = current_class_type;
1956
1957 /* Put functions on the TYPE_METHODS list and everything else on the
1958 TYPE_FIELDS list. Note that these are built up in reverse order.
1959 We reverse them (to obtain declaration order) in finish_struct. */
1960 if (TREE_CODE (decl) == FUNCTION_DECL
1961 || DECL_FUNCTION_TEMPLATE_P (decl))
1962 {
1963 /* We also need to add this function to the
1964 CLASSTYPE_METHOD_VEC. */
1965 add_method (current_class_type, 0, decl);
1966
1967 TREE_CHAIN (decl) = TYPE_METHODS (current_class_type);
1968 TYPE_METHODS (current_class_type) = decl;
1969 }
1970 else
1971 {
1972 /* All TYPE_DECLs go at the end of TYPE_FIELDS. Ordinary fields
1973 go at the beginning. The reason is that lookup_field_1
1974 searches the list in order, and we want a field name to
1975 override a type name so that the "struct stat hack" will
1976 work. In particular:
1977
1978 struct S { enum E { }; int E } s;
1979 s.E = 3;
1980
1981 is legal. In addition, the FIELD_DECLs must be maintained in
1982 declaration order so that class layout works as expected.
1983 However, we don't need that order until class layout, so we
1984 save a little time by putting FIELD_DECLs on in reverse order
1985 here, and then reversing them in finish_struct_1. (We could
1986 also keep a pointer to the correct insertion points in the
1987 list.) */
1988
1989 if (TREE_CODE (decl) == TYPE_DECL)
1990 TYPE_FIELDS (current_class_type)
1991 = chainon (TYPE_FIELDS (current_class_type), decl);
1992 else
1993 {
1994 TREE_CHAIN (decl) = TYPE_FIELDS (current_class_type);
1995 TYPE_FIELDS (current_class_type) = decl;
1996 }
8f032717
MM
1997
1998 /* Enter the DECL into the scope of the class. */
1999 if (TREE_CODE (decl) != USING_DECL)
2000 pushdecl_class_level (decl);
61a127b3
MM
2001 }
2002}
2003
2004/* Finish a class definition T with the indicate ATTRIBUTES. If SEMI,
2005 the definition is immediately followed by a semicolon. Returns the
2006 type. */
ce4a0391
MM
2007
2008tree
fbdd0024 2009finish_class_definition (t, attributes, semi, pop_scope_p)
ce4a0391 2010 tree t;
ce4a0391
MM
2011 tree attributes;
2012 int semi;
fbdd0024 2013 int pop_scope_p;
ce4a0391 2014{
ce4a0391
MM
2015 /* finish_struct nukes this anyway; if finish_exception does too,
2016 then it can go. */
2017 if (semi)
2018 note_got_semicolon (t);
2019
dc8263bc
JM
2020 /* If we got any attributes in class_head, xref_tag will stick them in
2021 TREE_TYPE of the type. Grab them now. */
2022 attributes = chainon (TREE_TYPE (t), attributes);
2023 TREE_TYPE (t) = NULL_TREE;
2024
ce4a0391
MM
2025 if (TREE_CODE (t) == ENUMERAL_TYPE)
2026 ;
2027 else
2028 {
9f33663b 2029 t = finish_struct (t, attributes);
ce4a0391
MM
2030 if (semi)
2031 note_got_semicolon (t);
2032 }
2033
ce4a0391
MM
2034 if (! semi)
2035 check_for_missing_semicolon (t);
fbdd0024
MM
2036 if (pop_scope_p)
2037 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (t)));
ce4a0391
MM
2038 if (current_scope () == current_function_decl)
2039 do_pending_defargs ();
2040
2041 return t;
2042}
2043
2044/* Finish processing the default argument expressions cached during
2045 the processing of a class definition. */
2046
2047void
51632249 2048begin_inline_definitions ()
ce4a0391
MM
2049{
2050 if (pending_inlines
2051 && current_scope () == current_function_decl)
2052 do_pending_inlines ();
2053}
2054
2055/* Finish processing the inline function definitions cached during the
2056 processing of a class definition. */
2057
2058void
51632249 2059finish_inline_definitions ()
ce4a0391
MM
2060{
2061 if (current_class_type == NULL_TREE)
2062 clear_inline_text_obstack ();
ce4a0391 2063}
35acd3f2
MM
2064
2065/* Finish processing the declaration of a member class template
2066 TYPES whose template parameters are given by PARMS. */
2067
2068tree
61a127b3 2069finish_member_class_template (types)
35acd3f2
MM
2070 tree types;
2071{
36a117a5
MM
2072 tree t;
2073
2074 /* If there are declared, but undefined, partial specializations
2075 mixed in with the typespecs they will not yet have passed through
2076 maybe_process_partial_specialization, so we do that here. */
2077 for (t = types; t != NULL_TREE; t = TREE_CHAIN (t))
2078 if (IS_AGGR_TYPE_CODE (TREE_CODE (TREE_VALUE (t))))
2079 maybe_process_partial_specialization (TREE_VALUE (t));
2080
35acd3f2 2081 note_list_got_semicolon (types);
61a127b3 2082 grok_x_components (types);
35acd3f2
MM
2083 if (TYPE_CONTEXT (TREE_VALUE (types)) != current_class_type)
2084 /* The component was in fact a friend declaration. We avoid
2085 finish_member_template_decl performing certain checks by
2086 unsetting TYPES. */
2087 types = NULL_TREE;
61a127b3
MM
2088
2089 finish_member_template_decl (types);
2090
35acd3f2
MM
2091 /* As with other component type declarations, we do
2092 not store the new DECL on the list of
2093 component_decls. */
2094 return NULL_TREE;
2095}
36a117a5
MM
2096
2097/* Finish processsing a complete template declaration. The PARMS are
2098 the template parameters. */
2099
2100void
2101finish_template_decl (parms)
2102 tree parms;
2103{
2104 if (parms)
2105 end_template_decl ();
2106 else
2107 end_specialization ();
2108}
2109
2110/* Finish processing a a template-id (which names a type) of the form
2111 NAME < ARGS >. Return the TYPE_DECL for the type named by the
2112 template-id. If ENTERING_SCOPE is non-zero we are about to enter
2113 the scope of template-id indicated. */
2114
2115tree
2116finish_template_type (name, args, entering_scope)
2117 tree name;
2118 tree args;
2119 int entering_scope;
2120{
2121 tree decl;
2122
2123 decl = lookup_template_class (name, args,
2124 NULL_TREE, NULL_TREE, entering_scope);
2125 if (decl != error_mark_node)
2126 decl = TYPE_STUB_DECL (decl);
2127
2128 return decl;
2129}
648f19f6
MM
2130
2131/* SR is a SCOPE_REF node. Enter the scope of SR, whether it is a
2132 namespace scope or a class scope. */
2133
2134void
2135enter_scope_of (sr)
2136 tree sr;
2137{
2138 tree scope = TREE_OPERAND (sr, 0);
2139
2140 if (TREE_CODE (scope) == NAMESPACE_DECL)
2141 {
2142 push_decl_namespace (scope);
2143 TREE_COMPLEXITY (sr) = -1;
2144 }
2145 else if (scope != current_class_type)
2146 {
830fcda8
JM
2147 if (TREE_CODE (scope) == TYPENAME_TYPE)
2148 {
2149 /* In a declarator for a template class member, the scope will
2150 get here as an implicit typename, a TYPENAME_TYPE with a type. */
2151 scope = TREE_TYPE (scope);
2152 TREE_OPERAND (sr, 0) = scope;
2153 }
648f19f6
MM
2154 push_nested_class (scope, 3);
2155 TREE_COMPLEXITY (sr) = current_class_depth;
2156 }
2157}
ea6021e8
MM
2158
2159/* Finish processing a BASE_CLASS with the indicated ACCESS_SPECIFIER.
2160 Return a TREE_LIST containing the ACCESS_SPECIFIER and the
2161 BASE_CLASS, or NULL_TREE if an error occurred. The
2162 ACCESSS_SPECIFIER is one of
2163 access_{default,public,protected_private}[_virtual]_node.*/
2164
2165tree
6eabb241 2166finish_base_specifier (access_specifier, base_class)
ea6021e8
MM
2167 tree access_specifier;
2168 tree base_class;
ea6021e8
MM
2169{
2170 tree type;
2171 tree result;
2172
2173 if (base_class == NULL_TREE)
2174 {
8251199e 2175 error ("invalid base class");
ea6021e8
MM
2176 type = error_mark_node;
2177 }
2178 else
2179 type = TREE_TYPE (base_class);
6eabb241 2180
ea6021e8
MM
2181 if (! is_aggr_type (type, 1))
2182 result = NULL_TREE;
ea6021e8
MM
2183 else
2184 result = build_tree_list (access_specifier, type);
2185
2186 return result;
2187}
61a127b3
MM
2188
2189/* Called when multiple declarators are processed. If that is not
2190 premitted in this context, an error is issued. */
2191
2192void
2193check_multiple_declarators ()
2194{
2195 /* [temp]
2196
2197 In a template-declaration, explicit specialization, or explicit
2198 instantiation the init-declarator-list in the declaration shall
2199 contain at most one declarator.
2200
2201 We don't just use PROCESSING_TEMPLATE_DECL for the first
2202 condition since that would disallow the perfectly legal code,
2203 like `template <class T> struct S { int i, j; };'. */
2204 tree scope = current_scope ();
2205
2206 if (scope && TREE_CODE (scope) == FUNCTION_DECL)
2207 /* It's OK to write `template <class T> void f() { int i, j;}'. */
2208 return;
2209
2210 if (PROCESSING_REAL_TEMPLATE_DECL_P ()
2211 || processing_explicit_instantiation
2212 || processing_specialization)
2213 cp_error ("multiple declarators in template declaration");
2214}
2215
b894fc05
JM
2216tree
2217finish_typeof (expr)
2218 tree expr;
2219{
2220 if (processing_template_decl)
2221 {
2222 tree t;
2223
b894fc05 2224 t = make_lang_type (TYPEOF_TYPE);
b894fc05 2225 TYPE_FIELDS (t) = expr;
b894fc05
JM
2226
2227 return t;
2228 }
2229
2230 return TREE_TYPE (expr);
2231}
558475f0 2232
6f80451c 2233/* Create an empty statement tree rooted at T. */
558475f0
MM
2234
2235void
6f80451c
MM
2236begin_stmt_tree (t)
2237 tree *t;
558475f0
MM
2238{
2239 /* We create a trivial EXPR_STMT so that last_tree is never NULL in
2240 what follows. We remove the extraneous statement in
2241 finish_stmt_tree. */
6f80451c
MM
2242 *t = build_nt (EXPR_STMT, void_zero_node);
2243 SET_LAST_STMT (*t);
558475f0
MM
2244 last_expr_type = NULL_TREE;
2245}
2246
6f80451c 2247/* Finish the statement tree rooted at T. */
558475f0
MM
2248
2249void
6f80451c
MM
2250finish_stmt_tree (t)
2251 tree *t;
558475f0 2252{
a7e4cfa0
MM
2253 tree stmt;
2254
2255 /* Remove the fake extra statement added in begin_stmt_tree. */
6f80451c
MM
2256 stmt = TREE_CHAIN (*t);
2257 *t = stmt;
2258 SET_LAST_STMT (NULL_TREE);
a7e4cfa0 2259
6f80451c
MM
2260 if (current_function)
2261 {
2262 /* The line-number recorded in the outermost statement in a function
2263 is the line number of the end of the function. */
2264 STMT_LINENO (stmt) = lineno;
2265 STMT_LINENO_FOR_FN_P (stmt) = 1;
2266 }
a7e4cfa0
MM
2267}
2268
2269/* We're about to expand T, a statement. Set up appropriate context
2270 for the substitution. */
2271
2272void
2273prep_stmt (t)
2274 tree t;
2275{
2276 if (!STMT_LINENO_FOR_FN_P (t))
2277 lineno = STMT_LINENO (t);
2278 stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t);
558475f0
MM
2279}
2280
527f0080
MM
2281/* Some statements, like for-statements or if-statements, require a
2282 condition. This condition can be a declaration. If T is such a
2283 declaration it is processed, and an expression appropriate to use
2284 as the condition is returned. Otherwise, T itself is returned. */
2285
2286static tree
2287expand_cond (t)
2288 tree t;
2289{
ed5511d9 2290 if (t && TREE_CODE (t) == TREE_LIST)
527f0080 2291 {
ed5511d9
MM
2292 expand_stmt (TREE_PURPOSE (t));
2293 return TREE_VALUE (t);
527f0080
MM
2294 }
2295 else
2296 return t;
2297}
2298
62409b39
MM
2299/* Generate RTL for the statement T, and its substatements, and any
2300 other statements at its nesting level. */
558475f0
MM
2301
2302tree
2303expand_stmt (t)
2304 tree t;
2305{
47d7090e 2306 tree rval = NULL_TREE;
a7e4cfa0 2307
62409b39
MM
2308 while (t && t != error_mark_node)
2309 {
2310 int saved_stmts_are_full_exprs_p;
558475f0 2311
62409b39
MM
2312 /* Assume we'll have nothing to return. */
2313 rval = NULL_TREE;
a7e4cfa0 2314
62409b39
MM
2315 /* Set up context appropriately for handling this statement. */
2316 saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p;
2317 prep_stmt (t);
a7e4cfa0 2318
62409b39
MM
2319 switch (TREE_CODE (t))
2320 {
2321 case RETURN_STMT:
2322 finish_return_stmt (RETURN_EXPR (t));
2323 break;
558475f0 2324
62409b39 2325 case EXPR_STMT:
9bfadf57 2326 finish_expr_stmt (EXPR_STMT_EXPR (t));
62409b39 2327 break;
558475f0 2328
62409b39 2329 case DECL_STMT:
acef433b 2330 {
62409b39 2331 tree decl;
62409b39
MM
2332
2333 emit_line_note (input_filename, lineno);
2334 decl = DECL_STMT_DECL (t);
b35d4555
MM
2335 /* If this is a declaration for an automatic local
2336 variable, initialize it. Note that we might also see a
2337 declaration for a namespace-scope object (declared with
9ed9e79a
MM
2338 `extern'). We don't have to handle the initialization
2339 of those objects here; they can only be declarations,
2340 rather than definitions. */
b35d4555
MM
2341 if (TREE_CODE (decl) == VAR_DECL
2342 && !TREE_STATIC (decl)
2343 && !DECL_EXTERNAL (decl))
0fa5e05c
MM
2344 {
2345 /* Let the back-end know about this variable. */
2346 if (!ANON_AGGR_TYPE_P (TREE_TYPE (decl)))
2347 emit_local_var (decl);
2348 else
2349 expand_anon_union_decl (decl, NULL_TREE,
2350 DECL_ANON_UNION_ELEMS (decl));
2351 }
9ed9e79a 2352 else if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
f3010146 2353 make_rtl_for_local_static (decl);
acef433b 2354 }
62409b39 2355 break;
558475f0 2356
24bef158
MM
2357 case CLEANUP_STMT:
2358 finish_decl_cleanup (CLEANUP_DECL (t), CLEANUP_EXPR (t));
2359 break;
2360
b35d4555
MM
2361 case START_CATCH_STMT:
2362 begin_catch_block (TREE_TYPE (t));
2363 break;
2364
46e8c075
MM
2365 case CTOR_STMT:
2366 if (CTOR_BEGIN_P (t))
2367 begin_protect_partials ();
2368 else
2369 /* After this point, any exceptions will cause the
2370 destructor to be executed, so we no longer need to worry
2371 about destroying the various subobjects ourselves. */
2372 end_protect_partials ();
2373 break;
2374
62409b39
MM
2375 case FOR_STMT:
2376 {
2377 tree tmp;
2378
2379 begin_for_stmt ();
2380 expand_stmt (FOR_INIT_STMT (t));
2381 finish_for_init_stmt (NULL_TREE);
2382 finish_for_cond (expand_cond (FOR_COND (t)), NULL_TREE);
2383 tmp = FOR_EXPR (t);
2384 finish_for_expr (tmp, NULL_TREE);
2385 expand_stmt (FOR_BODY (t));
2386 finish_for_stmt (tmp, NULL_TREE);
2387 }
2388 break;
558475f0 2389
62409b39
MM
2390 case WHILE_STMT:
2391 {
2392 begin_while_stmt ();
2393 finish_while_stmt_cond (expand_cond (WHILE_COND (t)), NULL_TREE);
2394 expand_stmt (WHILE_BODY (t));
2395 finish_while_stmt (NULL_TREE);
2396 }
2397 break;
558475f0 2398
62409b39
MM
2399 case DO_STMT:
2400 {
2401 begin_do_stmt ();
2402 expand_stmt (DO_BODY (t));
2403 finish_do_body (NULL_TREE);
2404 finish_do_stmt (DO_COND (t), NULL_TREE);
2405 }
2406 break;
527f0080 2407
62409b39
MM
2408 case IF_STMT:
2409 begin_if_stmt ();
2410 finish_if_stmt_cond (expand_cond (IF_COND (t)), NULL_TREE);
2411 if (THEN_CLAUSE (t))
2412 {
2413 expand_stmt (THEN_CLAUSE (t));
2414 finish_then_clause (NULL_TREE);
2415 }
2416 if (ELSE_CLAUSE (t))
2417 {
2418 begin_else_clause ();
2419 expand_stmt (ELSE_CLAUSE (t));
2420 finish_else_clause (NULL_TREE);
2421 }
2422 finish_if_stmt ();
2423 break;
558475f0 2424
62409b39
MM
2425 case COMPOUND_STMT:
2426 begin_compound_stmt (COMPOUND_STMT_NO_SCOPE (t));
2427 expand_stmt (COMPOUND_BODY (t));
2428 rval = finish_compound_stmt (COMPOUND_STMT_NO_SCOPE (t),
2429 NULL_TREE);
2430 break;
558475f0 2431
62409b39
MM
2432 case BREAK_STMT:
2433 finish_break_stmt ();
2434 break;
558475f0 2435
62409b39
MM
2436 case CONTINUE_STMT:
2437 finish_continue_stmt ();
2438 break;
558475f0 2439
62409b39
MM
2440 case SWITCH_STMT:
2441 {
2442 tree cond;
558475f0 2443
62409b39
MM
2444 begin_switch_stmt ();
2445 cond = expand_cond (SWITCH_COND (t));
2446 finish_switch_cond (cond, NULL_TREE);
2447 expand_stmt (SWITCH_BODY (t));
2448 finish_switch_stmt (cond, NULL_TREE);
2449 }
2450 break;
2451
2452 case CASE_LABEL:
2453 finish_case_label (CASE_LOW (t), CASE_HIGH (t));
2454 break;
2455
2456 case LABEL_STMT:
b35d4555 2457 expand_label (LABEL_STMT_LABEL (t));
62409b39
MM
2458 break;
2459
2460 case GOTO_STMT:
b35d4555 2461 finish_goto_stmt (GOTO_DESTINATION (t));
62409b39
MM
2462 break;
2463
2464 case ASM_STMT:
2465 finish_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t), ASM_OUTPUTS
2466 (t), ASM_INPUTS (t), ASM_CLOBBERS (t));
2467 break;
2468
2469 case TRY_BLOCK:
2470 if (CLEANUP_P (t))
2471 {
2472 expand_eh_region_start ();
2473 expand_stmt (TRY_STMTS (t));
2474 finish_cleanup_try_block (NULL_TREE);
2475 finish_cleanup (TRY_HANDLERS (t), NULL_TREE);
2476 }
2477 else
2478 {
b35d4555
MM
2479 if (FN_TRY_BLOCK_P (t))
2480 begin_function_try_block ();
2481 else
2482 begin_try_block ();
2483
62409b39 2484 expand_stmt (TRY_STMTS (t));
b35d4555
MM
2485
2486 if (FN_TRY_BLOCK_P (t))
2487 {
2488 finish_function_try_block (NULL_TREE);
2489 expand_stmt (TRY_HANDLERS (t));
2490 finish_function_handler_sequence (NULL_TREE);
2491 }
2492 else
2493 {
2494 finish_try_block (NULL_TREE);
2495 expand_stmt (TRY_HANDLERS (t));
2496 finish_handler_sequence (NULL_TREE);
2497 }
62409b39
MM
2498 }
2499 break;
2500
2501 case HANDLER:
2502 begin_handler ();
62409b39 2503 expand_stmt (HANDLER_BODY (t));
b35d4555 2504 finish_handler (NULL_TREE, NULL_TREE);
62409b39
MM
2505 break;
2506
2507 case SUBOBJECT:
2508 finish_subobject (SUBOBJECT_CLEANUP (t));
2509 break;
2510
b35d4555 2511 case SCOPE_STMT:
d9b2d9da
MM
2512 if (!SCOPE_NO_CLEANUPS_P (t))
2513 {
2514 if (SCOPE_BEGIN_P (t))
2515 expand_start_bindings (2 * SCOPE_NULLIFIED_P (t));
2516 else if (SCOPE_END_P (t))
2517 expand_end_bindings (NULL_TREE, !SCOPE_NULLIFIED_P (t),
2518 SCOPE_PARTIAL_P (t));
2519 }
2520 else if (!SCOPE_NULLIFIED_P (t))
2521 emit_note (NULL,
2522 (SCOPE_BEGIN_P (t)
2523 ? NOTE_INSN_BLOCK_BEG
2524 : NOTE_INSN_BLOCK_END));
b35d4555
MM
2525 break;
2526
b35d4555
MM
2527 case RETURN_INIT:
2528 /* Clear this out so that finish_named_return_value can set it
2529 again. */
2530 DECL_NAME (DECL_RESULT (current_function_decl)) = NULL_TREE;
2531 finish_named_return_value (TREE_OPERAND (t, 0),
2532 TREE_OPERAND (t, 1));
2533 break;
2534
62409b39
MM
2535 default:
2536 my_friendly_abort (19990810);
2537 break;
f1dedc31 2538 }
558475f0 2539
62409b39
MM
2540 /* Restore saved state. */
2541 stmts_are_full_exprs_p = saved_stmts_are_full_exprs_p;
558475f0 2542
62409b39
MM
2543 /* Go on to the next statement in this scope. */
2544 t = TREE_CHAIN (t);
558475f0
MM
2545 }
2546
a7e4cfa0 2547 return rval;
558475f0
MM
2548}
2549
3eb24f73
MM
2550/* Called from expand_body via walk_tree. Replace all AGGR_INIT_EXPRs
2551 will equivalent CALL_EXPRs. */
2552
2553static tree
2554simplify_aggr_init_exprs_r (tp, walk_subtrees, data)
2555 tree *tp;
2556 int *walk_subtrees ATTRIBUTE_UNUSED;
2557 void *data ATTRIBUTE_UNUSED;
2558{
2559 tree aggr_init_expr;
2560 tree call_expr;
2561 tree fn;
2562 tree args;
2563 tree slot;
2564 tree type;
2565 tree call_type;
2566 int copy_from_buffer_p;
2567
2568 /* Only AGGR_INIT_EXPRs are interesting. */
2569 aggr_init_expr = *tp;
2570 if (TREE_CODE (aggr_init_expr) != AGGR_INIT_EXPR)
2571 return NULL_TREE;
2572
2573 /* Form an appropriate CALL_EXPR. */
2574 fn = TREE_OPERAND (aggr_init_expr, 0);
2575 args = TREE_OPERAND (aggr_init_expr, 1);
2576 slot = TREE_OPERAND (aggr_init_expr, 2);
2577 type = TREE_TYPE (aggr_init_expr);
2578 call_type = type;
2579 if (AGGR_INIT_VIA_CTOR_P (aggr_init_expr))
2580 {
2581 /* Replace the first argument with the address of the third
2582 argument to the AGGR_INIT_EXPR. */
2583 call_type = build_pointer_type (type);
2584 mark_addressable (slot);
2585 args = tree_cons (NULL_TREE, build1 (ADDR_EXPR, call_type, slot),
2586 TREE_CHAIN (args));
2587 }
2588 call_expr = build (CALL_EXPR, call_type, fn, args, NULL_TREE);
2589 TREE_SIDE_EFFECTS (call_expr) = 1;
2590
2591 /* If we're using the non-reentrant PCC calling convention, then we
2592 need to copy the returned value out of the static buffer into the
2593 SLOT. */
2594 copy_from_buffer_p = 0;
2595#ifdef PCC_STATIC_STRUCT_RETURN
2596 if (!AGGR_INIT_VIA_CTOR_P (aggr_init_expr) && aggregate_value_p (type))
2597 {
2598 int old_ac;
2599
2600 flag_access_control = 0;
2601 call_expr = build_aggr_init (slot, call_expr, LOOKUP_ONLYCONVERTING);
2602 flag_access_control = old_ac;
2603 copy_from_buffer_p = 1;
2604 }
2605#endif
2606
2607 /* If this AGGR_INIT_EXPR indicates the value returned by a
2608 function, then we want to use the value of the initialized
2609 location as the result. */
2610 if (AGGR_INIT_VIA_CTOR_P (aggr_init_expr) || copy_from_buffer_p)
2611 {
2612 call_expr = build (COMPOUND_EXPR, type,
2613 call_expr, slot);
2614 TREE_SIDE_EFFECTS (call_expr) = 1;
2615 }
2616
2617 /* Replace the AGGR_INIT_EXPR with the CALL_EXPR. */
2618 TREE_CHAIN (call_expr) = TREE_CHAIN (aggr_init_expr);
2619 *tp = call_expr;
2620
2621 /* Keep iterating. */
2622 return NULL_TREE;
2623}
2624
558475f0
MM
2625/* Generate RTL for FN. */
2626
2627void
2628expand_body (fn)
2629 tree fn;
2630{
62409b39
MM
2631 int saved_lineno;
2632 char *saved_input_filename;
558475f0 2633
62409b39
MM
2634 /* When the parser calls us after finishing the body of a template
2635 function, we don't really want to expand the body. When we're
2636 processing an in-class definition of an inline function,
2637 PROCESSING_TEMPLATE_DECL will no longer be set here, so we have
2638 to look at the function itself. */
2639 if (processing_template_decl
2640 || (DECL_LANG_SPECIFIC (fn)
2641 && DECL_TEMPLATE_INFO (fn)
2642 && uses_template_parms (DECL_TI_ARGS (fn))))
d658cd4c
MM
2643 {
2644 /* Normally, collection only occurs in rest_of_compilation. So,
2645 if we don't collect here, we never collect junk generated
2646 during the processing of templates until we hit a
2647 non-template function. */
2648 ggc_collect ();
2649 return;
2650 }
62409b39 2651
3eb24f73
MM
2652 /* Replace AGGR_INIT_EXPRs with appropriate CALL_EXPRs. */
2653 walk_tree (&DECL_SAVED_TREE (fn), simplify_aggr_init_exprs_r, NULL);
2654
84df082b
MM
2655 /* There's no reason to do any of the work here if we're only doing
2656 semantic analysis; this code just generates RTL. */
2657 if (flag_syntax_only)
2658 return;
2659
21b0c6dc
MM
2660 /* If possible, avoid generating RTL for this function. Instead,
2661 just record it as an inline function, and wait until end-of-file
2662 to decide whether to write it out or not. */
2663 if (/* We have to generate RTL if we can't inline trees. */
2664 flag_inline_trees
2665 /* Or if it's not an inline function. */
2666 && DECL_INLINE (fn)
2667 /* Or if we have to keep all inline functions anyhow. */
2668 && !flag_keep_inline_functions
2669 /* Or if we actually have a reference to the function. */
2670 && !DECL_NEEDED_P (fn)
2671 /* Or if we're at the end-of-file, and this function is not
2672 DECL_COMDAT. */
2673 && (!at_eof || DECL_COMDAT (fn))
2674 /* Or if this is a nested function. */
2675 && !hack_decl_function_context (fn))
2676 {
2677 /* Give the function RTL now so that we can assign it to a
2678 function pointer, etc. */
2679 make_function_rtl (fn);
2680 /* Set DECL_EXTERNAL so that assemble_external will be called as
2681 necessary. We'll clear it again in finish_file. */
2682 if (!DECL_EXTERNAL (fn))
2683 {
2684 DECL_NOT_REALLY_EXTERN (fn) = 1;
2685 DECL_EXTERNAL (fn) = 1;
2686 }
2687 /* Remember this function. In finish_file we'll decide if
2688 we actually need to write this function out. */
2689 mark_inline_for_output (fn);
2690 return;
2691 }
2692
46e8c075
MM
2693 /* Optimize the body of the function before expanding it. */
2694 optimize_function (fn);
2695
62409b39 2696 /* Save the current file name and line number. When we expand the
84df082b 2697 body of the function, we'll set LINENO and INPUT_FILENAME so that
62409b39
MM
2698 error-mesages come out in the right places. */
2699 saved_lineno = lineno;
2700 saved_input_filename = input_filename;
2701 lineno = DECL_SOURCE_LINE (fn);
2702 input_filename = DECL_SOURCE_FILE (fn);
2703
a8f73d4b 2704 start_function (NULL_TREE, fn, NULL_TREE, SF_PRE_PARSED | SF_EXPAND);
558475f0
MM
2705 store_parm_decls ();
2706
24bef158
MM
2707 /* We don't need to redeclare __FUNCTION__, __PRETTY_FUNCTION__, or
2708 any of the other magic variables we set up when starting a
2709 function body. */
2710 current_function_name_declared = 1;
2711
558475f0 2712 /* Expand the body. */
b35d4555 2713 expand_stmt (DECL_SAVED_TREE (fn));
558475f0 2714
62409b39
MM
2715 /* Statements should always be full-expressions at the outermost set
2716 of curly braces for a function. */
2717 my_friendly_assert (stmts_are_full_exprs_p, 19990831);
2718
2719 /* The outermost statement for a function contains the line number
2720 recorded when we finished processing the function. */
2721 lineno = STMT_LINENO (DECL_SAVED_TREE (fn));
2722
2723 /* Generate code for the function. */
fdfcc44c 2724 finish_function (lineno, 0);
62409b39 2725
46e8c075
MM
2726 /* If possible, obliterate the body of the function so that it can
2727 be garbage collected. */
2728 if (flag_dump_translation_unit)
2729 /* Keep the body; we're going to dump it. */
2730 ;
2731 else if (DECL_INLINE (fn) && flag_inline_trees)
2732 /* We might need the body of this function so that we can expand
2733 it inline somewhere else. */
2734 ;
2735 else
2736 /* We don't need the body; blow it away. */
d658cd4c
MM
2737 DECL_SAVED_TREE (fn) = NULL_TREE;
2738
62409b39
MM
2739 /* And restore the current source position. */
2740 lineno = saved_lineno;
2741 input_filename = saved_input_filename;
558475f0 2742}