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