00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "config.h"
00032 #include "system.h"
00033 #include "tree.h"
00034 #include "cp-tree.h"
00035 #include "tree-inline.h"
00036 #include "except.h"
00037 #include "lex.h"
00038 #include "toplev.h"
00039 #include "flags.h"
00040 #include "ggc.h"
00041 #include "rtl.h"
00042 #include "expr.h"
00043 #include "output.h"
00044 #include "timevar.h"
00045 #include "debug.h"
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 static tree maybe_convert_cond PARAMS ((tree));
00057 static tree simplify_aggr_init_exprs_r PARAMS ((tree *, int *, void *));
00058 static void deferred_type_access_control PARAMS ((void));
00059 static void emit_associated_thunks PARAMS ((tree));
00060 static void genrtl_try_block PARAMS ((tree));
00061 static void genrtl_eh_spec_block PARAMS ((tree));
00062 static void genrtl_handler PARAMS ((tree));
00063 static void genrtl_named_return_value PARAMS ((void));
00064 static void cp_expand_stmt PARAMS ((tree));
00065 static void genrtl_start_function PARAMS ((tree));
00066 static void genrtl_finish_function PARAMS ((tree));
00067 static tree clear_decl_rtl PARAMS ((tree *, int *, void *));
00068
00069
00070
00071 #define FINISH_COND(COND, STMT, SUBSTMT) \
00072 do { \
00073 if (last_tree != (STMT)) \
00074 { \
00075 RECHAIN_STMTS (STMT, SUBSTMT); \
00076 if (!processing_template_decl) \
00077 { \
00078 (COND) = build_tree_list (SUBSTMT, COND); \
00079 (SUBSTMT) = (COND); \
00080 } \
00081 } \
00082 else \
00083 (SUBSTMT) = (COND); \
00084 } while (0)
00085
00086
00087
00088
00089
00090 int
00091 stmts_are_full_exprs_p ()
00092 {
00093 return current_stmt_tree ()->stmts_are_full_exprs_p;
00094 }
00095
00096
00097
00098
00099
00100 stmt_tree
00101 current_stmt_tree ()
00102 {
00103 return (cfun
00104 ? &cfun->language->base.x_stmt_tree
00105 : &scope_chain->x_stmt_tree);
00106 }
00107
00108
00109
00110
00111
00112 int
00113 anon_aggr_type_p (node)
00114 tree node;
00115 {
00116 return ANON_AGGR_TYPE_P (node);
00117 }
00118
00119
00120
00121 tree
00122 do_poplevel ()
00123 {
00124 tree block = NULL_TREE;
00125
00126 if (stmts_are_full_exprs_p ())
00127 {
00128 tree scope_stmts = NULL_TREE;
00129
00130 if (!processing_template_decl)
00131 scope_stmts = add_scope_stmt (0, 0);
00132
00133 block = poplevel (kept_level_p (), 1, 0);
00134 if (block && !processing_template_decl)
00135 {
00136 SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmts)) = block;
00137 SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmts)) = block;
00138 }
00139 }
00140
00141 return block;
00142 }
00143
00144
00145
00146 void
00147 do_pushlevel ()
00148 {
00149 if (stmts_are_full_exprs_p ())
00150 {
00151 pushlevel (0);
00152 if (!processing_template_decl)
00153 add_scope_stmt (1, 0);
00154 }
00155 }
00156
00157
00158
00159 tree
00160 finish_goto_stmt (destination)
00161 tree destination;
00162 {
00163 if (TREE_CODE (destination) == IDENTIFIER_NODE)
00164 destination = lookup_label (destination);
00165
00166
00167
00168 if (TREE_CODE (destination) == LABEL_DECL)
00169 TREE_USED (destination) = 1;
00170
00171 if (TREE_CODE (destination) != LABEL_DECL)
00172
00173
00174
00175
00176 DECL_UNINLINABLE (current_function_decl) = 1;
00177
00178 check_goto (destination);
00179
00180 return add_stmt (build_stmt (GOTO_STMT, destination));
00181 }
00182
00183
00184
00185
00186 tree
00187 maybe_convert_cond (cond)
00188 tree cond;
00189 {
00190
00191 if (!cond)
00192 return NULL_TREE;
00193
00194
00195 if (processing_template_decl)
00196 return cond;
00197
00198
00199 cond = convert_from_reference (cond);
00200 return condition_conversion (cond);
00201 }
00202
00203
00204
00205 tree
00206 finish_expr_stmt (expr)
00207 tree expr;
00208 {
00209 tree r = NULL_TREE;
00210 tree expr_type = NULL_TREE;;
00211
00212 if (expr != NULL_TREE)
00213 {
00214 if (!processing_template_decl
00215 && !(stmts_are_full_exprs_p ())
00216 && ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
00217 && lvalue_p (expr))
00218 || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE))
00219 expr = default_conversion (expr);
00220
00221
00222 expr_type = TREE_TYPE (expr);
00223
00224 if (stmts_are_full_exprs_p ())
00225 expr = convert_to_void (expr, "statement");
00226
00227 r = add_stmt (build_stmt (EXPR_STMT, expr));
00228 }
00229
00230 finish_stmt ();
00231
00232
00233
00234 last_expr_type = expr_type;
00235
00236 return r;
00237 }
00238
00239
00240
00241
00242
00243 tree
00244 begin_if_stmt ()
00245 {
00246 tree r;
00247 do_pushlevel ();
00248 r = build_stmt (IF_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
00249 add_stmt (r);
00250 return r;
00251 }
00252
00253
00254
00255
00256 void
00257 finish_if_stmt_cond (cond, if_stmt)
00258 tree cond;
00259 tree if_stmt;
00260 {
00261 cond = maybe_convert_cond (cond);
00262 FINISH_COND (cond, if_stmt, IF_COND (if_stmt));
00263 }
00264
00265
00266
00267
00268 tree
00269 finish_then_clause (if_stmt)
00270 tree if_stmt;
00271 {
00272 RECHAIN_STMTS (if_stmt, THEN_CLAUSE (if_stmt));
00273 return if_stmt;
00274 }
00275
00276
00277
00278 void
00279 begin_else_clause ()
00280 {
00281 }
00282
00283
00284
00285
00286 void
00287 finish_else_clause (if_stmt)
00288 tree if_stmt;
00289 {
00290 RECHAIN_STMTS (if_stmt, ELSE_CLAUSE (if_stmt));
00291 }
00292
00293
00294
00295 void
00296 finish_if_stmt ()
00297 {
00298 finish_stmt ();
00299 do_poplevel ();
00300 }
00301
00302
00303
00304
00305 tree
00306 begin_while_stmt ()
00307 {
00308 tree r;
00309 r = build_stmt (WHILE_STMT, NULL_TREE, NULL_TREE);
00310 add_stmt (r);
00311 do_pushlevel ();
00312 return r;
00313 }
00314
00315
00316
00317
00318 void
00319 finish_while_stmt_cond (cond, while_stmt)
00320 tree cond;
00321 tree while_stmt;
00322 {
00323 cond = maybe_convert_cond (cond);
00324 if (processing_template_decl)
00325
00326 FINISH_COND (cond, while_stmt, WHILE_COND (while_stmt));
00327 else if (getdecls () == NULL_TREE)
00328
00329 WHILE_COND (while_stmt) = cond;
00330 else
00331 {
00332
00333
00334
00335
00336
00337 tree if_stmt;
00338 WHILE_COND (while_stmt) = boolean_true_node;
00339
00340 if_stmt = begin_if_stmt ();
00341 cond = build_unary_op (TRUTH_NOT_EXPR, cond, 0);
00342 finish_if_stmt_cond (cond, if_stmt);
00343 finish_break_stmt ();
00344 finish_then_clause (if_stmt);
00345 finish_if_stmt ();
00346 }
00347 }
00348
00349
00350
00351 void
00352 finish_while_stmt (while_stmt)
00353 tree while_stmt;
00354 {
00355 do_poplevel ();
00356 RECHAIN_STMTS (while_stmt, WHILE_BODY (while_stmt));
00357 finish_stmt ();
00358 }
00359
00360
00361
00362
00363 tree
00364 begin_do_stmt ()
00365 {
00366 tree r = build_stmt (DO_STMT, NULL_TREE, NULL_TREE);
00367 add_stmt (r);
00368 return r;
00369 }
00370
00371
00372
00373 void
00374 finish_do_body (do_stmt)
00375 tree do_stmt;
00376 {
00377 RECHAIN_STMTS (do_stmt, DO_BODY (do_stmt));
00378 }
00379
00380
00381
00382
00383 void
00384 finish_do_stmt (cond, do_stmt)
00385 tree cond;
00386 tree do_stmt;
00387 {
00388 cond = maybe_convert_cond (cond);
00389 DO_COND (do_stmt) = cond;
00390 finish_stmt ();
00391 }
00392
00393
00394
00395
00396 tree
00397 finish_return_stmt (expr)
00398 tree expr;
00399 {
00400 tree r;
00401
00402 if (!processing_template_decl)
00403 expr = check_return_expr (expr);
00404 if (!processing_template_decl)
00405 {
00406 if (DECL_DESTRUCTOR_P (current_function_decl))
00407 {
00408
00409
00410
00411
00412 return finish_goto_stmt (dtor_label);
00413 }
00414 }
00415 r = add_stmt (build_stmt (RETURN_STMT, expr));
00416 finish_stmt ();
00417
00418 return r;
00419 }
00420
00421
00422
00423 tree
00424 begin_for_stmt ()
00425 {
00426 tree r;
00427
00428 r = build_stmt (FOR_STMT, NULL_TREE, NULL_TREE,
00429 NULL_TREE, NULL_TREE);
00430 NEW_FOR_SCOPE_P (r) = flag_new_for_scope > 0;
00431 if (NEW_FOR_SCOPE_P (r))
00432 {
00433 do_pushlevel ();
00434 note_level_for_for ();
00435 }
00436 add_stmt (r);
00437
00438 return r;
00439 }
00440
00441
00442
00443
00444 void
00445 finish_for_init_stmt (for_stmt)
00446 tree for_stmt;
00447 {
00448 if (last_tree != for_stmt)
00449 RECHAIN_STMTS (for_stmt, FOR_INIT_STMT (for_stmt));
00450 do_pushlevel ();
00451 }
00452
00453
00454
00455
00456 void
00457 finish_for_cond (cond, for_stmt)
00458 tree cond;
00459 tree for_stmt;
00460 {
00461 cond = maybe_convert_cond (cond);
00462 if (processing_template_decl)
00463
00464 FINISH_COND (cond, for_stmt, FOR_COND (for_stmt));
00465 else if (getdecls () == NULL_TREE)
00466
00467 FOR_COND (for_stmt) = cond;
00468 else
00469 {
00470
00471
00472
00473
00474
00475 tree if_stmt;
00476 FOR_COND (for_stmt) = NULL_TREE;
00477
00478 if_stmt = begin_if_stmt ();
00479 cond = build_unary_op (TRUTH_NOT_EXPR, cond, 0);
00480 finish_if_stmt_cond (cond, if_stmt);
00481 finish_break_stmt ();
00482 finish_then_clause (if_stmt);
00483 finish_if_stmt ();
00484 }
00485 }
00486
00487
00488
00489
00490 void
00491 finish_for_expr (expr, for_stmt)
00492 tree expr;
00493 tree for_stmt;
00494 {
00495 FOR_EXPR (for_stmt) = expr;
00496 }
00497
00498
00499
00500
00501
00502 void
00503 finish_for_stmt (for_stmt)
00504 tree for_stmt;
00505 {
00506
00507 do_poplevel ();
00508 RECHAIN_STMTS (for_stmt, FOR_BODY (for_stmt));
00509 if (NEW_FOR_SCOPE_P (for_stmt))
00510 do_poplevel ();
00511 finish_stmt ();
00512 }
00513
00514
00515
00516 tree
00517 finish_break_stmt ()
00518 {
00519 return add_stmt (build_break_stmt ());
00520 }
00521
00522
00523
00524 tree
00525 finish_continue_stmt ()
00526 {
00527 return add_stmt (build_continue_stmt ());
00528 }
00529
00530
00531
00532
00533 tree
00534 begin_switch_stmt ()
00535 {
00536 tree r;
00537 do_pushlevel ();
00538 r = build_stmt (SWITCH_STMT, NULL_TREE, NULL_TREE, NULL_TREE);
00539 add_stmt (r);
00540 return r;
00541 }
00542
00543
00544
00545 void
00546 finish_switch_cond (cond, switch_stmt)
00547 tree cond;
00548 tree switch_stmt;
00549 {
00550 tree orig_type = NULL;
00551 if (!processing_template_decl)
00552 {
00553 tree index;
00554
00555
00556 cond = build_expr_type_conversion (WANT_INT | WANT_ENUM, cond, 1);
00557 if (cond == NULL_TREE)
00558 {
00559 error ("switch quantity not an integer");
00560 cond = error_mark_node;
00561 }
00562 orig_type = TREE_TYPE (cond);
00563 if (cond != error_mark_node)
00564 {
00565 cond = default_conversion (cond);
00566 cond = fold (build1 (CLEANUP_POINT_EXPR, TREE_TYPE (cond), cond));
00567 }
00568
00569 if (cond != error_mark_node)
00570 {
00571 index = get_unwidened (cond, NULL_TREE);
00572
00573
00574
00575
00576 if (TREE_UNSIGNED (TREE_TYPE (cond))
00577 == TREE_UNSIGNED (TREE_TYPE (index)))
00578 cond = index;
00579 }
00580 }
00581 FINISH_COND (cond, switch_stmt, SWITCH_COND (switch_stmt));
00582 SWITCH_TYPE (switch_stmt) = orig_type;
00583 push_switch (switch_stmt);
00584 }
00585
00586
00587
00588
00589 void
00590 finish_switch_stmt (switch_stmt)
00591 tree switch_stmt;
00592 {
00593 RECHAIN_STMTS (switch_stmt, SWITCH_BODY (switch_stmt));
00594 pop_switch ();
00595 finish_stmt ();
00596 do_poplevel ();
00597 }
00598
00599
00600
00601 static void
00602 genrtl_try_block (t)
00603 tree t;
00604 {
00605 if (CLEANUP_P (t))
00606 {
00607 expand_eh_region_start ();
00608 expand_stmt (TRY_STMTS (t));
00609 expand_eh_region_end_cleanup (TRY_HANDLERS (t));
00610 }
00611 else
00612 {
00613 if (!FN_TRY_BLOCK_P (t))
00614 emit_line_note (input_filename, lineno);
00615
00616 expand_eh_region_start ();
00617 expand_stmt (TRY_STMTS (t));
00618
00619 if (FN_TRY_BLOCK_P (t))
00620 {
00621 expand_start_all_catch ();
00622 in_function_try_handler = 1;
00623 expand_stmt (TRY_HANDLERS (t));
00624 in_function_try_handler = 0;
00625 expand_end_all_catch ();
00626 }
00627 else
00628 {
00629 expand_start_all_catch ();
00630 expand_stmt (TRY_HANDLERS (t));
00631 expand_end_all_catch ();
00632 }
00633 }
00634 }
00635
00636
00637
00638 static void
00639 genrtl_eh_spec_block (t)
00640 tree t;
00641 {
00642 expand_eh_region_start ();
00643 expand_stmt (EH_SPEC_STMTS (t));
00644 expand_eh_region_end_allowed (EH_SPEC_RAISES (t),
00645 build_call (call_unexpected_node,
00646 tree_cons (NULL_TREE,
00647 build_exc_ptr (),
00648 NULL_TREE)));
00649 }
00650
00651
00652
00653
00654 tree
00655 begin_try_block ()
00656 {
00657 tree r = build_stmt (TRY_BLOCK, NULL_TREE, NULL_TREE);
00658 add_stmt (r);
00659 return r;
00660 }
00661
00662
00663
00664 tree
00665 begin_function_try_block ()
00666 {
00667 tree r = build_stmt (TRY_BLOCK, NULL_TREE, NULL_TREE);
00668 FN_TRY_BLOCK_P (r) = 1;
00669 add_stmt (r);
00670 return r;
00671 }
00672
00673
00674
00675 void
00676 finish_try_block (try_block)
00677 tree try_block;
00678 {
00679 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
00680 }
00681
00682
00683
00684
00685 void
00686 finish_cleanup_try_block (try_block)
00687 tree try_block;
00688 {
00689 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
00690 }
00691
00692
00693
00694
00695 void
00696 finish_cleanup (cleanup, try_block)
00697 tree cleanup;
00698 tree try_block;
00699 {
00700 TRY_HANDLERS (try_block) = cleanup;
00701 CLEANUP_P (try_block) = 1;
00702 }
00703
00704
00705
00706 void
00707 finish_function_try_block (try_block)
00708 tree try_block;
00709 {
00710 if (TREE_CHAIN (try_block)
00711 && TREE_CODE (TREE_CHAIN (try_block)) == CTOR_INITIALIZER)
00712 {
00713
00714 TREE_CHAIN (TREE_CHAIN (try_block)) = last_tree;
00715
00716 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
00717 }
00718 else
00719 RECHAIN_STMTS (try_block, TRY_STMTS (try_block));
00720 in_function_try_handler = 1;
00721 }
00722
00723
00724
00725
00726 void
00727 finish_handler_sequence (try_block)
00728 tree try_block;
00729 {
00730 RECHAIN_STMTS (try_block, TRY_HANDLERS (try_block));
00731 check_handlers (TRY_HANDLERS (try_block));
00732 }
00733
00734
00735
00736 void
00737 finish_function_handler_sequence (try_block)
00738 tree try_block;
00739 {
00740 in_function_try_handler = 0;
00741 RECHAIN_STMTS (try_block, TRY_HANDLERS (try_block));
00742 check_handlers (TRY_HANDLERS (try_block));
00743 }
00744
00745
00746
00747 static void
00748 genrtl_handler (t)
00749 tree t;
00750 {
00751 genrtl_do_pushlevel ();
00752 if (!processing_template_decl)
00753 expand_start_catch (HANDLER_TYPE (t));
00754 expand_stmt (HANDLER_BODY (t));
00755 if (!processing_template_decl)
00756 expand_end_catch ();
00757 }
00758
00759
00760
00761 tree
00762 begin_handler ()
00763 {
00764 tree r;
00765 r = build_stmt (HANDLER, NULL_TREE, NULL_TREE);
00766 add_stmt (r);
00767
00768
00769 do_pushlevel ();
00770 note_level_for_catch ();
00771 return r;
00772 }
00773
00774
00775
00776
00777
00778 void
00779 finish_handler_parms (decl, handler)
00780 tree decl;
00781 tree handler;
00782 {
00783 tree type = NULL_TREE;
00784 if (processing_template_decl)
00785 {
00786 if (decl)
00787 {
00788 decl = pushdecl (decl);
00789 decl = push_template_decl (decl);
00790 add_decl_stmt (decl);
00791 RECHAIN_STMTS (handler, HANDLER_PARMS (handler));
00792 type = TREE_TYPE (decl);
00793 }
00794 }
00795 else
00796 type = expand_start_catch_block (decl);
00797
00798 HANDLER_TYPE (handler) = type;
00799 }
00800
00801
00802
00803
00804 void
00805 finish_handler (handler)
00806 tree handler;
00807 {
00808 if (!processing_template_decl)
00809 expand_end_catch_block ();
00810 do_poplevel ();
00811 RECHAIN_STMTS (handler, HANDLER_BODY (handler));
00812 }
00813
00814
00815
00816
00817
00818 tree
00819 begin_compound_stmt (has_no_scope)
00820 int has_no_scope;
00821 {
00822 tree r;
00823 int is_try = 0;
00824
00825 r = build_stmt (COMPOUND_STMT, NULL_TREE);
00826
00827 if (last_tree && TREE_CODE (last_tree) == TRY_BLOCK)
00828 is_try = 1;
00829
00830 add_stmt (r);
00831 if (has_no_scope)
00832 COMPOUND_STMT_NO_SCOPE (r) = 1;
00833
00834 last_expr_type = NULL_TREE;
00835
00836 if (!has_no_scope)
00837 {
00838 do_pushlevel ();
00839 if (is_try)
00840 note_level_for_try ();
00841 }
00842 else
00843
00844
00845
00846
00847 keep_next_level (0);
00848
00849 return r;
00850 }
00851
00852
00853
00854
00855
00856 tree
00857 finish_compound_stmt (has_no_scope, compound_stmt)
00858 int has_no_scope;
00859 tree compound_stmt;
00860 {
00861 tree r;
00862 tree t;
00863
00864 if (!has_no_scope)
00865 r = do_poplevel ();
00866 else
00867 r = NULL_TREE;
00868
00869 RECHAIN_STMTS (compound_stmt, COMPOUND_BODY (compound_stmt));
00870
00871
00872
00873
00874
00875 t = last_expr_type;
00876 finish_stmt ();
00877 last_expr_type = t;
00878
00879 return r;
00880 }
00881
00882
00883
00884
00885
00886 tree
00887 finish_asm_stmt (cv_qualifier, string, output_operands,
00888 input_operands, clobbers)
00889 tree cv_qualifier;
00890 tree string;
00891 tree output_operands;
00892 tree input_operands;
00893 tree clobbers;
00894 {
00895 tree r;
00896 tree t;
00897
00898 if (cv_qualifier != NULL_TREE
00899 && cv_qualifier != ridpointers[(int) RID_VOLATILE])
00900 {
00901 warning ("%s qualifier ignored on asm",
00902 IDENTIFIER_POINTER (cv_qualifier));
00903 cv_qualifier = NULL_TREE;
00904 }
00905
00906 if (!processing_template_decl)
00907 {
00908 int i;
00909 int ninputs;
00910 int noutputs;
00911
00912 for (t = input_operands; t; t = TREE_CHAIN (t))
00913 {
00914 tree converted_operand
00915 = decay_conversion (TREE_VALUE (t));
00916
00917
00918
00919
00920
00921 if (TREE_TYPE (converted_operand) == unknown_type_node)
00922 {
00923 error ("type of asm operand `%E' could not be determined",
00924 TREE_VALUE (t));
00925 converted_operand = error_mark_node;
00926 }
00927 TREE_VALUE (t) = converted_operand;
00928 }
00929
00930 ninputs = list_length (input_operands);
00931 noutputs = list_length (output_operands);
00932
00933 for (i = 0, t = output_operands; t; t = TREE_CHAIN (t), ++i)
00934 {
00935 bool allows_mem;
00936 bool allows_reg;
00937 bool is_inout;
00938 const char *constraint;
00939 tree operand;
00940
00941 constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t)));
00942 operand = TREE_VALUE (t);
00943
00944 if (!parse_output_constraint (&constraint,
00945 i, ninputs, noutputs,
00946 &allows_mem,
00947 &allows_reg,
00948 &is_inout))
00949 {
00950
00951
00952 TREE_TYPE (operand) = error_mark_node;
00953 continue;
00954 }
00955
00956
00957
00958
00959
00960
00961
00962 if (!allows_reg && DECL_P (operand))
00963 cxx_mark_addressable (operand);
00964 }
00965 }
00966
00967 r = build_stmt (ASM_STMT, cv_qualifier, string,
00968 output_operands, input_operands,
00969 clobbers);
00970 return add_stmt (r);
00971 }
00972
00973
00974
00975 void
00976 finish_label_stmt (name)
00977 tree name;
00978 {
00979 tree decl = define_label (input_filename, lineno, name);
00980 add_stmt (build_stmt (LABEL_STMT, decl));
00981 }
00982
00983
00984
00985
00986
00987 void
00988 finish_label_decl (name)
00989 tree name;
00990 {
00991 tree decl = declare_local_label (name);
00992 add_decl_stmt (decl);
00993 }
00994
00995
00996
00997 void
00998 finish_decl_cleanup (decl, cleanup)
00999 tree decl;
01000 tree cleanup;
01001 {
01002 add_stmt (build_stmt (CLEANUP_STMT, decl, cleanup));
01003 }
01004
01005
01006
01007 void
01008 finish_eh_cleanup (cleanup)
01009 tree cleanup;
01010 {
01011 tree r = build_stmt (CLEANUP_STMT, NULL_TREE, cleanup);
01012 CLEANUP_EH_ONLY (r) = 1;
01013 add_stmt (r);
01014 }
01015
01016
01017
01018 static void
01019 genrtl_named_return_value ()
01020 {
01021 tree decl = DECL_RESULT (current_function_decl);
01022
01023
01024
01025 if (DECL_REGISTER (decl))
01026 {
01027
01028
01029
01030
01031
01032
01033
01034 SET_DECL_RTL (decl, gen_reg_rtx (GET_MODE (DECL_RTL (decl))));
01035 if (TREE_ADDRESSABLE (decl))
01036 put_var_into_stack (decl, true);
01037 }
01038
01039 emit_local_var (decl);
01040 }
01041
01042
01043
01044
01045 void
01046 finish_named_return_value (return_id, init)
01047 tree return_id, init;
01048 {
01049 tree decl = DECL_RESULT (current_function_decl);
01050
01051
01052
01053
01054 if (pedantic)
01055 pedwarn ("ISO C++ does not permit named return values");
01056 cp_deprecated ("the named return value extension");
01057
01058 if (return_id != NULL_TREE)
01059 {
01060 if (DECL_NAME (decl) == NULL_TREE)
01061 DECL_NAME (decl) = return_id;
01062 else
01063 {
01064 error ("return identifier `%D' already in place", return_id);
01065 return;
01066 }
01067 }
01068
01069
01070 if (DECL_CONSTRUCTOR_P (current_function_decl))
01071 {
01072 error ("can't redefine default return value for constructors");
01073 return;
01074 }
01075
01076
01077 if (DECL_NAME (decl) != NULL_TREE)
01078 {
01079
01080 DECL_INITIAL (decl) = init;
01081 if (doing_semantic_analysis_p ())
01082 pushdecl (decl);
01083 if (!processing_template_decl)
01084 {
01085 cp_finish_decl (decl, init, NULL_TREE, 0);
01086 add_stmt (build_stmt (RETURN_INIT, NULL_TREE, NULL_TREE));
01087 }
01088 else
01089 add_stmt (build_stmt (RETURN_INIT, return_id, init));
01090 }
01091
01092
01093
01094
01095 DECL_UNINLINABLE (current_function_decl) = 1;
01096 }
01097
01098
01099
01100 void
01101 begin_mem_initializers ()
01102 {
01103 if (! DECL_CONSTRUCTOR_P (current_function_decl))
01104 error ("only constructors take base initializers");
01105 }
01106
01107
01108
01109
01110
01111 void
01112 finish_mem_initializers (tree mem_inits)
01113 {
01114
01115
01116 mem_inits = nreverse (mem_inits);
01117
01118 if (processing_template_decl)
01119 add_stmt (build_min_nt (CTOR_INITIALIZER, mem_inits));
01120 else
01121 emit_mem_initializers (mem_inits);
01122 }
01123
01124
01125
01126 tree *
01127 current_scope_stmt_stack ()
01128 {
01129 return &cfun->language->base.x_scope_stmt_stack;
01130 }
01131
01132
01133
01134 tree
01135 finish_parenthesized_expr (expr)
01136 tree expr;
01137 {
01138 if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (expr))))
01139
01140 C_SET_EXP_ORIGINAL_CODE (expr, ERROR_MARK);
01141
01142 if (TREE_CODE (expr) == OFFSET_REF)
01143
01144
01145 PTRMEM_OK_P (expr) = 0;
01146 return expr;
01147 }
01148
01149
01150
01151
01152 tree
01153 begin_stmt_expr ()
01154 {
01155
01156
01157
01158 if (! cfun && !last_tree)
01159 begin_stmt_tree (&scope_chain->x_saved_tree);
01160
01161 keep_next_level (1);
01162
01163
01164
01165
01166 return last_tree;
01167 }
01168
01169
01170
01171
01172
01173 tree
01174 begin_global_stmt_expr ()
01175 {
01176 if (! cfun && !last_tree)
01177 begin_stmt_tree (&scope_chain->x_saved_tree);
01178
01179 keep_next_level (1);
01180
01181 return last_tree ? last_tree : expand_start_stmt_expr(1);
01182 }
01183
01184
01185
01186 tree
01187 finish_global_stmt_expr (stmt_expr)
01188 tree stmt_expr;
01189 {
01190 stmt_expr = expand_end_stmt_expr (stmt_expr);
01191
01192 if (! cfun
01193 && TREE_CHAIN (scope_chain->x_saved_tree) == NULL_TREE)
01194 finish_stmt_tree (&scope_chain->x_saved_tree);
01195
01196 return stmt_expr;
01197 }
01198
01199
01200
01201
01202
01203
01204 tree
01205 finish_stmt_expr (rtl_expr)
01206 tree rtl_expr;
01207 {
01208 tree result;
01209
01210
01211
01212 if (!last_expr_type)
01213 last_expr_type = void_type_node;
01214 result = build_min (STMT_EXPR, last_expr_type, last_tree);
01215 TREE_SIDE_EFFECTS (result) = 1;
01216
01217
01218
01219 last_tree = rtl_expr;
01220 TREE_CHAIN (last_tree) = NULL_TREE;
01221
01222
01223
01224 if (! cfun
01225 && TREE_CHAIN (scope_chain->x_saved_tree) == NULL_TREE)
01226 finish_stmt_tree (&scope_chain->x_saved_tree);
01227
01228 return result;
01229 }
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241 tree
01242 finish_call_expr (tree fn, tree args, bool disallow_virtual)
01243 {
01244 if (fn == error_mark_node || args == error_mark_node)
01245 return error_mark_node;
01246
01247 if (processing_template_decl)
01248 return build_nt (CALL_EXPR, fn, args, NULL_TREE);
01249
01250
01251 my_friendly_assert (!args || TREE_CODE (args) == TREE_LIST,
01252 20020712);
01253
01254 if (BASELINK_P (fn))
01255 {
01256 tree object;
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276 if (current_class_type
01277 && DERIVED_FROM_P (BINFO_TYPE (BASELINK_ACCESS_BINFO (fn)),
01278 current_class_type)
01279 && current_class_ref)
01280 object = maybe_dummy_object (BINFO_TYPE (BASELINK_ACCESS_BINFO (fn)),
01281 NULL);
01282 else
01283 {
01284 tree representative_fn;
01285
01286 representative_fn = BASELINK_FUNCTIONS (fn);
01287 if (TREE_CODE (representative_fn) == TEMPLATE_ID_EXPR)
01288 representative_fn = TREE_OPERAND (representative_fn, 0);
01289 representative_fn = get_first_fn (representative_fn);
01290 object = build_dummy_object (DECL_CONTEXT (representative_fn));
01291 }
01292
01293 return build_new_method_call (object, fn, args, NULL_TREE,
01294 (disallow_virtual
01295 ? LOOKUP_NONVIRTUAL : 0));
01296 }
01297 else if (is_overloaded_fn (fn))
01298
01299 return build_new_function_call (fn, args);
01300 else if (CLASS_TYPE_P (TREE_TYPE (fn)))
01301 {
01302
01303
01304 tree result;
01305 result = build_opfncall (CALL_EXPR, LOOKUP_NORMAL, fn, args, NULL_TREE);
01306 if (result)
01307 return result;
01308 }
01309
01310
01311 return build_function_call (fn, args);
01312 }
01313
01314
01315
01316
01317
01318 tree
01319 finish_increment_expr (expr, code)
01320 tree expr;
01321 enum tree_code code;
01322 {
01323
01324
01325
01326
01327
01328 if (TREE_CODE (expr) == OFFSET_REF)
01329 expr = resolve_offset_ref (expr);
01330 return build_x_unary_op (code, expr);
01331 }
01332
01333
01334
01335 tree
01336 finish_this_expr ()
01337 {
01338 tree result;
01339
01340 if (current_class_ptr)
01341 {
01342 result = current_class_ptr;
01343 }
01344 else if (current_function_decl
01345 && DECL_STATIC_FUNCTION_P (current_function_decl))
01346 {
01347 error ("`this' is unavailable for static member functions");
01348 result = error_mark_node;
01349 }
01350 else
01351 {
01352 if (current_function_decl)
01353 error ("invalid use of `this' in non-member function");
01354 else
01355 error ("invalid use of `this' at top level");
01356 result = error_mark_node;
01357 }
01358
01359 return result;
01360 }
01361
01362
01363
01364
01365 tree
01366 finish_object_call_expr (fn, object, args)
01367 tree fn;
01368 tree object;
01369 tree args;
01370 {
01371 if (DECL_DECLARES_TYPE_P (fn))
01372 {
01373 if (processing_template_decl)
01374
01375
01376
01377
01378
01379
01380
01381
01382 fn = DECL_NAME (fn);
01383 else
01384 {
01385 error ("calling type `%T' like a method", fn);
01386 return error_mark_node;
01387 }
01388 }
01389
01390 if (processing_template_decl || name_p (fn))
01391 return build_method_call (object, fn, args, NULL_TREE, LOOKUP_NORMAL);
01392 else
01393 return build_new_method_call (object, fn, args, NULL_TREE, LOOKUP_NORMAL);
01394 }
01395
01396
01397
01398
01399 tree
01400 finish_qualified_object_call_expr (fn, object, args)
01401 tree fn;
01402 tree object;
01403 tree args;
01404 {
01405 return build_scoped_method_call (object, TREE_OPERAND (fn, 0),
01406 TREE_OPERAND (fn, 1), args);
01407 }
01408
01409
01410
01411
01412
01413 tree
01414 finish_pseudo_destructor_call_expr (object, scope, destructor)
01415 tree object;
01416 tree scope;
01417 tree destructor;
01418 {
01419 if (processing_template_decl)
01420 return build_min_nt (PSEUDO_DTOR_EXPR, object, scope, destructor);
01421
01422 if (scope && scope != destructor)
01423 error ("destructor specifier `%T::~%T()' must have matching names",
01424 scope, destructor);
01425
01426 if ((scope == NULL_TREE || IDENTIFIER_GLOBAL_VALUE (destructor))
01427 && (TREE_CODE (TREE_TYPE (object)) !=
01428 TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (destructor)))))
01429 error ("`%E' is not of type `%T'", object, destructor);
01430
01431 return cp_convert (void_type_node, object);
01432 }
01433
01434
01435
01436 tree
01437 finish_unary_op_expr (code, expr)
01438 enum tree_code code;
01439 tree expr;
01440 {
01441 tree result = build_x_unary_op (code, expr);
01442
01443
01444
01445 if (code == NEGATE_EXPR && TREE_CODE (expr) == INTEGER_CST
01446 && TREE_CODE (result) == INTEGER_CST
01447 && !TREE_UNSIGNED (TREE_TYPE (result))
01448 && INT_CST_LT (result, integer_zero_node))
01449 TREE_NEGATED_INT (result) = 1;
01450 overflow_warning (result);
01451 return result;
01452 }
01453
01454
01455
01456 tree
01457 finish_id_expr (expr)
01458 tree expr;
01459 {
01460 if (TREE_CODE (expr) == IDENTIFIER_NODE)
01461 expr = do_identifier (expr, 1, NULL_TREE);
01462
01463 if (TREE_TYPE (expr) == error_mark_node)
01464 expr = error_mark_node;
01465 return expr;
01466 }
01467
01468
01469
01470
01471 tree
01472 finish_fname (tree id)
01473 {
01474 tree decl;
01475
01476 decl = fname_decl (C_RID_CODE (id), id);
01477 if (processing_template_decl)
01478 decl = build_min_nt (LOOKUP_EXPR, DECL_NAME (decl));
01479 return decl;
01480 }
01481
01482 static tree current_type_lookups;
01483
01484
01485
01486
01487 static void
01488 deferred_type_access_control ()
01489 {
01490 tree lookup = type_lookups;
01491
01492 if (lookup == error_mark_node)
01493 return;
01494
01495 for (; lookup; lookup = TREE_CHAIN (lookup))
01496 enforce_access (TREE_PURPOSE (lookup), TREE_VALUE (lookup));
01497 }
01498
01499 void
01500 decl_type_access_control (decl)
01501 tree decl;
01502 {
01503 tree save_fn;
01504
01505 if (type_lookups == error_mark_node)
01506 return;
01507
01508 save_fn = current_function_decl;
01509
01510 if (decl && TREE_CODE (decl) == FUNCTION_DECL)
01511 current_function_decl = decl;
01512
01513 deferred_type_access_control ();
01514
01515 current_function_decl = save_fn;
01516
01517
01518
01519
01520 type_lookups = current_type_lookups;
01521 }
01522
01523 void
01524 save_type_access_control (lookups)
01525 tree lookups;
01526 {
01527 current_type_lookups = lookups;
01528 }
01529
01530
01531
01532 void
01533 reset_type_access_control ()
01534 {
01535 type_lookups = NULL_TREE;
01536 current_type_lookups = NULL_TREE;
01537 }
01538
01539
01540
01541
01542
01543 int
01544 begin_function_definition (decl_specs, attributes, declarator)
01545 tree decl_specs;
01546 tree attributes;
01547 tree declarator;
01548 {
01549 if (!start_function (decl_specs, declarator, attributes, SF_DEFAULT))
01550 return 0;
01551
01552 deferred_type_access_control ();
01553 type_lookups = error_mark_node;
01554
01555
01556
01557 reset_specialization ();
01558
01559 return 1;
01560 }
01561
01562
01563
01564
01565 tree
01566 begin_constructor_declarator (scope, name)
01567 tree scope;
01568 tree name;
01569 {
01570 tree result = build_nt (SCOPE_REF, scope, name);
01571 enter_scope_of (result);
01572 return result;
01573 }
01574
01575
01576
01577 tree
01578 finish_declarator (declarator, declspecs, attributes,
01579 prefix_attributes, initialized)
01580 tree declarator;
01581 tree declspecs;
01582 tree attributes;
01583 tree prefix_attributes;
01584 int initialized;
01585 {
01586 return start_decl (declarator, declspecs, initialized, attributes,
01587 prefix_attributes);
01588 }
01589
01590
01591
01592 void
01593 finish_translation_unit ()
01594 {
01595
01596
01597 pop_everything ();
01598 while (current_namespace != global_namespace)
01599 pop_namespace ();
01600
01601
01602 finish_fname_decls ();
01603
01604 finish_file ();
01605 }
01606
01607
01608
01609
01610 tree
01611 finish_template_type_parm (aggr, identifier)
01612 tree aggr;
01613 tree identifier;
01614 {
01615 if (aggr != class_type_node)
01616 {
01617 pedwarn ("template type parameters must use the keyword `class' or `typename'");
01618 aggr = class_type_node;
01619 }
01620
01621 return build_tree_list (aggr, identifier);
01622 }
01623
01624
01625
01626
01627 tree
01628 finish_template_template_parm (aggr, identifier)
01629 tree aggr;
01630 tree identifier;
01631 {
01632 tree decl = build_decl (TYPE_DECL, identifier, NULL_TREE);
01633 tree tmpl = build_lang_decl (TEMPLATE_DECL, identifier, NULL_TREE);
01634 DECL_TEMPLATE_PARMS (tmpl) = current_template_parms;
01635 DECL_TEMPLATE_RESULT (tmpl) = decl;
01636 DECL_ARTIFICIAL (decl) = 1;
01637 end_template_decl ();
01638
01639 my_friendly_assert (DECL_TEMPLATE_PARMS (tmpl), 20010110);
01640
01641 return finish_template_type_parm (aggr, tmpl);
01642 }
01643
01644
01645
01646
01647
01648 tree
01649 check_template_template_default_arg (tree argument)
01650 {
01651 if (TREE_CODE (argument) != TEMPLATE_DECL
01652 && TREE_CODE (argument) != TEMPLATE_TEMPLATE_PARM
01653 && TREE_CODE (argument) != TYPE_DECL
01654 && TREE_CODE (argument) != UNBOUND_CLASS_TEMPLATE)
01655 {
01656 error ("invalid default template argument");
01657 return error_mark_node;
01658 }
01659
01660 return argument;
01661 }
01662
01663
01664
01665
01666 tree
01667 finish_parmlist (parms, ellipsis)
01668 tree parms;
01669 int ellipsis;
01670 {
01671 if (parms)
01672 {
01673
01674
01675 TREE_PARMLIST (parms) = 1;
01676
01677
01678 PARMLIST_ELLIPSIS_P (parms) = ellipsis;
01679 }
01680 return parms;
01681 }
01682
01683
01684
01685 tree
01686 begin_class_definition (t)
01687 tree t;
01688 {
01689 if (t == error_mark_node)
01690 return error_mark_node;
01691
01692
01693 decl_type_access_control (TYPE_NAME (t));
01694 reset_type_access_control ();
01695
01696 if (processing_template_parmlist)
01697 {
01698 error ("definition of `%#T' inside template parameter list", t);
01699 return error_mark_node;
01700 }
01701
01702
01703
01704 if (IMPLICIT_TYPENAME_P (t))
01705 t = TREE_TYPE (t);
01706
01707
01708
01709
01710
01711
01712 else if (TREE_CODE (t) == TYPENAME_TYPE)
01713 {
01714 error ("invalid definition of qualified type `%T'", t);
01715 t = error_mark_node;
01716 }
01717
01718 if (t == error_mark_node || ! IS_AGGR_TYPE (t))
01719 {
01720 t = make_aggr_type (RECORD_TYPE);
01721 pushtag (make_anon_name (), t, 0);
01722 }
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747 if (PARTIAL_INSTANTIATION_P (t))
01748 {
01749 if (!pedantic)
01750 {
01751
01752
01753
01754
01755
01756
01757
01758
01759 TYPE_BINFO_BASETYPES (t) = NULL_TREE;
01760 TYPE_FIELDS (t) = NULL_TREE;
01761 TYPE_METHODS (t) = NULL_TREE;
01762 CLASSTYPE_DECL_LIST (t) = NULL_TREE;
01763 CLASSTYPE_NESTED_UDTS (t) = NULL;
01764 CLASSTYPE_VBASECLASSES (t) = NULL_TREE;
01765 TYPE_SIZE (t) = NULL_TREE;
01766 }
01767
01768
01769 PARTIAL_INSTANTIATION_P (t) = 0;
01770 }
01771
01772
01773 else if (COMPLETE_TYPE_P (t))
01774 duplicate_tag_error (t);
01775
01776
01777 DECL_SOURCE_FILE (TYPE_NAME (t)) = input_filename;
01778 DECL_SOURCE_LINE (TYPE_NAME (t)) = lineno;
01779
01780 if (TYPE_BEING_DEFINED (t))
01781 {
01782 t = make_aggr_type (TREE_CODE (t));
01783 pushtag (TYPE_IDENTIFIER (t), t, 0);
01784 }
01785 maybe_process_partial_specialization (t);
01786 pushclass (t, 1);
01787 TYPE_BEING_DEFINED (t) = 1;
01788 TYPE_PACKED (t) = flag_pack_struct;
01789
01790
01791
01792 if (! TYPE_ANONYMOUS_P (t))
01793 {
01794 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
01795 SET_CLASSTYPE_INTERFACE_UNKNOWN_X
01796 (t, interface_unknown);
01797 }
01798 reset_specialization();
01799
01800
01801 build_self_reference ();
01802
01803 return t;
01804 }
01805
01806
01807
01808 void
01809 finish_member_declaration (decl)
01810 tree decl;
01811 {
01812 if (decl == error_mark_node || decl == NULL_TREE)
01813 return;
01814
01815 if (decl == void_type_node)
01816
01817
01818 return;
01819
01820
01821 my_friendly_assert (TREE_CHAIN (decl) == NULL_TREE, 0);
01822
01823
01824 TREE_PRIVATE (decl)
01825 = (current_access_specifier == access_private_node);
01826 TREE_PROTECTED (decl)
01827 = (current_access_specifier == access_protected_node);
01828 if (TREE_CODE (decl) == TEMPLATE_DECL)
01829 {
01830 TREE_PRIVATE (DECL_TEMPLATE_RESULT (decl)) = TREE_PRIVATE (decl);
01831 TREE_PROTECTED (DECL_TEMPLATE_RESULT (decl)) = TREE_PROTECTED (decl);
01832 }
01833
01834
01835 DECL_CONTEXT (decl) = current_class_type;
01836
01837
01838
01839
01840
01841 if (DECL_LANG_SPECIFIC (decl) && DECL_LANGUAGE (decl) == lang_c)
01842 SET_DECL_LANGUAGE (decl, lang_cplusplus);
01843
01844
01845
01846
01847 if (TREE_CODE (decl) == FUNCTION_DECL
01848 || DECL_FUNCTION_TEMPLATE_P (decl))
01849 {
01850
01851
01852 add_method (current_class_type, decl, 0);
01853
01854 TREE_CHAIN (decl) = TYPE_METHODS (current_class_type);
01855 TYPE_METHODS (current_class_type) = decl;
01856
01857 maybe_add_class_template_decl_list (current_class_type, decl,
01858 0);
01859 }
01860
01861 else if (TREE_CODE (decl) == USING_DECL || pushdecl_class_level (decl))
01862 {
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880 if (TREE_CODE (decl) == TYPE_DECL)
01881 TYPE_FIELDS (current_class_type)
01882 = chainon (TYPE_FIELDS (current_class_type), decl);
01883 else
01884 {
01885 TREE_CHAIN (decl) = TYPE_FIELDS (current_class_type);
01886 TYPE_FIELDS (current_class_type) = decl;
01887 }
01888
01889 maybe_add_class_template_decl_list (current_class_type, decl,
01890 0);
01891 }
01892 }
01893
01894
01895
01896
01897
01898 tree
01899 finish_class_definition (t, attributes, semi, pop_scope_p)
01900 tree t;
01901 tree attributes;
01902 int semi;
01903 int pop_scope_p;
01904 {
01905 if (t == error_mark_node)
01906 return error_mark_node;
01907
01908
01909
01910 if (semi)
01911 note_got_semicolon (t);
01912
01913
01914
01915 attributes = chainon (TYPE_ATTRIBUTES (t), attributes);
01916 TYPE_ATTRIBUTES (t) = NULL_TREE;
01917
01918 if (TREE_CODE (t) == ENUMERAL_TYPE)
01919 ;
01920 else
01921 {
01922 t = finish_struct (t, attributes);
01923 if (semi)
01924 note_got_semicolon (t);
01925 }
01926
01927 if (! semi)
01928 check_for_missing_semicolon (t);
01929 if (pop_scope_p)
01930 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (t)));
01931 if (current_scope () == current_function_decl)
01932 do_pending_defargs ();
01933
01934 return t;
01935 }
01936
01937
01938
01939
01940 void
01941 begin_inline_definitions ()
01942 {
01943 if (current_scope () == current_function_decl)
01944 do_pending_inlines ();
01945 }
01946
01947
01948
01949
01950 tree
01951 finish_member_class_template (types)
01952 tree types;
01953 {
01954 tree t;
01955
01956
01957
01958
01959 for (t = types; t != NULL_TREE; t = TREE_CHAIN (t))
01960 if (IS_AGGR_TYPE_CODE (TREE_CODE (TREE_VALUE (t))))
01961 maybe_process_partial_specialization (TREE_VALUE (t));
01962
01963 note_list_got_semicolon (types);
01964 grok_x_components (types);
01965 if (TYPE_CONTEXT (TREE_VALUE (types)) != current_class_type)
01966
01967
01968
01969 types = NULL_TREE;
01970
01971 finish_member_template_decl (types);
01972
01973
01974
01975
01976 return NULL_TREE;
01977 }
01978
01979
01980
01981
01982 void
01983 finish_template_decl (parms)
01984 tree parms;
01985 {
01986 if (parms)
01987 end_template_decl ();
01988 else
01989 end_specialization ();
01990 }
01991
01992
01993
01994
01995
01996
01997 tree
01998 finish_template_type (name, args, entering_scope)
01999 tree name;
02000 tree args;
02001 int entering_scope;
02002 {
02003 tree decl;
02004
02005 decl = lookup_template_class (name, args,
02006 NULL_TREE, NULL_TREE,
02007 entering_scope, 1);
02008 if (decl != error_mark_node)
02009 decl = TYPE_STUB_DECL (decl);
02010
02011 return decl;
02012 }
02013
02014
02015
02016
02017 void
02018 enter_scope_of (sr)
02019 tree sr;
02020 {
02021 tree scope = TREE_OPERAND (sr, 0);
02022
02023 if (TREE_CODE (scope) == NAMESPACE_DECL)
02024 {
02025 push_decl_namespace (scope);
02026 TREE_COMPLEXITY (sr) = -1;
02027 }
02028 else if (scope != current_class_type)
02029 {
02030 if (TREE_CODE (scope) == TYPENAME_TYPE)
02031 {
02032
02033
02034 scope = TREE_TYPE (scope);
02035 TREE_OPERAND (sr, 0) = scope;
02036 }
02037 push_nested_class (scope, 3);
02038 TREE_COMPLEXITY (sr) = current_class_depth;
02039 }
02040 }
02041
02042
02043
02044
02045
02046
02047
02048 tree
02049 finish_base_specifier (access_specifier, base_class)
02050 tree access_specifier;
02051 tree base_class;
02052 {
02053 tree result;
02054
02055 if (base_class == error_mark_node)
02056 {
02057 error ("invalid base-class specification");
02058 result = NULL_TREE;
02059 }
02060 else if (! is_aggr_type (base_class, 1))
02061 result = NULL_TREE;
02062 else
02063 {
02064 if (cp_type_quals (base_class) != 0)
02065 {
02066 error ("base class `%T' has cv qualifiers", base_class);
02067 base_class = TYPE_MAIN_VARIANT (base_class);
02068 }
02069 result = build_tree_list (access_specifier, base_class);
02070 }
02071
02072 return result;
02073 }
02074
02075
02076
02077
02078 void
02079 check_multiple_declarators ()
02080 {
02081
02082
02083
02084
02085
02086
02087
02088
02089
02090 if (at_function_scope_p ())
02091
02092 return;
02093
02094 if (PROCESSING_REAL_TEMPLATE_DECL_P ()
02095 || processing_explicit_instantiation
02096 || processing_specialization)
02097 error ("multiple declarators in template declaration");
02098 }
02099
02100
02101
02102
02103 tree
02104 finish_typeof (expr)
02105 tree expr;
02106 {
02107 tree type;
02108
02109 if (processing_template_decl)
02110 {
02111 type = make_aggr_type (TYPEOF_TYPE);
02112 TYPE_FIELDS (type) = expr;
02113
02114 return type;
02115 }
02116
02117 if (TREE_CODE (expr) == OFFSET_REF)
02118 expr = resolve_offset_ref (expr);
02119
02120 type = TREE_TYPE (expr);
02121
02122 if (!type || type == unknown_type_node)
02123 {
02124 error ("type of `%E' is unknown", expr);
02125 return error_mark_node;
02126 }
02127
02128 return type;
02129 }
02130
02131
02132
02133 tree
02134 finish_sizeof (t)
02135 tree t;
02136 {
02137 if (processing_template_decl)
02138 return build_min_nt (SIZEOF_EXPR, t);
02139
02140 return TYPE_P (t) ? cxx_sizeof (t) : expr_sizeof (t);
02141 }
02142
02143
02144
02145
02146 tree
02147 finish_alignof (t)
02148 tree t;
02149 {
02150 if (processing_template_decl)
02151 return build_min_nt (ALIGNOF_EXPR, t);
02152
02153 return TYPE_P (t) ? cxx_alignof (t) : c_alignof_expr (t);
02154 }
02155
02156
02157
02158
02159 static void
02160 cp_expand_stmt (t)
02161 tree t;
02162 {
02163 switch (TREE_CODE (t))
02164 {
02165 case TRY_BLOCK:
02166 genrtl_try_block (t);
02167 break;
02168
02169 case EH_SPEC_BLOCK:
02170 genrtl_eh_spec_block (t);
02171 break;
02172
02173 case HANDLER:
02174 genrtl_handler (t);
02175 break;
02176
02177 case RETURN_INIT:
02178 genrtl_named_return_value ();
02179 break;
02180
02181 case USING_STMT:
02182 break;
02183
02184 default:
02185 abort ();
02186 break;
02187 }
02188 }
02189
02190
02191
02192
02193 static tree
02194 simplify_aggr_init_exprs_r (tp, walk_subtrees, data)
02195 tree *tp;
02196 int *walk_subtrees ATTRIBUTE_UNUSED;
02197 void *data ATTRIBUTE_UNUSED;
02198 {
02199 tree aggr_init_expr;
02200 tree call_expr;
02201 tree fn;
02202 tree args;
02203 tree slot;
02204 tree type;
02205 int copy_from_buffer_p;
02206
02207 aggr_init_expr = *tp;
02208
02209
02210
02211
02212
02213 if (TYPE_P (aggr_init_expr))
02214 {
02215 *walk_subtrees = 0;
02216 return NULL_TREE;
02217 }
02218
02219 else if (TREE_CODE (aggr_init_expr) != AGGR_INIT_EXPR)
02220 return NULL_TREE;
02221
02222
02223 fn = TREE_OPERAND (aggr_init_expr, 0);
02224 args = TREE_OPERAND (aggr_init_expr, 1);
02225 slot = TREE_OPERAND (aggr_init_expr, 2);
02226 type = TREE_TYPE (aggr_init_expr);
02227 if (AGGR_INIT_VIA_CTOR_P (aggr_init_expr))
02228 {
02229
02230
02231 cxx_mark_addressable (slot);
02232 args = tree_cons (NULL_TREE,
02233 build1 (ADDR_EXPR,
02234 build_pointer_type (TREE_TYPE (slot)),
02235 slot),
02236 TREE_CHAIN (args));
02237 }
02238 call_expr = build (CALL_EXPR,
02239 TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))),
02240 fn, args, NULL_TREE);
02241 TREE_SIDE_EFFECTS (call_expr) = 1;
02242
02243
02244
02245
02246 copy_from_buffer_p = 0;
02247 #ifdef PCC_STATIC_STRUCT_RETURN
02248 if (!AGGR_INIT_VIA_CTOR_P (aggr_init_expr) && aggregate_value_p (type))
02249 {
02250 int old_ac = flag_access_control;
02251
02252 flag_access_control = 0;
02253 call_expr = build_aggr_init (slot, call_expr,
02254 DIRECT_BIND | LOOKUP_ONLYCONVERTING);
02255 flag_access_control = old_ac;
02256 copy_from_buffer_p = 1;
02257 }
02258 #endif
02259
02260
02261
02262
02263 if (AGGR_INIT_VIA_CTOR_P (aggr_init_expr) || copy_from_buffer_p)
02264 {
02265 call_expr = build (COMPOUND_EXPR, type,
02266 call_expr, slot);
02267 TREE_SIDE_EFFECTS (call_expr) = 1;
02268 }
02269
02270
02271 TREE_CHAIN (call_expr) = TREE_CHAIN (aggr_init_expr);
02272 *tp = call_expr;
02273
02274
02275 return NULL_TREE;
02276 }
02277
02278
02279
02280 static void
02281 emit_associated_thunks (fn)
02282 tree fn;
02283 {
02284
02285
02286
02287
02288
02289 if (DECL_VIRTUAL_P (fn))
02290 {
02291 tree thunk;
02292 for (thunk = DECL_THUNKS (fn); thunk; thunk = TREE_CHAIN (thunk))
02293 use_thunk (thunk, 1);
02294 }
02295 }
02296
02297
02298
02299 void
02300 expand_body (fn)
02301 tree fn;
02302 {
02303 int saved_lineno;
02304 const char *saved_input_filename;
02305 tree saved_function;
02306
02307
02308
02309
02310
02311
02312 if (processing_template_decl
02313 || (DECL_LANG_SPECIFIC (fn)
02314 && DECL_TEMPLATE_INFO (fn)
02315 && uses_template_parms (DECL_TI_ARGS (fn))))
02316 {
02317
02318
02319
02320
02321 ggc_collect ();
02322 return;
02323 }
02324
02325
02326 walk_tree_without_duplicates (&DECL_SAVED_TREE (fn),
02327 simplify_aggr_init_exprs_r,
02328 NULL);
02329
02330
02331
02332 if (maybe_clone_body (fn))
02333 {
02334
02335
02336 TREE_ASM_WRITTEN (fn) = 1;
02337 return;
02338 }
02339
02340
02341
02342 if (flag_syntax_only)
02343 return;
02344
02345 #ifdef KEY
02346
02347
02348 if (DECL_COPY_CONSTRUCTOR_P (fn) &&
02349 DECL_COMPLETE_CONSTRUCTOR_P (fn) &&
02350 DECL_ASSEMBLER_NAME_SET_P (fn))
02351 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (fn)) = 1;
02352 #endif
02353
02354
02355
02356
02357 if (
02358 (DECL_INLINE (fn) || DECL_COMDAT (fn))
02359
02360 && !flag_keep_inline_functions
02361
02362 && !DECL_NEEDED_P (fn))
02363 {
02364
02365
02366 if (!DECL_EXTERNAL (fn))
02367 {
02368 DECL_NOT_REALLY_EXTERN (fn) = 1;
02369 DECL_EXTERNAL (fn) = 1;
02370 }
02371
02372
02373 defer_fn (fn);
02374
02375 (*debug_hooks->deferred_inline_function) (fn);
02376 return;
02377 }
02378
02379
02380
02381 if (DECL_DECLARED_INLINE_P (fn))
02382 import_export_decl (fn);
02383
02384
02385
02386
02387
02388
02389 if (DECL_EXTERNAL (fn))
02390 return;
02391
02392
02393
02394
02395 saved_lineno = lineno;
02396 saved_input_filename = input_filename;
02397 saved_function = current_function_decl;
02398 lineno = DECL_SOURCE_LINE (fn);
02399 input_filename = DECL_SOURCE_FILE (fn);
02400 current_function_decl = fn;
02401
02402 timevar_push (TV_INTEGRATION);
02403
02404
02405 optimize_function (fn);
02406
02407 timevar_pop (TV_INTEGRATION);
02408 timevar_push (TV_EXPAND);
02409
02410 genrtl_start_function (fn);
02411 current_function_is_thunk = DECL_THUNK_P (fn);
02412
02413
02414 expand_stmt (DECL_SAVED_TREE (fn));
02415
02416
02417
02418 my_friendly_assert (stmts_are_full_exprs_p (), 19990831);
02419
02420
02421
02422 lineno = STMT_LINENO (DECL_SAVED_TREE (fn));
02423
02424
02425 genrtl_finish_function (fn);
02426
02427
02428
02429 if (dump_enabled_p (TDI_all))
02430
02431 ;
02432 else if (DECL_INLINE (fn) && flag_inline_trees)
02433
02434
02435 ;
02436 #ifndef SGI_MONGOOSE
02437 else
02438
02439 DECL_SAVED_TREE (fn) = NULL_TREE;
02440 #endif
02441
02442
02443 current_function_decl = saved_function;
02444 lineno = saved_lineno;
02445 input_filename = saved_input_filename;
02446 extract_interface_info ();
02447
02448 timevar_pop (TV_EXPAND);
02449
02450
02451 emit_associated_thunks (fn);
02452 }
02453
02454
02455
02456
02457
02458 tree
02459 nullify_returns_r (tp, walk_subtrees, data)
02460 tree *tp;
02461 int *walk_subtrees;
02462 void *data;
02463 {
02464 tree nrv = (tree) data;
02465
02466
02467
02468 if (TYPE_P (*tp))
02469 *walk_subtrees = 0;
02470 else if (TREE_CODE (*tp) == RETURN_STMT)
02471 RETURN_STMT_EXPR (*tp) = NULL_TREE;
02472 else if (TREE_CODE (*tp) == CLEANUP_STMT
02473 && CLEANUP_DECL (*tp) == nrv)
02474 CLEANUP_EH_ONLY (*tp) = 1;
02475
02476
02477 return NULL_TREE;
02478 }
02479
02480
02481
02482 static void
02483 genrtl_start_function (fn)
02484 tree fn;
02485 {
02486
02487 current_function_decl = fn;
02488
02489 init_function_start (fn, DECL_SOURCE_FILE (fn), DECL_SOURCE_LINE (fn));
02490
02491
02492 expanding_p = 1;
02493
02494
02495
02496
02497
02498 immediate_size_expand = 0;
02499 cfun->x_dont_save_pending_sizes_p = 1;
02500
02501
02502 announce_function (fn);
02503
02504
02505 my_friendly_assert (!DECL_PENDING_INLINE_P (fn), 20000911);
02506 if (DECL_SAVED_FUNCTION_DATA (fn))
02507 {
02508
02509
02510 *cp_function_chain = *DECL_SAVED_FUNCTION_DATA (fn);
02511
02512
02513
02514 cfun->x_whole_function_mode_p = 1;
02515
02516
02517
02518 if (!current_function_cannot_inline)
02519 current_function_cannot_inline = cp_function_chain->cannot_inline;
02520
02521
02522
02523
02524 if (! DECL_INLINE (fn))
02525 DECL_SAVED_FUNCTION_DATA (fn) = NULL;
02526 }
02527
02528
02529 ++function_depth;
02530
02531
02532 expand_function_start (fn, 0);
02533
02534 if (DECL_MAIN_P (fn))
02535 expand_main_function ();
02536
02537
02538 if (current_function_return_value)
02539 COPY_DECL_RTL (DECL_RESULT (fn), current_function_return_value);
02540 }
02541
02542
02543
02544 static void
02545 genrtl_finish_function (fn)
02546 tree fn;
02547 {
02548 tree t;
02549
02550 #if 0
02551 if (write_symbols != NO_DEBUG)
02552 {
02553
02554
02555
02556 tree ttype = target_type (fntype);
02557 tree parmdecl;
02558
02559 if (IS_AGGR_TYPE (ttype))
02560
02561 note_debug_info_needed (ttype);
02562
02563 for (parmdecl = DECL_ARGUMENTS (fndecl); parmdecl; parmdecl = TREE_CHAIN (parmdecl))
02564 {
02565 ttype = target_type (TREE_TYPE (parmdecl));
02566 if (IS_AGGR_TYPE (ttype))
02567
02568 note_debug_info_needed (ttype);
02569 }
02570 }
02571 #endif
02572
02573
02574 do_pending_stack_adjust ();
02575
02576
02577
02578 if (DECL_NAME (DECL_RESULT (fn)))
02579 emit_jump (return_label);
02580
02581
02582
02583
02584
02585 immediate_size_expand = 1;
02586
02587
02588 expand_function_end (input_filename, lineno, 0);
02589
02590
02591
02592
02593
02594
02595 if (function_depth > 1)
02596 ggc_push_context ();
02597
02598
02599
02600 DECL_DEFER_OUTPUT (fn) = 0;
02601
02602
02603
02604 rest_of_compilation (fn);
02605
02606
02607 if (function_depth > 1)
02608 ggc_pop_context ();
02609
02610 #if 0
02611
02612
02613
02614 if (ctype && TREE_ASM_WRITTEN (fn))
02615 note_debug_info_needed (ctype);
02616 #endif
02617
02618
02619
02620
02621 if (DECL_STATIC_CONSTRUCTOR (fn))
02622 static_ctors = tree_cons (NULL_TREE, fn, static_ctors);
02623
02624
02625
02626
02627 if (DECL_STATIC_DESTRUCTOR (fn))
02628 static_dtors = tree_cons (NULL_TREE, fn, static_dtors);
02629
02630 --function_depth;
02631
02632
02633 my_friendly_assert (!DECL_SAVED_INSNS (fn), 20010903);
02634
02635
02636
02637
02638
02639
02640
02641 walk_tree_without_duplicates (&DECL_SAVED_TREE (fn),
02642 clear_decl_rtl,
02643 NULL);
02644
02645
02646 for (t = DECL_ARGUMENTS (fn); t; t = TREE_CHAIN (t))
02647 {
02648 SET_DECL_RTL (t, NULL_RTX);
02649 DECL_INCOMING_RTL (t) = NULL_RTX;
02650 }
02651
02652 if (!(flag_inline_trees && DECL_INLINE (fn)))
02653
02654
02655 DECL_INITIAL (fn) = error_mark_node;
02656
02657
02658
02659
02660 current_function_decl = NULL_TREE;
02661 }
02662
02663
02664
02665
02666 static tree
02667 clear_decl_rtl (tp, walk_subtrees, data)
02668 tree *tp;
02669 int *walk_subtrees ATTRIBUTE_UNUSED;
02670 void *data ATTRIBUTE_UNUSED;
02671 {
02672 if (nonstatic_local_decl_p (*tp))
02673 SET_DECL_RTL (*tp, NULL_RTX);
02674
02675 return NULL_TREE;
02676 }
02677
02678
02679
02680 void
02681 init_cp_semantics ()
02682 {
02683 lang_expand_stmt = cp_expand_stmt;
02684 }