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 #include "config.h"
00028 #include "system.h"
00029 #include "tree.h"
00030 #include "cp-tree.h"
00031 #include "flags.h"
00032 #include "real.h"
00033 #include "rtl.h"
00034 #include "toplev.h"
00035 #include "ggc.h"
00036 #include "insn-config.h"
00037 #include "integrate.h"
00038 #include "tree-inline.h"
00039 #include "target.h"
00040 #ifdef SGI_MONGOOSE
00041 #include "defaults.h"
00042 #endif
00043
00044 static tree bot_manip PARAMS ((tree *, int *, void *));
00045 static tree bot_replace PARAMS ((tree *, int *, void *));
00046 static tree build_cplus_array_type_1 PARAMS ((tree, tree));
00047 static int list_hash_eq PARAMS ((const void *, const void *));
00048 static hashval_t list_hash_pieces PARAMS ((tree, tree, tree));
00049 static hashval_t list_hash PARAMS ((const void *));
00050 static cp_lvalue_kind lvalue_p_1 PARAMS ((tree, int, int));
00051 static tree no_linkage_helper PARAMS ((tree *, int *, void *));
00052 static tree build_srcloc PARAMS ((const char *, int));
00053 static tree mark_local_for_remap_r PARAMS ((tree *, int *, void *));
00054 static tree cp_unsave_r PARAMS ((tree *, int *, void *));
00055 static tree build_target_expr PARAMS ((tree, tree));
00056 static tree count_trees_r PARAMS ((tree *, int *, void *));
00057 static tree verify_stmt_tree_r PARAMS ((tree *, int *, void *));
00058 static tree find_tree_r PARAMS ((tree *, int *, void *));
00059 extern int cp_statement_code_p PARAMS ((enum tree_code));
00060
00061 static tree handle_java_interface_attribute PARAMS ((tree *, tree, tree, int, bool *));
00062 static tree handle_com_interface_attribute PARAMS ((tree *, tree, tree, int, bool *));
00063 static tree handle_init_priority_attribute PARAMS ((tree *, tree, tree, int, bool *));
00064
00065
00066
00067
00068
00069 static cp_lvalue_kind
00070 lvalue_p_1 (ref, treat_class_rvalues_as_lvalues, allow_cast_as_lvalue)
00071 tree ref;
00072 int treat_class_rvalues_as_lvalues;
00073 int allow_cast_as_lvalue;
00074 {
00075 cp_lvalue_kind op1_lvalue_kind = clk_none;
00076 cp_lvalue_kind op2_lvalue_kind = clk_none;
00077
00078 if (TREE_CODE (TREE_TYPE (ref)) == REFERENCE_TYPE)
00079 return clk_ordinary;
00080
00081 if (ref == current_class_ptr)
00082 return clk_none;
00083
00084 switch (TREE_CODE (ref))
00085 {
00086
00087
00088 case PREINCREMENT_EXPR:
00089 case PREDECREMENT_EXPR:
00090 case SAVE_EXPR:
00091 case UNSAVE_EXPR:
00092 case TRY_CATCH_EXPR:
00093 case WITH_CLEANUP_EXPR:
00094 case REALPART_EXPR:
00095 case IMAGPART_EXPR:
00096 return lvalue_p_1 (TREE_OPERAND (ref, 0),
00097 treat_class_rvalues_as_lvalues,
00098 allow_cast_as_lvalue);
00099
00100 case NOP_EXPR:
00101
00102
00103
00104
00105 if (allow_cast_as_lvalue ||
00106 same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (ref)),
00107 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (ref, 0)))))
00108 return lvalue_p_1 (TREE_OPERAND (ref, 0),
00109 treat_class_rvalues_as_lvalues,
00110 allow_cast_as_lvalue);
00111 else
00112 return clk_none;
00113
00114 case COMPONENT_REF:
00115 op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 0),
00116 treat_class_rvalues_as_lvalues,
00117 allow_cast_as_lvalue);
00118 if (op1_lvalue_kind
00119
00120
00121 && TREE_CODE (TREE_OPERAND (ref, 1)) == FIELD_DECL
00122 && DECL_C_BIT_FIELD (TREE_OPERAND (ref, 1)))
00123 {
00124
00125
00126 op1_lvalue_kind &= ~clk_ordinary;
00127
00128 op1_lvalue_kind |= clk_bitfield;
00129 }
00130 return op1_lvalue_kind;
00131
00132 case STRING_CST:
00133 return clk_ordinary;
00134
00135 case VAR_DECL:
00136 if (TREE_READONLY (ref) && ! TREE_STATIC (ref)
00137 && DECL_LANG_SPECIFIC (ref)
00138 && DECL_IN_AGGR_P (ref))
00139 return clk_none;
00140 case INDIRECT_REF:
00141 case ARRAY_REF:
00142 case PARM_DECL:
00143 case RESULT_DECL:
00144 if (TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
00145 return clk_ordinary;
00146 break;
00147
00148
00149 case SCOPE_REF:
00150 abort ();
00151 case OFFSET_REF:
00152 if (TREE_CODE (TREE_OPERAND (ref, 1)) == FUNCTION_DECL)
00153 return clk_ordinary;
00154
00155 case MAX_EXPR:
00156 case MIN_EXPR:
00157 op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 0),
00158 treat_class_rvalues_as_lvalues,
00159 allow_cast_as_lvalue);
00160 op2_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 1),
00161 treat_class_rvalues_as_lvalues,
00162 allow_cast_as_lvalue);
00163 break;
00164
00165 case COND_EXPR:
00166 op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 1),
00167 treat_class_rvalues_as_lvalues,
00168 allow_cast_as_lvalue);
00169 op2_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 2),
00170 treat_class_rvalues_as_lvalues,
00171 allow_cast_as_lvalue);
00172 break;
00173
00174 case MODIFY_EXPR:
00175 return clk_ordinary;
00176
00177 case COMPOUND_EXPR:
00178 return lvalue_p_1 (TREE_OPERAND (ref, 1),
00179 treat_class_rvalues_as_lvalues,
00180 allow_cast_as_lvalue);
00181
00182 case TARGET_EXPR:
00183 return treat_class_rvalues_as_lvalues ? clk_class : clk_none;
00184
00185 case CALL_EXPR:
00186 case VA_ARG_EXPR:
00187 return ((treat_class_rvalues_as_lvalues
00188 && IS_AGGR_TYPE (TREE_TYPE (ref)))
00189 ? clk_class : clk_none);
00190
00191 case FUNCTION_DECL:
00192
00193
00194 return (DECL_NONSTATIC_MEMBER_FUNCTION_P (ref)
00195 ? clk_none : clk_ordinary);
00196
00197 default:
00198 break;
00199 }
00200
00201
00202
00203 if (!op1_lvalue_kind || !op2_lvalue_kind)
00204 return clk_none;
00205
00206
00207
00208 op1_lvalue_kind = op1_lvalue_kind | op2_lvalue_kind;
00209
00210
00211 if ((op1_lvalue_kind & ~clk_ordinary) != clk_none)
00212 op1_lvalue_kind &= ~clk_ordinary;
00213 return op1_lvalue_kind;
00214 }
00215
00216
00217
00218
00219
00220
00221 cp_lvalue_kind
00222 real_lvalue_p (ref)
00223 tree ref;
00224 {
00225 return lvalue_p_1 (ref, 0, 1);
00226 }
00227
00228
00229
00230
00231
00232 cp_lvalue_kind
00233 real_non_cast_lvalue_p (tree ref)
00234 {
00235 return lvalue_p_1 (ref,
00236 0,
00237 0);
00238 }
00239
00240
00241
00242
00243 int
00244 lvalue_p (ref)
00245 tree ref;
00246 {
00247 return
00248 (lvalue_p_1 (ref, 1, 1) != clk_none);
00249 }
00250
00251 int
00252 non_cast_lvalue_p (ref)
00253 tree ref;
00254 {
00255 return
00256 (lvalue_p_1 (ref, 1, 0) != clk_none);
00257 }
00258
00259
00260
00261
00262 int
00263 lvalue_or_else (ref, string)
00264 tree ref;
00265 const char *string;
00266 {
00267 int ret = lvalue_p_1 (ref, 1, 1);
00268 int win = (ret != clk_none);
00269 if (! win)
00270 error ("non-lvalue in %s", string);
00271 return win;
00272 }
00273
00274 int
00275 non_cast_lvalue_or_else (ref, string)
00276 tree ref;
00277 const char *string;
00278 {
00279 int ret = lvalue_p_1 (ref, 1, 0);
00280 int win = (ret != clk_none);
00281 if (! win)
00282 error ("non-lvalue in %s", string);
00283 return win;
00284 }
00285
00286
00287
00288 static tree
00289 build_target_expr (decl, value)
00290 tree decl;
00291 tree value;
00292 {
00293 tree t;
00294
00295 t = build (TARGET_EXPR, TREE_TYPE (decl), decl, value,
00296 cxx_maybe_build_cleanup (decl), NULL_TREE);
00297
00298
00299
00300
00301 TREE_SIDE_EFFECTS (t) = 1;
00302
00303 return t;
00304 }
00305
00306
00307
00308
00309
00310
00311
00312
00313 tree
00314 build_cplus_new (type, init)
00315 tree type;
00316 tree init;
00317 {
00318 tree fn;
00319 tree slot;
00320 tree rval;
00321
00322
00323
00324 abstract_virtuals_error (NULL_TREE, type);
00325
00326 if (TREE_CODE (init) != CALL_EXPR && TREE_CODE (init) != AGGR_INIT_EXPR)
00327 return convert (type, init);
00328
00329 slot = build (VAR_DECL, type);
00330 DECL_ARTIFICIAL (slot) = 1;
00331 DECL_CONTEXT (slot) = current_function_decl;
00332 layout_decl (slot, 0);
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342 fn = TREE_OPERAND (init, 0);
00343 rval = build (AGGR_INIT_EXPR, type, fn, TREE_OPERAND (init, 1), slot);
00344 TREE_SIDE_EFFECTS (rval) = 1;
00345 AGGR_INIT_VIA_CTOR_P (rval)
00346 = (TREE_CODE (fn) == ADDR_EXPR
00347 && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL
00348 && DECL_CONSTRUCTOR_P (TREE_OPERAND (fn, 0)));
00349 rval = build_target_expr (slot, rval);
00350
00351 return rval;
00352 }
00353
00354
00355
00356
00357 tree
00358 build_target_expr_with_type (init, type)
00359 tree init;
00360 tree type;
00361 {
00362 tree slot;
00363 tree rval;
00364
00365 if (TREE_CODE (init) == TARGET_EXPR)
00366 return init;
00367
00368 slot = build (VAR_DECL, type);
00369 DECL_ARTIFICIAL (slot) = 1;
00370 DECL_CONTEXT (slot) = current_function_decl;
00371 layout_decl (slot, 0);
00372 rval = build_target_expr (slot, init);
00373
00374 return rval;
00375 }
00376
00377
00378
00379 tree
00380 get_target_expr (init)
00381 tree init;
00382 {
00383 return build_target_expr_with_type (init, TREE_TYPE (init));
00384 }
00385
00386
00387
00388
00389
00390 tree
00391 break_out_calls (exp)
00392 tree exp;
00393 {
00394 register tree t1, t2 = NULL_TREE;
00395 register enum tree_code code;
00396 register int changed = 0;
00397 register int i;
00398
00399 if (exp == NULL_TREE)
00400 return exp;
00401
00402 code = TREE_CODE (exp);
00403
00404 if (code == CALL_EXPR)
00405 return copy_node (exp);
00406
00407
00408 if (code == SAVE_EXPR)
00409 return exp;
00410
00411 switch (TREE_CODE_CLASS (code))
00412 {
00413 default:
00414 abort ();
00415
00416 case 'c':
00417 case 't':
00418 case 'x':
00419 return exp;
00420
00421 case 'd':
00422 #if 0
00423
00424 t1 = break_out_calls (DECL_INITIAL (exp));
00425 if (t1 != DECL_INITIAL (exp))
00426 {
00427 exp = copy_node (exp);
00428 DECL_INITIAL (exp) = t1;
00429 }
00430 #endif
00431 return exp;
00432
00433 case 'b':
00434 {
00435
00436
00437
00438 abort ();
00439 }
00440 return exp;
00441
00442 case 'e':
00443 case 'r':
00444 case 's':
00445 for (i = TREE_CODE_LENGTH (code) - 1; i >= 0; i--)
00446 {
00447 t1 = break_out_calls (TREE_OPERAND (exp, i));
00448 if (t1 != TREE_OPERAND (exp, i))
00449 {
00450 exp = copy_node (exp);
00451 TREE_OPERAND (exp, i) = t1;
00452 }
00453 }
00454 return exp;
00455
00456 case '<':
00457 case '2':
00458 t2 = break_out_calls (TREE_OPERAND (exp, 1));
00459 if (t2 != TREE_OPERAND (exp, 1))
00460 changed = 1;
00461 case '1':
00462 t1 = break_out_calls (TREE_OPERAND (exp, 0));
00463 if (t1 != TREE_OPERAND (exp, 0))
00464 changed = 1;
00465 if (changed)
00466 {
00467 if (TREE_CODE_LENGTH (code) == 1)
00468 return build1 (code, TREE_TYPE (exp), t1);
00469 else
00470 return build (code, TREE_TYPE (exp), t1, t2);
00471 }
00472 return exp;
00473 }
00474
00475 }
00476
00477
00478
00479
00480
00481 tree
00482 build_cplus_method_type (basetype, rettype, argtypes)
00483 tree basetype, rettype, argtypes;
00484 {
00485 register tree t;
00486 tree ptype;
00487 int hashcode;
00488
00489
00490 t = make_node (METHOD_TYPE);
00491
00492 TYPE_METHOD_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
00493 TREE_TYPE (t) = rettype;
00494 ptype = build_pointer_type (basetype);
00495
00496
00497
00498 argtypes = tree_cons (NULL_TREE, ptype, argtypes);
00499 TYPE_ARG_TYPES (t) = argtypes;
00500 TREE_SIDE_EFFECTS (argtypes) = 1;
00501
00502
00503
00504 hashcode = TYPE_HASH (basetype) + TYPE_HASH (rettype) +
00505 type_hash_list (argtypes);
00506
00507 t = type_hash_canon (hashcode, t);
00508
00509 if (!COMPLETE_TYPE_P (t))
00510 layout_type (t);
00511
00512 return t;
00513 }
00514
00515 static tree
00516 build_cplus_array_type_1 (elt_type, index_type)
00517 tree elt_type;
00518 tree index_type;
00519 {
00520 tree t;
00521
00522 if (elt_type == error_mark_node || index_type == error_mark_node)
00523 return error_mark_node;
00524
00525
00526
00527
00528 if ((processing_template_decl
00529 && index_type && TYPE_MAX_VALUE (index_type)
00530 && TREE_CODE (TYPE_MAX_VALUE (index_type)) != INTEGER_CST)
00531 || uses_template_parms (elt_type)
00532 || (index_type && uses_template_parms (index_type)))
00533 {
00534 t = make_node (ARRAY_TYPE);
00535 TREE_TYPE (t) = elt_type;
00536 TYPE_DOMAIN (t) = index_type;
00537 }
00538 else
00539 t = build_array_type (elt_type, index_type);
00540
00541
00542
00543 TYPE_NEEDS_CONSTRUCTING (t)
00544 = TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (elt_type));
00545 TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)
00546 = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TYPE_MAIN_VARIANT (elt_type));
00547 return t;
00548 }
00549
00550 tree
00551 build_cplus_array_type (elt_type, index_type)
00552 tree elt_type;
00553 tree index_type;
00554 {
00555 tree t;
00556 int type_quals = cp_type_quals (elt_type);
00557 int cv_quals = type_quals & (TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE);
00558 int other_quals = type_quals & ~(TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE);
00559
00560 if (cv_quals)
00561 elt_type = cp_build_qualified_type (elt_type, other_quals);
00562
00563 t = build_cplus_array_type_1 (elt_type, index_type);
00564
00565 if (cv_quals)
00566 t = cp_build_qualified_type (t, cv_quals);
00567
00568 return t;
00569 }
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591 tree
00592 cp_build_qualified_type_real (type, type_quals, complain)
00593 tree type;
00594 int type_quals;
00595 tsubst_flags_t complain;
00596 {
00597 tree result;
00598 int bad_quals = TYPE_UNQUALIFIED;
00599
00600
00601
00602
00603 int bad_func_quals = TYPE_UNQUALIFIED;
00604
00605 if (type == error_mark_node)
00606 return type;
00607
00608 if (type_quals == cp_type_quals (type))
00609 return type;
00610
00611
00612
00613 if (type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)
00614 && (TREE_CODE (type) == REFERENCE_TYPE
00615 || TREE_CODE (type) == FUNCTION_TYPE
00616 || TREE_CODE (type) == METHOD_TYPE))
00617 {
00618 bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
00619 if (TREE_CODE (type) != REFERENCE_TYPE)
00620 bad_func_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
00621 type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
00622 }
00623
00624
00625
00626 if ((type_quals & TYPE_QUAL_RESTRICT)
00627 && TREE_CODE (type) != TEMPLATE_TYPE_PARM
00628 && TREE_CODE (type) != TYPENAME_TYPE
00629 && !POINTER_TYPE_P (type))
00630 {
00631 bad_quals |= TYPE_QUAL_RESTRICT;
00632 type_quals &= ~TYPE_QUAL_RESTRICT;
00633 }
00634
00635 if (bad_quals == TYPE_UNQUALIFIED)
00636 ;
00637 else if (!(complain & (tf_error | tf_ignore_bad_quals)))
00638 return error_mark_node;
00639 else if (bad_func_quals && !(complain & tf_error))
00640 return error_mark_node;
00641 else
00642 {
00643 if (complain & tf_ignore_bad_quals)
00644
00645
00646 bad_quals &= ~TYPE_QUAL_CONST;
00647 bad_quals |= bad_func_quals;
00648 if (bad_quals)
00649 {
00650 tree bad_type = build_qualified_type (ptr_type_node, bad_quals);
00651
00652 if (!(complain & tf_ignore_bad_quals)
00653 || bad_func_quals)
00654 error ("`%V' qualifiers cannot be applied to `%T'",
00655 bad_type, type);
00656 }
00657 }
00658
00659 if (TREE_CODE (type) == ARRAY_TYPE)
00660 {
00661
00662
00663 tree t;
00664 tree element_type
00665 = cp_build_qualified_type_real (TREE_TYPE (type),
00666 type_quals,
00667 complain);
00668
00669 if (element_type == error_mark_node)
00670 return error_mark_node;
00671
00672
00673 for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
00674 if (cp_type_quals (t) == type_quals
00675 && TYPE_NAME (t) == TYPE_NAME (type)
00676 && TYPE_CONTEXT (t) == TYPE_CONTEXT (type))
00677 break;
00678
00679 if (!t)
00680 {
00681
00682
00683 t = build_type_copy (type);
00684 TREE_TYPE (t) = element_type;
00685 }
00686
00687
00688
00689
00690
00691
00692
00693
00694 TYPE_NEEDS_CONSTRUCTING (t)
00695 = TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (element_type));
00696 TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)
00697 = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TYPE_MAIN_VARIANT (element_type));
00698 return t;
00699 }
00700 else if (TYPE_PTRMEMFUNC_P (type))
00701 {
00702
00703
00704
00705
00706 tree t;
00707
00708 t = TYPE_PTRMEMFUNC_FN_TYPE (type);
00709 t = cp_build_qualified_type_real (t, type_quals, complain);
00710 return build_ptrmemfunc_type (t);
00711 }
00712
00713
00714 result = build_qualified_type (type, type_quals);
00715
00716
00717
00718
00719
00720 if (result != type
00721 && TREE_CODE (type) == POINTER_TYPE
00722 && TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE)
00723 TYPE_LANG_SPECIFIC (result) = NULL;
00724
00725 return result;
00726 }
00727
00728
00729
00730
00731
00732
00733 tree
00734 canonical_type_variant (t)
00735 tree t;
00736 {
00737 return cp_build_qualified_type (TYPE_MAIN_VARIANT (t), cp_type_quals (t));
00738 }
00739
00740
00741
00742
00743 void
00744 unshare_base_binfos (binfo)
00745 tree binfo;
00746 {
00747 tree binfos = BINFO_BASETYPES (binfo);
00748 tree new_binfo;
00749 int j;
00750
00751 if (binfos == NULL_TREE)
00752 return;
00753
00754
00755 for (j = TREE_VEC_LENGTH (binfos)-1;
00756 j >= 0; j--)
00757 {
00758 tree base_binfo = TREE_VEC_ELT (binfos, j);
00759 new_binfo = TREE_VEC_ELT (binfos, j)
00760 = make_binfo (BINFO_OFFSET (base_binfo),
00761 base_binfo,
00762 BINFO_VTABLE (base_binfo),
00763 BINFO_VIRTUALS (base_binfo));
00764 TREE_VIA_PUBLIC (new_binfo) = TREE_VIA_PUBLIC (base_binfo);
00765 TREE_VIA_PROTECTED (new_binfo) = TREE_VIA_PROTECTED (base_binfo);
00766 TREE_VIA_VIRTUAL (new_binfo) = TREE_VIA_VIRTUAL (base_binfo);
00767 BINFO_INHERITANCE_CHAIN (new_binfo) = binfo;
00768 BINFO_PRIMARY_BASE_OF (new_binfo) = NULL_TREE;
00769 unshare_base_binfos (new_binfo);
00770 }
00771 }
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783 static GTY ((param_is (union tree_node))) htab_t list_hash_table;
00784
00785 struct list_proxy
00786 {
00787 tree purpose;
00788 tree value;
00789 tree chain;
00790 };
00791
00792
00793
00794
00795 static int
00796 list_hash_eq (entry, data)
00797 const void *entry;
00798 const void *data;
00799 {
00800 tree t = (tree) entry;
00801 struct list_proxy *proxy = (struct list_proxy *) data;
00802
00803 return (TREE_VALUE (t) == proxy->value
00804 && TREE_PURPOSE (t) == proxy->purpose
00805 && TREE_CHAIN (t) == proxy->chain);
00806 }
00807
00808
00809
00810
00811
00812 static hashval_t
00813 list_hash_pieces (purpose, value, chain)
00814 tree purpose;
00815 tree value;
00816 tree chain;
00817 {
00818 hashval_t hashcode = 0;
00819
00820 if (chain)
00821 hashcode += TYPE_HASH (chain);
00822
00823 if (value)
00824 hashcode += TYPE_HASH (value);
00825 else
00826 hashcode += 1007;
00827 if (purpose)
00828 hashcode += TYPE_HASH (purpose);
00829 else
00830 hashcode += 1009;
00831 return hashcode;
00832 }
00833
00834
00835
00836 static hashval_t
00837 list_hash (p)
00838 const void *p;
00839 {
00840 tree t = (tree) p;
00841 return list_hash_pieces (TREE_PURPOSE (t),
00842 TREE_VALUE (t),
00843 TREE_CHAIN (t));
00844 }
00845
00846
00847
00848
00849
00850 tree
00851 hash_tree_cons (purpose, value, chain)
00852 tree purpose, value, chain;
00853 {
00854 int hashcode = 0;
00855 PTR* slot;
00856 struct list_proxy proxy;
00857
00858
00859 hashcode = list_hash_pieces (purpose, value, chain);
00860
00861
00862 proxy.purpose = purpose;
00863 proxy.value = value;
00864 proxy.chain = chain;
00865
00866 slot = htab_find_slot_with_hash (list_hash_table, &proxy, hashcode,
00867 INSERT);
00868
00869 if (!*slot)
00870 *slot = (PTR) tree_cons (purpose, value, chain);
00871 return *slot;
00872 }
00873
00874
00875
00876 tree
00877 hash_tree_chain (value, chain)
00878 tree value, chain;
00879 {
00880 return hash_tree_cons (NULL_TREE, value, chain);
00881 }
00882
00883
00884
00885 tree
00886 hash_chainon (list1, list2)
00887 tree list1, list2;
00888 {
00889 if (list2 == 0)
00890 return list1;
00891 if (list1 == 0)
00892 return list2;
00893 if (TREE_CHAIN (list1) == NULL_TREE)
00894 return hash_tree_chain (TREE_VALUE (list1), list2);
00895 return hash_tree_chain (TREE_VALUE (list1),
00896 hash_chainon (TREE_CHAIN (list1), list2));
00897 }
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914 tree
00915 make_binfo (offset, binfo, vtable, virtuals)
00916 tree offset, binfo;
00917 tree vtable, virtuals;
00918 {
00919 tree new_binfo = make_tree_vec (11);
00920 tree type;
00921
00922 if (TREE_CODE (binfo) == TREE_VEC)
00923 type = BINFO_TYPE (binfo);
00924 else
00925 {
00926 type = binfo;
00927 binfo = CLASS_TYPE_P (type) ? TYPE_BINFO (binfo) : NULL_TREE;
00928 }
00929
00930 TREE_TYPE (new_binfo) = TYPE_MAIN_VARIANT (type);
00931 BINFO_OFFSET (new_binfo) = offset;
00932 BINFO_VTABLE (new_binfo) = vtable;
00933 BINFO_VIRTUALS (new_binfo) = virtuals;
00934
00935 if (binfo && BINFO_BASETYPES (binfo) != NULL_TREE)
00936 BINFO_BASETYPES (new_binfo) = copy_node (BINFO_BASETYPES (binfo));
00937 return new_binfo;
00938 }
00939
00940
00941
00942
00943
00944
00945
00946 tree
00947 reverse_path (binfo)
00948 tree binfo;
00949 {
00950 tree reversed_path;
00951
00952 reversed_path = NULL_TREE;
00953 while (binfo)
00954 {
00955 reversed_path = tree_cons (NULL_TREE, binfo, reversed_path);
00956 binfo = BINFO_INHERITANCE_CHAIN (binfo);
00957 }
00958
00959 return reversed_path;
00960 }
00961
00962 void
00963 debug_binfo (elem)
00964 tree elem;
00965 {
00966 HOST_WIDE_INT n;
00967 tree virtuals;
00968
00969 fprintf (stderr, "type \"%s\", offset = ",
00970 TYPE_NAME_STRING (BINFO_TYPE (elem)));
00971 fprintf (stderr, HOST_WIDE_INT_PRINT_DEC,
00972 TREE_INT_CST_LOW (BINFO_OFFSET (elem)));
00973 fprintf (stderr, "\nvtable type:\n");
00974 debug_tree (BINFO_TYPE (elem));
00975 if (BINFO_VTABLE (elem))
00976 fprintf (stderr, "vtable decl \"%s\"\n",
00977 IDENTIFIER_POINTER (DECL_NAME (get_vtbl_decl_for_binfo (elem))));
00978 else
00979 fprintf (stderr, "no vtable decl yet\n");
00980 fprintf (stderr, "virtuals:\n");
00981 virtuals = BINFO_VIRTUALS (elem);
00982 n = 0;
00983
00984 while (virtuals)
00985 {
00986 tree fndecl = TREE_VALUE (virtuals);
00987 fprintf (stderr, "%s [%ld =? %ld]\n",
00988 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl)),
00989 (long) n, (long) TREE_INT_CST_LOW (DECL_VINDEX (fndecl)));
00990 ++n;
00991 virtuals = TREE_CHAIN (virtuals);
00992 }
00993 }
00994
00995 int
00996 count_functions (t)
00997 tree t;
00998 {
00999 int i;
01000 if (TREE_CODE (t) == FUNCTION_DECL)
01001 return 1;
01002 else if (TREE_CODE (t) == OVERLOAD)
01003 {
01004 for (i=0; t; t = OVL_CHAIN (t))
01005 i++;
01006 return i;
01007 }
01008
01009 abort ();
01010 return 0;
01011 }
01012
01013 int
01014 is_overloaded_fn (x)
01015 tree x;
01016 {
01017
01018 if (TREE_CODE (x) == OFFSET_REF)
01019 x = TREE_OPERAND (x, 1);
01020 if (BASELINK_P (x))
01021 x = BASELINK_FUNCTIONS (x);
01022 return (TREE_CODE (x) == FUNCTION_DECL
01023 || TREE_CODE (x) == TEMPLATE_ID_EXPR
01024 || DECL_FUNCTION_TEMPLATE_P (x)
01025 || TREE_CODE (x) == OVERLOAD);
01026 }
01027
01028 int
01029 really_overloaded_fn (x)
01030 tree x;
01031 {
01032
01033 if (TREE_CODE (x) == OFFSET_REF)
01034 x = TREE_OPERAND (x, 1);
01035 if (BASELINK_P (x))
01036 x = BASELINK_FUNCTIONS (x);
01037
01038 return ((TREE_CODE (x) == OVERLOAD && OVL_CHAIN (x))
01039 || DECL_FUNCTION_TEMPLATE_P (OVL_CURRENT (x))
01040 || TREE_CODE (x) == TEMPLATE_ID_EXPR);
01041 }
01042
01043
01044
01045
01046 tree
01047 get_overloaded_fn (fns)
01048 tree fns;
01049 {
01050 if (TREE_CODE (fns) == TEMPLATE_ID_EXPR)
01051 fns = TREE_OPERAND (fns, 0);
01052 if (BASELINK_P (fns))
01053 fns = BASELINK_FUNCTIONS (fns);
01054 return fns;
01055 }
01056
01057 tree
01058 get_first_fn (from)
01059 tree from;
01060 {
01061 my_friendly_assert (is_overloaded_fn (from), 9);
01062
01063 if (BASELINK_P (from))
01064 from = BASELINK_FUNCTIONS (from);
01065 return OVL_CURRENT (from);
01066 }
01067
01068
01069
01070
01071 int
01072 bound_pmf_p (t)
01073 tree t;
01074 {
01075 return (TREE_CODE (t) == OFFSET_REF
01076 && TYPE_PTRMEMFUNC_P (TREE_TYPE (TREE_OPERAND (t, 1))));
01077 }
01078
01079
01080
01081 tree
01082 ovl_cons (decl, chain)
01083 tree decl;
01084 tree chain;
01085 {
01086 tree result = make_node (OVERLOAD);
01087 TREE_TYPE (result) = unknown_type_node;
01088 OVL_FUNCTION (result) = decl;
01089 TREE_CHAIN (result) = chain;
01090
01091 return result;
01092 }
01093
01094
01095
01096
01097 tree
01098 build_overload (decl, chain)
01099 tree decl;
01100 tree chain;
01101 {
01102 if (! chain && TREE_CODE (decl) != TEMPLATE_DECL)
01103 return decl;
01104 if (chain && TREE_CODE (chain) != OVERLOAD)
01105 chain = ovl_cons (chain, NULL_TREE);
01106 return ovl_cons (decl, chain);
01107 }
01108
01109 int
01110 is_aggr_type_2 (t1, t2)
01111 tree t1, t2;
01112 {
01113 if (TREE_CODE (t1) != TREE_CODE (t2))
01114 return 0;
01115 return IS_AGGR_TYPE (t1) && IS_AGGR_TYPE (t2);
01116 }
01117
01118
01119
01120 int
01121 cp_statement_code_p (code)
01122 enum tree_code code;
01123 {
01124 switch (code)
01125 {
01126 case CTOR_INITIALIZER:
01127 case RETURN_INIT:
01128 case TRY_BLOCK:
01129 case HANDLER:
01130 case EH_SPEC_BLOCK:
01131 case USING_STMT:
01132 case TAG_DEFN:
01133 return 1;
01134
01135 default:
01136 return 0;
01137 }
01138 }
01139
01140 #define PRINT_RING_SIZE 4
01141
01142 const char *
01143 cxx_printable_name (decl, v)
01144 tree decl;
01145 int v;
01146 {
01147 static tree decl_ring[PRINT_RING_SIZE];
01148 static char *print_ring[PRINT_RING_SIZE];
01149 static int ring_counter;
01150 int i;
01151
01152
01153 if (v < 2
01154 || TREE_CODE (decl) != FUNCTION_DECL
01155 || DECL_LANG_SPECIFIC (decl) == 0)
01156 return lang_decl_name (decl, v);
01157
01158
01159 for (i = 0; i < PRINT_RING_SIZE; i++)
01160 if (decl_ring[i] == decl)
01161
01162 return print_ring[i];
01163
01164 if (++ring_counter == PRINT_RING_SIZE)
01165 ring_counter = 0;
01166
01167 if (current_function_decl != NULL_TREE)
01168 {
01169 if (decl_ring[ring_counter] == current_function_decl)
01170 ring_counter += 1;
01171 if (ring_counter == PRINT_RING_SIZE)
01172 ring_counter = 0;
01173 if (decl_ring[ring_counter] == current_function_decl)
01174 abort ();
01175 }
01176
01177 if (print_ring[ring_counter])
01178 free (print_ring[ring_counter]);
01179
01180 print_ring[ring_counter] = xstrdup (lang_decl_name (decl, v));
01181 decl_ring[ring_counter] = decl;
01182 return print_ring[ring_counter];
01183 }
01184
01185
01186
01187
01188 tree
01189 build_exception_variant (type, raises)
01190 tree type;
01191 tree raises;
01192 {
01193 tree v = TYPE_MAIN_VARIANT (type);
01194 int type_quals = TYPE_QUALS (type);
01195
01196 for (; v; v = TYPE_NEXT_VARIANT (v))
01197 if (TYPE_QUALS (v) == type_quals
01198 && comp_except_specs (raises, TYPE_RAISES_EXCEPTIONS (v), 1))
01199 return v;
01200
01201
01202 v = build_type_copy (type);
01203 TYPE_RAISES_EXCEPTIONS (v) = raises;
01204 return v;
01205 }
01206
01207
01208
01209
01210
01211 tree
01212 bind_template_template_parm (t, newargs)
01213 tree t;
01214 tree newargs;
01215 {
01216 tree decl = TYPE_NAME (t);
01217 tree t2;
01218
01219 t2 = make_aggr_type (BOUND_TEMPLATE_TEMPLATE_PARM);
01220 decl = build_decl (TYPE_DECL, DECL_NAME (decl), NULL_TREE);
01221
01222
01223
01224 TEMPLATE_TYPE_PARM_INDEX (t2) = copy_node (TEMPLATE_TYPE_PARM_INDEX (t));
01225 TEMPLATE_PARM_DECL (TEMPLATE_TYPE_PARM_INDEX (t2)) = decl;
01226 TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (t2)
01227 = tree_cons (TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL (t),
01228 newargs, NULL_TREE);
01229
01230 TREE_TYPE (decl) = t2;
01231 TYPE_NAME (t2) = decl;
01232 TYPE_STUB_DECL (t2) = decl;
01233 TYPE_SIZE (t2) = 0;
01234
01235 return t2;
01236 }
01237
01238
01239
01240 static tree
01241 count_trees_r (tp, walk_subtrees, data)
01242 tree *tp ATTRIBUTE_UNUSED;
01243 int *walk_subtrees ATTRIBUTE_UNUSED;
01244 void *data;
01245 {
01246 ++ *((int*) data);
01247 return NULL_TREE;
01248 }
01249
01250
01251
01252
01253 int
01254 count_trees (t)
01255 tree t;
01256 {
01257 int n_trees = 0;
01258 walk_tree_without_duplicates (&t, count_trees_r, &n_trees);
01259 return n_trees;
01260 }
01261
01262
01263
01264 static tree
01265 verify_stmt_tree_r (tp, walk_subtrees, data)
01266 tree *tp;
01267 int *walk_subtrees ATTRIBUTE_UNUSED;
01268 void *data;
01269 {
01270 tree t = *tp;
01271 htab_t *statements = (htab_t *) data;
01272 void **slot;
01273
01274 if (!statement_code_p (TREE_CODE (t)))
01275 return NULL_TREE;
01276
01277
01278
01279 if (htab_find (*statements, t))
01280 abort ();
01281
01282 slot = htab_find_slot (*statements, t, INSERT);
01283 *slot = t;
01284
01285 return NULL_TREE;
01286 }
01287
01288
01289
01290
01291
01292 void
01293 verify_stmt_tree (t)
01294 tree t;
01295 {
01296 htab_t statements;
01297 statements = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);
01298 walk_tree (&t, verify_stmt_tree_r, &statements, NULL);
01299 htab_delete (statements);
01300 }
01301
01302
01303
01304 static tree
01305 find_tree_r (tp, walk_subtrees, data)
01306 tree *tp;
01307 int *walk_subtrees ATTRIBUTE_UNUSED;
01308 void *data;
01309 {
01310 if (*tp == (tree) data)
01311 return (tree) data;
01312
01313 return NULL_TREE;
01314 }
01315
01316
01317
01318 tree
01319 find_tree (t, x)
01320 tree t;
01321 tree x;
01322 {
01323 return walk_tree_without_duplicates (&t, find_tree_r, x);
01324 }
01325
01326
01327
01328 static tree
01329 no_linkage_helper (tp, walk_subtrees, data)
01330 tree *tp;
01331 int *walk_subtrees ATTRIBUTE_UNUSED;
01332 void *data ATTRIBUTE_UNUSED;
01333 {
01334 tree t = *tp;
01335
01336 if (TYPE_P (t)
01337 && (CLASS_TYPE_P (t) || TREE_CODE (t) == ENUMERAL_TYPE)
01338 && (decl_function_context (TYPE_MAIN_DECL (t))
01339 || TYPE_ANONYMOUS_P (t)))
01340 return t;
01341 return NULL_TREE;
01342 }
01343
01344
01345
01346
01347 tree
01348 no_linkage_check (t)
01349 tree t;
01350 {
01351
01352
01353 if (processing_template_decl)
01354 return NULL_TREE;
01355
01356 t = walk_tree_without_duplicates (&t, no_linkage_helper, NULL);
01357 if (t != error_mark_node)
01358 return t;
01359 return NULL_TREE;
01360 }
01361
01362 #ifdef GATHER_STATISTICS
01363 extern int depth_reached;
01364 #endif
01365
01366 void
01367 cxx_print_statistics ()
01368 {
01369 print_search_statistics ();
01370 print_class_statistics ();
01371 #ifdef GATHER_STATISTICS
01372 fprintf (stderr, "maximum template instantiation depth reached: %d\n",
01373 depth_reached);
01374 #endif
01375 }
01376
01377
01378
01379
01380
01381 tree
01382 array_type_nelts_top (type)
01383 tree type;
01384 {
01385 return fold (build (PLUS_EXPR, sizetype,
01386 array_type_nelts (type),
01387 integer_one_node));
01388 }
01389
01390
01391
01392
01393
01394 tree
01395 array_type_nelts_total (type)
01396 tree type;
01397 {
01398 tree sz = array_type_nelts_top (type);
01399 type = TREE_TYPE (type);
01400 while (TREE_CODE (type) == ARRAY_TYPE)
01401 {
01402 tree n = array_type_nelts_top (type);
01403 sz = fold (build (MULT_EXPR, sizetype, sz, n));
01404 type = TREE_TYPE (type);
01405 }
01406 return sz;
01407 }
01408
01409
01410
01411 static tree
01412 bot_manip (tp, walk_subtrees, data)
01413 tree *tp;
01414 int *walk_subtrees;
01415 void *data;
01416 {
01417 splay_tree target_remap = ((splay_tree) data);
01418 tree t = *tp;
01419
01420 if (TREE_CONSTANT (t))
01421 {
01422
01423
01424
01425 *walk_subtrees = 0;
01426 return NULL_TREE;
01427 }
01428 if (TREE_CODE (t) == TARGET_EXPR)
01429 {
01430 tree u;
01431
01432 if (TREE_CODE (TREE_OPERAND (t, 1)) == AGGR_INIT_EXPR)
01433 {
01434 mark_used (TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (t, 1), 0), 0));
01435 u = build_cplus_new
01436 (TREE_TYPE (t), break_out_target_exprs (TREE_OPERAND (t, 1)));
01437 }
01438 else
01439 {
01440 u = build_target_expr_with_type
01441 (break_out_target_exprs (TREE_OPERAND (t, 1)), TREE_TYPE (t));
01442 }
01443
01444
01445 splay_tree_insert (target_remap,
01446 (splay_tree_key) TREE_OPERAND (t, 0),
01447 (splay_tree_value) TREE_OPERAND (u, 0));
01448
01449
01450 *tp = u;
01451
01452
01453
01454 *walk_subtrees = 0;
01455 return NULL_TREE;
01456 }
01457 else if (TREE_CODE (t) == CALL_EXPR)
01458 mark_used (TREE_OPERAND (TREE_OPERAND (t, 0), 0));
01459
01460
01461 return copy_tree_r (tp, walk_subtrees, NULL);
01462 }
01463
01464
01465
01466
01467
01468 static tree
01469 bot_replace (t, walk_subtrees, data)
01470 tree *t;
01471 int *walk_subtrees ATTRIBUTE_UNUSED;
01472 void *data;
01473 {
01474 splay_tree target_remap = ((splay_tree) data);
01475
01476 if (TREE_CODE (*t) == VAR_DECL)
01477 {
01478 splay_tree_node n = splay_tree_lookup (target_remap,
01479 (splay_tree_key) *t);
01480 if (n)
01481 *t = (tree) n->value;
01482 }
01483
01484 return NULL_TREE;
01485 }
01486
01487
01488
01489
01490
01491
01492 tree
01493 break_out_target_exprs (t)
01494 tree t;
01495 {
01496 static int target_remap_count;
01497 static splay_tree target_remap;
01498
01499 if (!target_remap_count++)
01500 target_remap = splay_tree_new (splay_tree_compare_pointers,
01501 NULL,
01502 NULL);
01503 walk_tree (&t, bot_manip, target_remap, NULL);
01504 walk_tree (&t, bot_replace, target_remap, NULL);
01505
01506 if (!--target_remap_count)
01507 {
01508 splay_tree_delete (target_remap);
01509 target_remap = NULL;
01510 }
01511
01512 return t;
01513 }
01514
01515
01516
01517
01518
01519
01520
01521 tree
01522 build_min_nt VPARAMS ((enum tree_code code, ...))
01523 {
01524 register tree t;
01525 register int length;
01526 register int i;
01527
01528 VA_OPEN (p, code);
01529 VA_FIXEDARG (p, enum tree_code, code);
01530
01531 t = make_node (code);
01532 length = TREE_CODE_LENGTH (code);
01533 TREE_COMPLEXITY (t) = lineno;
01534
01535 for (i = 0; i < length; i++)
01536 {
01537 tree x = va_arg (p, tree);
01538 TREE_OPERAND (t, i) = x;
01539 }
01540
01541 VA_CLOSE (p);
01542 return t;
01543 }
01544
01545
01546
01547
01548 tree
01549 build_min VPARAMS ((enum tree_code code, tree tt, ...))
01550 {
01551 register tree t;
01552 register int length;
01553 register int i;
01554
01555 VA_OPEN (p, tt);
01556 VA_FIXEDARG (p, enum tree_code, code);
01557 VA_FIXEDARG (p, tree, tt);
01558
01559 t = make_node (code);
01560 length = TREE_CODE_LENGTH (code);
01561 TREE_TYPE (t) = tt;
01562 TREE_COMPLEXITY (t) = lineno;
01563
01564 for (i = 0; i < length; i++)
01565 {
01566 tree x = va_arg (p, tree);
01567 TREE_OPERAND (t, i) = x;
01568 }
01569
01570 VA_CLOSE (p);
01571 return t;
01572 }
01573
01574
01575
01576
01577
01578
01579 static GTY(()) tree shared_int_cache[256];
01580
01581 tree
01582 build_shared_int_cst (i)
01583 int i;
01584 {
01585 if (i >= 256)
01586 return build_int_2 (i, 0);
01587
01588 if (!shared_int_cache[i])
01589 shared_int_cache[i] = build_int_2 (i, 0);
01590
01591 return shared_int_cache[i];
01592 }
01593
01594 tree
01595 get_type_decl (t)
01596 tree t;
01597 {
01598 if (TREE_CODE (t) == TYPE_DECL)
01599 return t;
01600 if (TYPE_P (t))
01601 return TYPE_STUB_DECL (t);
01602 if (t == error_mark_node)
01603 return t;
01604
01605 abort ();
01606
01607
01608 return 0;
01609 }
01610
01611
01612
01613
01614 tree
01615 vec_binfo_member (elem, vec)
01616 tree elem, vec;
01617 {
01618 int i;
01619
01620 if (vec)
01621 for (i = 0; i < TREE_VEC_LENGTH (vec); ++i)
01622 if (same_type_p (elem, BINFO_TYPE (TREE_VEC_ELT (vec, i))))
01623 return TREE_VEC_ELT (vec, i);
01624
01625 return NULL_TREE;
01626 }
01627
01628
01629
01630
01631 tree
01632 decl_namespace_context (decl)
01633 tree decl;
01634 {
01635 while (1)
01636 {
01637 if (TREE_CODE (decl) == NAMESPACE_DECL)
01638 return decl;
01639 else if (TYPE_P (decl))
01640 decl = CP_DECL_CONTEXT (TYPE_MAIN_DECL (decl));
01641 else
01642 decl = CP_DECL_CONTEXT (decl);
01643 }
01644 }
01645
01646
01647
01648
01649
01650
01651
01652 int
01653 cp_tree_equal (t1, t2)
01654 tree t1, t2;
01655 {
01656 register enum tree_code code1, code2;
01657 int cmp;
01658
01659 if (t1 == t2)
01660 return 1;
01661 if (t1 == 0 || t2 == 0)
01662 return 0;
01663
01664 code1 = TREE_CODE (t1);
01665 code2 = TREE_CODE (t2);
01666
01667 if (code1 == NOP_EXPR || code1 == CONVERT_EXPR || code1 == NON_LVALUE_EXPR)
01668 {
01669 if (code2 == NOP_EXPR || code2 == CONVERT_EXPR || code2 == NON_LVALUE_EXPR)
01670 return cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
01671 else
01672 return cp_tree_equal (TREE_OPERAND (t1, 0), t2);
01673 }
01674 else if (code2 == NOP_EXPR || code2 == CONVERT_EXPR
01675 || code2 == NON_LVALUE_EXPR)
01676 return cp_tree_equal (t1, TREE_OPERAND (t2, 0));
01677
01678 if (code1 != code2)
01679 return 0;
01680
01681 switch (code1)
01682 {
01683 case INTEGER_CST:
01684 return TREE_INT_CST_LOW (t1) == TREE_INT_CST_LOW (t2)
01685 && TREE_INT_CST_HIGH (t1) == TREE_INT_CST_HIGH (t2);
01686
01687 case REAL_CST:
01688 return REAL_VALUES_EQUAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2));
01689
01690 case STRING_CST:
01691 return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
01692 && !memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
01693 TREE_STRING_LENGTH (t1));
01694
01695 case CONSTRUCTOR:
01696
01697
01698
01699 if (!(same_type_p (TREE_TYPE (t1), TREE_TYPE (t2))
01700
01701 && TREE_OPERAND (t1, 0) == TREE_OPERAND (t2, 0)))
01702 return 0;
01703 return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
01704
01705 case TREE_LIST:
01706 cmp = cp_tree_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2));
01707 if (cmp <= 0)
01708 return cmp;
01709 cmp = cp_tree_equal (TREE_VALUE (t1), TREE_VALUE (t2));
01710 if (cmp <= 0)
01711 return cmp;
01712 return cp_tree_equal (TREE_CHAIN (t1), TREE_CHAIN (t2));
01713
01714 case SAVE_EXPR:
01715 return cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
01716
01717 case CALL_EXPR:
01718 cmp = cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
01719 if (cmp <= 0)
01720 return cmp;
01721 return simple_cst_list_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
01722
01723 case TARGET_EXPR:
01724
01725
01726
01727
01728 if ((TREE_CODE (TREE_OPERAND (t1, 0)) == VAR_DECL
01729 && DECL_NAME (TREE_OPERAND (t1, 0)) == NULL_TREE
01730 && !DECL_RTL_SET_P (TREE_OPERAND (t1, 0)))
01731 || (TREE_CODE (TREE_OPERAND (t2, 0)) == VAR_DECL
01732 && DECL_NAME (TREE_OPERAND (t2, 0)) == NULL_TREE
01733 && !DECL_RTL_SET_P (TREE_OPERAND (t2, 0))))
01734 cmp = 1;
01735 else
01736 cmp = cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
01737 if (cmp <= 0)
01738 return cmp;
01739 return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
01740
01741 case WITH_CLEANUP_EXPR:
01742 cmp = cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
01743 if (cmp <= 0)
01744 return cmp;
01745 return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t1, 1));
01746
01747 case COMPONENT_REF:
01748 if (TREE_OPERAND (t1, 1) == TREE_OPERAND (t2, 1))
01749 return cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
01750 return 0;
01751
01752 case VAR_DECL:
01753 case PARM_DECL:
01754 case CONST_DECL:
01755 case FUNCTION_DECL:
01756 return 0;
01757
01758 case TEMPLATE_PARM_INDEX:
01759 return (TEMPLATE_PARM_IDX (t1) == TEMPLATE_PARM_IDX (t2)
01760 && TEMPLATE_PARM_LEVEL (t1) == TEMPLATE_PARM_LEVEL (t2)
01761 && same_type_p (TREE_TYPE (TEMPLATE_PARM_DECL (t1)),
01762 TREE_TYPE (TEMPLATE_PARM_DECL (t2))));
01763
01764 case SIZEOF_EXPR:
01765 case ALIGNOF_EXPR:
01766 if (TREE_CODE (TREE_OPERAND (t1, 0)) != TREE_CODE (TREE_OPERAND (t2, 0)))
01767 return 0;
01768 if (TYPE_P (TREE_OPERAND (t1, 0)))
01769 return same_type_p (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
01770 break;
01771
01772 case PTRMEM_CST:
01773
01774
01775 return (PTRMEM_CST_MEMBER (t1) == PTRMEM_CST_MEMBER (t2)
01776 && same_type_p (PTRMEM_CST_CLASS (t1), PTRMEM_CST_CLASS (t2)));
01777
01778 default:
01779 break;
01780 }
01781
01782 switch (TREE_CODE_CLASS (code1))
01783 {
01784 case '1':
01785 case '2':
01786 case '<':
01787 case 'e':
01788 case 'r':
01789 case 's':
01790 {
01791 int i;
01792
01793 cmp = 1;
01794 for (i = 0; i < TREE_CODE_LENGTH (code1); ++i)
01795 {
01796 cmp = cp_tree_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i));
01797 if (cmp <= 0)
01798 return cmp;
01799 }
01800 return cmp;
01801 }
01802
01803 case 't':
01804 return same_type_p (t1, t2) ? 1 : 0;
01805 }
01806
01807 return -1;
01808 }
01809
01810
01811
01812
01813 tree
01814 build_zc_wrapper (ptr)
01815 struct z_candidate *ptr;
01816 {
01817 tree t = make_node (WRAPPER);
01818 WRAPPER_ZC (t) = ptr;
01819 return t;
01820 }
01821
01822 static tree
01823 build_srcloc (file, line)
01824 const char *file;
01825 int line;
01826 {
01827 tree t;
01828
01829 t = make_node (SRCLOC);
01830 SRCLOC_FILE (t) = file;
01831 SRCLOC_LINE (t) = line;
01832
01833 return t;
01834 }
01835
01836 tree
01837 build_srcloc_here ()
01838 {
01839 return build_srcloc (input_filename, lineno);
01840 }
01841
01842
01843
01844 tree
01845 lvalue_type (arg)
01846 tree arg;
01847 {
01848 tree type = TREE_TYPE (arg);
01849 if (TREE_CODE (arg) == OVERLOAD)
01850 type = unknown_type_node;
01851 return type;
01852 }
01853
01854
01855
01856
01857 tree
01858 error_type (arg)
01859 tree arg;
01860 {
01861 tree type = TREE_TYPE (arg);
01862 if (TREE_CODE (type) == ARRAY_TYPE)
01863 ;
01864 else if (real_lvalue_p (arg))
01865 type = build_reference_type (lvalue_type (arg));
01866 else if (IS_AGGR_TYPE (type))
01867 type = lvalue_type (arg);
01868
01869 return type;
01870 }
01871
01872
01873
01874 int
01875 varargs_function_p (function)
01876 tree function;
01877 {
01878 tree parm = TYPE_ARG_TYPES (TREE_TYPE (function));
01879 for (; parm; parm = TREE_CHAIN (parm))
01880 if (TREE_VALUE (parm) == void_type_node)
01881 return 0;
01882 return 1;
01883 }
01884
01885
01886
01887 int
01888 member_p (decl)
01889 tree decl;
01890 {
01891 const tree ctx = DECL_CONTEXT (decl);
01892 return (ctx && TYPE_P (ctx));
01893 }
01894
01895
01896
01897
01898 tree
01899 build_dummy_object (type)
01900 tree type;
01901 {
01902 tree decl = build1 (NOP_EXPR, build_pointer_type (type), void_zero_node);
01903 return build_indirect_ref (decl, NULL);
01904 }
01905
01906
01907
01908
01909
01910 tree
01911 maybe_dummy_object (type, binfop)
01912 tree type;
01913 tree *binfop;
01914 {
01915 tree decl, context;
01916 tree binfo;
01917
01918 if (current_class_type
01919 && (binfo = lookup_base (current_class_type, type,
01920 ba_ignore | ba_quiet, NULL)))
01921 context = current_class_type;
01922 else
01923 {
01924
01925 context = type;
01926 binfo = TYPE_BINFO (type);
01927 }
01928
01929 if (binfop)
01930 *binfop = binfo;
01931
01932 if (current_class_ref && context == current_class_type
01933
01934
01935
01936 && same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (current_class_ref)),
01937 current_class_type))
01938 decl = current_class_ref;
01939 else
01940 decl = build_dummy_object (context);
01941
01942 return decl;
01943 }
01944
01945
01946
01947 int
01948 is_dummy_object (ob)
01949 tree ob;
01950 {
01951 if (TREE_CODE (ob) == INDIRECT_REF)
01952 ob = TREE_OPERAND (ob, 0);
01953 return (TREE_CODE (ob) == NOP_EXPR
01954 && TREE_OPERAND (ob, 0) == void_zero_node);
01955 }
01956
01957
01958
01959 int
01960 pod_type_p (t)
01961 tree t;
01962 {
01963 t = strip_array_types (t);
01964
01965 if (t == error_mark_node)
01966 return 1;
01967 if (INTEGRAL_TYPE_P (t))
01968 return 1;
01969 if (FLOAT_TYPE_P (t))
01970 return 1;
01971 if (TYPE_PTR_P (t))
01972 return 1;
01973 if (TYPE_PTRMEM_P (t))
01974 return 1;
01975 if (TYPE_PTRMEMFUNC_P (t))
01976 return 1;
01977
01978 if (! CLASS_TYPE_P (t))
01979 return 0;
01980 if (CLASSTYPE_NON_POD_P (t))
01981 return 0;
01982 return 1;
01983 }
01984
01985
01986
01987
01988 int
01989 zero_init_p (t)
01990 tree t;
01991 {
01992 t = strip_array_types (t);
01993
01994 if (t == error_mark_node)
01995 return 1;
01996
01997
01998 if (TYPE_PTRMEM_P (t))
01999 return 0;
02000
02001
02002
02003 if (CLASS_TYPE_P (t) && CLASSTYPE_NON_ZERO_INIT_P (t))
02004 return 0;
02005
02006 return 1;
02007 }
02008
02009
02010 const struct attribute_spec cxx_attribute_table[] =
02011 {
02012
02013 { "java_interface", 0, 0, false, false, false, handle_java_interface_attribute },
02014 { "com_interface", 0, 0, false, false, false, handle_com_interface_attribute },
02015 { "init_priority", 1, 1, true, false, false, handle_init_priority_attribute },
02016 { NULL, 0, 0, false, false, false, NULL }
02017 };
02018
02019
02020
02021 static tree
02022 handle_java_interface_attribute (node, name, args, flags, no_add_attrs)
02023 tree *node;
02024 tree name;
02025 tree args ATTRIBUTE_UNUSED;
02026 int flags;
02027 bool *no_add_attrs;
02028 {
02029 if (DECL_P (*node)
02030 || !CLASS_TYPE_P (*node)
02031 || !TYPE_FOR_JAVA (*node))
02032 {
02033 error ("`%s' attribute can only be applied to Java class definitions",
02034 IDENTIFIER_POINTER (name));
02035 *no_add_attrs = true;
02036 return NULL_TREE;
02037 }
02038 if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
02039 *node = build_type_copy (*node);
02040 TYPE_JAVA_INTERFACE (*node) = 1;
02041
02042 return NULL_TREE;
02043 }
02044
02045
02046
02047 static tree
02048 handle_com_interface_attribute (node, name, args, flags, no_add_attrs)
02049 tree *node;
02050 tree name;
02051 tree args ATTRIBUTE_UNUSED;
02052 int flags ATTRIBUTE_UNUSED;
02053 bool *no_add_attrs;
02054 {
02055 static int warned;
02056
02057 *no_add_attrs = true;
02058
02059 if (DECL_P (*node)
02060 || !CLASS_TYPE_P (*node)
02061 || *node != TYPE_MAIN_VARIANT (*node))
02062 {
02063 warning ("`%s' attribute can only be applied to class definitions",
02064 IDENTIFIER_POINTER (name));
02065 return NULL_TREE;
02066 }
02067
02068 if (!warned++)
02069 warning ("`%s' is obsolete; g++ vtables are now COM-compatible by default",
02070 IDENTIFIER_POINTER (name));
02071
02072 return NULL_TREE;
02073 }
02074
02075
02076
02077 static tree
02078 handle_init_priority_attribute (node, name, args, flags, no_add_attrs)
02079 tree *node;
02080 tree name;
02081 tree args;
02082 int flags ATTRIBUTE_UNUSED;
02083 bool *no_add_attrs;
02084 {
02085 tree initp_expr = TREE_VALUE (args);
02086 tree decl = *node;
02087 tree type = TREE_TYPE (decl);
02088 int pri;
02089
02090 STRIP_NOPS (initp_expr);
02091
02092 if (!initp_expr || TREE_CODE (initp_expr) != INTEGER_CST)
02093 {
02094 error ("requested init_priority is not an integer constant");
02095 *no_add_attrs = true;
02096 return NULL_TREE;
02097 }
02098
02099 pri = TREE_INT_CST_LOW (initp_expr);
02100
02101 type = strip_array_types (type);
02102
02103 if (decl == NULL_TREE
02104 || TREE_CODE (decl) != VAR_DECL
02105 || !TREE_STATIC (decl)
02106 || DECL_EXTERNAL (decl)
02107 || (TREE_CODE (type) != RECORD_TYPE
02108 && TREE_CODE (type) != UNION_TYPE)
02109
02110
02111
02112
02113 || current_function_decl)
02114 {
02115 error ("can only use `%s' attribute on file-scope definitions of objects of class type",
02116 IDENTIFIER_POINTER (name));
02117 *no_add_attrs = true;
02118 return NULL_TREE;
02119 }
02120
02121 if (pri > MAX_INIT_PRIORITY || pri <= 0)
02122 {
02123 error ("requested init_priority is out of range");
02124 *no_add_attrs = true;
02125 return NULL_TREE;
02126 }
02127
02128
02129
02130 if (pri <= MAX_RESERVED_INIT_PRIORITY)
02131 {
02132 warning
02133 ("requested init_priority is reserved for internal use");
02134 }
02135
02136 if (SUPPORTS_INIT_PRIORITY)
02137 {
02138 DECL_INIT_PRIORITY (decl) = pri;
02139 return NULL_TREE;
02140 }
02141 else
02142 {
02143 error ("`%s' attribute is not supported on this platform",
02144 IDENTIFIER_POINTER (name));
02145 *no_add_attrs = true;
02146 return NULL_TREE;
02147 }
02148 }
02149
02150
02151
02152
02153 tree
02154 make_ptrmem_cst (type, member)
02155 tree type;
02156 tree member;
02157 {
02158 tree ptrmem_cst = make_node (PTRMEM_CST);
02159
02160
02161 TREE_CONSTANT (ptrmem_cst) = 1;
02162 TREE_TYPE (ptrmem_cst) = type;
02163 PTRMEM_CST_MEMBER (ptrmem_cst) = member;
02164 return ptrmem_cst;
02165 }
02166
02167
02168
02169
02170 tree
02171 cp_walk_subtrees (tp, walk_subtrees_p, func, data, htab)
02172 tree *tp;
02173 int *walk_subtrees_p;
02174 walk_tree_fn func;
02175 void *data;
02176 void *htab;
02177 {
02178 enum tree_code code = TREE_CODE (*tp);
02179 tree result;
02180
02181 #define WALK_SUBTREE(NODE) \
02182 do \
02183 { \
02184 result = walk_tree (&(NODE), func, data, htab); \
02185 if (result) \
02186 return result; \
02187 } \
02188 while (0)
02189
02190
02191
02192 switch (code)
02193 {
02194 case DEFAULT_ARG:
02195 case TEMPLATE_TEMPLATE_PARM:
02196 case BOUND_TEMPLATE_TEMPLATE_PARM:
02197 case UNBOUND_CLASS_TEMPLATE:
02198 case TEMPLATE_PARM_INDEX:
02199 case TEMPLATE_TYPE_PARM:
02200 case TYPENAME_TYPE:
02201 case TYPEOF_TYPE:
02202
02203
02204 *walk_subtrees_p = 0;
02205 break;
02206
02207 case PTRMEM_CST:
02208 WALK_SUBTREE (TREE_TYPE (*tp));
02209 *walk_subtrees_p = 0;
02210 break;
02211
02212 case TREE_LIST:
02213
02214 if (!BASELINK_P (*tp))
02215 WALK_SUBTREE (TREE_PURPOSE (*tp));
02216 break;
02217
02218 case OVERLOAD:
02219 WALK_SUBTREE (OVL_FUNCTION (*tp));
02220 WALK_SUBTREE (OVL_CHAIN (*tp));
02221 *walk_subtrees_p = 0;
02222 break;
02223
02224 case RECORD_TYPE:
02225 if (TYPE_PTRMEMFUNC_P (*tp))
02226 WALK_SUBTREE (TYPE_PTRMEMFUNC_FN_TYPE (*tp));
02227 break;
02228
02229 default:
02230 break;
02231 }
02232
02233
02234 return NULL_TREE;
02235
02236 #undef WALK_SUBTREE
02237 }
02238
02239
02240
02241
02242 int
02243 cp_cannot_inline_tree_fn (fnp)
02244 tree *fnp;
02245 {
02246 tree fn = *fnp;
02247
02248 if (flag_really_no_inline
02249 && lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
02250 return 1;
02251
02252
02253
02254 if (DECL_TEMPLATE_INFO (fn)
02255 && TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (fn)))
02256 {
02257 fn = *fnp = instantiate_decl (fn, 0);
02258 if (TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (fn)))
02259 return 1;
02260 }
02261
02262
02263
02264 if (!DECL_DECLARED_INLINE_P (fn) && !(*targetm.binds_local_p) (fn))
02265 {
02266 DECL_UNINLINABLE (fn) = 1;
02267 return 1;
02268 }
02269
02270 if (varargs_function_p (fn))
02271 {
02272 DECL_UNINLINABLE (fn) = 1;
02273 return 1;
02274 }
02275
02276 if (! function_attribute_inlinable_p (fn))
02277 {
02278 DECL_UNINLINABLE (fn) = 1;
02279 return 1;
02280 }
02281
02282 #ifdef KEY
02283 if (flag_exceptions && TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn)))
02284 {
02285 DECL_UNINLINABLE (fn) = 1;
02286 return 1;
02287 }
02288 #endif
02289
02290 return 0;
02291 }
02292
02293
02294
02295
02296
02297 tree
02298 cp_add_pending_fn_decls (fns_p, prev_fn)
02299 void *fns_p;
02300 tree prev_fn;
02301 {
02302 varray_type *fnsp = (varray_type *)fns_p;
02303 struct saved_scope *s;
02304
02305 for (s = scope_chain; s; s = s->prev)
02306 if (s->function_decl && s->function_decl != prev_fn)
02307 {
02308 VARRAY_PUSH_TREE (*fnsp, s->function_decl);
02309 prev_fn = s->function_decl;
02310 }
02311
02312 return prev_fn;
02313 }
02314
02315
02316
02317
02318
02319 int
02320 cp_is_overload_p (t)
02321 tree t;
02322 {
02323 return TREE_CODE (t) == OVERLOAD;
02324 }
02325
02326
02327
02328
02329 int
02330 cp_auto_var_in_fn_p (var, fn)
02331 tree var, fn;
02332 {
02333 return (DECL_P (var) && DECL_CONTEXT (var) == fn
02334 && nonstatic_local_decl_p (var));
02335 }
02336
02337
02338
02339
02340
02341 tree
02342 cp_copy_res_decl_for_inlining (result, fn, caller, decl_map_,
02343 need_decl, target_exprs)
02344 tree result, fn, caller;
02345 void *decl_map_;
02346 int *need_decl;
02347 void *target_exprs;
02348 {
02349 splay_tree decl_map = (splay_tree)decl_map_;
02350 varray_type *texps = (varray_type *)target_exprs;
02351 tree var;
02352 int aggregate_return_p;
02353
02354
02355 aggregate_return_p = IS_AGGR_TYPE (TREE_TYPE (result));
02356 *need_decl = ! aggregate_return_p;
02357
02358
02359
02360
02361
02362
02363
02364
02365 if (aggregate_return_p)
02366 {
02367 if (VARRAY_ACTIVE_SIZE (*texps) == 0)
02368 abort ();
02369 var = TREE_OPERAND (VARRAY_TOP_TREE (*texps), 0);
02370 if (! same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (var),
02371 TREE_TYPE (result)))
02372 abort ();
02373 }
02374
02375 else
02376 var = copy_decl_for_inlining (result, fn, caller);
02377
02378 if (DECL_SAVED_FUNCTION_DATA (fn))
02379 {
02380 tree nrv = DECL_SAVED_FUNCTION_DATA (fn)->x_return_value;
02381 if (nrv)
02382 {
02383
02384
02385
02386 DECL_NAME (var) = DECL_NAME (nrv);
02387 DECL_SOURCE_LOCATION (var) = DECL_SOURCE_LOCATION (nrv);
02388 DECL_ABSTRACT_ORIGIN (var) = DECL_ORIGIN (nrv);
02389
02390 DECL_INITIAL (var) = DECL_INITIAL (nrv);
02391
02392 TREE_ADDRESSABLE (var) = TREE_ADDRESSABLE (nrv);
02393
02394 splay_tree_insert (decl_map,
02395 (splay_tree_key) nrv,
02396 (splay_tree_value) var);
02397 }
02398 }
02399
02400 return var;
02401 }
02402
02403
02404
02405
02406 int
02407 cp_start_inlining (fn)
02408 tree fn;
02409 {
02410 if (DECL_TEMPLATE_INSTANTIATION (fn))
02411 return push_tinst_level (fn);
02412 else
02413 return 1;
02414 }
02415
02416
02417
02418
02419 void
02420 cp_end_inlining (fn)
02421 tree fn ATTRIBUTE_UNUSED;
02422 {
02423 if (DECL_TEMPLATE_INSTANTIATION (fn))
02424 pop_tinst_level ();
02425 }
02426
02427
02428
02429 void
02430 init_tree ()
02431 {
02432 lang_statement_code_p = cp_statement_code_p;
02433 list_hash_table = htab_create_ggc (31, list_hash, list_hash_eq, NULL);
02434 }
02435
02436
02437
02438
02439
02440 static tree
02441 mark_local_for_remap_r (tp, walk_subtrees, data)
02442 tree *tp;
02443 int *walk_subtrees ATTRIBUTE_UNUSED;
02444 void *data;
02445 {
02446 tree t = *tp;
02447 splay_tree st = (splay_tree) data;
02448 tree decl;
02449
02450
02451 if (TREE_CODE (t) == DECL_STMT
02452 && nonstatic_local_decl_p (DECL_STMT_DECL (t)))
02453 decl = DECL_STMT_DECL (t);
02454 else if (TREE_CODE (t) == LABEL_STMT)
02455 decl = LABEL_STMT_LABEL (t);
02456 else if (TREE_CODE (t) == TARGET_EXPR
02457 && nonstatic_local_decl_p (TREE_OPERAND (t, 0)))
02458 decl = TREE_OPERAND (t, 0);
02459 else if (TREE_CODE (t) == CASE_LABEL)
02460 decl = CASE_LABEL_DECL (t);
02461 else
02462 decl = NULL_TREE;
02463
02464 if (decl)
02465 {
02466 tree copy;
02467
02468
02469 copy = copy_decl_for_inlining (decl,
02470 DECL_CONTEXT (decl),
02471 DECL_CONTEXT (decl));
02472
02473
02474 splay_tree_insert (st,
02475 (splay_tree_key) decl,
02476 (splay_tree_value) copy);
02477 }
02478
02479 return NULL_TREE;
02480 }
02481
02482
02483
02484
02485
02486 static tree
02487 cp_unsave_r (tp, walk_subtrees, data)
02488 tree *tp;
02489 int *walk_subtrees;
02490 void *data;
02491 {
02492 splay_tree st = (splay_tree) data;
02493 splay_tree_node n;
02494
02495
02496 if (nonstatic_local_decl_p (*tp))
02497 {
02498
02499 n = splay_tree_lookup (st, (splay_tree_key) *tp);
02500
02501
02502 if (n)
02503 *tp = (tree) n->value;
02504 }
02505 else if (TREE_CODE (*tp) == SAVE_EXPR)
02506 remap_save_expr (tp, st, current_function_decl, walk_subtrees);
02507 else
02508 {
02509 copy_tree_r (tp, walk_subtrees, NULL);
02510
02511
02512 unsave_expr_1 (*tp);
02513 }
02514
02515
02516 return NULL_TREE;
02517 }
02518
02519
02520
02521 tree
02522 cxx_unsave_expr_now (tp)
02523 tree tp;
02524 {
02525 splay_tree st;
02526
02527
02528
02529 st = splay_tree_new (splay_tree_compare_pointers, NULL, NULL);
02530
02531
02532 walk_tree (&tp, mark_local_for_remap_r, st, NULL);
02533
02534
02535 walk_tree (&tp, cp_unsave_r, st, NULL);
02536
02537
02538 splay_tree_delete (st);
02539
02540 return tp;
02541 }
02542
02543
02544
02545
02546
02547 special_function_kind
02548 special_function_p (decl)
02549 tree decl;
02550 {
02551
02552
02553
02554 if (DECL_COPY_CONSTRUCTOR_P (decl))
02555 return sfk_copy_constructor;
02556 if (DECL_CONSTRUCTOR_P (decl))
02557 return sfk_constructor;
02558 if (DECL_OVERLOADED_OPERATOR_P (decl) == NOP_EXPR)
02559 return sfk_assignment_operator;
02560 if (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl))
02561 return sfk_destructor;
02562 if (DECL_COMPLETE_DESTRUCTOR_P (decl))
02563 return sfk_complete_destructor;
02564 if (DECL_BASE_DESTRUCTOR_P (decl))
02565 return sfk_base_destructor;
02566 if (DECL_DELETING_DESTRUCTOR_P (decl))
02567 return sfk_deleting_destructor;
02568 if (DECL_CONV_FN_P (decl))
02569 return sfk_conversion;
02570
02571 return sfk_none;
02572 }
02573
02574
02575
02576
02577 bool
02578 name_p (tree node)
02579 {
02580 if (TREE_CODE (node) == TEMPLATE_ID_EXPR)
02581 node = TREE_OPERAND (node, 0);
02582 return (
02583 TREE_CODE (node) == IDENTIFIER_NODE
02584
02585 || TREE_CODE (node) == BIT_NOT_EXPR
02586
02587 || TREE_CODE (node) == SCOPE_REF);
02588 }
02589
02590
02591
02592 int
02593 char_type_p (type)
02594 tree type;
02595 {
02596 return (same_type_p (type, char_type_node)
02597 || same_type_p (type, unsigned_char_type_node)
02598 || same_type_p (type, signed_char_type_node)
02599 || same_type_p (type, wchar_type_node));
02600 }
02601
02602
02603
02604
02605
02606
02607
02608
02609 linkage_kind
02610 decl_linkage (decl)
02611 tree decl;
02612 {
02613
02614
02615
02616
02617
02618
02619
02620
02621 if (!DECL_NAME (decl))
02622 return lk_none;
02623
02624
02625 if (TREE_PUBLIC (decl))
02626 return lk_external;
02627
02628
02629
02630
02631
02632
02633 if (DECL_LANG_SPECIFIC (decl) && DECL_COMDAT (decl))
02634 return lk_external;
02635
02636
02637
02638 if (decl_function_context (decl))
02639 return lk_none;
02640
02641
02642 return lk_internal;
02643 }
02644
02645
02646
02647
02648
02649 tree
02650 stabilize_expr (exp, initp)
02651 tree exp;
02652 tree *initp;
02653 {
02654 tree init_expr;
02655
02656 if (!TREE_SIDE_EFFECTS (exp))
02657 {
02658 init_expr = void_zero_node;
02659 }
02660 else if (!real_lvalue_p (exp)
02661 || !TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (exp)))
02662 {
02663 init_expr = get_target_expr (exp);
02664 exp = TARGET_EXPR_SLOT (init_expr);
02665 }
02666 else
02667 {
02668 exp = build_unary_op (ADDR_EXPR, exp, 1);
02669 init_expr = get_target_expr (exp);
02670 exp = TARGET_EXPR_SLOT (init_expr);
02671 exp = build_indirect_ref (exp, 0);
02672 }
02673
02674 *initp = init_expr;
02675 return exp;
02676 }
02677
02678 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
02679
02680
02681
02682 void
02683 lang_check_failed (file, line, function)
02684 const char *file;
02685 int line;
02686 const char *function;
02687 {
02688 internal_error ("lang_* check: failed in %s, at %s:%d",
02689 function, trim_filename (file), line);
02690 }
02691 #endif
02692
02693 #include "gt-cp-tree.h"