]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/cp/semantics.c
cp-tree.h (language_function): Rename expanding_p to x_expanding_p.
[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 return r;
873 }
874
875
876 /* Finish a compound-statement, which may be given by COMPOUND_STMT.
877 If HAS_NO_SCOPE is non-zero, the compound statement does not define
878 a scope. */
879
880 tree
881 finish_compound_stmt (has_no_scope, compound_stmt)
882 int has_no_scope;
883 tree compound_stmt;
884 {
885 tree r;
886 tree t;
887
888 if (!has_no_scope)
889 r = do_poplevel ();
890 else
891 r = NULL_TREE;
892
893 if (building_stmt_tree ())
894 RECHAIN_STMTS (compound_stmt, COMPOUND_BODY (compound_stmt));
895
896 /* When we call finish_stmt we will lose LAST_EXPR_TYPE. But, since
897 the precise purpose of that variable is store the type of the
898 last expression statement within the last compound statement, we
899 preserve the value. */
900 t = last_expr_type;
901 finish_stmt ();
902 last_expr_type = t;
903
904 return r;
905 }
906
907 /* Finish an asm-statement, whose components are a CV_QUALIFIER, a
908 STRING, some OUTPUT_OPERANDS, some INPUT_OPERANDS, and some
909 CLOBBERS. */
910
911 void
912 finish_asm_stmt (cv_qualifier, string, output_operands,
913 input_operands, clobbers)
914 tree cv_qualifier;
915 tree string;
916 tree output_operands;
917 tree input_operands;
918 tree clobbers;
919 {
920 if (TREE_CHAIN (string))
921 {
922 if (building_stmt_tree ())
923 /* We need to build the combined string on the permanent
924 obstack so that we can use it during instantiations. */
925 push_permanent_obstack ();
926
927 string = combine_strings (string);
928
929 if (building_stmt_tree ())
930 pop_obstacks ();
931 }
932
933 if (cv_qualifier != NULL_TREE
934 && cv_qualifier != ridpointers[(int) RID_VOLATILE])
935 {
936 cp_warning ("%s qualifier ignored on asm",
937 IDENTIFIER_POINTER (cv_qualifier));
938 cv_qualifier = NULL_TREE;
939 }
940
941 if (building_stmt_tree ())
942 {
943 tree r = build_min_nt (ASM_STMT, cv_qualifier, string,
944 output_operands, input_operands,
945 clobbers);
946 add_tree (r);
947 }
948 else
949 {
950 emit_line_note (input_filename, lineno);
951 if (output_operands != NULL_TREE || input_operands != NULL_TREE
952 || clobbers != NULL_TREE)
953 {
954 tree t;
955
956 for (t = input_operands; t; t = TREE_CHAIN (t))
957 TREE_VALUE (t) = decay_conversion (TREE_VALUE (t));
958
959 c_expand_asm_operands (string, output_operands,
960 input_operands,
961 clobbers,
962 cv_qualifier != NULL_TREE,
963 input_filename, lineno);
964 }
965 else
966 expand_asm (string);
967
968 finish_stmt ();
969 }
970 }
971
972 /* Finish a label with the indicated NAME. */
973
974 void
975 finish_label_stmt (name)
976 tree name;
977 {
978 tree decl = define_label (input_filename, lineno, name);
979
980 if (building_stmt_tree ())
981 add_tree (build_min_nt (LABEL_STMT, decl));
982 else if (decl)
983 expand_label (decl);
984 }
985
986 /* Finish a series of declarations for local labels. G++ allows users
987 to declare "local" labels, i.e., labels with scope. This extension
988 is useful when writing code involving statement-expressions. */
989
990 void
991 finish_label_decl (name)
992 tree name;
993 {
994 tree decl = declare_local_label (name);
995 if (building_stmt_tree ())
996 add_decl_stmt (decl);
997 }
998
999 /* Create a declaration statement for the declaration given by the
1000 DECL. */
1001
1002 void
1003 add_decl_stmt (decl)
1004 tree decl;
1005 {
1006 tree decl_stmt;
1007
1008 /* We need the type to last until instantiation time. */
1009 decl_stmt = build_min_nt (DECL_STMT, decl);
1010 add_tree (decl_stmt);
1011 }
1012
1013 /* We're in a constructor, and have just constructed a a subobject of
1014 *THIS. CLEANUP is code to run if an exception is thrown before the
1015 end of the current function is reached. */
1016
1017 void
1018 finish_subobject (cleanup)
1019 tree cleanup;
1020 {
1021 if (building_stmt_tree ())
1022 {
1023 tree r = build_min_nt (SUBOBJECT, cleanup);
1024 add_tree (r);
1025 }
1026 else
1027 add_partial_entry (cleanup);
1028 }
1029
1030 /* Bind a name and initialization to the return value of
1031 the current function. */
1032
1033 void
1034 finish_named_return_value (return_id, init)
1035 tree return_id, init;
1036 {
1037 tree decl = DECL_RESULT (current_function_decl);
1038
1039 if (pedantic)
1040 /* Give this error as many times as there are occurrences,
1041 so that users can use Emacs compilation buffers to find
1042 and fix all such places. */
1043 pedwarn ("ANSI C++ does not permit named return values");
1044
1045 if (return_id != NULL_TREE)
1046 {
1047 if (DECL_NAME (decl) == NULL_TREE)
1048 {
1049 DECL_NAME (decl) = return_id;
1050 DECL_ASSEMBLER_NAME (decl) = return_id;
1051 }
1052 else
1053 {
1054 cp_error ("return identifier `%D' already in place", return_id);
1055 return;
1056 }
1057 }
1058
1059 /* Can't let this happen for constructors. */
1060 if (DECL_CONSTRUCTOR_P (current_function_decl))
1061 {
1062 error ("can't redefine default return value for constructors");
1063 return;
1064 }
1065
1066 /* If we have a named return value, put that in our scope as well. */
1067 if (DECL_NAME (decl) != NULL_TREE)
1068 {
1069 /* Let `cp_finish_decl' know that this initializer is ok. */
1070 DECL_INITIAL (decl) = init;
1071 pushdecl (decl);
1072
1073 if (building_stmt_tree ())
1074 add_tree (build_min_nt (RETURN_INIT, return_id, init));
1075 else
1076 {
1077 cp_finish_decl (decl, init, NULL_TREE, 0, 0);
1078 store_return_init (decl);
1079 }
1080 }
1081 }
1082
1083 /* Cache the value of this class's main virtual function table pointer
1084 in a register variable. This will save one indirection if a
1085 more than one virtual function call is made this function. */
1086
1087 void
1088 setup_vtbl_ptr ()
1089 {
1090 if (base_init_expr == 0
1091 && DECL_CONSTRUCTOR_P (current_function_decl))
1092 {
1093 if (building_stmt_tree ())
1094 add_tree (build_min_nt
1095 (CTOR_INITIALIZER,
1096 current_member_init_list, current_base_init_list));
1097 else
1098 emit_base_init (current_class_type);
1099 }
1100
1101 /* Always keep the BLOCK node associated with the outermost pair of
1102 curley braces of a function. These are needed for correct
1103 operation of dwarfout.c. */
1104 keep_next_level (1);
1105 }
1106
1107 /* Begin a new scope. */
1108
1109 static void
1110 do_pushlevel ()
1111 {
1112 if (!building_stmt_tree ())
1113 {
1114 emit_line_note (input_filename, lineno);
1115 clear_last_expr ();
1116 }
1117 push_momentary ();
1118 if (stmts_are_full_exprs_p)
1119 pushlevel (0);
1120 if (!building_stmt_tree () && stmts_are_full_exprs_p)
1121 expand_start_bindings (0);
1122 }
1123
1124 /* Finish a scope. */
1125
1126 static tree
1127 do_poplevel ()
1128 {
1129 tree t;
1130
1131 if (!building_stmt_tree () && stmts_are_full_exprs_p)
1132 expand_end_bindings (getdecls (), kept_level_p (), 0);
1133 if (stmts_are_full_exprs_p)
1134 t = poplevel (kept_level_p (), 1, 0);
1135 else
1136 t = NULL_TREE;
1137 pop_momentary ();
1138 return t;
1139 }
1140
1141 /* Finish a parenthesized expression EXPR. */
1142
1143 tree
1144 finish_parenthesized_expr (expr)
1145 tree expr;
1146 {
1147 if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (expr))))
1148 /* This inhibits warnings in truthvalue_conversion. */
1149 C_SET_EXP_ORIGINAL_CODE (expr, ERROR_MARK);
1150
1151 return expr;
1152 }
1153
1154 /* Begin a statement-expression. The value returned must be passed to
1155 finish_stmt_expr. */
1156
1157 tree
1158 begin_stmt_expr ()
1159 {
1160 keep_next_level (1);
1161 /* If we're building a statement tree, then the upcoming compound
1162 statement will be chained onto the tree structure, starting at
1163 last_tree. We return last_tree so that we can later unhook the
1164 compound statement. */
1165 return building_stmt_tree () ? last_tree : expand_start_stmt_expr();
1166 }
1167
1168 /* Finish a statement-expression. RTL_EXPR should be the value
1169 returned by the previous begin_stmt_expr; EXPR is the
1170 statement-expression. Returns an expression representing the
1171 statement-expression. */
1172
1173 tree
1174 finish_stmt_expr (rtl_expr, expr)
1175 tree rtl_expr;
1176 tree expr;
1177 {
1178 tree result;
1179
1180 if (!building_stmt_tree ())
1181 {
1182 rtl_expr = expand_end_stmt_expr (rtl_expr);
1183 /* The statements have side effects, so the group does. */
1184 TREE_SIDE_EFFECTS (rtl_expr) = 1;
1185 }
1186
1187 if (building_stmt_tree ())
1188 {
1189 /* If the last thing in the statement-expression was not an
1190 expression-statement, then it has type `void'. */
1191 if (!last_expr_type)
1192 last_expr_type = void_type_node;
1193 result = build_min (STMT_EXPR, last_expr_type, last_tree);
1194 TREE_SIDE_EFFECTS (result) = 1;
1195
1196 /* Remove the compound statement from the tree structure; it is
1197 now saved in the STMT_EXPR. */
1198 last_tree = rtl_expr;
1199 TREE_CHAIN (last_tree) = NULL_TREE;
1200 }
1201 else if (expr && TREE_CODE (expr) == BLOCK)
1202 {
1203 result = build (BIND_EXPR, TREE_TYPE (rtl_expr),
1204 NULL_TREE, rtl_expr, expr);
1205 delete_block (expr);
1206 }
1207 else
1208 result = rtl_expr;
1209
1210 if (expr && TREE_CODE (expr) == BLOCK)
1211 /* Remove the block from the tree at this point. It gets put back
1212 at the proper place when the STMT_EXPR or BIND_EXPR is
1213 expanded. */
1214 delete_block (expr);
1215
1216 return result;
1217 }
1218
1219 /* Finish a call to FN with ARGS. Returns a representation of the
1220 call. */
1221
1222 tree
1223 finish_call_expr (fn, args, koenig)
1224 tree fn;
1225 tree args;
1226 int koenig;
1227 {
1228 tree result;
1229
1230 if (koenig)
1231 {
1232 if (TREE_CODE (fn) == BIT_NOT_EXPR)
1233 fn = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND (fn, 0));
1234 else if (TREE_CODE (fn) != TEMPLATE_ID_EXPR)
1235 fn = do_identifier (fn, 2, args);
1236 }
1237 result = build_x_function_call (fn, args, current_class_ref);
1238
1239 if (TREE_CODE (result) == CALL_EXPR
1240 && (! TREE_TYPE (result)
1241 || TREE_CODE (TREE_TYPE (result)) != VOID_TYPE))
1242 result = require_complete_type (result);
1243
1244 return result;
1245 }
1246
1247 /* Finish a call to a postfix increment or decrement or EXPR. (Which
1248 is indicated by CODE, which should be POSTINCREMENT_EXPR or
1249 POSTDECREMENT_EXPR.) */
1250
1251 tree
1252 finish_increment_expr (expr, code)
1253 tree expr;
1254 enum tree_code code;
1255 {
1256 /* If we get an OFFSET_REF, turn it into what it really means (e.g.,
1257 a COMPONENT_REF). This way if we've got, say, a reference to a
1258 static member that's being operated on, we don't end up trying to
1259 find a member operator for the class it's in. */
1260
1261 if (TREE_CODE (expr) == OFFSET_REF)
1262 expr = resolve_offset_ref (expr);
1263 return build_x_unary_op (code, expr);
1264 }
1265
1266 /* Finish a use of `this'. Returns an expression for `this'. */
1267
1268 tree
1269 finish_this_expr ()
1270 {
1271 tree result;
1272
1273 if (current_class_ptr)
1274 {
1275 #ifdef WARNING_ABOUT_CCD
1276 TREE_USED (current_class_ptr) = 1;
1277 #endif
1278 result = current_class_ptr;
1279 }
1280 else if (current_function_decl
1281 && DECL_STATIC_FUNCTION_P (current_function_decl))
1282 {
1283 error ("`this' is unavailable for static member functions");
1284 result = error_mark_node;
1285 }
1286 else
1287 {
1288 if (current_function_decl)
1289 error ("invalid use of `this' in non-member function");
1290 else
1291 error ("invalid use of `this' at top level");
1292 result = error_mark_node;
1293 }
1294
1295 return result;
1296 }
1297
1298 /* Finish a member function call using OBJECT and ARGS as arguments to
1299 FN. Returns an expression for the call. */
1300
1301 tree
1302 finish_object_call_expr (fn, object, args)
1303 tree fn;
1304 tree object;
1305 tree args;
1306 {
1307 #if 0
1308 /* This is a future direction of this code, but because
1309 build_x_function_call cannot always undo what is done in
1310 build_component_ref entirely yet, we cannot do this. */
1311
1312 tree real_fn = build_component_ref (object, fn, NULL_TREE, 1);
1313 return finish_call_expr (real_fn, args);
1314 #else
1315 if (TREE_CODE (fn) == TYPE_DECL)
1316 {
1317 if (processing_template_decl)
1318 /* This can happen on code like:
1319
1320 class X;
1321 template <class T> void f(T t) {
1322 t.X();
1323 }
1324
1325 We just grab the underlying IDENTIFIER. */
1326 fn = DECL_NAME (fn);
1327 else
1328 {
1329 cp_error ("calling type `%T' like a method", fn);
1330 return error_mark_node;
1331 }
1332 }
1333
1334 return build_method_call (object, fn, args, NULL_TREE, LOOKUP_NORMAL);
1335 #endif
1336 }
1337
1338 /* Finish a qualified member function call using OBJECT and ARGS as
1339 arguments to FN. Returns an expressino for the call. */
1340
1341 tree
1342 finish_qualified_object_call_expr (fn, object, args)
1343 tree fn;
1344 tree object;
1345 tree args;
1346 {
1347 return build_scoped_method_call (object, TREE_OPERAND (fn, 0),
1348 TREE_OPERAND (fn, 1), args);
1349 }
1350
1351 /* Finish a pseudo-destructor call expression of OBJECT, with SCOPE
1352 being the scope, if any, of DESTRUCTOR. Returns an expression for
1353 the call. */
1354
1355 tree
1356 finish_pseudo_destructor_call_expr (object, scope, destructor)
1357 tree object;
1358 tree scope;
1359 tree destructor;
1360 {
1361 if (processing_template_decl)
1362 return build_min_nt (PSEUDO_DTOR_EXPR, object, scope, destructor);
1363
1364 if (scope && scope != destructor)
1365 cp_error ("destructor specifier `%T::~%T()' must have matching names",
1366 scope, destructor);
1367
1368 if ((scope == NULL_TREE || IDENTIFIER_GLOBAL_VALUE (destructor))
1369 && (TREE_CODE (TREE_TYPE (object)) !=
1370 TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (destructor)))))
1371 cp_error ("`%E' is not of type `%T'", object, destructor);
1372
1373 return cp_convert (void_type_node, object);
1374 }
1375
1376 /* Finish a call to a globally qualified member function FN using
1377 ARGS. Returns an expression for the call. */
1378
1379 tree
1380 finish_qualified_call_expr (fn, args)
1381 tree fn;
1382 tree args;
1383 {
1384 if (processing_template_decl)
1385 return build_min_nt (CALL_EXPR, fn, args, NULL_TREE);
1386 else
1387 return build_member_call (TREE_OPERAND (fn, 0),
1388 TREE_OPERAND (fn, 1),
1389 args);
1390 }
1391
1392 /* Finish an expression taking the address of LABEL. Returns an
1393 expression for the address. */
1394
1395 tree
1396 finish_label_address_expr (label)
1397 tree label;
1398 {
1399 tree result;
1400
1401 label = lookup_label (label);
1402 if (label == NULL_TREE)
1403 result = null_pointer_node;
1404 else
1405 {
1406 TREE_USED (label) = 1;
1407 result = build1 (ADDR_EXPR, ptr_type_node, label);
1408 TREE_CONSTANT (result) = 1;
1409 }
1410
1411 return result;
1412 }
1413
1414 /* Finish an expression of the form CODE EXPR. */
1415
1416 tree
1417 finish_unary_op_expr (code, expr)
1418 enum tree_code code;
1419 tree expr;
1420 {
1421 tree result = build_x_unary_op (code, expr);
1422 if (code == NEGATE_EXPR && TREE_CODE (expr) == INTEGER_CST)
1423 TREE_NEGATED_INT (result) = 1;
1424 overflow_warning (result);
1425 return result;
1426 }
1427
1428 /* Finish an id-expression. */
1429
1430 tree
1431 finish_id_expr (expr)
1432 tree expr;
1433 {
1434 if (TREE_CODE (expr) == IDENTIFIER_NODE)
1435 expr = do_identifier (expr, 1, NULL_TREE);
1436
1437 return expr;
1438 }
1439
1440 /* Begin a new-placement. */
1441
1442 int
1443 begin_new_placement ()
1444 {
1445 /* The arguments to a placement new might be passed to a
1446 deallocation function, in the event that the allocation throws an
1447 exception. Since we don't expand exception handlers until the
1448 end of a function, we must make sure the arguments stay around
1449 that long. */
1450 return suspend_momentary ();
1451 }
1452
1453 /* Finish a new-placement. The ARGS are the placement arguments. The
1454 COOKIE is the value returned by the previous call to
1455 begin_new_placement. */
1456
1457 tree
1458 finish_new_placement (args, cookie)
1459 tree args;
1460 int cookie;
1461 {
1462 resume_momentary (cookie);
1463 return args;
1464 }
1465
1466 /* Begin a function defniition declared with DECL_SPECS and
1467 DECLARATOR. Returns non-zero if the function-declaration is
1468 legal. */
1469
1470 int
1471 begin_function_definition (decl_specs, declarator)
1472 tree decl_specs;
1473 tree declarator;
1474 {
1475 tree specs;
1476 tree attrs;
1477 split_specs_attrs (decl_specs, &specs, &attrs);
1478 if (!start_function (specs, declarator, attrs, SF_DEFAULT))
1479 return 0;
1480
1481 reinit_parse_for_function ();
1482 /* The things we're about to see are not directly qualified by any
1483 template headers we've seen thus far. */
1484 reset_specialization ();
1485
1486 return 1;
1487 }
1488
1489 /* Begin a constructor declarator of the form `SCOPE::NAME'. Returns
1490 a SCOPE_REF. */
1491
1492 tree
1493 begin_constructor_declarator (scope, name)
1494 tree scope;
1495 tree name;
1496 {
1497 tree result = build_parse_node (SCOPE_REF, scope, name);
1498 enter_scope_of (result);
1499 return result;
1500 }
1501
1502 /* Finish an init-declarator. Returns a DECL. */
1503
1504 tree
1505 finish_declarator (declarator, declspecs, attributes,
1506 prefix_attributes, initialized)
1507 tree declarator;
1508 tree declspecs;
1509 tree attributes;
1510 tree prefix_attributes;
1511 int initialized;
1512 {
1513 return start_decl (declarator, declspecs, initialized, attributes,
1514 prefix_attributes);
1515 }
1516
1517 /* Finish a translation unit. */
1518
1519 void
1520 finish_translation_unit ()
1521 {
1522 /* In case there were missing closebraces,
1523 get us back to the global binding level. */
1524 while (! toplevel_bindings_p ())
1525 poplevel (0, 0, 0);
1526 while (current_namespace != global_namespace)
1527 pop_namespace ();
1528 finish_file ();
1529 }
1530
1531 /* Finish a template type parameter, specified as AGGR IDENTIFIER.
1532 Returns the parameter. */
1533
1534 tree
1535 finish_template_type_parm (aggr, identifier)
1536 tree aggr;
1537 tree identifier;
1538 {
1539 if (aggr != class_type_node)
1540 {
1541 pedwarn ("template type parameters must use the keyword `class' or `typename'");
1542 aggr = class_type_node;
1543 }
1544
1545 return build_tree_list (aggr, identifier);
1546 }
1547
1548 /* Finish a template template parameter, specified as AGGR IDENTIFIER.
1549 Returns the parameter. */
1550
1551 tree
1552 finish_template_template_parm (aggr, identifier)
1553 tree aggr;
1554 tree identifier;
1555 {
1556 tree decl = build_decl (TYPE_DECL, identifier, NULL_TREE);
1557 tree tmpl = build_lang_decl (TEMPLATE_DECL, identifier, NULL_TREE);
1558 DECL_TEMPLATE_PARMS (tmpl) = current_template_parms;
1559 DECL_TEMPLATE_RESULT (tmpl) = decl;
1560 SET_DECL_ARTIFICIAL (decl);
1561 end_template_decl ();
1562
1563 return finish_template_type_parm (aggr, tmpl);
1564 }
1565
1566 /* Finish a parameter list, indicated by PARMS. If ELLIPSIS is
1567 non-zero, the parameter list was terminated by a `...'. */
1568
1569 tree
1570 finish_parmlist (parms, ellipsis)
1571 tree parms;
1572 int ellipsis;
1573 {
1574 if (!ellipsis)
1575 chainon (parms, void_list_node);
1576 /* We mark the PARMS as a parmlist so that declarator processing can
1577 disambiguate certain constructs. */
1578 if (parms != NULL_TREE)
1579 TREE_PARMLIST (parms) = 1;
1580
1581 return parms;
1582 }
1583
1584 /* Begin a class definition, as indicated by T. */
1585
1586 tree
1587 begin_class_definition (t)
1588 tree t;
1589 {
1590 push_permanent_obstack ();
1591
1592 if (t == error_mark_node
1593 || ! IS_AGGR_TYPE (t))
1594 {
1595 t = make_lang_type (RECORD_TYPE);
1596 pushtag (make_anon_name (), t, 0);
1597 }
1598
1599 /* In a definition of a member class template, we will get here with an
1600 implicit typename, a TYPENAME_TYPE with a type. */
1601 if (TREE_CODE (t) == TYPENAME_TYPE)
1602 t = TREE_TYPE (t);
1603
1604 /* If we generated a partial instantiation of this type, but now
1605 we're seeing a real definition, we're actually looking at a
1606 partial specialization. Consider:
1607
1608 template <class T, class U>
1609 struct Y {};
1610
1611 template <class T>
1612 struct X {};
1613
1614 template <class T, class U>
1615 void f()
1616 {
1617 typename X<Y<T, U> >::A a;
1618 }
1619
1620 template <class T, class U>
1621 struct X<Y<T, U> >
1622 {
1623 };
1624
1625 We have to undo the effects of the previous partial
1626 instantiation. */
1627 if (PARTIAL_INSTANTIATION_P (t))
1628 {
1629 if (!pedantic)
1630 {
1631 /* Unfortunately, when we're not in pedantic mode, we
1632 attempt to actually fill in some of the fields of the
1633 partial instantiation, in order to support the implicit
1634 typename extension. Clear those fields now, in
1635 preparation for the definition here. The fields cleared
1636 here must match those set in instantiate_class_template.
1637 Look for a comment mentioning begin_class_definition
1638 there. */
1639 TYPE_BINFO_BASETYPES (t) = NULL_TREE;
1640 TYPE_FIELDS (t) = NULL_TREE;
1641 TYPE_METHODS (t) = NULL_TREE;
1642 CLASSTYPE_TAGS (t) = NULL_TREE;
1643 TYPE_SIZE (t) = NULL_TREE;
1644 }
1645
1646 /* This isn't a partial instantiation any more. */
1647 PARTIAL_INSTANTIATION_P (t) = 0;
1648 }
1649 /* If this type was already complete, and we see another definition,
1650 that's an error. */
1651 else if (TYPE_SIZE (t))
1652 duplicate_tag_error (t);
1653
1654 /* Update the location of the decl. */
1655 DECL_SOURCE_FILE (TYPE_NAME (t)) = input_filename;
1656 DECL_SOURCE_LINE (TYPE_NAME (t)) = lineno;
1657
1658 if (TYPE_BEING_DEFINED (t))
1659 {
1660 t = make_lang_type (TREE_CODE (t));
1661 pushtag (TYPE_IDENTIFIER (t), t, 0);
1662 }
1663 maybe_process_partial_specialization (t);
1664 pushclass (t, 1);
1665 TYPE_BEING_DEFINED (t) = 1;
1666 /* Reset the interface data, at the earliest possible
1667 moment, as it might have been set via a class foo;
1668 before. */
1669 {
1670 tree name = TYPE_IDENTIFIER (t);
1671
1672 if (! ANON_AGGRNAME_P (name))
1673 {
1674 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
1675 SET_CLASSTYPE_INTERFACE_UNKNOWN_X
1676 (t, interface_unknown);
1677 }
1678
1679 /* Only leave this bit clear if we know this
1680 class is part of an interface-only specification. */
1681 if (! CLASSTYPE_INTERFACE_KNOWN (t)
1682 || ! CLASSTYPE_INTERFACE_ONLY (t))
1683 CLASSTYPE_VTABLE_NEEDS_WRITING (t) = 1;
1684 }
1685 #if 0
1686 tmp = TYPE_IDENTIFIER ($<ttype>0);
1687 if (tmp && IDENTIFIER_TEMPLATE (tmp))
1688 overload_template_name (tmp, 1);
1689 #endif
1690 reset_specialization();
1691
1692 /* In case this is a local class within a template
1693 function, we save the current tree structure so
1694 that we can get it back later. */
1695 begin_tree ();
1696
1697 /* Make a declaration for this class in its own scope. */
1698 build_self_reference ();
1699
1700 return t;
1701 }
1702
1703 /* Finish the member declaration given by DECL. */
1704
1705 void
1706 finish_member_declaration (decl)
1707 tree decl;
1708 {
1709 if (decl == error_mark_node || decl == NULL_TREE)
1710 return;
1711
1712 if (decl == void_type_node)
1713 /* The COMPONENT was a friend, not a member, and so there's
1714 nothing for us to do. */
1715 return;
1716
1717 /* We should see only one DECL at a time. */
1718 my_friendly_assert (TREE_CHAIN (decl) == NULL_TREE, 0);
1719
1720 /* Set up access control for DECL. */
1721 TREE_PRIVATE (decl)
1722 = (current_access_specifier == access_private_node);
1723 TREE_PROTECTED (decl)
1724 = (current_access_specifier == access_protected_node);
1725 if (TREE_CODE (decl) == TEMPLATE_DECL)
1726 {
1727 TREE_PRIVATE (DECL_RESULT (decl)) = TREE_PRIVATE (decl);
1728 TREE_PROTECTED (DECL_RESULT (decl)) = TREE_PROTECTED (decl);
1729 }
1730
1731 /* Mark the DECL as a member of the current class. */
1732 if (TREE_CODE (decl) == FUNCTION_DECL
1733 || DECL_FUNCTION_TEMPLATE_P (decl))
1734 /* Historically, DECL_CONTEXT was not set for a FUNCTION_DECL in
1735 finish_struct. Presumably it is already set as the function is
1736 parsed. Perhaps DECL_CLASS_CONTEXT is already set, too? */
1737 DECL_CLASS_CONTEXT (decl) = current_class_type;
1738 else
1739 DECL_CONTEXT (decl) = current_class_type;
1740
1741 /* Put functions on the TYPE_METHODS list and everything else on the
1742 TYPE_FIELDS list. Note that these are built up in reverse order.
1743 We reverse them (to obtain declaration order) in finish_struct. */
1744 if (TREE_CODE (decl) == FUNCTION_DECL
1745 || DECL_FUNCTION_TEMPLATE_P (decl))
1746 {
1747 /* We also need to add this function to the
1748 CLASSTYPE_METHOD_VEC. */
1749 add_method (current_class_type, 0, decl);
1750
1751 TREE_CHAIN (decl) = TYPE_METHODS (current_class_type);
1752 TYPE_METHODS (current_class_type) = decl;
1753 }
1754 else
1755 {
1756 /* All TYPE_DECLs go at the end of TYPE_FIELDS. Ordinary fields
1757 go at the beginning. The reason is that lookup_field_1
1758 searches the list in order, and we want a field name to
1759 override a type name so that the "struct stat hack" will
1760 work. In particular:
1761
1762 struct S { enum E { }; int E } s;
1763 s.E = 3;
1764
1765 is legal. In addition, the FIELD_DECLs must be maintained in
1766 declaration order so that class layout works as expected.
1767 However, we don't need that order until class layout, so we
1768 save a little time by putting FIELD_DECLs on in reverse order
1769 here, and then reversing them in finish_struct_1. (We could
1770 also keep a pointer to the correct insertion points in the
1771 list.) */
1772
1773 if (TREE_CODE (decl) == TYPE_DECL)
1774 TYPE_FIELDS (current_class_type)
1775 = chainon (TYPE_FIELDS (current_class_type), decl);
1776 else
1777 {
1778 TREE_CHAIN (decl) = TYPE_FIELDS (current_class_type);
1779 TYPE_FIELDS (current_class_type) = decl;
1780 }
1781
1782 /* Enter the DECL into the scope of the class. */
1783 if (TREE_CODE (decl) != USING_DECL)
1784 pushdecl_class_level (decl);
1785 }
1786 }
1787
1788 /* Finish a class definition T with the indicate ATTRIBUTES. If SEMI,
1789 the definition is immediately followed by a semicolon. Returns the
1790 type. */
1791
1792 tree
1793 finish_class_definition (t, attributes, semi, pop_scope_p)
1794 tree t;
1795 tree attributes;
1796 int semi;
1797 int pop_scope_p;
1798 {
1799 /* finish_struct nukes this anyway; if finish_exception does too,
1800 then it can go. */
1801 if (semi)
1802 note_got_semicolon (t);
1803
1804 /* If we got any attributes in class_head, xref_tag will stick them in
1805 TREE_TYPE of the type. Grab them now. */
1806 attributes = chainon (TREE_TYPE (t), attributes);
1807 TREE_TYPE (t) = NULL_TREE;
1808
1809 if (TREE_CODE (t) == ENUMERAL_TYPE)
1810 ;
1811 else
1812 {
1813 t = finish_struct (t, attributes);
1814 if (semi)
1815 note_got_semicolon (t);
1816 }
1817
1818 pop_obstacks ();
1819
1820 if (! semi)
1821 check_for_missing_semicolon (t);
1822 if (pop_scope_p)
1823 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (t)));
1824 if (current_scope () == current_function_decl)
1825 do_pending_defargs ();
1826
1827 return t;
1828 }
1829
1830 /* Finish processing the default argument expressions cached during
1831 the processing of a class definition. */
1832
1833 void
1834 begin_inline_definitions ()
1835 {
1836 if (pending_inlines
1837 && current_scope () == current_function_decl)
1838 do_pending_inlines ();
1839 }
1840
1841 /* Finish processing the inline function definitions cached during the
1842 processing of a class definition. */
1843
1844 void
1845 finish_inline_definitions ()
1846 {
1847 if (current_class_type == NULL_TREE)
1848 clear_inline_text_obstack ();
1849
1850 /* Undo the begin_tree in begin_class_definition. */
1851 end_tree ();
1852 }
1853
1854 /* Finish processing the declaration of a member class template
1855 TYPES whose template parameters are given by PARMS. */
1856
1857 tree
1858 finish_member_class_template (types)
1859 tree types;
1860 {
1861 tree t;
1862
1863 /* If there are declared, but undefined, partial specializations
1864 mixed in with the typespecs they will not yet have passed through
1865 maybe_process_partial_specialization, so we do that here. */
1866 for (t = types; t != NULL_TREE; t = TREE_CHAIN (t))
1867 if (IS_AGGR_TYPE_CODE (TREE_CODE (TREE_VALUE (t))))
1868 maybe_process_partial_specialization (TREE_VALUE (t));
1869
1870 note_list_got_semicolon (types);
1871 grok_x_components (types);
1872 if (TYPE_CONTEXT (TREE_VALUE (types)) != current_class_type)
1873 /* The component was in fact a friend declaration. We avoid
1874 finish_member_template_decl performing certain checks by
1875 unsetting TYPES. */
1876 types = NULL_TREE;
1877
1878 finish_member_template_decl (types);
1879
1880 /* As with other component type declarations, we do
1881 not store the new DECL on the list of
1882 component_decls. */
1883 return NULL_TREE;
1884 }
1885
1886 /* Finish processsing a complete template declaration. The PARMS are
1887 the template parameters. */
1888
1889 void
1890 finish_template_decl (parms)
1891 tree parms;
1892 {
1893 if (parms)
1894 end_template_decl ();
1895 else
1896 end_specialization ();
1897 }
1898
1899 /* Finish processing a a template-id (which names a type) of the form
1900 NAME < ARGS >. Return the TYPE_DECL for the type named by the
1901 template-id. If ENTERING_SCOPE is non-zero we are about to enter
1902 the scope of template-id indicated. */
1903
1904 tree
1905 finish_template_type (name, args, entering_scope)
1906 tree name;
1907 tree args;
1908 int entering_scope;
1909 {
1910 tree decl;
1911
1912 decl = lookup_template_class (name, args,
1913 NULL_TREE, NULL_TREE, entering_scope);
1914 if (decl != error_mark_node)
1915 decl = TYPE_STUB_DECL (decl);
1916
1917 return decl;
1918 }
1919
1920 /* SR is a SCOPE_REF node. Enter the scope of SR, whether it is a
1921 namespace scope or a class scope. */
1922
1923 void
1924 enter_scope_of (sr)
1925 tree sr;
1926 {
1927 tree scope = TREE_OPERAND (sr, 0);
1928
1929 if (TREE_CODE (scope) == NAMESPACE_DECL)
1930 {
1931 push_decl_namespace (scope);
1932 TREE_COMPLEXITY (sr) = -1;
1933 }
1934 else if (scope != current_class_type)
1935 {
1936 if (TREE_CODE (scope) == TYPENAME_TYPE)
1937 {
1938 /* In a declarator for a template class member, the scope will
1939 get here as an implicit typename, a TYPENAME_TYPE with a type. */
1940 scope = TREE_TYPE (scope);
1941 TREE_OPERAND (sr, 0) = scope;
1942 }
1943 push_nested_class (scope, 3);
1944 TREE_COMPLEXITY (sr) = current_class_depth;
1945 }
1946 }
1947
1948 /* Finish processing a BASE_CLASS with the indicated ACCESS_SPECIFIER.
1949 Return a TREE_LIST containing the ACCESS_SPECIFIER and the
1950 BASE_CLASS, or NULL_TREE if an error occurred. The
1951 ACCESSS_SPECIFIER is one of
1952 access_{default,public,protected_private}[_virtual]_node.*/
1953
1954 tree
1955 finish_base_specifier (access_specifier, base_class)
1956 tree access_specifier;
1957 tree base_class;
1958 {
1959 tree type;
1960 tree result;
1961
1962 if (base_class == NULL_TREE)
1963 {
1964 error ("invalid base class");
1965 type = error_mark_node;
1966 }
1967 else
1968 type = TREE_TYPE (base_class);
1969
1970 if (! is_aggr_type (type, 1))
1971 result = NULL_TREE;
1972 else
1973 result = build_tree_list (access_specifier, type);
1974
1975 return result;
1976 }
1977
1978 /* Called when multiple declarators are processed. If that is not
1979 premitted in this context, an error is issued. */
1980
1981 void
1982 check_multiple_declarators ()
1983 {
1984 /* [temp]
1985
1986 In a template-declaration, explicit specialization, or explicit
1987 instantiation the init-declarator-list in the declaration shall
1988 contain at most one declarator.
1989
1990 We don't just use PROCESSING_TEMPLATE_DECL for the first
1991 condition since that would disallow the perfectly legal code,
1992 like `template <class T> struct S { int i, j; };'. */
1993 tree scope = current_scope ();
1994
1995 if (scope && TREE_CODE (scope) == FUNCTION_DECL)
1996 /* It's OK to write `template <class T> void f() { int i, j;}'. */
1997 return;
1998
1999 if (PROCESSING_REAL_TEMPLATE_DECL_P ()
2000 || processing_explicit_instantiation
2001 || processing_specialization)
2002 cp_error ("multiple declarators in template declaration");
2003 }
2004
2005 tree
2006 finish_typeof (expr)
2007 tree expr;
2008 {
2009 if (processing_template_decl)
2010 {
2011 tree t;
2012
2013 push_permanent_obstack ();
2014 t = make_lang_type (TYPEOF_TYPE);
2015 TYPE_FIELDS (t) = expr;
2016 pop_obstacks ();
2017
2018 return t;
2019 }
2020
2021 return TREE_TYPE (expr);
2022 }
2023
2024 /* Create an empty statement tree for FN. */
2025
2026 void
2027 begin_stmt_tree (fn)
2028 tree fn;
2029 {
2030 /* We create a trivial EXPR_STMT so that last_tree is never NULL in
2031 what follows. We remove the extraneous statement in
2032 finish_stmt_tree. */
2033 DECL_SAVED_TREE (fn) = build_nt (EXPR_STMT, void_zero_node);
2034 last_tree = DECL_SAVED_TREE (fn);
2035 last_expr_type = NULL_TREE;
2036 }
2037
2038 /* Finish the statement tree for FN. */
2039
2040 void
2041 finish_stmt_tree (fn)
2042 tree fn;
2043 {
2044 tree stmt;
2045
2046 /* Remove the fake extra statement added in begin_stmt_tree. */
2047 stmt = TREE_CHAIN (DECL_SAVED_TREE (fn));
2048 DECL_SAVED_TREE (fn) = stmt;
2049
2050 /* The line-number recorded in the outermost statement in a function
2051 is the line number of the end of the function. */
2052 STMT_LINENO (stmt) = lineno;
2053 STMT_LINENO_FOR_FN_P (stmt) = 1;
2054 }
2055
2056 /* We're about to expand T, a statement. Set up appropriate context
2057 for the substitution. */
2058
2059 void
2060 prep_stmt (t)
2061 tree t;
2062 {
2063 if (!STMT_LINENO_FOR_FN_P (t))
2064 lineno = STMT_LINENO (t);
2065 stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t);
2066 }
2067
2068 /* Some statements, like for-statements or if-statements, require a
2069 condition. This condition can be a declaration. If T is such a
2070 declaration it is processed, and an expression appropriate to use
2071 as the condition is returned. Otherwise, T itself is returned. */
2072
2073 static tree
2074 expand_cond (t)
2075 tree t;
2076 {
2077 if (t && TREE_CODE (t) == TREE_LIST)
2078 {
2079 expand_stmt (TREE_PURPOSE (t));
2080 return TREE_VALUE (t);
2081 }
2082 else
2083 return t;
2084 }
2085
2086 /* Generate RTL for the statement T, and its substatements, and any
2087 other statements at its nesting level. */
2088
2089 tree
2090 expand_stmt (t)
2091 tree t;
2092 {
2093 tree rval;
2094
2095 while (t && t != error_mark_node)
2096 {
2097 int saved_stmts_are_full_exprs_p;
2098
2099 /* Assume we'll have nothing to return. */
2100 rval = NULL_TREE;
2101
2102 /* Set up context appropriately for handling this statement. */
2103 saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p;
2104 prep_stmt (t);
2105
2106 switch (TREE_CODE (t))
2107 {
2108 case RETURN_STMT:
2109 finish_return_stmt (RETURN_EXPR (t));
2110 break;
2111
2112 case EXPR_STMT:
2113 finish_expr_stmt_real (EXPR_STMT_EXPR (t),
2114 EXPR_STMT_ASSIGNS_THIS (t));
2115 break;
2116
2117 case DECL_STMT:
2118 {
2119 tree decl;
2120 int i = suspend_momentary ();
2121
2122 emit_line_note (input_filename, lineno);
2123 decl = DECL_STMT_DECL (t);
2124 if (TREE_CODE (decl) == LABEL_DECL)
2125 finish_label_decl (DECL_NAME (decl));
2126 else
2127 {
2128 /* If we marked this variable as dead when we processed it
2129 before, we must undo that now. The variable has been
2130 resuscitated. */
2131 if (TREE_CODE (decl) == VAR_DECL)
2132 DECL_DEAD_FOR_LOCAL (decl) = 0;
2133 /* We need to clear DECL_CONTEXT so that maybe_push_decl
2134 will push it into the current scope. */
2135 if (DECL_CONTEXT (decl) == current_function_decl)
2136 {
2137 DECL_CONTEXT (decl) = NULL_TREE;
2138 maybe_push_decl (decl);
2139 }
2140 /* If this is a declaration for an automatic local
2141 variable, initialize it. Note that we might also see a
2142 declaration for a namespace-scope object (declared with
2143 `extern') or an object with static storage duration
2144 (declared with `static'). We don't have to handle the
2145 initialization of those objects here; the former can
2146 never be a definition (only a declaration), and the
2147 latter is handled in finish_file. */
2148 if (TREE_CODE (decl) == VAR_DECL
2149 && !TREE_STATIC (decl)
2150 && !DECL_EXTERNAL (decl))
2151 {
2152 /* Support the old for-scope rules for backwards
2153 compatibility. */
2154 maybe_inject_for_scope_var (decl);
2155 /* Let the back-end know about this variable. */
2156 initialize_local_var (decl, DECL_INITIAL (decl), 0);
2157 }
2158 }
2159 resume_momentary (i);
2160 }
2161 break;
2162
2163 case FOR_STMT:
2164 {
2165 tree tmp;
2166
2167 begin_for_stmt ();
2168 expand_stmt (FOR_INIT_STMT (t));
2169 finish_for_init_stmt (NULL_TREE);
2170 finish_for_cond (expand_cond (FOR_COND (t)), NULL_TREE);
2171 tmp = FOR_EXPR (t);
2172 finish_for_expr (tmp, NULL_TREE);
2173 expand_stmt (FOR_BODY (t));
2174 finish_for_stmt (tmp, NULL_TREE);
2175 }
2176 break;
2177
2178 case WHILE_STMT:
2179 {
2180 begin_while_stmt ();
2181 finish_while_stmt_cond (expand_cond (WHILE_COND (t)), NULL_TREE);
2182 expand_stmt (WHILE_BODY (t));
2183 finish_while_stmt (NULL_TREE);
2184 }
2185 break;
2186
2187 case DO_STMT:
2188 {
2189 begin_do_stmt ();
2190 expand_stmt (DO_BODY (t));
2191 finish_do_body (NULL_TREE);
2192 finish_do_stmt (DO_COND (t), NULL_TREE);
2193 }
2194 break;
2195
2196 case IF_STMT:
2197 begin_if_stmt ();
2198 finish_if_stmt_cond (expand_cond (IF_COND (t)), NULL_TREE);
2199 if (THEN_CLAUSE (t))
2200 {
2201 expand_stmt (THEN_CLAUSE (t));
2202 finish_then_clause (NULL_TREE);
2203 }
2204 if (ELSE_CLAUSE (t))
2205 {
2206 begin_else_clause ();
2207 expand_stmt (ELSE_CLAUSE (t));
2208 finish_else_clause (NULL_TREE);
2209 }
2210 finish_if_stmt ();
2211 break;
2212
2213 case COMPOUND_STMT:
2214 begin_compound_stmt (COMPOUND_STMT_NO_SCOPE (t));
2215 expand_stmt (COMPOUND_BODY (t));
2216 rval = finish_compound_stmt (COMPOUND_STMT_NO_SCOPE (t),
2217 NULL_TREE);
2218 break;
2219
2220 case BREAK_STMT:
2221 finish_break_stmt ();
2222 break;
2223
2224 case CONTINUE_STMT:
2225 finish_continue_stmt ();
2226 break;
2227
2228 case SWITCH_STMT:
2229 {
2230 tree cond;
2231
2232 begin_switch_stmt ();
2233 cond = expand_cond (SWITCH_COND (t));
2234 finish_switch_cond (cond, NULL_TREE);
2235 expand_stmt (SWITCH_BODY (t));
2236 finish_switch_stmt (cond, NULL_TREE);
2237 }
2238 break;
2239
2240 case CASE_LABEL:
2241 finish_case_label (CASE_LOW (t), CASE_HIGH (t));
2242 break;
2243
2244 case LABEL_STMT:
2245 finish_label_stmt (DECL_NAME (LABEL_STMT_LABEL (t)));
2246 break;
2247
2248 case GOTO_STMT:
2249 if (TREE_CODE (GOTO_DESTINATION (t)) == LABEL_DECL)
2250 finish_goto_stmt (DECL_NAME (GOTO_DESTINATION (t)));
2251 else
2252 finish_goto_stmt (GOTO_DESTINATION (t));
2253 break;
2254
2255 case ASM_STMT:
2256 finish_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t), ASM_OUTPUTS
2257 (t), ASM_INPUTS (t), ASM_CLOBBERS (t));
2258 break;
2259
2260 case TRY_BLOCK:
2261 if (CLEANUP_P (t))
2262 {
2263 expand_eh_region_start ();
2264 expand_stmt (TRY_STMTS (t));
2265 finish_cleanup_try_block (NULL_TREE);
2266 finish_cleanup (TRY_HANDLERS (t), NULL_TREE);
2267 }
2268 else
2269 {
2270 begin_try_block ();
2271 expand_stmt (TRY_STMTS (t));
2272 finish_try_block (NULL_TREE);
2273 expand_stmt (TRY_HANDLERS (t));
2274 finish_handler_sequence (NULL_TREE);
2275 }
2276 break;
2277
2278 case HANDLER:
2279 begin_handler ();
2280 if (HANDLER_PARMS (t))
2281 expand_start_catch_block (DECL_STMT_DECL (HANDLER_PARMS (t)));
2282 else
2283 expand_start_catch_block (NULL_TREE);
2284 finish_handler_parms (NULL_TREE);
2285 expand_stmt (HANDLER_BODY (t));
2286 finish_handler (NULL_TREE);
2287 break;
2288
2289 case SUBOBJECT:
2290 finish_subobject (SUBOBJECT_CLEANUP (t));
2291 break;
2292
2293 default:
2294 my_friendly_abort (19990810);
2295 break;
2296 }
2297
2298 /* Restore saved state. */
2299 stmts_are_full_exprs_p = saved_stmts_are_full_exprs_p;
2300
2301 /* Go on to the next statement in this scope. */
2302 t = TREE_CHAIN (t);
2303 }
2304
2305 return rval;
2306 }
2307
2308 /* Generate RTL for FN. */
2309
2310 void
2311 expand_body (fn)
2312 tree fn;
2313 {
2314 int saved_lineno;
2315 char *saved_input_filename;
2316 tree t;
2317 tree try_block;
2318
2319 /* When the parser calls us after finishing the body of a template
2320 function, we don't really want to expand the body. When we're
2321 processing an in-class definition of an inline function,
2322 PROCESSING_TEMPLATE_DECL will no longer be set here, so we have
2323 to look at the function itself. */
2324 if (processing_template_decl
2325 || (DECL_LANG_SPECIFIC (fn)
2326 && DECL_TEMPLATE_INFO (fn)
2327 && uses_template_parms (DECL_TI_ARGS (fn))))
2328 return;
2329
2330 /* Save the current file name and line number. When we expand the
2331 body of the funciton, we'll set LINENO and INPUT_FILENAME so that
2332 error-mesages come out in the right places. */
2333 saved_lineno = lineno;
2334 saved_input_filename = input_filename;
2335 lineno = DECL_SOURCE_LINE (fn);
2336 input_filename = DECL_SOURCE_FILE (fn);
2337
2338 start_function (NULL_TREE, fn, NULL_TREE, SF_PRE_PARSED | SF_EXPAND);
2339 store_parm_decls ();
2340
2341 /* There are a few things that we do not handle recursively. For
2342 example, a function try-block is handled differently from an
2343 ordinary try-block, so we must handle it here. */
2344 t = DECL_SAVED_TREE (fn);
2345 try_block = NULL_TREE;
2346 if (t && TREE_CODE (t) == TRY_BLOCK)
2347 {
2348 try_block = t;
2349 begin_function_try_block ();
2350 t = TRY_STMTS (try_block);
2351 }
2352
2353 if (t && TREE_CODE (t) == RETURN_INIT)
2354 {
2355 /* Clear this out so that finish_named_return_value can set it
2356 again. */
2357 DECL_NAME (DECL_RESULT (fn)) = NULL_TREE;
2358 finish_named_return_value (TREE_OPERAND (t, 0), TREE_OPERAND (t, 1));
2359 t = TREE_CHAIN (t);
2360 }
2361
2362 if (t && TREE_CODE (t) == CTOR_INITIALIZER)
2363 {
2364 current_member_init_list = TREE_OPERAND (t, 0);
2365 current_base_init_list = TREE_OPERAND (t, 1);
2366 t = TREE_CHAIN (t);
2367 }
2368
2369 /* If this is a constructor, we need to initialize our members and
2370 base-classes. */
2371 setup_vtbl_ptr ();
2372
2373 /* Expand the body. */
2374 expand_stmt (t);
2375
2376 /* If there was a function try-block, expand the handlers. */
2377 if (try_block)
2378 {
2379 finish_function_try_block (NULL_TREE);
2380 expand_stmt (TRY_HANDLERS (try_block));
2381 finish_function_handler_sequence (NULL_TREE);
2382 }
2383
2384 /* Statements should always be full-expressions at the outermost set
2385 of curly braces for a function. */
2386 my_friendly_assert (stmts_are_full_exprs_p, 19990831);
2387
2388 /* The outermost statement for a function contains the line number
2389 recorded when we finished processing the function. */
2390 lineno = STMT_LINENO (DECL_SAVED_TREE (fn));
2391
2392 /* Generate code for the function. */
2393 finish_function (lineno, 0);
2394
2395 /* And restore the current source position. */
2396 lineno = saved_lineno;
2397 input_filename = saved_input_filename;
2398 }