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