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