OSDN Git Service

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