OSDN Git Service

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