]>
Commit | Line | Data |
---|---|---|
f2c5f623 BC |
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 | |
2f6e4e97 | 3 | for the standard codes). |
283334f0 | 4 | Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. |
4f78b9a8 | 5 | Written by Benjamin Chelf (chelf@codesourcery.com). |
f2c5f623 | 6 | |
1322177d | 7 | This file is part of GCC. |
f2c5f623 | 8 | |
1322177d LB |
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. | |
f2c5f623 | 13 | |
1322177d LB |
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. | |
f2c5f623 BC |
18 | |
19 | You should have received a copy of the GNU General Public License | |
1322177d LB |
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. */ | |
f2c5f623 BC |
23 | |
24 | #include "config.h" | |
25 | #include "system.h" | |
4977bab6 ZW |
26 | #include "coretypes.h" |
27 | #include "tm.h" | |
f2c5f623 BC |
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" | |
5f1989e6 KG |
34 | /* In order for the format checking to accept the C frontend |
35 | diagnostic framework extensions, you must define this token before | |
36 | including toplev.h. */ | |
37 | #define GCC_DIAG_STYLE __gcc_cdiag__ | |
f2c5f623 BC |
38 | #include "toplev.h" |
39 | #include "flags.h" | |
40 | #include "ggc.h" | |
41 | #include "rtl.h" | |
d6684bc8 | 42 | #include "expr.h" |
f2c5f623 BC |
43 | #include "output.h" |
44 | #include "timevar.h" | |
969d70ca | 45 | #include "predict.h" |
96c6931d | 46 | #include "tree-inline.h" |
f2c5f623 | 47 | |
54f7877c MM |
48 | /* If non-NULL, the address of a language-specific function for |
49 | expanding statements. */ | |
2f6e4e97 | 50 | void (*lang_expand_stmt) (tree); |
54f7877c | 51 | |
8f17b5c5 MM |
52 | /* If non-NULL, the address of a language-specific function for |
53 | expanding a DECL_STMT. After the language-independent cases are | |
54 | handled, this function will be called. If this function is not | |
55 | defined, it is assumed that declarations other than those for | |
56 | variables and labels do not require any RTL generation. */ | |
2f6e4e97 | 57 | void (*lang_expand_decl_stmt) (tree); |
8f17b5c5 | 58 | |
2f6e4e97 AJ |
59 | static tree find_reachable_label_1 (tree *, int *, void *); |
60 | static tree find_reachable_label (tree); | |
61 | static bool expand_unreachable_if_stmt (tree); | |
62 | static tree expand_unreachable_stmt (tree, int); | |
63 | static void genrtl_do_stmt_1 (tree, tree); | |
96c6931d | 64 | |
ae499cce MM |
65 | /* Create an empty statement tree rooted at T. */ |
66 | ||
67 | void | |
2f6e4e97 | 68 | begin_stmt_tree (tree *t) |
ae499cce MM |
69 | { |
70 | /* We create a trivial EXPR_STMT so that last_tree is never NULL in | |
71 | what follows. We remove the extraneous statement in | |
72 | finish_stmt_tree. */ | |
73 | *t = build_nt (EXPR_STMT, void_zero_node); | |
74 | last_tree = *t; | |
75 | last_expr_type = NULL_TREE; | |
de097a2d | 76 | last_expr_filename = input_filename; |
ae499cce MM |
77 | } |
78 | ||
79 | /* T is a statement. Add it to the statement-tree. */ | |
80 | ||
56cb9733 | 81 | tree |
2f6e4e97 | 82 | add_stmt (tree t) |
ae499cce | 83 | { |
de097a2d JM |
84 | if (input_filename != last_expr_filename) |
85 | { | |
86 | /* If the filename has changed, also add in a FILE_STMT. Do a string | |
87 | compare first, though, as it might be an equivalent string. */ | |
88 | int add = (strcmp (input_filename, last_expr_filename) != 0); | |
89 | last_expr_filename = input_filename; | |
90 | if (add) | |
91 | { | |
92 | tree pos = build_nt (FILE_STMT, get_identifier (input_filename)); | |
93 | add_stmt (pos); | |
94 | } | |
95 | } | |
96 | ||
ae499cce MM |
97 | /* Add T to the statement-tree. */ |
98 | TREE_CHAIN (last_tree) = t; | |
99 | last_tree = t; | |
2f6e4e97 | 100 | |
ae499cce | 101 | /* When we expand a statement-tree, we must know whether or not the |
0ba8a114 | 102 | statements are full-expressions. We record that fact here. */ |
ae499cce | 103 | STMT_IS_FULL_EXPR_P (last_tree) = stmts_are_full_exprs_p (); |
b850de4f | 104 | |
56cb9733 | 105 | return t; |
ae499cce MM |
106 | } |
107 | ||
8f17b5c5 MM |
108 | /* Create a declaration statement for the declaration given by the |
109 | DECL. */ | |
110 | ||
111 | void | |
2f6e4e97 | 112 | add_decl_stmt (tree decl) |
8f17b5c5 MM |
113 | { |
114 | tree decl_stmt; | |
115 | ||
116 | /* We need the type to last until instantiation time. */ | |
117 | decl_stmt = build_stmt (DECL_STMT, decl); | |
2f6e4e97 | 118 | add_stmt (decl_stmt); |
8f17b5c5 MM |
119 | } |
120 | ||
121 | /* Add a scope-statement to the statement-tree. BEGIN_P indicates | |
122 | whether this statements opens or closes a scope. PARTIAL_P is true | |
123 | for a partial scope, i.e, the scope that begins after a label when | |
124 | an object that needs a cleanup is created. If BEGIN_P is nonzero, | |
125 | returns a new TREE_LIST representing the top of the SCOPE_STMT | |
126 | stack. The TREE_PURPOSE is the new SCOPE_STMT. If BEGIN_P is | |
127 | zero, returns a TREE_LIST whose TREE_VALUE is the new SCOPE_STMT, | |
0ba8a114 | 128 | and whose TREE_PURPOSE is the matching SCOPE_STMT with |
8f17b5c5 MM |
129 | SCOPE_BEGIN_P set. */ |
130 | ||
131 | tree | |
2f6e4e97 | 132 | add_scope_stmt (int begin_p, int partial_p) |
8f17b5c5 | 133 | { |
de8e49f3 | 134 | tree *stack_ptr = current_scope_stmt_stack (); |
8f17b5c5 | 135 | tree ss; |
de8e49f3 | 136 | tree top = *stack_ptr; |
8f17b5c5 MM |
137 | |
138 | /* Build the statement. */ | |
139 | ss = build_stmt (SCOPE_STMT, NULL_TREE); | |
140 | SCOPE_BEGIN_P (ss) = begin_p; | |
141 | SCOPE_PARTIAL_P (ss) = partial_p; | |
142 | ||
143 | /* Keep the scope stack up to date. */ | |
144 | if (begin_p) | |
145 | { | |
de8e49f3 NS |
146 | top = tree_cons (ss, NULL_TREE, top); |
147 | *stack_ptr = top; | |
8f17b5c5 MM |
148 | } |
149 | else | |
150 | { | |
9f175208 JM |
151 | if (partial_p != SCOPE_PARTIAL_P (TREE_PURPOSE (top))) |
152 | abort (); | |
8f17b5c5 | 153 | TREE_VALUE (top) = ss; |
de8e49f3 | 154 | *stack_ptr = TREE_CHAIN (top); |
8f17b5c5 MM |
155 | } |
156 | ||
157 | /* Add the new statement to the statement-tree. */ | |
158 | add_stmt (ss); | |
159 | ||
160 | return top; | |
161 | } | |
162 | ||
ae499cce MM |
163 | /* Finish the statement tree rooted at T. */ |
164 | ||
165 | void | |
2f6e4e97 | 166 | finish_stmt_tree (tree *t) |
ae499cce MM |
167 | { |
168 | tree stmt; | |
2f6e4e97 | 169 | |
ae499cce MM |
170 | /* Remove the fake extra statement added in begin_stmt_tree. */ |
171 | stmt = TREE_CHAIN (*t); | |
172 | *t = stmt; | |
173 | last_tree = NULL_TREE; | |
174 | ||
8f17b5c5 | 175 | if (cfun && stmt) |
ae499cce MM |
176 | { |
177 | /* The line-number recorded in the outermost statement in a function | |
178 | is the line number of the end of the function. */ | |
d479d37f | 179 | STMT_LINENO (stmt) = input_line; |
ae499cce MM |
180 | STMT_LINENO_FOR_FN_P (stmt) = 1; |
181 | } | |
182 | } | |
183 | ||
0dfdeca6 BC |
184 | /* Build a generic statement based on the given type of node and |
185 | arguments. Similar to `build_nt', except that we set | |
64094f6a RH |
186 | STMT_LINENO to be the current line number. */ |
187 | /* ??? This should be obsolete with the lineno_stmt productions | |
188 | in the grammar. */ | |
0dfdeca6 BC |
189 | |
190 | tree | |
e34d07f2 | 191 | build_stmt (enum tree_code code, ...) |
0dfdeca6 | 192 | { |
b3694847 SS |
193 | tree t; |
194 | int length; | |
195 | int i; | |
e34d07f2 | 196 | va_list p; |
2f6e4e97 | 197 | |
e34d07f2 | 198 | va_start (p, code); |
0dfdeca6 BC |
199 | |
200 | t = make_node (code); | |
201 | length = TREE_CODE_LENGTH (code); | |
d479d37f | 202 | STMT_LINENO (t) = input_line; |
0dfdeca6 BC |
203 | |
204 | for (i = 0; i < length; i++) | |
205 | TREE_OPERAND (t, i) = va_arg (p, tree); | |
206 | ||
e34d07f2 | 207 | va_end (p); |
0dfdeca6 BC |
208 | return t; |
209 | } | |
210 | ||
f2c5f623 BC |
211 | /* Some statements, like for-statements or if-statements, require a |
212 | condition. This condition can be a declaration. If T is such a | |
213 | declaration it is processed, and an expression appropriate to use | |
214 | as the condition is returned. Otherwise, T itself is returned. */ | |
215 | ||
216 | tree | |
2f6e4e97 | 217 | expand_cond (tree t) |
f2c5f623 BC |
218 | { |
219 | if (t && TREE_CODE (t) == TREE_LIST) | |
220 | { | |
221 | expand_stmt (TREE_PURPOSE (t)); | |
222 | return TREE_VALUE (t); | |
223 | } | |
2f6e4e97 | 224 | else |
f2c5f623 BC |
225 | return t; |
226 | } | |
227 | ||
228 | /* Create RTL for the local static variable DECL. */ | |
229 | ||
230 | void | |
2f6e4e97 | 231 | make_rtl_for_local_static (tree decl) |
f2c5f623 BC |
232 | { |
233 | const char *asmspec = NULL; | |
234 | ||
235 | /* If we inlined this variable, we could see it's declaration | |
236 | again. */ | |
95ee998c | 237 | if (TREE_ASM_WRITTEN (decl)) |
f2c5f623 BC |
238 | return; |
239 | ||
2c21b247 MM |
240 | /* If the DECL_ASSEMBLER_NAME is not the same as the DECL_NAME, then |
241 | either we already created RTL for this DECL (and since it was a | |
0a7394bc | 242 | local variable, its DECL_ASSEMBLER_NAME got hacked up to prevent |
2c21b247 MM |
243 | clashes with other local statics with the same name by a previous |
244 | call to make_decl_rtl), or the user explicitly requested a | |
245 | particular assembly name for this variable, using the GNU | |
246 | extension for this purpose: | |
247 | ||
248 | int i asm ("j"); | |
249 | ||
250 | There's no way to know which case we're in, here. But, it turns | |
251 | out we're safe. If there's already RTL, then | |
252 | rest_of_decl_compilation ignores the ASMSPEC parameter, so we | |
253 | may as well not pass it in. If there isn't RTL, then we didn't | |
254 | already create RTL, which means that the modification to | |
255 | DECL_ASSEMBLER_NAME came only via the explicit extension. */ | |
256 | if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl) | |
45dcf572 | 257 | && !DECL_RTL_SET_P (decl)) |
2c21b247 | 258 | asmspec = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); |
f2c5f623 BC |
259 | |
260 | rest_of_decl_compilation (decl, asmspec, /*top_level=*/0, /*at_end=*/0); | |
261 | } | |
262 | ||
263 | /* Let the back-end know about DECL. */ | |
264 | ||
265 | void | |
2f6e4e97 | 266 | emit_local_var (tree decl) |
f2c5f623 BC |
267 | { |
268 | /* Create RTL for this variable. */ | |
19e7881c | 269 | if (!DECL_RTL_SET_P (decl)) |
f2c5f623 | 270 | { |
3645c4dc RH |
271 | if (DECL_C_HARD_REGISTER (decl)) |
272 | /* The user specified an assembler name for this variable. | |
273 | Set that up now. */ | |
f2c5f623 BC |
274 | rest_of_decl_compilation |
275 | (decl, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), | |
276 | /*top_level=*/0, /*at_end=*/0); | |
277 | else | |
278 | expand_decl (decl); | |
279 | } | |
280 | ||
03307888 JM |
281 | if (DECL_INITIAL (decl)) |
282 | { | |
283 | /* Actually do the initialization. */ | |
284 | if (stmts_are_full_exprs_p ()) | |
285 | expand_start_target_temps (); | |
f2c5f623 | 286 | |
03307888 | 287 | expand_decl_init (decl); |
f2c5f623 | 288 | |
03307888 JM |
289 | if (stmts_are_full_exprs_p ()) |
290 | expand_end_target_temps (); | |
291 | } | |
f2c5f623 BC |
292 | } |
293 | ||
ec5c56db | 294 | /* Helper for generating the RTL at the beginning of a scope. */ |
f2c5f623 BC |
295 | |
296 | void | |
2f6e4e97 | 297 | genrtl_do_pushlevel (void) |
f2c5f623 | 298 | { |
0cea056b | 299 | emit_line_note (input_location); |
f2c5f623 BC |
300 | clear_last_expr (); |
301 | } | |
302 | ||
ec5c56db | 303 | /* Generate the RTL for DESTINATION, which is a GOTO_STMT. */ |
f2c5f623 BC |
304 | |
305 | void | |
2f6e4e97 | 306 | genrtl_goto_stmt (tree destination) |
f2c5f623 BC |
307 | { |
308 | if (TREE_CODE (destination) == IDENTIFIER_NODE) | |
309 | abort (); | |
2f6e4e97 | 310 | |
f2c5f623 BC |
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; | |
2f6e4e97 | 315 | |
0cea056b | 316 | emit_line_note (input_location); |
2f6e4e97 | 317 | |
f2c5f623 BC |
318 | if (TREE_CODE (destination) == LABEL_DECL) |
319 | { | |
320 | label_rtx (destination); | |
2f6e4e97 | 321 | expand_goto (destination); |
f2c5f623 BC |
322 | } |
323 | else | |
324 | expand_computed_goto (destination); | |
325 | } | |
326 | ||
1574ef13 AO |
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. */ | |
f2c5f623 | 330 | |
1574ef13 | 331 | void |
2f6e4e97 | 332 | genrtl_expr_stmt (tree expr) |
1574ef13 | 333 | { |
b0832fe1 | 334 | genrtl_expr_stmt_value (expr, -1, 1); |
1574ef13 AO |
335 | } |
336 | ||
337 | /* Generate the RTL for EXPR, which is an EXPR_STMT. WANT_VALUE tells | |
338 | whether to (1) save the value of the expression, (0) discard it or | |
339 | (-1) use expr_stmts_for_value to tell. The use of -1 is | |
b0832fe1 | 340 | deprecated, and retained only for backward compatibility. |
da7d8304 | 341 | MAYBE_LAST is nonzero if this EXPR_STMT might be the last statement |
b0832fe1 | 342 | in expression statement. */ |
1574ef13 | 343 | |
2f6e4e97 AJ |
344 | void |
345 | genrtl_expr_stmt_value (tree expr, int want_value, int maybe_last) | |
f2c5f623 BC |
346 | { |
347 | if (expr != NULL_TREE) | |
348 | { | |
0cea056b | 349 | emit_line_note (input_location); |
2f6e4e97 | 350 | |
f2c5f623 BC |
351 | if (stmts_are_full_exprs_p ()) |
352 | expand_start_target_temps (); | |
2f6e4e97 | 353 | |
8f17b5c5 | 354 | if (expr != error_mark_node) |
b0832fe1 | 355 | expand_expr_stmt_value (expr, want_value, maybe_last); |
2f6e4e97 | 356 | |
f2c5f623 BC |
357 | if (stmts_are_full_exprs_p ()) |
358 | expand_end_target_temps (); | |
359 | } | |
360 | } | |
361 | ||
ec5c56db | 362 | /* Generate the RTL for T, which is a DECL_STMT. */ |
f2c5f623 BC |
363 | |
364 | void | |
2f6e4e97 | 365 | genrtl_decl_stmt (tree t) |
f2c5f623 BC |
366 | { |
367 | tree decl; | |
0cea056b | 368 | emit_line_note (input_location); |
f2c5f623 BC |
369 | decl = DECL_STMT_DECL (t); |
370 | /* If this is a declaration for an automatic local | |
371 | variable, initialize it. Note that we might also see a | |
372 | declaration for a namespace-scope object (declared with | |
373 | `extern'). We don't have to handle the initialization | |
374 | of those objects here; they can only be declarations, | |
375 | rather than definitions. */ | |
2f6e4e97 | 376 | if (TREE_CODE (decl) == VAR_DECL |
f2c5f623 BC |
377 | && !TREE_STATIC (decl) |
378 | && !DECL_EXTERNAL (decl)) | |
379 | { | |
380 | /* Let the back-end know about this variable. */ | |
381 | if (!anon_aggr_type_p (TREE_TYPE (decl))) | |
382 | emit_local_var (decl); | |
383 | else | |
2f6e4e97 | 384 | expand_anon_union_decl (decl, NULL_TREE, |
f2c5f623 BC |
385 | DECL_ANON_UNION_ELEMS (decl)); |
386 | } | |
387 | else if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)) | |
0ba8a114 | 388 | make_rtl_for_local_static (decl); |
2f6e4e97 | 389 | else if (TREE_CODE (decl) == LABEL_DECL |
8f17b5c5 MM |
390 | && C_DECLARED_LABEL_FLAG (decl)) |
391 | declare_nonlocal_label (decl); | |
392 | else if (lang_expand_decl_stmt) | |
393 | (*lang_expand_decl_stmt) (t); | |
f2c5f623 BC |
394 | } |
395 | ||
ec5c56db | 396 | /* Generate the RTL for T, which is an IF_STMT. */ |
f2c5f623 BC |
397 | |
398 | void | |
2f6e4e97 | 399 | genrtl_if_stmt (tree t) |
f2c5f623 BC |
400 | { |
401 | tree cond; | |
402 | genrtl_do_pushlevel (); | |
403 | cond = expand_cond (IF_COND (t)); | |
0cea056b | 404 | emit_line_note (input_location); |
f2c5f623 BC |
405 | expand_start_cond (cond, 0); |
406 | if (THEN_CLAUSE (t)) | |
96c6931d | 407 | { |
7454096f | 408 | tree nextt = THEN_CLAUSE (t); |
2f6e4e97 | 409 | |
96c6931d | 410 | if (cond && integer_zerop (cond)) |
7454096f GK |
411 | nextt = expand_unreachable_stmt (nextt, warn_notreached); |
412 | expand_stmt (nextt); | |
96c6931d RS |
413 | } |
414 | ||
f2c5f623 BC |
415 | if (ELSE_CLAUSE (t)) |
416 | { | |
7454096f | 417 | tree nextt = ELSE_CLAUSE (t); |
f2c5f623 | 418 | expand_start_else (); |
96c6931d | 419 | if (cond && integer_nonzerop (cond)) |
7454096f GK |
420 | nextt = expand_unreachable_stmt (nextt, warn_notreached); |
421 | expand_stmt (nextt); | |
f2c5f623 BC |
422 | } |
423 | expand_end_cond (); | |
424 | } | |
425 | ||
ec5c56db | 426 | /* Generate the RTL for T, which is a WHILE_STMT. */ |
f2c5f623 BC |
427 | |
428 | void | |
2f6e4e97 | 429 | genrtl_while_stmt (tree t) |
f2c5f623 | 430 | { |
8cadeff1 RS |
431 | tree cond = WHILE_COND (t); |
432 | ||
0cea056b | 433 | emit_line_note (input_location); |
2f6e4e97 | 434 | expand_start_loop (1); |
f2c5f623 BC |
435 | genrtl_do_pushlevel (); |
436 | ||
8cadeff1 RS |
437 | if (cond && !integer_nonzerop (cond)) |
438 | { | |
439 | cond = expand_cond (cond); | |
0cea056b | 440 | emit_line_note (input_location); |
8cadeff1 RS |
441 | expand_exit_loop_top_cond (0, cond); |
442 | genrtl_do_pushlevel (); | |
443 | } | |
2f6e4e97 | 444 | |
f2c5f623 BC |
445 | expand_stmt (WHILE_BODY (t)); |
446 | ||
447 | expand_end_loop (); | |
448 | } | |
449 | ||
0b82d59c RS |
450 | /* Generate the RTL for a DO_STMT with condition COND and loop BODY |
451 | body. This is reused for expanding unreachable WHILE_STMTS. */ | |
f2c5f623 | 452 | |
0b82d59c | 453 | static void |
2f6e4e97 | 454 | genrtl_do_stmt_1 (tree cond, tree body) |
f2c5f623 | 455 | { |
d599b81f RH |
456 | /* Recognize the common special-case of do { ... } while (0) and do |
457 | not emit the loop widgetry in this case. In particular this | |
458 | avoids cluttering the rtl with dummy loop notes, which can affect | |
85341ddd NS |
459 | alignment of adjacent labels. COND can be NULL due to parse |
460 | errors. */ | |
461 | if (!cond || integer_zerop (cond)) | |
f0de0c5d RH |
462 | { |
463 | expand_start_null_loop (); | |
0b82d59c | 464 | expand_stmt (body); |
f0de0c5d RH |
465 | expand_end_null_loop (); |
466 | } | |
4977bab6 ZW |
467 | else if (integer_nonzerop (cond)) |
468 | { | |
0cea056b | 469 | emit_line_note (input_location); |
4977bab6 ZW |
470 | expand_start_loop (1); |
471 | ||
0b82d59c | 472 | expand_stmt (body); |
4977bab6 | 473 | |
0cea056b | 474 | emit_line_note (input_location); |
4977bab6 ZW |
475 | expand_end_loop (); |
476 | } | |
d599b81f RH |
477 | else |
478 | { | |
0cea056b | 479 | emit_line_note (input_location); |
d599b81f | 480 | expand_start_loop_continue_elsewhere (1); |
f2c5f623 | 481 | |
0b82d59c | 482 | expand_stmt (body); |
f2c5f623 | 483 | |
d599b81f RH |
484 | expand_loop_continue_here (); |
485 | cond = expand_cond (cond); | |
0cea056b | 486 | emit_line_note (input_location); |
d599b81f RH |
487 | expand_exit_loop_if_false (0, cond); |
488 | expand_end_loop (); | |
489 | } | |
f2c5f623 BC |
490 | } |
491 | ||
0b82d59c RS |
492 | /* Generate the RTL for T, which is a DO_STMT. */ |
493 | ||
494 | void | |
2f6e4e97 | 495 | genrtl_do_stmt (tree t) |
0b82d59c RS |
496 | { |
497 | genrtl_do_stmt_1 (DO_COND (t), DO_BODY (t)); | |
498 | } | |
499 | ||
ec5c56db | 500 | /* Build the node for a return statement and return it. */ |
0dfdeca6 BC |
501 | |
502 | tree | |
2f6e4e97 | 503 | build_return_stmt (tree expr) |
0dfdeca6 BC |
504 | { |
505 | return (build_stmt (RETURN_STMT, expr)); | |
506 | } | |
507 | ||
ec5c56db | 508 | /* Generate the RTL for STMT, which is a RETURN_STMT. */ |
f2c5f623 BC |
509 | |
510 | void | |
2f6e4e97 | 511 | genrtl_return_stmt (tree stmt) |
f2c5f623 | 512 | { |
0d97bf4c JM |
513 | tree expr; |
514 | ||
d65b1d77 | 515 | expr = RETURN_STMT_EXPR (stmt); |
56cb9733 | 516 | |
0cea056b | 517 | emit_line_note (input_location); |
56cb9733 MM |
518 | if (!expr) |
519 | expand_null_return (); | |
520 | else | |
521 | { | |
522 | expand_start_target_temps (); | |
523 | expand_return (expr); | |
524 | expand_end_target_temps (); | |
525 | } | |
f2c5f623 BC |
526 | } |
527 | ||
ec5c56db | 528 | /* Generate the RTL for T, which is a FOR_STMT. */ |
f2c5f623 BC |
529 | |
530 | void | |
2f6e4e97 | 531 | genrtl_for_stmt (tree t) |
f2c5f623 | 532 | { |
8cadeff1 | 533 | tree cond = FOR_COND (t); |
070588f0 | 534 | location_t saved_loc; |
8f17b5c5 | 535 | |
f2c5f623 BC |
536 | if (NEW_FOR_SCOPE_P (t)) |
537 | genrtl_do_pushlevel (); | |
538 | ||
539 | expand_stmt (FOR_INIT_STMT (t)); | |
540 | ||
8f17b5c5 | 541 | /* Expand the initialization. */ |
0cea056b | 542 | emit_line_note (input_location); |
4977bab6 | 543 | if (FOR_EXPR (t)) |
2f6e4e97 | 544 | expand_start_loop_continue_elsewhere (1); |
4977bab6 ZW |
545 | else |
546 | expand_start_loop (1); | |
f2c5f623 | 547 | genrtl_do_pushlevel (); |
8f17b5c5 MM |
548 | |
549 | /* Save the filename and line number so that we expand the FOR_EXPR | |
550 | we can reset them back to the saved values. */ | |
070588f0 | 551 | saved_loc = input_location; |
8f17b5c5 MM |
552 | |
553 | /* Expand the condition. */ | |
8cadeff1 RS |
554 | if (cond && !integer_nonzerop (cond)) |
555 | { | |
556 | cond = expand_cond (cond); | |
0cea056b | 557 | emit_line_note (input_location); |
8cadeff1 RS |
558 | expand_exit_loop_top_cond (0, cond); |
559 | genrtl_do_pushlevel (); | |
560 | } | |
f2c5f623 | 561 | |
8f17b5c5 | 562 | /* Expand the body. */ |
f2c5f623 BC |
563 | expand_stmt (FOR_BODY (t)); |
564 | ||
8f17b5c5 | 565 | /* Expand the increment expression. */ |
070588f0 | 566 | input_location = saved_loc; |
0cea056b | 567 | emit_line_note (input_location); |
8f17b5c5 | 568 | if (FOR_EXPR (t)) |
4977bab6 ZW |
569 | { |
570 | expand_loop_continue_here (); | |
571 | genrtl_expr_stmt (FOR_EXPR (t)); | |
572 | } | |
f2c5f623 BC |
573 | expand_end_loop (); |
574 | } | |
575 | ||
ec5c56db | 576 | /* Build a break statement node and return it. */ |
0dfdeca6 BC |
577 | |
578 | tree | |
2f6e4e97 | 579 | build_break_stmt (void) |
0dfdeca6 BC |
580 | { |
581 | return (build_stmt (BREAK_STMT)); | |
582 | } | |
583 | ||
ec5c56db | 584 | /* Generate the RTL for a BREAK_STMT. */ |
f2c5f623 BC |
585 | |
586 | void | |
2f6e4e97 | 587 | genrtl_break_stmt (void) |
f2c5f623 | 588 | { |
0cea056b | 589 | emit_line_note (input_location); |
f2c5f623 | 590 | if ( ! expand_exit_something ()) |
e13e48e7 | 591 | abort (); |
f2c5f623 BC |
592 | } |
593 | ||
ec5c56db | 594 | /* Build a continue statement node and return it. */ |
0dfdeca6 BC |
595 | |
596 | tree | |
2f6e4e97 | 597 | build_continue_stmt (void) |
0dfdeca6 BC |
598 | { |
599 | return (build_stmt (CONTINUE_STMT)); | |
600 | } | |
601 | ||
ec5c56db | 602 | /* Generate the RTL for a CONTINUE_STMT. */ |
f2c5f623 BC |
603 | |
604 | void | |
2f6e4e97 | 605 | genrtl_continue_stmt (void) |
f2c5f623 | 606 | { |
0cea056b | 607 | emit_line_note (input_location); |
f2c5f623 | 608 | if (! expand_continue_loop (0)) |
e13e48e7 | 609 | abort (); |
f2c5f623 BC |
610 | } |
611 | ||
ec5c56db | 612 | /* Generate the RTL for T, which is a SCOPE_STMT. */ |
f2c5f623 BC |
613 | |
614 | void | |
2f6e4e97 | 615 | genrtl_scope_stmt (tree t) |
f2c5f623 | 616 | { |
7b2b3f29 MM |
617 | tree block = SCOPE_STMT_BLOCK (t); |
618 | ||
f2c5f623 BC |
619 | if (!SCOPE_NO_CLEANUPS_P (t)) |
620 | { | |
621 | if (SCOPE_BEGIN_P (t)) | |
7b2b3f29 | 622 | expand_start_bindings_and_block (2 * SCOPE_NULLIFIED_P (t), block); |
f2c5f623 BC |
623 | else if (SCOPE_END_P (t)) |
624 | expand_end_bindings (NULL_TREE, !SCOPE_NULLIFIED_P (t), 0); | |
625 | } | |
626 | else if (!SCOPE_NULLIFIED_P (t)) | |
627 | { | |
2e040219 NS |
628 | rtx note = emit_note (SCOPE_BEGIN_P (t) |
629 | ? NOTE_INSN_BLOCK_BEG : NOTE_INSN_BLOCK_END); | |
7b2b3f29 MM |
630 | NOTE_BLOCK (note) = block; |
631 | } | |
632 | ||
633 | /* If we're at the end of a scope that contains inlined nested | |
634 | functions, we have to decide whether or not to write them out. */ | |
635 | if (block && SCOPE_END_P (t)) | |
636 | { | |
637 | tree fn; | |
638 | ||
639 | for (fn = BLOCK_VARS (block); fn; fn = TREE_CHAIN (fn)) | |
640 | { | |
2f6e4e97 | 641 | if (TREE_CODE (fn) == FUNCTION_DECL |
7b2b3f29 | 642 | && DECL_CONTEXT (fn) == current_function_decl |
1da326c3 SB |
643 | && DECL_STRUCT_FUNCTION (fn) |
644 | && DECL_STRUCT_FUNCTION (fn)->saved_for_inline | |
7b2b3f29 MM |
645 | && !TREE_ASM_WRITTEN (fn) |
646 | && TREE_ADDRESSABLE (fn)) | |
647 | { | |
648 | push_function_context (); | |
649 | output_inline_function (fn); | |
650 | pop_function_context (); | |
651 | } | |
652 | } | |
f2c5f623 BC |
653 | } |
654 | } | |
655 | ||
ec5c56db | 656 | /* Generate the RTL for T, which is a SWITCH_STMT. */ |
f2c5f623 BC |
657 | |
658 | void | |
2f6e4e97 | 659 | genrtl_switch_stmt (tree t) |
f2c5f623 BC |
660 | { |
661 | tree cond; | |
662 | genrtl_do_pushlevel (); | |
2f6e4e97 | 663 | |
f2c5f623 | 664 | cond = expand_cond (SWITCH_COND (t)); |
56cb9733 | 665 | if (cond == error_mark_node) |
f2c5f623 | 666 | /* The code is in error, but we don't want expand_end_case to |
ec5c56db | 667 | crash. */ |
de7df9eb | 668 | cond = truthvalue_false_node; |
f2c5f623 | 669 | |
0cea056b | 670 | emit_line_note (input_location); |
56cb9733 | 671 | expand_start_case (1, cond, TREE_TYPE (cond), "switch statement"); |
7454096f | 672 | expand_stmt (expand_unreachable_stmt (SWITCH_BODY (t), warn_notreached)); |
6f9fdf4d | 673 | expand_end_case_type (cond, SWITCH_TYPE (t)); |
f2c5f623 BC |
674 | } |
675 | ||
ec5c56db | 676 | /* Create a CASE_LABEL tree node and return it. */ |
0dfdeca6 BC |
677 | |
678 | tree | |
2f6e4e97 | 679 | build_case_label (tree low_value, tree high_value, tree label_decl) |
0dfdeca6 | 680 | { |
56cb9733 | 681 | return build_stmt (CASE_LABEL, low_value, high_value, label_decl); |
0dfdeca6 BC |
682 | } |
683 | ||
684 | ||
ec5c56db | 685 | /* Generate the RTL for a CASE_LABEL. */ |
f2c5f623 | 686 | |
2f6e4e97 AJ |
687 | void |
688 | genrtl_case_label (tree case_label) | |
f2c5f623 | 689 | { |
56cb9733 | 690 | tree duplicate; |
8f17b5c5 MM |
691 | tree cleanup; |
692 | ||
693 | cleanup = last_cleanup_this_contour (); | |
694 | if (cleanup) | |
695 | { | |
696 | static int explained = 0; | |
0108ae51 | 697 | warning ("destructor needed for `%D'", (TREE_PURPOSE (cleanup))); |
8f17b5c5 MM |
698 | warning ("where case label appears here"); |
699 | if (!explained) | |
700 | { | |
701 | warning ("(enclose actions of previous case statements requiring destructors in their own scope.)"); | |
702 | explained = 1; | |
703 | } | |
704 | } | |
705 | ||
2f6e4e97 | 706 | add_case_node (CASE_LOW (case_label), CASE_HIGH (case_label), |
56cb9733 | 707 | CASE_LABEL_DECL (case_label), &duplicate); |
f2c5f623 BC |
708 | } |
709 | ||
ec5c56db | 710 | /* Generate the RTL for T, which is a COMPOUND_STMT. */ |
f2c5f623 | 711 | |
4cf88f57 | 712 | void |
2f6e4e97 | 713 | genrtl_compound_stmt (tree t) |
f2c5f623 | 714 | { |
91088ddb JM |
715 | #ifdef ENABLE_CHECKING |
716 | struct nesting *n = current_nesting_level (); | |
717 | #endif | |
718 | ||
f2c5f623 | 719 | expand_stmt (COMPOUND_BODY (t)); |
91088ddb JM |
720 | |
721 | #ifdef ENABLE_CHECKING | |
722 | /* Make sure that we've pushed and popped the same number of levels. */ | |
8a827ab2 | 723 | if (!COMPOUND_STMT_NO_SCOPE (t) && n != current_nesting_level ()) |
91088ddb JM |
724 | abort (); |
725 | #endif | |
f2c5f623 BC |
726 | } |
727 | ||
ec5c56db | 728 | /* Generate the RTL for an ASM_STMT. */ |
f2c5f623 BC |
729 | |
730 | void | |
2f6e4e97 AJ |
731 | genrtl_asm_stmt (tree cv_qualifier, tree string, tree output_operands, |
732 | tree input_operands, tree clobbers, int asm_input_p) | |
f2c5f623 | 733 | { |
f2c5f623 BC |
734 | if (cv_qualifier != NULL_TREE |
735 | && cv_qualifier != ridpointers[(int) RID_VOLATILE]) | |
736 | { | |
737 | warning ("%s qualifier ignored on asm", | |
738 | IDENTIFIER_POINTER (cv_qualifier)); | |
739 | cv_qualifier = NULL_TREE; | |
740 | } | |
741 | ||
0cea056b | 742 | emit_line_note (input_location); |
4f78b9a8 | 743 | if (asm_input_p) |
4c46ea23 | 744 | expand_asm (string, cv_qualifier != NULL_TREE); |
4f78b9a8 | 745 | else |
2f6e4e97 | 746 | c_expand_asm_operands (string, output_operands, input_operands, |
4f78b9a8 | 747 | clobbers, cv_qualifier != NULL_TREE, |
177560b2 | 748 | input_location); |
f2c5f623 BC |
749 | } |
750 | ||
b39b8084 | 751 | /* Generate the RTL for a CLEANUP_STMT. */ |
f2c5f623 | 752 | |
2f6e4e97 AJ |
753 | void |
754 | genrtl_cleanup_stmt (tree t) | |
f2c5f623 | 755 | { |
659e5a7a | 756 | tree decl = CLEANUP_DECL (t); |
1b288fec JM |
757 | if (!decl || !DECL_P (decl) |
758 | || (DECL_SIZE (decl) && TREE_TYPE (decl) != error_mark_node)) | |
659e5a7a | 759 | expand_decl_cleanup_eh (decl, CLEANUP_EXPR (t), CLEANUP_EH_ONLY (t)); |
f2c5f623 BC |
760 | } |
761 | ||
54f7877c MM |
762 | /* We're about to expand T, a statement. Set up appropriate context |
763 | for the substitution. */ | |
764 | ||
765 | void | |
2f6e4e97 | 766 | prep_stmt (tree t) |
54f7877c MM |
767 | { |
768 | if (!STMT_LINENO_FOR_FN_P (t)) | |
d479d37f | 769 | input_line = STMT_LINENO (t); |
54f7877c MM |
770 | current_stmt_tree ()->stmts_are_full_exprs_p = STMT_IS_FULL_EXPR_P (t); |
771 | } | |
772 | ||
4cf88f57 | 773 | /* Generate the RTL for the statement T, its substatements, and any |
ec5c56db | 774 | other statements at its nesting level. */ |
4cf88f57 | 775 | |
54f7877c | 776 | void |
2f6e4e97 | 777 | expand_stmt (tree t) |
f2c5f623 | 778 | { |
54f7877c MM |
779 | while (t && t != error_mark_node) |
780 | { | |
781 | int saved_stmts_are_full_exprs_p; | |
782 | ||
783 | /* Set up context appropriately for handling this statement. */ | |
784 | saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p (); | |
785 | prep_stmt (t); | |
786 | ||
787 | switch (TREE_CODE (t)) | |
788 | { | |
de097a2d JM |
789 | case FILE_STMT: |
790 | input_filename = FILE_STMT_FILENAME (t); | |
791 | break; | |
792 | ||
54f7877c | 793 | case RETURN_STMT: |
56cb9733 | 794 | genrtl_return_stmt (t); |
e55614ca GK |
795 | t = expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached); |
796 | goto process_t; | |
54f7877c MM |
797 | |
798 | case EXPR_STMT: | |
b0832fe1 JJ |
799 | genrtl_expr_stmt_value (EXPR_STMT_EXPR (t), TREE_ADDRESSABLE (t), |
800 | TREE_CHAIN (t) == NULL | |
801 | || (TREE_CODE (TREE_CHAIN (t)) == SCOPE_STMT | |
802 | && TREE_CHAIN (TREE_CHAIN (t)) == NULL)); | |
54f7877c MM |
803 | break; |
804 | ||
805 | case DECL_STMT: | |
806 | genrtl_decl_stmt (t); | |
807 | break; | |
808 | ||
809 | case FOR_STMT: | |
810 | genrtl_for_stmt (t); | |
811 | break; | |
812 | ||
813 | case WHILE_STMT: | |
814 | genrtl_while_stmt (t); | |
815 | break; | |
816 | ||
817 | case DO_STMT: | |
818 | genrtl_do_stmt (t); | |
819 | break; | |
820 | ||
821 | case IF_STMT: | |
822 | genrtl_if_stmt (t); | |
823 | break; | |
824 | ||
825 | case COMPOUND_STMT: | |
826 | genrtl_compound_stmt (t); | |
827 | break; | |
828 | ||
829 | case BREAK_STMT: | |
830 | genrtl_break_stmt (); | |
e55614ca GK |
831 | t = expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached); |
832 | goto process_t; | |
54f7877c MM |
833 | |
834 | case CONTINUE_STMT: | |
835 | genrtl_continue_stmt (); | |
e55614ca GK |
836 | t = expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached); |
837 | goto process_t; | |
54f7877c MM |
838 | |
839 | case SWITCH_STMT: | |
840 | genrtl_switch_stmt (t); | |
841 | break; | |
842 | ||
843 | case CASE_LABEL: | |
56cb9733 | 844 | genrtl_case_label (t); |
54f7877c MM |
845 | break; |
846 | ||
847 | case LABEL_STMT: | |
848 | expand_label (LABEL_STMT_LABEL (t)); | |
849 | break; | |
850 | ||
851 | case GOTO_STMT: | |
969d70ca JH |
852 | /* Emit information for branch prediction. */ |
853 | if (!GOTO_FAKE_P (t) | |
d50672ef JH |
854 | && TREE_CODE (GOTO_DESTINATION (t)) == LABEL_DECL |
855 | && flag_guess_branch_prob) | |
969d70ca | 856 | { |
2e040219 | 857 | rtx note = emit_note (NOTE_INSN_PREDICTION); |
969d70ca JH |
858 | |
859 | NOTE_PREDICTION (note) = NOTE_PREDICT (PRED_GOTO, NOT_TAKEN); | |
860 | } | |
54f7877c | 861 | genrtl_goto_stmt (GOTO_DESTINATION (t)); |
e55614ca GK |
862 | t = expand_unreachable_stmt (TREE_CHAIN (t), warn_notreached); |
863 | goto process_t; | |
54f7877c MM |
864 | |
865 | case ASM_STMT: | |
866 | genrtl_asm_stmt (ASM_CV_QUAL (t), ASM_STRING (t), | |
4f78b9a8 RH |
867 | ASM_OUTPUTS (t), ASM_INPUTS (t), |
868 | ASM_CLOBBERS (t), ASM_INPUT_P (t)); | |
54f7877c MM |
869 | break; |
870 | ||
8f17b5c5 MM |
871 | case SCOPE_STMT: |
872 | genrtl_scope_stmt (t); | |
873 | break; | |
874 | ||
6e4ae815 | 875 | case CLEANUP_STMT: |
b39b8084 | 876 | genrtl_cleanup_stmt (t); |
6e4ae815 MM |
877 | break; |
878 | ||
54f7877c MM |
879 | default: |
880 | if (lang_expand_stmt) | |
881 | (*lang_expand_stmt) (t); | |
2f6e4e97 | 882 | else |
54f7877c MM |
883 | abort (); |
884 | break; | |
885 | } | |
886 | ||
e55614ca GK |
887 | /* Go on to the next statement in this scope. */ |
888 | t = TREE_CHAIN (t); | |
889 | ||
890 | process_t: | |
54f7877c | 891 | /* Restore saved state. */ |
e92044c3 RK |
892 | current_stmt_tree ()->stmts_are_full_exprs_p |
893 | = saved_stmts_are_full_exprs_p; | |
54f7877c | 894 | } |
f2c5f623 | 895 | } |
96c6931d RS |
896 | \f |
897 | /* If *TP is a potentially reachable label, return nonzero. */ | |
898 | ||
899 | static tree | |
2f6e4e97 AJ |
900 | find_reachable_label_1 (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, |
901 | void *data ATTRIBUTE_UNUSED) | |
96c6931d RS |
902 | { |
903 | switch (TREE_CODE (*tp)) | |
904 | { | |
905 | case LABEL_STMT: | |
906 | case CASE_LABEL: | |
907 | return *tp; | |
908 | ||
909 | default: | |
910 | break; | |
911 | } | |
912 | return NULL_TREE; | |
913 | } | |
914 | ||
915 | /* Determine whether expression EXP contains a potentially | |
916 | reachable label. */ | |
917 | static tree | |
2f6e4e97 | 918 | find_reachable_label (tree exp) |
96c6931d | 919 | { |
070588f0 | 920 | location_t saved_loc = input_location; |
51657442 SB |
921 | tree ret = walk_tree_without_duplicates |
922 | (&exp, find_reachable_label_1, NULL); | |
070588f0 | 923 | input_location = saved_loc; |
96c6931d RS |
924 | return ret; |
925 | } | |
926 | ||
927 | /* Expand an unreachable if statement, T. This function returns | |
928 | true if the IF_STMT contains a potentially reachable code_label. */ | |
929 | static bool | |
2f6e4e97 | 930 | expand_unreachable_if_stmt (tree t) |
96c6931d | 931 | { |
e55614ca | 932 | tree n; |
2f6e4e97 | 933 | |
96c6931d RS |
934 | if (find_reachable_label (IF_COND (t)) != NULL_TREE) |
935 | { | |
936 | genrtl_if_stmt (t); | |
937 | return true; | |
938 | } | |
939 | ||
940 | if (THEN_CLAUSE (t) && ELSE_CLAUSE (t)) | |
941 | { | |
e55614ca | 942 | n = expand_unreachable_stmt (THEN_CLAUSE (t), 0); |
2f6e4e97 | 943 | |
e55614ca | 944 | if (n != NULL_TREE) |
96c6931d RS |
945 | { |
946 | rtx label; | |
e55614ca | 947 | expand_stmt (n); |
96c6931d RS |
948 | label = gen_label_rtx (); |
949 | emit_jump (label); | |
e55614ca | 950 | expand_stmt (expand_unreachable_stmt (ELSE_CLAUSE (t), 0)); |
96c6931d RS |
951 | emit_label (label); |
952 | return true; | |
953 | } | |
954 | else | |
e55614ca | 955 | n = expand_unreachable_stmt (ELSE_CLAUSE (t), 0); |
96c6931d RS |
956 | } |
957 | else if (THEN_CLAUSE (t)) | |
e55614ca | 958 | n = expand_unreachable_stmt (THEN_CLAUSE (t), 0); |
96c6931d | 959 | else if (ELSE_CLAUSE (t)) |
e55614ca GK |
960 | n = expand_unreachable_stmt (ELSE_CLAUSE (t), 0); |
961 | else | |
962 | n = NULL_TREE; | |
2f6e4e97 | 963 | |
e55614ca | 964 | expand_stmt (n); |
2f6e4e97 | 965 | |
e55614ca | 966 | return n != NULL_TREE; |
96c6931d RS |
967 | } |
968 | ||
969 | /* Expand an unreachable statement list. This function skips all | |
970 | statements preceding the first potentially reachable label and | |
e55614ca GK |
971 | then returns the label (or, in same cases, the statement after |
972 | one containing the label). */ | |
973 | static tree | |
2f6e4e97 | 974 | expand_unreachable_stmt (tree t, int warn) |
96c6931d RS |
975 | { |
976 | int saved; | |
977 | ||
978 | while (t && t != error_mark_node) | |
979 | { | |
980 | if (warn) | |
981 | switch (TREE_CODE (t)) | |
982 | { | |
983 | case BREAK_STMT: | |
984 | case CONTINUE_STMT: | |
985 | case EXPR_STMT: | |
986 | case GOTO_STMT: | |
987 | case IF_STMT: | |
988 | case RETURN_STMT: | |
989 | if (!STMT_LINENO_FOR_FN_P (t)) | |
d479d37f | 990 | input_line = STMT_LINENO (t); |
96c6931d RS |
991 | warning("will never be executed"); |
992 | warn = false; | |
993 | break; | |
994 | ||
995 | default: | |
996 | break; | |
997 | } | |
998 | ||
999 | switch (TREE_CODE (t)) | |
1000 | { | |
1001 | case GOTO_STMT: | |
1002 | case CONTINUE_STMT: | |
1003 | case BREAK_STMT: | |
1004 | break; | |
1005 | ||
1006 | case FILE_STMT: | |
1007 | input_filename = FILE_STMT_FILENAME (t); | |
1008 | break; | |
1009 | ||
1010 | case RETURN_STMT: | |
1011 | if (find_reachable_label (RETURN_STMT_EXPR (t)) != NULL_TREE) | |
e55614ca | 1012 | return t; |
96c6931d RS |
1013 | break; |
1014 | ||
1015 | case EXPR_STMT: | |
1016 | if (find_reachable_label (EXPR_STMT_EXPR (t)) != NULL_TREE) | |
e55614ca | 1017 | return t; |
96c6931d RS |
1018 | break; |
1019 | ||
1020 | case IF_STMT: | |
1021 | if (expand_unreachable_if_stmt (t)) | |
e55614ca | 1022 | return TREE_CHAIN (t); |
96c6931d RS |
1023 | break; |
1024 | ||
0b82d59c RS |
1025 | case WHILE_STMT: |
1026 | /* If the start of a while statement is unreachable, there is | |
1027 | no need to rotate the loop, instead the WHILE_STMT can be | |
1028 | expanded like a DO_STMT. */ | |
1029 | genrtl_do_stmt_1 (WHILE_COND (t), WHILE_BODY (t)); | |
1030 | return TREE_CHAIN (t); | |
1031 | ||
96c6931d | 1032 | case COMPOUND_STMT: |
e55614ca GK |
1033 | { |
1034 | tree n; | |
1035 | n = expand_unreachable_stmt (COMPOUND_BODY (t), warn); | |
1036 | if (n != NULL_TREE) | |
1037 | { | |
1038 | expand_stmt (n); | |
1039 | return TREE_CHAIN (t); | |
1040 | } | |
1041 | warn = false; | |
1042 | break; | |
1043 | } | |
96c6931d RS |
1044 | |
1045 | case SCOPE_STMT: | |
1046 | saved = stmts_are_full_exprs_p (); | |
1047 | prep_stmt (t); | |
1048 | genrtl_scope_stmt (t); | |
1049 | current_stmt_tree ()->stmts_are_full_exprs_p = saved; | |
1050 | break; | |
1051 | ||
1052 | default: | |
e55614ca | 1053 | return t; |
96c6931d RS |
1054 | } |
1055 | t = TREE_CHAIN (t); | |
1056 | } | |
e55614ca | 1057 | return NULL_TREE; |
96c6931d | 1058 | } |