OSDN Git Service

* configure.in: Fix typo.
[pf3gnuchains/gcc-fork.git] / gcc / c-semantics.c
1 /* This file contains the definitions and documentation for the common
2    tree codes used in the GNU C and C++ compilers (see c-common.def
3    for the standard codes).  
4    Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
5    Written by Benjamin Chelf (chelf@codesourcery.com).
6
7 This file is part of GCC.
8
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
12 version.
13
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17 for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING.  If not, write to the Free
21 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 02111-1307, USA.  */
23
24 #include "config.h"
25 #include "system.h"
26 #include "coretypes.h"
27 #include "tm.h"
28 #include "tree.h"
29 #include "function.h"
30 #include "splay-tree.h"
31 #include "varray.h"
32 #include "c-common.h"
33 #include "except.h"
34 #include "toplev.h"
35 #include "flags.h"
36 #include "ggc.h"
37 #include "rtl.h"
38 #include "expr.h"
39 #include "output.h"
40 #include "timevar.h"
41 #include "predict.h"
42
43 /* If non-NULL, the address of a language-specific function for
44    expanding statements.  */
45 void (*lang_expand_stmt) PARAMS ((tree));
46
47 /* If non-NULL, the address of a language-specific function for
48    expanding a DECL_STMT.  After the language-independent cases are
49    handled, this function will be called.  If this function is not
50    defined, it is assumed that declarations other than those for
51    variables and labels do not require any RTL generation.  */
52 void (*lang_expand_decl_stmt) PARAMS ((tree));
53
54 /* Create an empty statement tree rooted at T.  */
55
56 void
57 begin_stmt_tree (t)
58      tree *t;
59 {
60   /* We create a trivial EXPR_STMT so that last_tree is never NULL in
61      what follows.  We remove the extraneous statement in
62      finish_stmt_tree.  */
63   *t = build_nt (EXPR_STMT, void_zero_node);
64   last_tree = *t;
65   last_expr_type = NULL_TREE;
66   last_expr_filename = input_filename;
67 }
68
69 /* T is a statement.  Add it to the statement-tree.  */
70
71 tree
72 add_stmt (t)
73      tree t;
74 {
75   if (input_filename != last_expr_filename)
76     {
77       /* If the filename has changed, also add in a FILE_STMT.  Do a string
78          compare first, though, as it might be an equivalent string.  */
79       int add = (strcmp (input_filename, last_expr_filename) != 0);
80       last_expr_filename = input_filename;
81       if (add)
82         {
83           tree pos = build_nt (FILE_STMT, get_identifier (input_filename));
84           add_stmt (pos);
85         }
86     }
87
88   /* Add T to the statement-tree.  */
89   TREE_CHAIN (last_tree) = t;
90   last_tree = t;
91   
92   /* When we expand a statement-tree, we must know whether or not the
93      statements are full-expressions.  We record that fact here.  */
94   STMT_IS_FULL_EXPR_P (last_tree) = stmts_are_full_exprs_p ();
95
96   /* Keep track of the number of statements in this function.  */
97   if (current_function_decl)
98     ++DECL_NUM_STMTS (current_function_decl);
99
100   return t;
101 }
102
103 /* Create a declaration statement for the declaration given by the
104    DECL.  */
105
106 void
107 add_decl_stmt (decl)
108      tree decl;
109 {
110   tree decl_stmt;
111
112   /* We need the type to last until instantiation time.  */
113   decl_stmt = build_stmt (DECL_STMT, decl);
114   add_stmt (decl_stmt); 
115 }
116
117 /* Add a scope-statement to the statement-tree.  BEGIN_P indicates
118    whether this statements opens or closes a scope.  PARTIAL_P is true
119    for a partial scope, i.e, the scope that begins after a label when
120    an object that needs a cleanup is created.  If BEGIN_P is nonzero,
121    returns a new TREE_LIST representing the top of the SCOPE_STMT
122    stack.  The TREE_PURPOSE is the new SCOPE_STMT.  If BEGIN_P is
123    zero, returns a TREE_LIST whose TREE_VALUE is the new SCOPE_STMT,
124    and whose TREE_PURPOSE is the matching SCOPE_STMT with
125    SCOPE_BEGIN_P set.  */
126
127 tree
128 add_scope_stmt (begin_p, partial_p)
129      int begin_p;
130      int partial_p;
131 {
132   tree *stack_ptr = current_scope_stmt_stack ();
133   tree ss;
134   tree top = *stack_ptr;
135
136   /* Build the statement.  */
137   ss = build_stmt (SCOPE_STMT, NULL_TREE);
138   SCOPE_BEGIN_P (ss) = begin_p;
139   SCOPE_PARTIAL_P (ss) = partial_p;
140
141   /* Keep the scope stack up to date.  */
142   if (begin_p)
143     {
144       top = tree_cons (ss, NULL_TREE, top);
145       *stack_ptr = top;
146     }
147   else
148     {
149       if (partial_p != SCOPE_PARTIAL_P (TREE_PURPOSE (top)))
150         abort ();
151       TREE_VALUE (top) = ss;
152       *stack_ptr = TREE_CHAIN (top);
153     }
154
155   /* Add the new statement to the statement-tree.  */
156   add_stmt (ss);
157
158   return top;
159 }
160
161 /* Finish the statement tree rooted at T.  */
162
163 void
164 finish_stmt_tree (t)
165      tree *t;
166 {
167   tree stmt;
168   
169   /* Remove the fake extra statement added in begin_stmt_tree.  */
170   stmt = TREE_CHAIN (*t);
171   *t = stmt;
172   last_tree = NULL_TREE;
173
174   if (cfun && stmt)
175     {
176       /* The line-number recorded in the outermost statement in a function
177          is the line number of the end of the function.  */
178       STMT_LINENO (stmt) = lineno;
179       STMT_LINENO_FOR_FN_P (stmt) = 1;
180     }
181 }
182
183 /* Build a generic statement based on the given type of node and
184    arguments. Similar to `build_nt', except that we set
185    STMT_LINENO to be the current line number.  */
186 /* ??? This should be obsolete with the lineno_stmt productions
187    in the grammar.  */
188
189 tree
190 build_stmt VPARAMS ((enum tree_code code, ...))
191 {
192   tree t;
193   int length;
194   int i;
195
196   VA_OPEN (p, code);
197   VA_FIXEDARG (p, enum tree_code, code);
198
199   t = make_node (code);
200   length = TREE_CODE_LENGTH (code);
201   STMT_LINENO (t) = lineno;
202
203   for (i = 0; i < length; i++)
204     TREE_OPERAND (t, i) = va_arg (p, tree);
205
206   VA_CLOSE (p);
207   return t;
208 }
209
210 /* Some statements, like for-statements or if-statements, require a
211    condition.  This condition can be a declaration.  If T is such a
212    declaration it is processed, and an expression appropriate to use
213    as the condition is returned.  Otherwise, T itself is returned.  */
214
215 tree
216 expand_cond (t)
217      tree t;
218 {
219   if (t && TREE_CODE (t) == TREE_LIST)
220     {
221       expand_stmt (TREE_PURPOSE (t));
222       return TREE_VALUE (t);
223     }
224   else 
225     return t;
226 }
227
228 /* Create RTL for the local static variable DECL.  */
229
230 void
231 make_rtl_for_local_static (decl)
232      tree decl;
233 {
234   const char *asmspec = NULL;
235
236   /* If we inlined this variable, we could see it's declaration
237      again.  */
238   if (TREE_ASM_WRITTEN (decl))
239     return;
240
241   /* If the DECL_ASSEMBLER_NAME is not the same as the DECL_NAME, then
242      either we already created RTL for this DECL (and since it was a
243      local variable, its DECL_ASSEMBLER_NAME got hacked up to prevent
244      clashes with other local statics with the same name by a previous
245      call to make_decl_rtl), or the user explicitly requested a
246      particular assembly name for this variable, using the GNU
247      extension for this purpose:
248
249        int i asm ("j");
250
251      There's no way to know which case we're in, here.  But, it turns
252      out we're safe.  If there's already RTL, then
253      rest_of_decl_compilation ignores the ASMSPEC parameter, so we
254      may as well not pass it in.  If there isn't RTL, then we didn't
255      already create RTL, which means that the modification to
256      DECL_ASSEMBLER_NAME came only via the explicit extension.  */
257   if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl)
258       && !DECL_RTL_SET_P (decl))
259     asmspec = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
260
261   rest_of_decl_compilation (decl, asmspec, /*top_level=*/0, /*at_end=*/0);
262 }
263
264 /* Let the back-end know about DECL.  */
265
266 void
267 emit_local_var (decl)
268      tree decl;
269 {
270   /* Create RTL for this variable.  */
271   if (!DECL_RTL_SET_P (decl))
272     {
273       if (DECL_C_HARD_REGISTER (decl))
274         /* The user specified an assembler name for this variable.
275            Set that up now.  */
276         rest_of_decl_compilation
277           (decl, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
278            /*top_level=*/0, /*at_end=*/0);
279       else
280         expand_decl (decl);
281     }
282
283   /* Actually do the initialization.  */
284   if (stmts_are_full_exprs_p ())
285     expand_start_target_temps ();
286
287   expand_decl_init (decl);
288
289   if (stmts_are_full_exprs_p ())
290     expand_end_target_temps ();
291 }
292
293 /* Helper for generating the RTL at the beginning of a scope.  */
294
295 void
296 genrtl_do_pushlevel ()
297 {
298   emit_line_note (input_filename, lineno);
299   clear_last_expr ();
300 }
301
302 /* Generate the RTL for DESTINATION, which is a GOTO_STMT.  */
303
304 void
305 genrtl_goto_stmt (destination)
306      tree destination;
307 {
308   if (TREE_CODE (destination) == IDENTIFIER_NODE)
309     abort ();
310   
311   /* We warn about unused labels with -Wunused.  That means we have to
312      mark the used labels as used.  */
313   if (TREE_CODE (destination) == LABEL_DECL)
314     TREE_USED (destination) = 1;
315   
316   emit_line_note (input_filename, lineno);
317   
318   if (TREE_CODE (destination) == LABEL_DECL)
319     {
320       label_rtx (destination);
321       expand_goto (destination); 
322     }
323   else
324     expand_computed_goto (destination);
325 }
326
327 /* Generate the RTL for EXPR, which is an EXPR_STMT.  Provided just
328    for backward compatibility.  genrtl_expr_stmt_value() should be
329    used for new code.  */
330
331 void
332 genrtl_expr_stmt (expr)
333      tree expr;
334 {
335   genrtl_expr_stmt_value (expr, -1, 1);
336 }
337
338 /* Generate the RTL for EXPR, which is an EXPR_STMT.  WANT_VALUE tells
339    whether to (1) save the value of the expression, (0) discard it or
340    (-1) use expr_stmts_for_value to tell.  The use of -1 is
341    deprecated, and retained only for backward compatibility.
342    MAYBE_LAST is nonzero if this EXPR_STMT might be the last statement
343    in expression statement.  */
344
345 void 
346 genrtl_expr_stmt_value (expr, want_value, maybe_last)
347      tree expr;
348      int want_value, maybe_last;
349 {
350   if (expr != NULL_TREE)
351     {
352       emit_line_note (input_filename, lineno);
353       
354       if (stmts_are_full_exprs_p ())
355         expand_start_target_temps ();
356       
357       if (expr != error_mark_node)
358         expand_expr_stmt_value (expr, want_value, maybe_last);
359       
360       if (stmts_are_full_exprs_p ())
361         expand_end_target_temps ();
362     }
363 }
364
365 /* Generate the RTL for T, which is a DECL_STMT.  */
366
367 void
368 genrtl_decl_stmt (t)
369      tree t;
370 {
371   tree decl;
372   emit_line_note (input_filename, lineno);
373   decl = DECL_STMT_DECL (t);
374   /* If this is a declaration for an automatic local
375      variable, initialize it.  Note that we might also see a
376      declaration for a namespace-scope object (declared with
377      `extern').  We don't have to handle the initialization
378      of those objects here; they can only be declarations,
379      rather than definitions.  */
380   if (TREE_CODE (decl) == VAR_DECL 
381       && !TREE_STATIC (decl)
382       && !DECL_EXTERNAL (decl))
383     {
384       /* Let the back-end know about this variable.  */
385       if (!anon_aggr_type_p (TREE_TYPE (decl)))
386         emit_local_var (decl);
387       else
388         expand_anon_union_decl (decl, NULL_TREE, 
389                                 DECL_ANON_UNION_ELEMS (decl));
390     }
391   else if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
392     make_rtl_for_local_static (decl);
393   else if (TREE_CODE (decl) == LABEL_DECL 
394            && C_DECLARED_LABEL_FLAG (decl))
395     declare_nonlocal_label (decl);
396   else if (lang_expand_decl_stmt)
397     (*lang_expand_decl_stmt) (t);
398 }
399
400 /* Generate the RTL for T, which is an IF_STMT.  */
401
402 void
403 genrtl_if_stmt (t)
404      tree t;
405 {
406   tree cond;
407   genrtl_do_pushlevel ();
408   cond = expand_cond (IF_COND (t));
409   emit_line_note (input_filename, lineno);
410   expand_start_cond (cond, 0);
411   if (THEN_CLAUSE (t))
412     expand_stmt (THEN_CLAUSE (t));
413   if (ELSE_CLAUSE (t))
414     {
415       expand_start_else ();
416       expand_stmt (ELSE_CLAUSE (t));
417     }
418   expand_end_cond ();
419 }
420
421 /* Generate the RTL for T, which is a WHILE_STMT.  */
422
423 void
424 genrtl_while_stmt (t)
425      tree t;
426 {
427   tree cond = WHILE_COND (t);
428
429   emit_nop ();
430   emit_line_note (input_filename, lineno);
431   expand_start_loop (1); 
432   genrtl_do_pushlevel ();
433
434   if (cond && !integer_nonzerop (cond))
435     {
436       cond = expand_cond (cond);
437       emit_line_note (input_filename, lineno);
438       expand_exit_loop_top_cond (0, cond);
439       genrtl_do_pushlevel ();
440     }
441   
442   expand_stmt (WHILE_BODY (t));
443
444   expand_end_loop ();
445 }
446
447 /* Generate the RTL for T, which is a DO_STMT.  */
448
449 void
450 genrtl_do_stmt (t)
451      tree t;
452 {
453   tree cond = DO_COND (t);
454
455   /* Recognize the common special-case of do { ... } while (0) and do
456      not emit the loop widgetry in this case.  In particular this
457      avoids cluttering the rtl with dummy loop notes, which can affect
458      alignment of adjacent labels.  COND can be NULL due to parse
459      errors.  */
460   if (!cond || integer_zerop (cond))
461     {
462       expand_start_null_loop ();
463       expand_stmt (DO_BODY (t));
464       expand_end_null_loop ();
465     }
466   else if (integer_nonzerop (cond))
467     {
468       emit_nop ();
469       emit_line_note (input_filename, lineno);
470       expand_start_loop (1);
471
472       expand_stmt (DO_BODY (t));
473
474       emit_line_note (input_filename, lineno);
475       expand_end_loop ();
476     }
477   else
478     {
479       emit_nop ();
480       emit_line_note (input_filename, lineno);
481       expand_start_loop_continue_elsewhere (1);
482
483       expand_stmt (DO_BODY (t));
484
485       expand_loop_continue_here ();
486       cond = expand_cond (cond);
487       emit_line_note (input_filename, lineno);
488       expand_exit_loop_if_false (0, cond);
489       expand_end_loop ();
490     }
491 }
492
493 /* Build the node for a return statement and return it.  */
494
495 tree
496 build_return_stmt (expr)
497      tree expr;
498 {
499   return (build_stmt (RETURN_STMT, expr));
500 }
501
502 /* Generate the RTL for STMT, which is a RETURN_STMT.  */
503
504 void
505 genrtl_return_stmt (stmt)
506      tree stmt;
507 {
508   tree expr;
509
510   expr = RETURN_STMT_EXPR (stmt);
511
512   emit_line_note (input_filename, lineno);
513   if (!expr)
514     expand_null_return ();
515   else
516     {
517       expand_start_target_temps ();
518       expand_return (expr);
519       expand_end_target_temps ();
520     }
521 }
522
523 /* Generate the RTL for T, which is a FOR_STMT.  */
524
525 void
526 genrtl_for_stmt (t)
527      tree t;
528 {
529   tree cond = FOR_COND (t);
530   const char *saved_filename;
531   int saved_lineno;
532
533   if (NEW_FOR_SCOPE_P (t))
534     genrtl_do_pushlevel ();
535
536   expand_stmt (FOR_INIT_STMT (t));
537
538   /* Expand the initialization.  */
539   emit_nop ();
540   emit_line_note (input_filename, lineno);
541   if (FOR_EXPR (t))
542     expand_start_loop_continue_elsewhere (1); 
543   else
544     expand_start_loop (1);
545   genrtl_do_pushlevel ();
546
547   /* Save the filename and line number so that we expand the FOR_EXPR
548      we can reset them back to the saved values.  */
549   saved_filename = input_filename;
550   saved_lineno = lineno;
551
552   /* Expand the condition.  */
553   if (cond && !integer_nonzerop (cond))
554     {
555       cond = expand_cond (cond);
556       emit_line_note (input_filename, lineno);
557       expand_exit_loop_top_cond (0, cond);
558       genrtl_do_pushlevel ();
559     }
560
561   /* Expand the body.  */
562   expand_stmt (FOR_BODY (t));
563
564   /* Expand the increment expression.  */
565   input_filename = saved_filename;
566   lineno = saved_lineno;
567   emit_line_note (input_filename, lineno);
568   if (FOR_EXPR (t))
569     {
570       expand_loop_continue_here ();
571       genrtl_expr_stmt (FOR_EXPR (t));
572     }
573   expand_end_loop ();
574 }
575
576 /* Build a break statement node and return it.  */
577
578 tree
579 build_break_stmt ()
580 {
581   return (build_stmt (BREAK_STMT));
582 }
583
584 /* Generate the RTL for a BREAK_STMT.  */
585
586 void
587 genrtl_break_stmt ()
588 {
589   emit_line_note (input_filename, lineno);
590   if ( ! expand_exit_something ())
591     error ("break statement not within loop or switch");
592 }
593
594 /* Build a continue statement node and return it.  */
595
596 tree
597 build_continue_stmt ()
598 {
599   return (build_stmt (CONTINUE_STMT));
600 }
601
602 /* Generate the RTL for a CONTINUE_STMT.  */
603
604 void
605 genrtl_continue_stmt ()
606 {
607   emit_line_note (input_filename, lineno);
608   if (! expand_continue_loop (0))
609     error ("continue statement not within a loop");   
610 }
611
612 /* Generate the RTL for T, which is a SCOPE_STMT.  */
613
614 void
615 genrtl_scope_stmt (t)
616      tree t;
617 {
618   tree block = SCOPE_STMT_BLOCK (t);
619
620   if (!SCOPE_NO_CLEANUPS_P (t))
621     {
622       if (SCOPE_BEGIN_P (t))
623         expand_start_bindings_and_block (2 * SCOPE_NULLIFIED_P (t), block);
624       else if (SCOPE_END_P (t))
625         expand_end_bindings (NULL_TREE, !SCOPE_NULLIFIED_P (t), 0);
626     }
627   else if (!SCOPE_NULLIFIED_P (t))
628     {
629       rtx note = emit_note (NULL,
630                             (SCOPE_BEGIN_P (t) 
631                              ? NOTE_INSN_BLOCK_BEG
632                              : NOTE_INSN_BLOCK_END));
633       NOTE_BLOCK (note) = block;
634     }
635
636   /* If we're at the end of a scope that contains inlined nested
637      functions, we have to decide whether or not to write them out.  */
638   if (block && SCOPE_END_P (t))
639     {
640       tree fn;
641
642       for (fn = BLOCK_VARS (block); fn; fn = TREE_CHAIN (fn))
643         {
644           if (TREE_CODE (fn) == FUNCTION_DECL 
645               && DECL_CONTEXT (fn) == current_function_decl
646               && DECL_SAVED_INSNS (fn)
647               && !TREE_ASM_WRITTEN (fn)
648               && TREE_ADDRESSABLE (fn))
649             {
650               push_function_context ();
651               output_inline_function (fn);
652               pop_function_context ();
653             }
654         }
655     }
656 }
657
658 /* Generate the RTL for T, which is a SWITCH_STMT.  */
659
660 void
661 genrtl_switch_stmt (t)
662      tree t;
663 {
664   tree cond;
665   genrtl_do_pushlevel ();
666  
667   cond = expand_cond (SWITCH_COND (t));
668   if (cond == error_mark_node)
669     /* The code is in error, but we don't want expand_end_case to
670        crash.  */
671     cond = boolean_false_node;
672
673   emit_line_note (input_filename, lineno);
674   expand_start_case (1, cond, TREE_TYPE (cond), "switch statement");
675   expand_stmt (SWITCH_BODY (t));
676   expand_end_case_type (cond, SWITCH_TYPE (t));
677 }
678
679 /* Create a CASE_LABEL tree node and return it.  */
680
681 tree
682 build_case_label (low_value, high_value, label_decl)
683      tree low_value;
684      tree high_value;
685      tree label_decl;
686 {
687   return build_stmt (CASE_LABEL, low_value, high_value, label_decl);
688 }
689
690
691 /* Generate the RTL for a CASE_LABEL.  */
692
693 void 
694 genrtl_case_label (case_label)
695      tree case_label;
696 {
697   tree duplicate;
698   tree cleanup;
699
700   cleanup = last_cleanup_this_contour ();
701   if (cleanup)
702     {
703       static int explained = 0;
704       warning ("destructor needed for `%#D'", (TREE_PURPOSE (cleanup)));
705       warning ("where case label appears here");
706       if (!explained)
707         {
708           warning ("(enclose actions of previous case statements requiring destructors in their own scope.)");
709           explained = 1;
710         }
711     }
712
713   add_case_node (CASE_LOW (case_label), CASE_HIGH (case_label), 
714                  CASE_LABEL_DECL (case_label), &duplicate);
715 }
716
717 /* Generate the RTL for T, which is a COMPOUND_STMT.  */
718
719 void
720 genrtl_compound_stmt (t)
721     tree t;
722 {
723 #ifdef ENABLE_CHECKING
724   struct nesting *n = current_nesting_level ();
725 #endif
726
727   expand_stmt (COMPOUND_BODY (t));
728
729 #ifdef ENABLE_CHECKING
730   /* Make sure that we've pushed and popped the same number of levels.  */
731   if (!COMPOUND_STMT_NO_SCOPE (t) && n != current_nesting_level ())
732     abort ();
733 #endif
734 }
735
736 /* Generate the RTL for an ASM_STMT.  */
737
738 void
739 genrtl_asm_stmt (cv_qualifier, string, output_operands,
740                  input_operands, clobbers, asm_input_p)
741      tree cv_qualifier;
742      tree string;
743      tree output_operands;
744      tree input_operands;
745      tree clobbers;
746      int asm_input_p;
747 {
748   if (cv_qualifier != NULL_TREE
749       && cv_qualifier != ridpointers[(int) RID_VOLATILE])
750     {
751       warning ("%s qualifier ignored on asm",
752                IDENTIFIER_POINTER (cv_qualifier));
753       cv_qualifier = NULL_TREE;
754     }
755
756   emit_line_note (input_filename, lineno);
757   if (asm_input_p)
758     expand_asm (string, cv_qualifier != NULL_TREE);
759   else
760     c_expand_asm_operands (string, output_operands, input_operands, 
761                            clobbers, cv_qualifier != NULL_TREE,
762                            input_filename, lineno);
763 }
764
765 /* Generate the RTL for a DECL_CLEANUP.  */
766
767 void 
768 genrtl_decl_cleanup (t)
769      tree t;
770 {
771   tree decl = CLEANUP_DECL (t);
772   if (!decl || (DECL_SIZE (decl) && TREE_TYPE (decl) != error_mark_node))
773     expand_decl_cleanup_eh (decl, CLEANUP_EXPR (t), CLEANUP_EH_ONLY (t));
774 }
775
776 /* We're about to expand T, a statement.  Set up appropriate context
777    for the substitution.  */
778
779 void
780 prep_stmt (t)
781      tree t;
782 {
783   if (!STMT_LINENO_FOR_FN_P (t))
784     lineno = STMT_LINENO (t);
785   current_stmt_tree ()->stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t);
786 }
787
788 /* Generate the RTL for the statement T, its substatements, and any
789    other statements at its nesting level.  */
790
791 void
792 expand_stmt (t)
793      tree t;
794 {
795   while (t && t != error_mark_node)
796     {
797       int saved_stmts_are_full_exprs_p;
798
799       /* Set up context appropriately for handling this statement.  */
800       saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
801       prep_stmt (t);
802
803       switch (TREE_CODE (t))
804         {
805         case FILE_STMT:
806           input_filename = FILE_STMT_FILENAME (t);
807           break;
808
809         case RETURN_STMT:
810           genrtl_return_stmt (t);
811           break;
812
813         case EXPR_STMT:
814           genrtl_expr_stmt_value (EXPR_STMT_EXPR (t), TREE_ADDRESSABLE (t),
815                                   TREE_CHAIN (t) == NULL
816                                   || (TREE_CODE (TREE_CHAIN (t)) == SCOPE_STMT
817                                       && TREE_CHAIN (TREE_CHAIN (t)) == NULL));
818           break;
819
820         case DECL_STMT:
821           genrtl_decl_stmt (t);
822           break;
823
824         case FOR_STMT:
825           genrtl_for_stmt (t);
826           break;
827
828         case WHILE_STMT:
829           genrtl_while_stmt (t);
830           break;
831
832         case DO_STMT:
833           genrtl_do_stmt (t);
834           break;
835
836         case IF_STMT:
837           genrtl_if_stmt (t);
838           break;
839
840         case COMPOUND_STMT:
841           genrtl_compound_stmt (t);
842           break;
843
844         case BREAK_STMT:
845           genrtl_break_stmt ();
846           break;
847
848         case CONTINUE_STMT:
849           genrtl_continue_stmt ();
850           break;
851
852         case SWITCH_STMT:
853           genrtl_switch_stmt (t);
854           break;
855
856         case CASE_LABEL:
857           genrtl_case_label (t);
858           break;
859
860         case LABEL_STMT:
861           expand_label (LABEL_STMT_LABEL (t));
862           break;
863
864         case GOTO_STMT:
865           /* Emit information for branch prediction.  */
866           if (!GOTO_FAKE_P (t)
867               && TREE_CODE (GOTO_DESTINATION (t)) == LABEL_DECL)
868             {
869               rtx note = emit_note (NULL, NOTE_INSN_PREDICTION);
870
871               NOTE_PREDICTION (note) = NOTE_PREDICT (PRED_GOTO, NOT_TAKEN);
872             }
873           genrtl_goto_stmt (GOTO_DESTINATION (t));
874           break;
875
876         case ASM_STMT:
877           genrtl_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t),
878                            ASM_OUTPUTS (t), ASM_INPUTS (t),
879                            ASM_CLOBBERS (t), ASM_INPUT_P (t));
880           break;
881
882         case SCOPE_STMT:
883           genrtl_scope_stmt (t);
884           break;
885
886         case CLEANUP_STMT:
887           genrtl_decl_cleanup (t);
888           break;
889
890         default:
891           if (lang_expand_stmt)
892             (*lang_expand_stmt) (t);
893           else 
894             abort ();
895           break;
896         }
897
898       /* Restore saved state.  */
899       current_stmt_tree ()->stmts_are_full_exprs_p
900         = saved_stmts_are_full_exprs_p;
901
902       /* Go on to the next statement in this scope.  */
903       t = TREE_CHAIN (t);
904     }
905 }