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
00032
00033
00034
00035 #include "config.h"
00036 #include "system.h"
00037 #include "tree.h"
00038 #include "rtl.h"
00039 #include "expr.h"
00040 #include "flags.h"
00041 #include "cp-tree.h"
00042 #include "decl.h"
00043 #include "lex.h"
00044 #include "output.h"
00045 #include "except.h"
00046 #include "toplev.h"
00047 #include "ggc.h"
00048 #include "timevar.h"
00049 #include "cpplib.h"
00050 #include "target.h"
00051 #include "c-common.h"
00052 #include "timevar.h"
00053 #ifdef SGI_MONGOOSE
00054 #include "defaults.h"
00055 #endif
00056
00057 #ifdef KEY
00058 extern void gxx_emits_decl PARAMS ((tree));
00059 #endif // KEY
00060
00061 extern cpp_reader *parse_in;
00062
00063
00064
00065 typedef struct priority_info_s {
00066
00067
00068 int initializations_p;
00069
00070
00071 int destructions_p;
00072 } *priority_info;
00073
00074 static void mark_vtable_entries PARAMS ((tree));
00075 static void grok_function_init PARAMS ((tree, tree));
00076 static int maybe_emit_vtables (tree);
00077 static void add_using_namespace PARAMS ((tree, tree, int));
00078 static cxx_binding *ambiguous_decl (tree, cxx_binding *, cxx_binding *,int);
00079 static tree build_anon_union_vars PARAMS ((tree, tree*, int, int));
00080 static int acceptable_java_type PARAMS ((tree));
00081 static void output_vtable_inherit PARAMS ((tree));
00082 static tree start_objects PARAMS ((int, int));
00083 static void finish_objects PARAMS ((int, int, tree));
00084 static tree merge_functions PARAMS ((tree, tree));
00085 static tree decl_namespace PARAMS ((tree));
00086 static tree validate_nonmember_using_decl PARAMS ((tree, tree *, tree *));
00087 static void do_nonmember_using_decl PARAMS ((tree, tree, tree, tree,
00088 tree *, tree *));
00089 static tree start_static_storage_duration_function PARAMS ((void));
00090 static void finish_static_storage_duration_function PARAMS ((tree));
00091 static priority_info get_priority_info PARAMS ((int));
00092 static void do_static_initialization PARAMS ((tree, tree));
00093 static void do_static_destruction PARAMS ((tree));
00094 static tree start_static_initialization_or_destruction PARAMS ((tree, int));
00095 static void finish_static_initialization_or_destruction PARAMS ((tree));
00096 static void generate_ctor_or_dtor_function PARAMS ((int, int));
00097 static int generate_ctor_and_dtor_functions_for_priority
00098 PARAMS ((splay_tree_node, void *));
00099 static tree prune_vars_needing_no_initialization PARAMS ((tree *));
00100 static void write_out_vars PARAMS ((tree));
00101 static void import_export_class PARAMS ((tree));
00102 static tree get_guard_bits PARAMS ((tree));
00103
00104
00105
00106
00107 static GTY(()) varray_type pending_statics;
00108 #define pending_statics_used \
00109 (pending_statics ? pending_statics->elements_used : 0)
00110
00111
00112
00113 static GTY(()) varray_type deferred_fns;
00114 #define deferred_fns_used \
00115 (deferred_fns ? deferred_fns->elements_used : 0)
00116
00117
00118
00119 extern int spew_debug;
00120
00121
00122
00123 int at_eof;
00124
00125 #ifdef SGI_MONGOOSE
00126
00127
00128
00129 void (*back_end_hook) PARAMS ((tree));
00130 #endif
00131
00132
00133
00134 tree static_ctors;
00135 tree static_dtors;
00136
00137
00138
00139 tree global_namespace;
00140
00141
00142
00143
00144
00145
00146
00147 int
00148 grok_method_quals (ctype, function, quals)
00149 tree ctype, function, quals;
00150 {
00151 tree fntype = TREE_TYPE (function);
00152 tree raises = TYPE_RAISES_EXCEPTIONS (fntype);
00153 int type_quals = TYPE_UNQUALIFIED;
00154 int dup_quals = TYPE_UNQUALIFIED;
00155 int this_quals = TYPE_UNQUALIFIED;
00156
00157 do
00158 {
00159 int tq = cp_type_qual_from_rid (TREE_VALUE (quals));
00160
00161 if ((type_quals | this_quals) & tq)
00162 dup_quals |= tq;
00163 else if (tq & TYPE_QUAL_RESTRICT)
00164 this_quals |= tq;
00165 else
00166 type_quals |= tq;
00167 quals = TREE_CHAIN (quals);
00168 }
00169 while (quals);
00170
00171 if (dup_quals != TYPE_UNQUALIFIED)
00172 error ("duplicate type qualifiers in %s declaration",
00173 TREE_CODE (function) == FUNCTION_DECL
00174 ? "member function" : "type");
00175
00176 ctype = cp_build_qualified_type (ctype, type_quals);
00177 fntype = build_cplus_method_type (ctype, TREE_TYPE (fntype),
00178 (TREE_CODE (fntype) == METHOD_TYPE
00179 ? TREE_CHAIN (TYPE_ARG_TYPES (fntype))
00180 : TYPE_ARG_TYPES (fntype)));
00181 if (raises)
00182 fntype = build_exception_variant (fntype, raises);
00183
00184 TREE_TYPE (function) = fntype;
00185 return this_quals;
00186 }
00187
00188
00189
00190
00191
00192 void
00193 warn_if_unknown_interface (decl)
00194 tree decl;
00195 {
00196 static int already_warned = 0;
00197 if (already_warned++)
00198 return;
00199
00200 if (flag_alt_external_templates)
00201 {
00202 tree til = tinst_for_decl ();
00203 int sl = lineno;
00204 const char *sf = input_filename;
00205
00206 if (til)
00207 {
00208 lineno = TINST_LINE (til);
00209 input_filename = TINST_FILE (til);
00210 }
00211 warning ("template `%#D' instantiated in file without #pragma interface",
00212 decl);
00213 lineno = sl;
00214 input_filename = sf;
00215 }
00216 else
00217 cp_warning_at ("template `%#D' defined in file without #pragma interface",
00218 decl);
00219 }
00220
00221
00222
00223 void
00224 grok_x_components (specs)
00225 tree specs;
00226 {
00227 tree t;
00228
00229 specs = strip_attrs (specs);
00230
00231 check_tag_decl (specs);
00232 t = groktypename (build_tree_list (specs, NULL_TREE));
00233
00234
00235
00236 if (t == NULL_TREE || !ANON_AGGR_TYPE_P (t))
00237 return;
00238
00239 fixup_anonymous_aggr (t);
00240 finish_member_declaration (build_decl (FIELD_DECL, NULL_TREE, t));
00241 }
00242
00243
00244
00245
00246 tree
00247 cp_build_parm_decl (name, type)
00248 tree name;
00249 tree type;
00250 {
00251 tree parm = build_decl (PARM_DECL, name, type);
00252 DECL_ARG_TYPE (parm) = type_passed_as (type);
00253 return parm;
00254 }
00255
00256
00257
00258
00259 tree
00260 build_artificial_parm (name, type)
00261 tree name;
00262 tree type;
00263 {
00264 tree parm = cp_build_parm_decl (name, type);
00265 DECL_ARTIFICIAL (parm) = 1;
00266
00267
00268 TREE_READONLY (parm) = 1;
00269 return parm;
00270 }
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285 void
00286 maybe_retrofit_in_chrg (fn)
00287 tree fn;
00288 {
00289 tree basetype, arg_types, parms, parm, fntype;
00290
00291
00292 if (DECL_HAS_IN_CHARGE_PARM_P (fn))
00293 return;
00294
00295
00296
00297 if (uses_template_parms (fn))
00298 return;
00299
00300
00301
00302 if (DECL_CONSTRUCTOR_P (fn)
00303 && !TYPE_USES_VIRTUAL_BASECLASSES (DECL_CONTEXT (fn)))
00304 return;
00305
00306 arg_types = TYPE_ARG_TYPES (TREE_TYPE (fn));
00307 basetype = TREE_TYPE (TREE_VALUE (arg_types));
00308 arg_types = TREE_CHAIN (arg_types);
00309
00310 parms = TREE_CHAIN (DECL_ARGUMENTS (fn));
00311
00312
00313
00314 if (TYPE_USES_VIRTUAL_BASECLASSES (DECL_CONTEXT (fn)))
00315 {
00316 parm = build_artificial_parm (vtt_parm_identifier, vtt_parm_type);
00317
00318
00319 TREE_CHAIN (parm) = parms;
00320 parms = parm;
00321
00322
00323 arg_types = hash_tree_chain (vtt_parm_type, arg_types);
00324
00325 DECL_HAS_VTT_PARM_P (fn) = 1;
00326 }
00327
00328
00329 parm = build_artificial_parm (in_charge_identifier, integer_type_node);
00330 TREE_CHAIN (parm) = parms;
00331 parms = parm;
00332 arg_types = hash_tree_chain (integer_type_node, arg_types);
00333
00334
00335 TREE_CHAIN (DECL_ARGUMENTS (fn)) = parms;
00336
00337
00338 fntype = build_cplus_method_type (basetype, TREE_TYPE (TREE_TYPE (fn)),
00339 arg_types);
00340 if (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn)))
00341 fntype = build_exception_variant (fntype,
00342 TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn)));
00343 TREE_TYPE (fn) = fntype;
00344
00345
00346 DECL_HAS_IN_CHARGE_PARM_P (fn) = 1;
00347 }
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369 void
00370 grokclassfn (ctype, function, flags, quals)
00371 tree ctype, function;
00372 enum overload_flags flags;
00373 tree quals;
00374 {
00375 tree fn_name = DECL_NAME (function);
00376 int this_quals = TYPE_UNQUALIFIED;
00377
00378
00379
00380 SET_DECL_LANGUAGE (function, lang_cplusplus);
00381
00382 if (fn_name == NULL_TREE)
00383 {
00384 error ("name missing for member function");
00385 fn_name = get_identifier ("<anonymous>");
00386 DECL_NAME (function) = fn_name;
00387 }
00388
00389 if (quals)
00390 this_quals = grok_method_quals (ctype, function, quals);
00391
00392 if (TREE_CODE (TREE_TYPE (function)) == METHOD_TYPE)
00393 {
00394
00395
00396
00397 tree type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (function)));
00398 tree qual_type;
00399 tree parm;
00400
00401
00402
00403 this_quals |= TYPE_QUAL_CONST;
00404 qual_type = cp_build_qualified_type (type, this_quals);
00405 parm = build_artificial_parm (this_identifier, qual_type);
00406 c_apply_type_quals_to_decl (this_quals, parm);
00407 TREE_CHAIN (parm) = last_function_parms;
00408 last_function_parms = parm;
00409 }
00410
00411 DECL_ARGUMENTS (function) = last_function_parms;
00412 DECL_CONTEXT (function) = ctype;
00413
00414 if (flags == DTOR_FLAG)
00415 DECL_DESTRUCTOR_P (function) = 1;
00416
00417 if (flags == DTOR_FLAG || DECL_CONSTRUCTOR_P (function))
00418 maybe_retrofit_in_chrg (function);
00419
00420 if (flags == DTOR_FLAG)
00421 {
00422 DECL_DESTRUCTOR_P (function) = 1;
00423 TYPE_HAS_DESTRUCTOR (ctype) = 1;
00424 }
00425 }
00426
00427
00428
00429
00430 tree
00431 grok_array_decl (array_expr, index_exp)
00432 tree array_expr, index_exp;
00433 {
00434 tree type = TREE_TYPE (array_expr);
00435 tree p1, p2, i1, i2;
00436
00437 if (type == error_mark_node || index_exp == error_mark_node)
00438 return error_mark_node;
00439 if (processing_template_decl)
00440 return build_min (ARRAY_REF, type ? TREE_TYPE (type) : NULL_TREE,
00441 array_expr, index_exp);
00442
00443 if (type == NULL_TREE)
00444 {
00445
00446
00447 error ("parser may be lost: is there a '{' missing somewhere?");
00448 return NULL_TREE;
00449 }
00450
00451 if (TREE_CODE (type) == OFFSET_TYPE
00452 || TREE_CODE (type) == REFERENCE_TYPE)
00453 type = TREE_TYPE (type);
00454
00455
00456 if (IS_AGGR_TYPE (type) || IS_AGGR_TYPE (TREE_TYPE (index_exp)))
00457 return build_opfncall (ARRAY_REF, LOOKUP_NORMAL,
00458 array_expr, index_exp, NULL_TREE);
00459
00460
00461
00462
00463
00464 if (TREE_CODE (type) == ARRAY_TYPE)
00465 p1 = array_expr;
00466 else
00467 p1 = build_expr_type_conversion (WANT_POINTER, array_expr, 0);
00468
00469 if (TREE_CODE (TREE_TYPE (index_exp)) == ARRAY_TYPE)
00470 p2 = index_exp;
00471 else
00472 p2 = build_expr_type_conversion (WANT_POINTER, index_exp, 0);
00473
00474 i1 = build_expr_type_conversion (WANT_INT | WANT_ENUM, array_expr, 0);
00475 i2 = build_expr_type_conversion (WANT_INT | WANT_ENUM, index_exp, 0);
00476
00477 if ((p1 && i2) && (i1 && p2))
00478 error ("ambiguous conversion for array subscript");
00479
00480 if (p1 && i2)
00481 array_expr = p1, index_exp = i2;
00482 else if (i1 && p2)
00483 array_expr = p2, index_exp = i1;
00484 else
00485 {
00486 error ("invalid types `%T[%T]' for array subscript",
00487 type, TREE_TYPE (index_exp));
00488 return error_mark_node;
00489 }
00490
00491 if (array_expr == error_mark_node || index_exp == error_mark_node)
00492 error ("ambiguous conversion for array subscript");
00493
00494 return build_array_ref (array_expr, index_exp);
00495 }
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505 tree
00506 delete_sanity (exp, size, doing_vec, use_global_delete)
00507 tree exp, size;
00508 int doing_vec, use_global_delete;
00509 {
00510 tree t, type;
00511
00512
00513 tree maxindex = NULL_TREE;
00514
00515 if (exp == error_mark_node)
00516 return exp;
00517
00518 if (processing_template_decl)
00519 {
00520 t = build_min (DELETE_EXPR, void_type_node, exp, size);
00521 DELETE_EXPR_USE_GLOBAL (t) = use_global_delete;
00522 DELETE_EXPR_USE_VEC (t) = doing_vec;
00523 return t;
00524 }
00525
00526 if (TREE_CODE (exp) == OFFSET_REF)
00527 exp = resolve_offset_ref (exp);
00528 exp = convert_from_reference (exp);
00529 t = stabilize_reference (exp);
00530 t = build_expr_type_conversion (WANT_POINTER, t, 1);
00531
00532 if (t == NULL_TREE || t == error_mark_node)
00533 {
00534 error ("type `%#T' argument given to `delete', expected pointer",
00535 TREE_TYPE (exp));
00536 return error_mark_node;
00537 }
00538
00539 if (doing_vec == 2)
00540 {
00541 maxindex = cp_build_binary_op (MINUS_EXPR, size, integer_one_node);
00542 pedwarn ("anachronistic use of array size in vector delete");
00543 }
00544
00545 type = TREE_TYPE (t);
00546
00547
00548
00549
00550 if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
00551 {
00552 error ("cannot delete a function. Only pointer-to-objects are valid arguments to `delete'");
00553 return error_mark_node;
00554 }
00555
00556
00557 if (TREE_CODE (TREE_TYPE (type)) == VOID_TYPE)
00558 {
00559 warning ("deleting `%T' is undefined", type);
00560 doing_vec = 0;
00561 }
00562
00563
00564 if (TREE_CODE (t) == ADDR_EXPR
00565 && TREE_CODE (TREE_OPERAND (t, 0)) == VAR_DECL
00566 && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == ARRAY_TYPE)
00567 warning ("deleting array `%#D'", TREE_OPERAND (t, 0));
00568
00569
00570 if (integer_zerop (t))
00571 return build1 (NOP_EXPR, void_type_node, t);
00572
00573 if (doing_vec)
00574 return build_vec_delete (t, maxindex, sfk_deleting_destructor,
00575 use_global_delete);
00576 else
00577 return build_delete (type, t, sfk_deleting_destructor,
00578 LOOKUP_NORMAL, use_global_delete);
00579 }
00580
00581
00582
00583
00584 void
00585 check_member_template (tmpl)
00586 tree tmpl;
00587 {
00588 tree decl;
00589
00590 my_friendly_assert (TREE_CODE (tmpl) == TEMPLATE_DECL, 0);
00591 decl = DECL_TEMPLATE_RESULT (tmpl);
00592
00593 if (TREE_CODE (decl) == FUNCTION_DECL
00594 || (TREE_CODE (decl) == TYPE_DECL
00595 && IS_AGGR_TYPE (TREE_TYPE (decl))))
00596 {
00597 if (current_function_decl)
00598
00599
00600
00601 error ("invalid declaration of member template `%#D' in local class",
00602 decl);
00603
00604 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_VIRTUAL_P (decl))
00605 {
00606
00607
00608
00609 error
00610 ("invalid use of `virtual' in template declaration of `%#D'",
00611 decl);
00612 DECL_VIRTUAL_P (decl) = 0;
00613 }
00614
00615
00616
00617 DECL_IGNORED_P (tmpl) = 1;
00618 }
00619 else
00620 error ("template declaration of `%#D'", decl);
00621 }
00622
00623
00624
00625 static int
00626 acceptable_java_type (type)
00627 tree type;
00628 {
00629 if (TREE_CODE (type) == VOID_TYPE || TYPE_FOR_JAVA (type))
00630 return 1;
00631 if (TREE_CODE (type) == POINTER_TYPE || TREE_CODE (type) == REFERENCE_TYPE)
00632 {
00633 type = TREE_TYPE (type);
00634 if (TREE_CODE (type) == RECORD_TYPE)
00635 {
00636 tree args; int i;
00637 if (! TYPE_FOR_JAVA (type))
00638 return 0;
00639 if (! CLASSTYPE_TEMPLATE_INFO (type))
00640 return 1;
00641 args = CLASSTYPE_TI_ARGS (type);
00642 i = TREE_VEC_LENGTH (args);
00643 while (--i >= 0)
00644 {
00645 type = TREE_VEC_ELT (args, i);
00646 if (TREE_CODE (type) == POINTER_TYPE)
00647 type = TREE_TYPE (type);
00648 if (! TYPE_FOR_JAVA (type))
00649 return 0;
00650 }
00651 return 1;
00652 }
00653 }
00654 return 0;
00655 }
00656
00657
00658
00659
00660
00661 int
00662 check_java_method (method)
00663 tree method;
00664 {
00665 int jerr = 0;
00666 tree arg_types = TYPE_ARG_TYPES (TREE_TYPE (method));
00667 tree ret_type = TREE_TYPE (TREE_TYPE (method));
00668 if (! acceptable_java_type (ret_type))
00669 {
00670 error ("Java method '%D' has non-Java return type `%T'",
00671 method, ret_type);
00672 jerr++;
00673 }
00674 for (; arg_types != NULL_TREE; arg_types = TREE_CHAIN (arg_types))
00675 {
00676 tree type = TREE_VALUE (arg_types);
00677 if (! acceptable_java_type (type))
00678 {
00679 error ("Java method '%D' has non-Java parameter type `%T'",
00680 method, type);
00681 jerr++;
00682 }
00683 }
00684 return jerr ? 0 : 1;
00685 }
00686
00687
00688
00689
00690
00691 tree
00692 check_classfn (ctype, function)
00693 tree ctype, function;
00694 {
00695 int ix;
00696 int is_template;
00697
00698 if (DECL_USE_TEMPLATE (function)
00699 && !(TREE_CODE (function) == TEMPLATE_DECL
00700 && DECL_TEMPLATE_SPECIALIZATION (function))
00701 && is_member_template (DECL_TI_TEMPLATE (function)))
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712 return NULL_TREE;
00713
00714
00715 is_template = (TREE_CODE (function) == TEMPLATE_DECL
00716 || (processing_template_decl - template_class_depth (ctype)));
00717
00718 ix = lookup_fnfields_1 (complete_type (ctype),
00719 DECL_CONSTRUCTOR_P (function) ? ctor_identifier :
00720 DECL_DESTRUCTOR_P (function) ? dtor_identifier :
00721 DECL_NAME (function));
00722
00723 if (ix >= 0)
00724 {
00725 tree methods = CLASSTYPE_METHOD_VEC (ctype);
00726 tree fndecls, fndecl = 0;
00727 bool is_conv_op;
00728 const char *format = NULL;
00729
00730 for (fndecls = TREE_VEC_ELT (methods, ix);
00731 fndecls; fndecls = OVL_NEXT (fndecls))
00732 {
00733 tree p1, p2;
00734
00735 fndecl = OVL_CURRENT (fndecls);
00736 p1 = TYPE_ARG_TYPES (TREE_TYPE (function));
00737 p2 = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
00738
00739
00740
00741
00742
00743
00744
00745
00746 if (DECL_STATIC_FUNCTION_P (fndecl)
00747 && TREE_CODE (TREE_TYPE (function)) == METHOD_TYPE)
00748 p1 = TREE_CHAIN (p1);
00749
00750
00751
00752 if (is_template != (TREE_CODE (fndecl) == TEMPLATE_DECL))
00753 continue;
00754
00755 if (same_type_p (TREE_TYPE (TREE_TYPE (function)),
00756 TREE_TYPE (TREE_TYPE (fndecl)))
00757 && compparms (p1, p2)
00758 && (DECL_TEMPLATE_SPECIALIZATION (function)
00759 == DECL_TEMPLATE_SPECIALIZATION (fndecl))
00760 && (!DECL_TEMPLATE_SPECIALIZATION (function)
00761 || (DECL_TI_TEMPLATE (function)
00762 == DECL_TI_TEMPLATE (fndecl))))
00763 return fndecl;
00764 }
00765 error ("prototype for `%#D' does not match any in class `%T'",
00766 function, ctype);
00767 is_conv_op = DECL_CONV_FN_P (fndecl);
00768
00769 if (is_conv_op)
00770 ix = CLASSTYPE_FIRST_CONVERSION_SLOT;
00771 fndecls = TREE_VEC_ELT (methods, ix);
00772 while (fndecls)
00773 {
00774 fndecl = OVL_CURRENT (fndecls);
00775 fndecls = OVL_NEXT (fndecls);
00776
00777 if (!fndecls && is_conv_op)
00778 {
00779 if (TREE_VEC_LENGTH (methods) > ix)
00780 {
00781 ix++;
00782 fndecls = TREE_VEC_ELT (methods, ix);
00783 if (!DECL_CONV_FN_P (OVL_CURRENT (fndecls)))
00784 {
00785 fndecls = NULL_TREE;
00786 is_conv_op = false;
00787 }
00788 }
00789 else
00790 is_conv_op = false;
00791 }
00792 if (format)
00793 format = " %#D";
00794 else if (fndecls)
00795 format = "candidates are: %#D";
00796 else
00797 format = "candidate is: %#D";
00798 cp_error_at (format, fndecl);
00799 }
00800 }
00801 else if (!COMPLETE_TYPE_P (ctype))
00802 cxx_incomplete_type_error (function, ctype);
00803 else
00804 error ("no `%#D' member function declared in class `%T'",
00805 function, ctype);
00806
00807
00808
00809
00810
00811 if (COMPLETE_TYPE_P (ctype))
00812 add_method (ctype, function, 1);
00813 return NULL_TREE;
00814 }
00815
00816
00817
00818
00819
00820
00821 void
00822 finish_static_data_member_decl (decl, init, asmspec_tree, flags)
00823 tree decl;
00824 tree init;
00825 tree asmspec_tree;
00826 int flags;
00827 {
00828 my_friendly_assert (TREE_PUBLIC (decl), 0);
00829
00830 DECL_CONTEXT (decl) = current_class_type;
00831
00832
00833
00834
00835
00836 if (!asmspec_tree && current_class_type)
00837 DECL_INITIAL (decl) = error_mark_node;
00838
00839 if (! processing_template_decl)
00840 {
00841 if (!pending_statics)
00842 VARRAY_TREE_INIT (pending_statics, 32, "pending_statics");
00843 VARRAY_PUSH_TREE (pending_statics, decl);
00844 }
00845
00846 if (LOCAL_CLASS_P (current_class_type))
00847 pedwarn ("local class `%#T' shall not have static data member `%#D'",
00848 current_class_type, decl);
00849
00850
00851 if (init != NULL_TREE && TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl)))
00852 {
00853 static int explained = 0;
00854
00855 error ("initializer invalid for static member with constructor");
00856 if (!explained)
00857 {
00858 error ("(an out of class initialization is required)");
00859 explained = 1;
00860 }
00861 init = NULL_TREE;
00862 }
00863
00864
00865 if (CP_TYPE_CONST_P (TREE_TYPE (decl)) && init == 0)
00866 TREE_USED (decl) = 1;
00867 DECL_INITIAL (decl) = init;
00868 DECL_IN_AGGR_P (decl) = 1;
00869
00870 cp_finish_decl (decl, init, asmspec_tree, flags);
00871 }
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891 tree
00892 grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
00893 tree declarator, declspecs, init, asmspec_tree, attrlist;
00894 {
00895 tree value;
00896 const char *asmspec = 0;
00897 int flags = LOOKUP_ONLYCONVERTING;
00898
00899
00900 if (init == NULL_TREE && declarator != NULL_TREE
00901 && TREE_CODE (declarator) == CALL_EXPR
00902 && TREE_OPERAND (declarator, 0)
00903 && (TREE_CODE (TREE_OPERAND (declarator, 0)) == IDENTIFIER_NODE
00904 || TREE_CODE (TREE_OPERAND (declarator, 0)) == SCOPE_REF)
00905 && parmlist_is_exprlist (CALL_DECLARATOR_PARMS (declarator)))
00906 {
00907
00908
00909
00910
00911
00912
00913
00914
00915 static int explained;
00916
00917 error ("invalid data member initialization");
00918 if (!explained)
00919 {
00920 error ("(use `=' to initialize static data members)");
00921 explained = 1;
00922 }
00923
00924 declarator = TREE_OPERAND (declarator, 0);
00925 flags = 0;
00926 }
00927
00928 if (declspecs == NULL_TREE
00929 && TREE_CODE (declarator) == SCOPE_REF
00930 && TREE_CODE (TREE_OPERAND (declarator, 1)) == IDENTIFIER_NODE)
00931 {
00932
00933 if (! IS_AGGR_TYPE_CODE (TREE_CODE (TREE_OPERAND (declarator, 0))))
00934 ;
00935 else if (TREE_COMPLEXITY (declarator) == current_class_depth)
00936 pop_nested_class ();
00937 return do_class_using_decl (declarator);
00938 }
00939
00940 if (init
00941 && TREE_CODE (init) == TREE_LIST
00942 && TREE_VALUE (init) == error_mark_node
00943 && TREE_CHAIN (init) == NULL_TREE)
00944 init = NULL_TREE;
00945
00946 value = grokdeclarator (declarator, declspecs, FIELD, init != 0, &attrlist);
00947 if (! value || value == error_mark_node)
00948
00949 return value;
00950 if (TREE_TYPE (value) == error_mark_node)
00951 return error_mark_node;
00952
00953 if (TREE_CODE (value) == TYPE_DECL && init)
00954 {
00955 error ("typedef `%D' is initialized (use __typeof__ instead)", value);
00956 init = NULL_TREE;
00957 }
00958
00959
00960 if (TREE_CODE (value) == VOID_TYPE)
00961 return void_type_node;
00962
00963 if (DECL_NAME (value) != NULL_TREE
00964 && IDENTIFIER_POINTER (DECL_NAME (value))[0] == '_'
00965 && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (value)), "_vptr"))
00966 error ("member `%D' conflicts with virtual function table field name",
00967 value);
00968
00969
00970 if (TREE_CODE (value) == TYPE_DECL)
00971 {
00972 DECL_NONLOCAL (value) = 1;
00973 DECL_CONTEXT (value) = current_class_type;
00974
00975 if (CLASS_TYPE_P (TREE_TYPE (value)))
00976 CLASSTYPE_GOT_SEMICOLON (TREE_TYPE (value)) = 1;
00977
00978 if (processing_template_decl)
00979 value = push_template_decl (value);
00980
00981 return value;
00982 }
00983
00984 if (DECL_IN_AGGR_P (value))
00985 {
00986 error ("`%D' is already defined in `%T'", value,
00987 DECL_CONTEXT (value));
00988 return void_type_node;
00989 }
00990
00991 if (asmspec_tree)
00992 asmspec = TREE_STRING_POINTER (asmspec_tree);
00993
00994 if (init)
00995 {
00996 if (TREE_CODE (value) == FUNCTION_DECL)
00997 {
00998 grok_function_init (value, init);
00999 init = NULL_TREE;
01000 }
01001 else if (pedantic && TREE_CODE (value) != VAR_DECL)
01002
01003 init = NULL_TREE;
01004 else
01005 {
01006
01007
01008 if (TREE_CODE (init) == TREE_LIST)
01009 {
01010 if (TREE_CHAIN (init) == NULL_TREE)
01011 init = TREE_VALUE (init);
01012 else
01013 init = digest_init (TREE_TYPE (value), init, (tree *)0);
01014 }
01015
01016 if (!processing_template_decl)
01017 {
01018 if (TREE_CODE (init) == CONST_DECL)
01019 init = DECL_INITIAL (init);
01020 else if (TREE_READONLY_DECL_P (init))
01021 init = decl_constant_value (init);
01022 else if (TREE_CODE (init) == CONSTRUCTOR)
01023 init = digest_init (TREE_TYPE (value), init, (tree *)0);
01024 if (init != error_mark_node && ! TREE_CONSTANT (init))
01025 {
01026
01027
01028
01029 if (TREE_CODE (TREE_TYPE (value)) != REFERENCE_TYPE
01030 || (TREE_STATIC (init) == 0
01031 && (!DECL_P (init) || DECL_EXTERNAL (init) == 0)))
01032 {
01033 error ("field initializer is not constant");
01034 init = error_mark_node;
01035 }
01036 }
01037 }
01038 }
01039 }
01040
01041 if (processing_template_decl
01042 && (TREE_CODE (value) == VAR_DECL || TREE_CODE (value) == FUNCTION_DECL))
01043 value = push_template_decl (value);
01044
01045 if (attrlist)
01046 cplus_decl_attributes (&value, attrlist, 0);
01047
01048 if (TREE_CODE (value) == VAR_DECL)
01049 {
01050 finish_static_data_member_decl (value, init, asmspec_tree,
01051 flags);
01052 return value;
01053 }
01054 if (TREE_CODE (value) == FIELD_DECL)
01055 {
01056 if (asmspec)
01057 error ("`asm' specifiers are not permitted on non-static data members");
01058 if (DECL_INITIAL (value) == error_mark_node)
01059 init = error_mark_node;
01060 cp_finish_decl (value, init, NULL_TREE, flags);
01061 DECL_INITIAL (value) = init;
01062 DECL_IN_AGGR_P (value) = 1;
01063 return value;
01064 }
01065 if (TREE_CODE (value) == FUNCTION_DECL)
01066 {
01067 if (asmspec)
01068 {
01069
01070
01071 SET_DECL_RTL (value, NULL_RTX);
01072 SET_DECL_ASSEMBLER_NAME (value, get_identifier (asmspec));
01073 }
01074 if (!DECL_FRIEND_P (value))
01075 grok_special_member_properties (value);
01076
01077 cp_finish_decl (value, init, asmspec_tree, flags);
01078
01079
01080 if (DECL_FRIEND_P (value))
01081 return void_type_node;
01082
01083 DECL_IN_AGGR_P (value) = 1;
01084 return value;
01085 }
01086 abort ();
01087
01088 return NULL_TREE;
01089 }
01090
01091
01092
01093
01094 tree
01095 grokbitfield (declarator, declspecs, width)
01096 tree declarator, declspecs, width;
01097 {
01098 register tree value = grokdeclarator (declarator, declspecs, BITFIELD,
01099 0, NULL);
01100
01101 if (! value) return NULL_TREE;
01102
01103
01104 if (TREE_CODE (value) == VOID_TYPE)
01105 return void_type_node;
01106
01107 if (TREE_CODE (value) == TYPE_DECL)
01108 {
01109 error ("cannot declare `%D' to be a bit-field type", value);
01110 return NULL_TREE;
01111 }
01112
01113
01114
01115
01116
01117 if (TREE_CODE (value) == FUNCTION_DECL)
01118 {
01119 error ("cannot declare bit-field `%D' with function type",
01120 DECL_NAME (value));
01121 return NULL_TREE;
01122 }
01123
01124 if (DECL_IN_AGGR_P (value))
01125 {
01126 error ("`%D' is already defined in the class %T", value,
01127 DECL_CONTEXT (value));
01128 return void_type_node;
01129 }
01130
01131 if (TREE_STATIC (value))
01132 {
01133 error ("static member `%D' cannot be a bit-field", value);
01134 return NULL_TREE;
01135 }
01136 cp_finish_decl (value, NULL_TREE, NULL_TREE, 0);
01137
01138 if (width != error_mark_node)
01139 {
01140 constant_expression_warning (width);
01141 DECL_INITIAL (value) = width;
01142 SET_DECL_C_BIT_FIELD (value);
01143 }
01144
01145 DECL_IN_AGGR_P (value) = 1;
01146 return value;
01147 }
01148
01149
01150
01151
01152 tree
01153 grokoptypename (declspecs, declarator, scope)
01154 tree declspecs, declarator;
01155 tree scope;
01156 {
01157 tree t = grokdeclarator (declarator, declspecs, TYPENAME, 0, NULL);
01158
01159
01160
01161 if (scope && current_template_parms
01162 && uses_template_parms (t)
01163 && uses_template_parms (scope))
01164 {
01165 tree args = current_template_args ();
01166
01167 push_scope (scope);
01168 t = tsubst (t, args, tf_error | tf_warning, NULL_TREE);
01169 pop_scope (scope);
01170 }
01171
01172 return mangle_conv_op_name_for_type (t);
01173 }
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210 static void
01211 grok_function_init (decl, init)
01212 tree decl;
01213 tree init;
01214 {
01215
01216
01217 tree type = TREE_TYPE (decl);
01218
01219 if (TREE_CODE (type) == FUNCTION_TYPE)
01220 error ("initializer specified for non-member function `%D'", decl);
01221 else if (integer_zerop (init))
01222 DECL_PURE_VIRTUAL_P (decl) = 1;
01223 else
01224 error ("invalid initializer for virtual method `%D'", decl);
01225 }
01226
01227 void
01228 cplus_decl_attributes (decl, attributes, flags)
01229 tree *decl, attributes;
01230 int flags;
01231 {
01232 if (*decl == NULL_TREE || *decl == void_type_node)
01233 return;
01234
01235 if (TREE_CODE (*decl) == TEMPLATE_DECL)
01236 decl = &DECL_TEMPLATE_RESULT (*decl);
01237
01238 decl_attributes (decl, attributes, flags);
01239
01240 if (TREE_CODE (*decl) == TYPE_DECL)
01241 SET_IDENTIFIER_TYPE_VALUE (DECL_NAME (*decl), TREE_TYPE (*decl));
01242 }
01243
01244
01245
01246
01247
01248
01249
01250 tree
01251 constructor_name_full (thing)
01252 tree thing;
01253 {
01254 if (TREE_CODE (thing) == TEMPLATE_TYPE_PARM
01255 || TREE_CODE (thing) == BOUND_TEMPLATE_TEMPLATE_PARM
01256 || TREE_CODE (thing) == TYPENAME_TYPE)
01257 thing = TYPE_NAME (thing);
01258 else if (IS_AGGR_TYPE_CODE (TREE_CODE (thing)))
01259 {
01260 if (TYPE_WAS_ANONYMOUS (thing) && TYPE_HAS_CONSTRUCTOR (thing))
01261 thing = DECL_NAME (OVL_CURRENT (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (thing), 0)));
01262 else
01263 thing = TYPE_NAME (thing);
01264 }
01265 if (TREE_CODE (thing) == TYPE_DECL
01266 || (TREE_CODE (thing) == TEMPLATE_DECL
01267 && TREE_CODE (DECL_TEMPLATE_RESULT (thing)) == TYPE_DECL))
01268 thing = DECL_NAME (thing);
01269 my_friendly_assert (TREE_CODE (thing) == IDENTIFIER_NODE, 197);
01270 return thing;
01271 }
01272
01273
01274
01275
01276
01277
01278
01279 tree
01280 constructor_name (thing)
01281 tree thing;
01282 {
01283 tree t;
01284 thing = constructor_name_full (thing);
01285 t = IDENTIFIER_TEMPLATE (thing);
01286 if (!t)
01287 return thing;
01288 return t;
01289 }
01290
01291
01292
01293 bool
01294 constructor_name_p (tree name, tree type)
01295 {
01296 return (name == constructor_name (type)
01297 || name == constructor_name_full (type));
01298 }
01299
01300
01301
01302
01303 void
01304 defer_fn (fn)
01305 tree fn;
01306 {
01307 if (DECL_DEFERRED_FN (fn))
01308 return;
01309 DECL_DEFERRED_FN (fn) = 1;
01310 if (!deferred_fns)
01311 VARRAY_TREE_INIT (deferred_fns, 32, "deferred_fns");
01312
01313 VARRAY_PUSH_TREE (deferred_fns, fn);
01314 }
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324 static tree
01325 build_anon_union_vars (anon_decl, elems, static_p, external_p)
01326 tree anon_decl;
01327 tree* elems;
01328 int static_p;
01329 int external_p;
01330 {
01331 tree type = TREE_TYPE (anon_decl);
01332 tree main_decl = NULL_TREE;
01333 tree field;
01334
01335
01336
01337 if (TREE_CODE (type) != UNION_TYPE)
01338 error ("anonymous struct not inside named type");
01339
01340 for (field = TYPE_FIELDS (type);
01341 field != NULL_TREE;
01342 field = TREE_CHAIN (field))
01343 {
01344 tree decl;
01345
01346 if (DECL_ARTIFICIAL (field))
01347 continue;
01348 if (TREE_CODE (field) != FIELD_DECL)
01349 {
01350 cp_pedwarn_at ("`%#D' invalid; an anonymous union can only have non-static data members",
01351 field);
01352 continue;
01353 }
01354
01355 if (TREE_PRIVATE (field))
01356 cp_pedwarn_at ("private member `%#D' in anonymous union", field);
01357 else if (TREE_PROTECTED (field))
01358 cp_pedwarn_at ("protected member `%#D' in anonymous union", field);
01359
01360 if (DECL_NAME (field) == NULL_TREE
01361 && ANON_AGGR_TYPE_P (TREE_TYPE (field)))
01362 {
01363 decl = build_anon_union_vars (field, elems, static_p, external_p);
01364 if (!decl)
01365 continue;
01366 }
01367 else if (DECL_NAME (field) == NULL_TREE)
01368 continue;
01369 else
01370 {
01371 decl = build_decl (VAR_DECL, DECL_NAME (field), TREE_TYPE (field));
01372
01373 DECL_INITIAL (decl) = error_mark_node;
01374 TREE_PUBLIC (decl) = 0;
01375 TREE_STATIC (decl) = static_p;
01376 DECL_EXTERNAL (decl) = external_p;
01377 decl = pushdecl (decl);
01378 DECL_INITIAL (decl) = NULL_TREE;
01379 }
01380
01381
01382
01383
01384
01385 if (main_decl == NULL_TREE
01386 || tree_int_cst_lt (DECL_SIZE (main_decl), DECL_SIZE (decl)))
01387 {
01388 if (main_decl)
01389 TREE_ASM_WRITTEN (main_decl) = 1;
01390 main_decl = decl;
01391 }
01392 else
01393
01394
01395 TREE_ASM_WRITTEN (decl) = 1;
01396
01397 if (DECL_NAME (field) == NULL_TREE
01398 && ANON_AGGR_TYPE_P (TREE_TYPE (field)))
01399
01400
01401 continue;
01402
01403
01404
01405 *elems = tree_cons (NULL_TREE, decl, *elems);
01406 TREE_TYPE (*elems) = type;
01407 }
01408
01409 return main_decl;
01410 }
01411
01412
01413
01414
01415
01416 void
01417 finish_anon_union (anon_union_decl)
01418 tree anon_union_decl;
01419 {
01420 tree type = TREE_TYPE (anon_union_decl);
01421 tree main_decl;
01422 int public_p = TREE_PUBLIC (anon_union_decl);
01423 int static_p = TREE_STATIC (anon_union_decl);
01424 int external_p = DECL_EXTERNAL (anon_union_decl);
01425
01426
01427 DECL_CONTEXT (anon_union_decl) = DECL_CONTEXT (TYPE_NAME (type));
01428
01429 if (TYPE_FIELDS (type) == NULL_TREE)
01430 return;
01431
01432 if (public_p)
01433 {
01434 error ("namespace-scope anonymous aggregates must be static");
01435 return;
01436 }
01437
01438 if (!processing_template_decl)
01439 {
01440 main_decl
01441 = build_anon_union_vars (anon_union_decl,
01442 &DECL_ANON_UNION_ELEMS (anon_union_decl),
01443 static_p, external_p);
01444
01445 if (main_decl == NULL_TREE)
01446 {
01447 warning ("anonymous aggregate with no members");
01448 return;
01449 }
01450
01451 if (static_p)
01452 {
01453 make_decl_rtl (main_decl, 0);
01454 COPY_DECL_RTL (main_decl, anon_union_decl);
01455 expand_anon_union_decl (anon_union_decl,
01456 NULL_TREE,
01457 DECL_ANON_UNION_ELEMS (anon_union_decl));
01458 return;
01459 }
01460 }
01461
01462 add_decl_stmt (anon_union_decl);
01463 }
01464
01465
01466
01467
01468
01469
01470
01471
01472 void
01473 finish_builtin_type (type, name, fields, len, align_type)
01474 tree type;
01475 const char *name;
01476 tree fields[];
01477 int len;
01478 tree align_type;
01479 {
01480 register int i;
01481
01482 TYPE_FIELDS (type) = fields[0];
01483 for (i = 0; i < len; i++)
01484 {
01485 layout_type (TREE_TYPE (fields[i]));
01486 DECL_FIELD_CONTEXT (fields[i]) = type;
01487 TREE_CHAIN (fields[i]) = fields[i+1];
01488 }
01489 DECL_FIELD_CONTEXT (fields[i]) = type;
01490 TYPE_ALIGN (type) = TYPE_ALIGN (align_type);
01491 TYPE_USER_ALIGN (type) = TYPE_USER_ALIGN (align_type);
01492 layout_type (type);
01493 #if 0
01494 TYPE_NAME (type) = make_type_decl (get_identifier (name), type);
01495 #else
01496 TYPE_NAME (type) = build_decl (TYPE_DECL, get_identifier (name), type);
01497 #endif
01498 TYPE_STUB_DECL (type) = TYPE_NAME (type);
01499 layout_decl (TYPE_NAME (type), 0);
01500 }
01501
01502
01503
01504
01505
01506 tree
01507 coerce_new_type (type)
01508 tree type;
01509 {
01510 int e = 0;
01511 tree args = TYPE_ARG_TYPES (type);
01512
01513 my_friendly_assert (TREE_CODE (type) == FUNCTION_TYPE, 20001107);
01514
01515 if (!same_type_p (TREE_TYPE (type), ptr_type_node))
01516 e = 1, error ("`operator new' must return type `%T'", ptr_type_node);
01517
01518 if (!args || args == void_list_node
01519 || !same_type_p (TREE_VALUE (args), size_type_node))
01520 {
01521 e = 2;
01522 if (args && args != void_list_node)
01523 args = TREE_CHAIN (args);
01524 pedwarn ("`operator new' takes type `size_t' (`%T') as first parameter", size_type_node);
01525 }
01526 switch (e)
01527 {
01528 case 2:
01529 args = tree_cons (NULL_TREE, size_type_node, args);
01530
01531 case 1:
01532 type = build_exception_variant
01533 (build_function_type (ptr_type_node, args),
01534 TYPE_RAISES_EXCEPTIONS (type));
01535
01536 default:;
01537 }
01538 return type;
01539 }
01540
01541 tree
01542 coerce_delete_type (type)
01543 tree type;
01544 {
01545 int e = 0;
01546 tree args = TYPE_ARG_TYPES (type);
01547
01548 my_friendly_assert (TREE_CODE (type) == FUNCTION_TYPE, 20001107);
01549
01550 if (!same_type_p (TREE_TYPE (type), void_type_node))
01551 e = 1, error ("`operator delete' must return type `%T'", void_type_node);
01552
01553 if (!args || args == void_list_node
01554 || !same_type_p (TREE_VALUE (args), ptr_type_node))
01555 {
01556 e = 2;
01557 if (args && args != void_list_node)
01558 args = TREE_CHAIN (args);
01559 error ("`operator delete' takes type `%T' as first parameter", ptr_type_node);
01560 }
01561 switch (e)
01562 {
01563 case 2:
01564 args = tree_cons (NULL_TREE, ptr_type_node, args);
01565
01566 case 1:
01567 type = build_exception_variant
01568 (build_function_type (void_type_node, args),
01569 TYPE_RAISES_EXCEPTIONS (type));
01570
01571 default:;
01572 }
01573
01574 return type;
01575 }
01576
01577 static void
01578 mark_vtable_entries (decl)
01579 tree decl;
01580 {
01581 tree entries = CONSTRUCTOR_ELTS (DECL_INITIAL (decl));
01582
01583 for (; entries; entries = TREE_CHAIN (entries))
01584 {
01585 tree fnaddr = TREE_VALUE (entries);
01586 tree fn;
01587
01588 if (TREE_CODE (fnaddr) != ADDR_EXPR
01589 && TREE_CODE (fnaddr) != FDESC_EXPR)
01590
01591
01592 continue;
01593
01594 fn = TREE_OPERAND (fnaddr, 0);
01595 TREE_ADDRESSABLE (fn) = 1;
01596
01597
01598
01599
01600 if (DECL_THUNK_P (fn))
01601 use_thunk (fn, 0);
01602 mark_used (fn);
01603 }
01604 }
01605
01606
01607
01608
01609 void
01610 comdat_linkage (decl)
01611 tree decl;
01612 {
01613 if (flag_weak)
01614 make_decl_one_only (decl);
01615 else if (TREE_CODE (decl) == FUNCTION_DECL
01616 || (TREE_CODE (decl) == VAR_DECL && DECL_ARTIFICIAL (decl)))
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632
01633 TREE_PUBLIC (decl) = 0;
01634 else
01635 {
01636
01637
01638 if (DECL_INITIAL (decl) == 0
01639 || DECL_INITIAL (decl) == error_mark_node)
01640 DECL_COMMON (decl) = 1;
01641 else if (EMPTY_CONSTRUCTOR_P (DECL_INITIAL (decl)))
01642 {
01643 DECL_COMMON (decl) = 1;
01644 DECL_INITIAL (decl) = error_mark_node;
01645 }
01646 else if (!DECL_EXPLICIT_INSTANTIATION (decl))
01647 {
01648
01649
01650 DECL_EXTERNAL (decl) = 1;
01651 DECL_NOT_REALLY_EXTERN (decl) = 0;
01652 }
01653 }
01654
01655 if (DECL_LANG_SPECIFIC (decl))
01656 DECL_COMDAT (decl) = 1;
01657 }
01658
01659
01660
01661
01662
01663 void
01664 maybe_make_one_only (decl)
01665 tree decl;
01666 {
01667
01668
01669
01670
01671
01672
01673 if (! flag_weak)
01674 return;
01675
01676
01677
01678
01679
01680
01681 make_decl_one_only (decl);
01682
01683 if (TREE_CODE (decl) == VAR_DECL)
01684 {
01685 DECL_COMDAT (decl) = 1;
01686
01687 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)) = 1;
01688 }
01689 }
01690
01691
01692
01693
01694
01695
01696
01697
01698 void
01699 import_export_vtable (decl, type, final)
01700 tree decl, type;
01701 int final;
01702 {
01703 if (DECL_INTERFACE_KNOWN (decl))
01704 return;
01705
01706 if (TYPE_FOR_JAVA (type))
01707 {
01708 TREE_PUBLIC (decl) = 1;
01709 DECL_EXTERNAL (decl) = 1;
01710 DECL_INTERFACE_KNOWN (decl) = 1;
01711 }
01712 else if (CLASSTYPE_INTERFACE_KNOWN (type))
01713 {
01714 TREE_PUBLIC (decl) = 1;
01715 DECL_EXTERNAL (decl) = CLASSTYPE_INTERFACE_ONLY (type);
01716 DECL_INTERFACE_KNOWN (decl) = 1;
01717 }
01718 else
01719 {
01720
01721
01722
01723 int found = (CLASSTYPE_TEMPLATE_INSTANTIATION (type)
01724 || CLASSTYPE_KEY_METHOD (type) != NULL_TREE);
01725
01726 if (final || ! found)
01727 {
01728 comdat_linkage (decl);
01729 DECL_EXTERNAL (decl) = 0;
01730 }
01731 else
01732 {
01733 TREE_PUBLIC (decl) = 1;
01734 DECL_EXTERNAL (decl) = 1;
01735 }
01736 }
01737 }
01738
01739
01740
01741
01742 static void
01743 import_export_class (ctype)
01744 tree ctype;
01745 {
01746
01747 int import_export = 0;
01748
01749
01750
01751
01752
01753
01754 my_friendly_assert (at_eof, 20000226);
01755
01756 if (CLASSTYPE_INTERFACE_KNOWN (ctype))
01757 return;
01758
01759
01760
01761
01762
01763
01764 if (CLASSTYPE_INTERFACE_ONLY (ctype))
01765 return;
01766
01767 if (lookup_attribute ("dllimport", TYPE_ATTRIBUTES (ctype)))
01768 import_export = -1;
01769 else if (lookup_attribute ("dllexport", TYPE_ATTRIBUTES (ctype)))
01770 import_export = 1;
01771
01772
01773
01774 if (import_export == 0
01775 && CLASSTYPE_IMPLICIT_INSTANTIATION (ctype)
01776 && ! flag_implicit_templates)
01777 import_export = -1;
01778
01779
01780
01781 if (import_export == 0
01782 && TYPE_POLYMORPHIC_P (ctype))
01783 {
01784 tree method = CLASSTYPE_KEY_METHOD (ctype);
01785 if (method)
01786 import_export = (DECL_REALLY_EXTERN (method) ? -1 : 1);
01787 }
01788
01789 #ifdef MULTIPLE_SYMBOL_SPACES
01790 if (import_export == -1)
01791 import_export = 0;
01792 #endif
01793
01794 if (import_export)
01795 {
01796 SET_CLASSTYPE_INTERFACE_KNOWN (ctype);
01797 CLASSTYPE_INTERFACE_ONLY (ctype) = (import_export < 0);
01798 }
01799 }
01800
01801
01802
01803
01804 static void
01805 output_vtable_inherit (vars)
01806 tree vars;
01807 {
01808 tree parent;
01809 rtx child_rtx, parent_rtx;
01810
01811 child_rtx = XEXP (DECL_RTL (vars), 0);
01812
01813 parent = binfo_for_vtable (vars);
01814
01815 if (parent == TYPE_BINFO (DECL_CONTEXT (vars)))
01816 parent_rtx = const0_rtx;
01817 else if (parent)
01818 {
01819 parent = get_vtbl_decl_for_binfo (TYPE_BINFO (BINFO_TYPE (parent)));
01820 parent_rtx = XEXP (DECL_RTL (parent), 0);
01821 }
01822 else
01823 abort ();
01824
01825 assemble_vtable_inherit (child_rtx, parent_rtx);
01826 }
01827
01828
01829
01830
01831 static int
01832 maybe_emit_vtables (tree ctype)
01833 {
01834 tree vtbl;
01835 tree primary_vtbl;
01836
01837
01838
01839 primary_vtbl = CLASSTYPE_VTABLES (ctype);
01840 if (TREE_ASM_WRITTEN (primary_vtbl))
01841 return 0;
01842
01843 if (TREE_TYPE (primary_vtbl) == void_type_node)
01844 return 0;
01845
01846 import_export_class (ctype);
01847 import_export_vtable (primary_vtbl, ctype, 1);
01848
01849
01850 for (vtbl = CLASSTYPE_VTABLES (ctype); vtbl; vtbl = TREE_CHAIN (vtbl))
01851 if (!DECL_EXTERNAL (vtbl) && DECL_NEEDED_P (vtbl))
01852 break;
01853
01854 if (!vtbl)
01855 {
01856
01857
01858
01859 if (DECL_COMDAT (primary_vtbl)
01860 && CLASSTYPE_DEBUG_REQUESTED (ctype))
01861 note_debug_info_needed (ctype);
01862 return 0;
01863 }
01864
01865
01866
01867 for (vtbl = CLASSTYPE_VTABLES (ctype); vtbl; vtbl = TREE_CHAIN (vtbl))
01868 {
01869
01870 import_export_vtable (vtbl, ctype, 1);
01871 mark_vtable_entries (vtbl);
01872 if (TREE_TYPE (DECL_INITIAL (vtbl)) == 0)
01873 store_init_value (vtbl, DECL_INITIAL (vtbl));
01874
01875 if (write_symbols == DWARF_DEBUG || write_symbols == DWARF2_DEBUG)
01876 {
01877
01878
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898 DECL_IGNORED_P (vtbl) = 1;
01899 }
01900
01901
01902 if (flag_weak)
01903 comdat_linkage (vtbl);
01904
01905 rest_of_decl_compilation (vtbl, NULL, 1, 1);
01906
01907 if (flag_vtable_gc)
01908 output_vtable_inherit (vtbl);
01909
01910
01911
01912 if (flag_syntax_only)
01913 TREE_ASM_WRITTEN (vtbl) = 1;
01914 }
01915
01916
01917
01918 note_debug_info_needed (ctype);
01919
01920 return 1;
01921 }
01922
01923
01924
01925
01926 void
01927 import_export_decl (decl)
01928 tree decl;
01929 {
01930 if (DECL_INTERFACE_KNOWN (decl))
01931 return;
01932
01933 if (DECL_TEMPLATE_INSTANTIATION (decl)
01934 || DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (decl))
01935 {
01936 DECL_NOT_REALLY_EXTERN (decl) = 1;
01937 if ((DECL_IMPLICIT_INSTANTIATION (decl)
01938 || DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (decl))
01939 && (flag_implicit_templates
01940 || (flag_implicit_inline_templates
01941 && DECL_DECLARED_INLINE_P (decl))))
01942 {
01943 if (!TREE_PUBLIC (decl))
01944
01945
01946 ;
01947 else
01948 comdat_linkage (decl);
01949 }
01950 else
01951 {
01952 DECL_EXTERNAL (decl) = 1;
01953 DECL_NOT_REALLY_EXTERN (decl) = 0;
01954 }
01955 }
01956 else if (DECL_FUNCTION_MEMBER_P (decl))
01957 {
01958 if (!DECL_DECLARED_INLINE_P (decl))
01959 {
01960 tree ctype = DECL_CONTEXT (decl);
01961 import_export_class (ctype);
01962 if (CLASSTYPE_INTERFACE_KNOWN (ctype))
01963 {
01964 DECL_NOT_REALLY_EXTERN (decl)
01965 = ! (CLASSTYPE_INTERFACE_ONLY (ctype)
01966 || (DECL_DECLARED_INLINE_P (decl)
01967 && ! flag_implement_inlines
01968 && !DECL_VINDEX (decl)));
01969
01970 if (!DECL_NOT_REALLY_EXTERN (decl))
01971 DECL_EXTERNAL (decl) = 1;
01972
01973
01974 if (DECL_ARTIFICIAL (decl) && flag_weak)
01975 comdat_linkage (decl);
01976 else
01977 maybe_make_one_only (decl);
01978 }
01979 }
01980 else
01981 comdat_linkage (decl);
01982 }
01983 else
01984 comdat_linkage (decl);
01985
01986 DECL_INTERFACE_KNOWN (decl) = 1;
01987 }
01988
01989
01990
01991
01992
01993 void
01994 import_export_tinfo (decl, type, is_in_library)
01995 tree decl;
01996 tree type;
01997 int is_in_library;
01998 {
01999 if (DECL_INTERFACE_KNOWN (decl))
02000 return;
02001
02002 if (IS_AGGR_TYPE (type))
02003 import_export_class (type);
02004
02005 if (IS_AGGR_TYPE (type) && CLASSTYPE_INTERFACE_KNOWN (type)
02006 && TYPE_POLYMORPHIC_P (type)
02007
02008
02009
02010 && flag_rtti)
02011 {
02012 DECL_NOT_REALLY_EXTERN (decl) = !CLASSTYPE_INTERFACE_ONLY (type);
02013 DECL_COMDAT (decl) = 0;
02014 }
02015 else
02016 {
02017 DECL_NOT_REALLY_EXTERN (decl) = 1;
02018 DECL_COMDAT (decl) = 1;
02019 }
02020
02021
02022 if (flag_weak)
02023 DECL_COMDAT (decl) = 1;
02024 else if (is_in_library)
02025 DECL_COMDAT (decl) = 0;
02026
02027 DECL_INTERFACE_KNOWN (decl) = 1;
02028 }
02029
02030
02031
02032
02033
02034 tree
02035 build_cleanup (decl)
02036 tree decl;
02037 {
02038 tree temp;
02039 tree type = TREE_TYPE (decl);
02040
02041
02042
02043 my_friendly_assert (!TYPE_HAS_TRIVIAL_DESTRUCTOR (type), 20030106);
02044
02045
02046
02047 mark_used (decl);
02048
02049 if (TREE_CODE (type) == ARRAY_TYPE)
02050 temp = decl;
02051 else
02052 {
02053 cxx_mark_addressable (decl);
02054 temp = build1 (ADDR_EXPR, build_pointer_type (type), decl);
02055 }
02056 temp = build_delete (TREE_TYPE (temp), temp,
02057 sfk_complete_destructor,
02058 LOOKUP_NORMAL|LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0);
02059 return temp;
02060 }
02061
02062
02063
02064
02065 tree
02066 get_guard (decl)
02067 tree decl;
02068 {
02069 tree sname;
02070 tree guard;
02071
02072 sname = mangle_guard_variable (decl);
02073 guard = IDENTIFIER_GLOBAL_VALUE (sname);
02074 if (! guard)
02075 {
02076 tree guard_type;
02077
02078
02079
02080 guard_type = long_long_integer_type_node;
02081 guard = build_decl (VAR_DECL, sname, guard_type);
02082
02083
02084 TREE_PUBLIC (guard) = TREE_PUBLIC (decl);
02085 TREE_STATIC (guard) = TREE_STATIC (decl);
02086 DECL_COMMON (guard) = DECL_COMMON (decl);
02087 DECL_ONE_ONLY (guard) = DECL_ONE_ONLY (decl);
02088 if (TREE_PUBLIC (decl))
02089 DECL_WEAK (guard) = DECL_WEAK (decl);
02090
02091 DECL_ARTIFICIAL (guard) = 1;
02092 TREE_USED (guard) = 1;
02093 pushdecl_top_level_and_finish (guard, NULL_TREE);
02094 }
02095 return guard;
02096 }
02097
02098
02099
02100
02101 static tree
02102 get_guard_bits (guard)
02103 tree guard;
02104 {
02105
02106
02107 guard = build1 (ADDR_EXPR,
02108 build_pointer_type (TREE_TYPE (guard)),
02109 guard);
02110 guard = build1 (NOP_EXPR,
02111 build_pointer_type (char_type_node),
02112 guard);
02113 guard = build1 (INDIRECT_REF, char_type_node, guard);
02114
02115 return guard;
02116 }
02117
02118
02119
02120
02121 tree
02122 get_guard_cond (guard)
02123 tree guard;
02124 {
02125 tree guard_value;
02126
02127
02128 guard = get_guard_bits (guard);
02129 guard_value = integer_zero_node;
02130 if (!same_type_p (TREE_TYPE (guard_value), TREE_TYPE (guard)))
02131 guard_value = convert (TREE_TYPE (guard), guard_value);
02132 return cp_build_binary_op (EQ_EXPR, guard, guard_value);
02133 }
02134
02135
02136
02137
02138 tree
02139 set_guard (guard)
02140 tree guard;
02141 {
02142 tree guard_init;
02143
02144
02145 guard = get_guard_bits (guard);
02146 guard_init = integer_one_node;
02147 if (!same_type_p (TREE_TYPE (guard_init), TREE_TYPE (guard)))
02148 guard_init = convert (TREE_TYPE (guard), guard_init);
02149 return build_modify_expr (guard, NOP_EXPR, guard_init);
02150 }
02151
02152
02153
02154
02155 static tree
02156 start_objects (method_type, initp)
02157 int method_type, initp;
02158 {
02159 tree fnname;
02160 tree body;
02161 char type[10];
02162
02163
02164
02165 if (initp != DEFAULT_INIT_PRIORITY)
02166 {
02167 char joiner;
02168
02169 #ifdef JOINER
02170 joiner = JOINER;
02171 #else
02172 joiner = '_';
02173 #endif
02174
02175 sprintf (type, "%c%c%.5u", method_type, joiner, initp);
02176 }
02177 else
02178 sprintf (type, "%c", method_type);
02179
02180 fnname = get_file_function_name_long (type);
02181
02182 start_function (void_list_node,
02183 make_call_declarator (fnname, void_list_node, NULL_TREE,
02184 NULL_TREE),
02185 NULL_TREE, SF_DEFAULT);
02186
02187
02188
02189 TREE_PUBLIC (current_function_decl) = ! targetm.have_ctors_dtors;
02190
02191
02192 TREE_USED (current_function_decl) = 1;
02193
02194
02195 if (method_type == 'I')
02196 DECL_GLOBAL_CTOR_P (current_function_decl) = 1;
02197 else
02198 DECL_GLOBAL_DTOR_P (current_function_decl) = 1;
02199 DECL_LANG_SPECIFIC (current_function_decl)->decl_flags.u2sel = 1;
02200
02201 body = begin_compound_stmt (0);
02202
02203
02204
02205
02206
02207 current_function_cannot_inline
02208 = "static constructors and destructors cannot be inlined";
02209
02210 return body;
02211 }
02212
02213
02214
02215
02216 static void
02217 finish_objects (method_type, initp, body)
02218 int method_type, initp;
02219 tree body;
02220 {
02221 tree fn;
02222
02223
02224 finish_compound_stmt (0, body);
02225 fn = finish_function (0);
02226 expand_body (fn);
02227
02228
02229
02230
02231 #ifndef KEY
02232 if (flag_syntax_only)
02233 #endif
02234 return;
02235
02236 if (targetm.have_ctors_dtors)
02237 {
02238 rtx fnsym = XEXP (DECL_RTL (fn), 0);
02239 if (method_type == 'I')
02240 (* targetm.asm_out.constructor) (fnsym, initp);
02241 else
02242 (* targetm.asm_out.destructor) (fnsym, initp);
02243 }
02244 }
02245
02246
02247
02248
02249 #define INITIALIZE_P_IDENTIFIER "__initialize_p"
02250 #define PRIORITY_IDENTIFIER "__priority"
02251
02252
02253
02254 #define SSDF_IDENTIFIER "__static_initialization_and_destruction"
02255
02256
02257 static GTY(()) tree initialize_p_decl;
02258
02259
02260 static GTY(()) tree priority_decl;
02261
02262
02263 static GTY(()) tree ssdf_decl;
02264
02265
02266
02267 static GTY(()) varray_type ssdf_decls;
02268
02269
02270
02271
02272 static splay_tree priority_info_map;
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286 static tree
02287 start_static_storage_duration_function ()
02288 {
02289 static unsigned ssdf_number;
02290
02291 tree parm_types;
02292 tree type;
02293 tree body;
02294 char id[sizeof (SSDF_IDENTIFIER) + 1 + 32];
02295
02296
02297
02298 sprintf (id, "%s_%u", SSDF_IDENTIFIER, ssdf_number++);
02299 if (ssdf_number == 0)
02300 {
02301
02302
02303 sorry ("too many initialization functions required");
02304 abort ();
02305 }
02306
02307
02308 parm_types = void_list_node;
02309 parm_types = tree_cons (NULL_TREE, integer_type_node, parm_types);
02310 parm_types = tree_cons (NULL_TREE, integer_type_node, parm_types);
02311 type = build_function_type (void_type_node, parm_types);
02312
02313
02314 ssdf_decl = build_lang_decl (FUNCTION_DECL,
02315 get_identifier (id),
02316 type);
02317 TREE_PUBLIC (ssdf_decl) = 0;
02318 DECL_ARTIFICIAL (ssdf_decl) = 1;
02319
02320
02321
02322 if (!ssdf_decls)
02323 {
02324 VARRAY_TREE_INIT (ssdf_decls, 32, "ssdf_decls");
02325
02326
02327
02328 priority_info_map = splay_tree_new (splay_tree_compare_ints,
02329 0,
02330
02331 (splay_tree_delete_value_fn) &free);
02332
02333
02334
02335
02336
02337 get_priority_info (DEFAULT_INIT_PRIORITY);
02338 }
02339
02340 VARRAY_PUSH_TREE (ssdf_decls, ssdf_decl);
02341
02342
02343 initialize_p_decl = cp_build_parm_decl
02344 (get_identifier (INITIALIZE_P_IDENTIFIER), integer_type_node);
02345 DECL_CONTEXT (initialize_p_decl) = ssdf_decl;
02346 TREE_USED (initialize_p_decl) = 1;
02347 priority_decl = cp_build_parm_decl
02348 (get_identifier (PRIORITY_IDENTIFIER), integer_type_node);
02349 DECL_CONTEXT (priority_decl) = ssdf_decl;
02350 TREE_USED (priority_decl) = 1;
02351
02352 TREE_CHAIN (initialize_p_decl) = priority_decl;
02353 DECL_ARGUMENTS (ssdf_decl) = initialize_p_decl;
02354
02355
02356 pushdecl (ssdf_decl);
02357
02358
02359
02360
02361
02362
02363
02364
02365 start_function (NULL_TREE,
02366 ssdf_decl,
02367 NULL_TREE,
02368 SF_PRE_PARSED);
02369
02370
02371 body = begin_compound_stmt (0);
02372
02373
02374
02375 current_function_cannot_inline
02376 = "static storage duration functions cannot be inlined";
02377
02378 return body;
02379 }
02380
02381
02382
02383
02384
02385 static void
02386 finish_static_storage_duration_function (body)
02387 tree body;
02388 {
02389
02390 finish_compound_stmt (0, body);
02391 expand_body (finish_function (0));
02392 }
02393
02394
02395
02396
02397
02398 static priority_info
02399 get_priority_info (priority)
02400 int priority;
02401 {
02402 priority_info pi;
02403 splay_tree_node n;
02404
02405 n = splay_tree_lookup (priority_info_map,
02406 (splay_tree_key) priority);
02407 if (!n)
02408 {
02409
02410
02411 pi = (priority_info) xmalloc (sizeof (struct priority_info_s));
02412 pi->initializations_p = 0;
02413 pi->destructions_p = 0;
02414 splay_tree_insert (priority_info_map,
02415 (splay_tree_key) priority,
02416 (splay_tree_value) pi);
02417 }
02418 else
02419 pi = (priority_info) n->value;
02420
02421 return pi;
02422 }
02423
02424
02425
02426
02427
02428 static tree
02429 start_static_initialization_or_destruction (decl, initp)
02430 tree decl;
02431 int initp;
02432 {
02433 tree guard_if_stmt = NULL_TREE;
02434 int priority;
02435 tree cond;
02436 tree guard;
02437 tree init_cond;
02438 priority_info pi;
02439
02440
02441 priority = DECL_INIT_PRIORITY (decl);
02442 if (!priority)
02443 priority = DEFAULT_INIT_PRIORITY;
02444
02445
02446
02447 pi = get_priority_info (priority);
02448 if (initp)
02449 pi->initializations_p = 1;
02450 else
02451 pi->destructions_p = 1;
02452
02453
02454
02455
02456
02457 input_filename = DECL_SOURCE_FILE (decl);
02458 lineno = DECL_SOURCE_LINE (decl);
02459
02460
02461
02462
02463
02464
02465
02466
02467
02468
02469
02470
02471
02472 if (member_p (decl))
02473 {
02474 DECL_CONTEXT (current_function_decl) = DECL_CONTEXT (decl);
02475 DECL_STATIC_FUNCTION_P (current_function_decl) = 1;
02476 }
02477
02478
02479
02480 guard_if_stmt = begin_if_stmt ();
02481 cond = cp_build_binary_op (EQ_EXPR,
02482 priority_decl,
02483 build_int_2 (priority, 0));
02484 init_cond = initp ? integer_one_node : integer_zero_node;
02485 init_cond = cp_build_binary_op (EQ_EXPR,
02486 initialize_p_decl,
02487 init_cond);
02488 cond = cp_build_binary_op (TRUTH_ANDIF_EXPR, cond, init_cond);
02489
02490
02491 guard = NULL_TREE;
02492
02493
02494
02495
02496 if (TREE_PUBLIC (decl) && (DECL_COMMON (decl)
02497 || DECL_ONE_ONLY (decl)
02498 || DECL_WEAK (decl)))
02499 {
02500 tree guard_cond;
02501
02502 guard = get_guard (decl);
02503
02504
02505
02506 if (flag_use_cxa_atexit)
02507 {
02508
02509
02510 my_friendly_assert (initp, 20000629);
02511 guard_cond = get_guard_cond (guard);
02512 }
02513
02514
02515
02516
02517
02518
02519
02520 else if (initp)
02521 guard_cond
02522 = cp_build_binary_op (EQ_EXPR,
02523 build_unary_op (PREINCREMENT_EXPR,
02524 guard,
02525 1),
02526 integer_one_node);
02527 else
02528 guard_cond
02529 = cp_build_binary_op (EQ_EXPR,
02530 build_unary_op (PREDECREMENT_EXPR,
02531 guard,
02532 1),
02533 integer_zero_node);
02534
02535 cond = cp_build_binary_op (TRUTH_ANDIF_EXPR, cond, guard_cond);
02536 }
02537
02538 finish_if_stmt_cond (cond, guard_if_stmt);
02539
02540
02541
02542 if (guard && initp && flag_use_cxa_atexit)
02543 finish_expr_stmt (set_guard (guard));
02544
02545 return guard_if_stmt;
02546 }
02547
02548
02549
02550
02551
02552 static void
02553 finish_static_initialization_or_destruction (guard_if_stmt)
02554 tree guard_if_stmt;
02555 {
02556 finish_then_clause (guard_if_stmt);
02557 finish_if_stmt ();
02558
02559
02560
02561 DECL_CONTEXT (current_function_decl) = NULL_TREE;
02562 DECL_STATIC_FUNCTION_P (current_function_decl) = 0;
02563 }
02564
02565
02566
02567
02568 static void
02569 do_static_initialization (decl, init)
02570 tree decl;
02571 tree init;
02572 {
02573 tree guard_if_stmt;
02574
02575
02576 guard_if_stmt
02577 = start_static_initialization_or_destruction (decl,
02578 1);
02579
02580
02581 if (init)
02582 finish_expr_stmt (init);
02583
02584
02585
02586 if (flag_use_cxa_atexit)
02587 register_dtor_fn (decl);
02588
02589
02590 finish_static_initialization_or_destruction (guard_if_stmt);
02591 }
02592
02593
02594
02595
02596
02597
02598 static void
02599 do_static_destruction (decl)
02600 tree decl;
02601 {
02602 tree guard_if_stmt;
02603
02604
02605
02606 my_friendly_assert (!flag_use_cxa_atexit, 20000121);
02607
02608
02609 if (TYPE_HAS_TRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))
02610 return;
02611
02612
02613 guard_if_stmt = start_static_initialization_or_destruction (decl,
02614 0);
02615 finish_expr_stmt (build_cleanup (decl));
02616 finish_static_initialization_or_destruction (guard_if_stmt);
02617 }
02618
02619
02620
02621
02622
02623
02624
02625
02626
02627 static tree
02628 prune_vars_needing_no_initialization (vars)
02629 tree *vars;
02630 {
02631 tree *var = vars;
02632 tree result = NULL_TREE;
02633
02634 while (*var)
02635 {
02636 tree t = *var;
02637 tree decl = TREE_VALUE (t);
02638 tree init = TREE_PURPOSE (t);
02639
02640
02641 if (decl == error_mark_node)
02642 {
02643 var = &TREE_CHAIN (t);
02644 continue;
02645 }
02646
02647
02648 my_friendly_assert (TREE_CODE (decl) == VAR_DECL, 19990420);
02649
02650
02651
02652 if (DECL_EXTERNAL (decl))
02653 {
02654 var = &TREE_CHAIN (t);
02655 continue;
02656 }
02657
02658
02659
02660 if (init && TREE_CODE (init) == TREE_LIST
02661 && value_member (error_mark_node, init))
02662 {
02663 var = &TREE_CHAIN (t);
02664 continue;
02665 }
02666
02667
02668
02669 *var = TREE_CHAIN (t);
02670 TREE_CHAIN (t) = result;
02671 result = t;
02672 }
02673
02674 return result;
02675 }
02676
02677
02678
02679
02680 static void
02681 write_out_vars (vars)
02682 tree vars;
02683 {
02684 tree v;
02685
02686 for (v = vars; v; v = TREE_CHAIN (v))
02687 if (! TREE_ASM_WRITTEN (TREE_VALUE (v)))
02688 rest_of_decl_compilation (TREE_VALUE (v), 0, 1, 1);
02689 }
02690
02691
02692
02693
02694
02695 static void
02696 generate_ctor_or_dtor_function (constructor_p, priority)
02697 int constructor_p;
02698 int priority;
02699 {
02700 char function_key;
02701 tree arguments;
02702 tree body;
02703 size_t i;
02704
02705
02706
02707 if (constructor_p)
02708 function_key = 'I';
02709 else
02710 function_key = 'D';
02711
02712
02713 body = start_objects (function_key, priority);
02714
02715
02716
02717 if (ssdf_decls)
02718 for (i = 0; i < ssdf_decls->elements_used; ++i)
02719 {
02720 arguments = tree_cons (NULL_TREE, build_int_2 (priority, 0),
02721 NULL_TREE);
02722 arguments = tree_cons (NULL_TREE, build_int_2 (constructor_p, 0),
02723 arguments);
02724 finish_expr_stmt (build_function_call (VARRAY_TREE (ssdf_decls, i),
02725 arguments));
02726 }
02727
02728
02729
02730
02731 if (priority == DEFAULT_INIT_PRIORITY)
02732 {
02733 tree fns;
02734
02735 for (fns = constructor_p ? static_ctors : static_dtors;
02736 fns;
02737 fns = TREE_CHAIN (fns))
02738 finish_expr_stmt (build_function_call (TREE_VALUE (fns), NULL_TREE));
02739 }
02740
02741
02742 finish_objects (function_key, priority, body);
02743 }
02744
02745
02746
02747
02748 static int
02749 generate_ctor_and_dtor_functions_for_priority (n, data)
02750 splay_tree_node n;
02751 void *data ATTRIBUTE_UNUSED;
02752 {
02753 int priority = (int) n->key;
02754 priority_info pi = (priority_info) n->value;
02755
02756
02757
02758 if (pi->initializations_p
02759 || (priority == DEFAULT_INIT_PRIORITY && static_ctors))
02760 generate_ctor_or_dtor_function (1,
02761 priority);
02762 if (pi->destructions_p
02763 || (priority == DEFAULT_INIT_PRIORITY && static_dtors))
02764 generate_ctor_or_dtor_function (0,
02765 priority);
02766
02767
02768 return 0;
02769 }
02770
02771
02772
02773
02774
02775
02776 void
02777 finish_file ()
02778 {
02779 tree vars;
02780 int reconsider;
02781 size_t i;
02782
02783 at_eof = 1;
02784
02785
02786 if (! global_bindings_p () || current_class_type || decl_namespace_list)
02787 return;
02788
02789
02790
02791 lineno -= 1;
02792
02793 interface_unknown = 1;
02794 interface_only = 0;
02795
02796
02797
02798
02799
02800
02801
02802
02803
02804
02805
02806
02807
02808
02809
02810
02811
02812 timevar_push (TV_VARCONST);
02813
02814 emit_support_tinfos ();
02815
02816 do
02817 {
02818 tree t;
02819
02820 reconsider = 0;
02821
02822
02823
02824 instantiate_pending_templates ();
02825
02826
02827
02828
02829
02830
02831
02832 while (keyed_classes != NULL_TREE
02833 && maybe_emit_vtables (TREE_VALUE (keyed_classes)))
02834 {
02835 reconsider = 1;
02836 keyed_classes = TREE_CHAIN (keyed_classes);
02837 }
02838
02839 t = keyed_classes;
02840 if (t != NULL_TREE)
02841 {
02842 tree next = TREE_CHAIN (t);
02843
02844 while (next)
02845 {
02846 if (maybe_emit_vtables (TREE_VALUE (next)))
02847 {
02848 reconsider = 1;
02849 TREE_CHAIN (t) = TREE_CHAIN (next);
02850 }
02851 else
02852 t = next;
02853
02854 next = TREE_CHAIN (t);
02855 }
02856 }
02857
02858
02859
02860 if (walk_globals (unemitted_tinfo_decl_p, emit_tinfo_decl, 0))
02861 reconsider = 1;
02862
02863
02864
02865
02866
02867
02868 vars = prune_vars_needing_no_initialization (&static_aggregates);
02869
02870 if (vars)
02871 {
02872 tree v;
02873
02874
02875
02876
02877
02878
02879
02880
02881 tree ssdf_body = start_static_storage_duration_function ();
02882
02883
02884 write_out_vars (vars);
02885
02886
02887 for (v = vars; v; v = TREE_CHAIN (v))
02888 do_static_initialization (TREE_VALUE (v),
02889 TREE_PURPOSE (v));
02890
02891
02892
02893
02894
02895
02896
02897 if (!flag_use_cxa_atexit)
02898 {
02899 vars = nreverse (vars);
02900 for (v = vars; v; v = TREE_CHAIN (v))
02901 do_static_destruction (TREE_VALUE (v));
02902 }
02903 else
02904 vars = NULL_TREE;
02905
02906
02907
02908 finish_static_storage_duration_function (ssdf_body);
02909
02910
02911
02912
02913 reconsider = 1;
02914 }
02915
02916 for (i = 0; i < deferred_fns_used; ++i)
02917 {
02918 tree decl = VARRAY_TREE (deferred_fns, i);
02919
02920
02921 if (DECL_ARTIFICIAL (decl) && ! DECL_INITIAL (decl)
02922 && TREE_USED (decl)
02923 && (! DECL_REALLY_EXTERN (decl) || DECL_INLINE (decl)))
02924 {
02925
02926
02927
02928
02929
02930 push_to_top_level ();
02931 synthesize_method (decl);
02932 pop_from_top_level ();
02933 reconsider = 1;
02934 }
02935
02936
02937
02938
02939
02940
02941
02942 if (!DECL_SAVED_TREE (decl))
02943 continue;
02944
02945 import_export_decl (decl);
02946
02947
02948
02949
02950
02951
02952
02953
02954
02955
02956
02957 if (DECL_NOT_REALLY_EXTERN (decl)
02958 && DECL_INITIAL (decl)
02959 && DECL_NEEDED_P (decl))
02960 DECL_EXTERNAL (decl) = 0;
02961
02962
02963
02964
02965
02966 if (!DECL_EXTERNAL (decl)
02967 && DECL_NEEDED_P (decl)
02968 && DECL_SAVED_TREE (decl)
02969 && !TREE_ASM_WRITTEN (decl))
02970 {
02971 int saved_not_really_extern;
02972
02973
02974
02975
02976 saved_not_really_extern = DECL_NOT_REALLY_EXTERN (decl);
02977
02978
02979 expand_body (decl);
02980
02981 DECL_EXTERNAL (decl) = 0;
02982 DECL_NOT_REALLY_EXTERN (decl) = saved_not_really_extern;
02983
02984
02985
02986 if (flag_syntax_only)
02987 TREE_ASM_WRITTEN (decl) = 1;
02988 reconsider = 1;
02989
02990 #ifdef KEY
02991
02992
02993
02994 gxx_emits_decl (decl);
02995 #endif
02996 }
02997 }
02998
02999 if (deferred_fns_used
03000 && wrapup_global_declarations (&VARRAY_TREE (deferred_fns, 0),
03001 deferred_fns_used))
03002 reconsider = 1;
03003 if (walk_namespaces (wrapup_globals_for_namespace, 0))
03004 reconsider = 1;
03005
03006
03007 for (i = 0; i < pending_statics_used; ++i)
03008 {
03009 tree decl = VARRAY_TREE (pending_statics, i);
03010 if (TREE_ASM_WRITTEN (decl))
03011 continue;
03012 import_export_decl (decl);
03013 if (DECL_NOT_REALLY_EXTERN (decl) && ! DECL_IN_AGGR_P (decl))
03014 DECL_EXTERNAL (decl) = 0;
03015 }
03016 if (pending_statics
03017 && wrapup_global_declarations (&VARRAY_TREE (pending_statics, 0),
03018 pending_statics_used))
03019 reconsider = 1;
03020 }
03021 while (reconsider);
03022
03023
03024 for (i = 0; i < deferred_fns_used; ++i)
03025 {
03026 tree decl = VARRAY_TREE (deferred_fns, i);
03027
03028 if (TREE_USED (decl) && DECL_DECLARED_INLINE_P (decl)
03029 && !(TREE_ASM_WRITTEN (decl) || DECL_SAVED_TREE (decl)
03030
03031
03032
03033 || DECL_EXPLICIT_INSTANTIATION (decl)))
03034 cp_warning_at ("inline function `%D' used but never defined", decl);
03035 }
03036
03037
03038 push_lang_context (lang_name_c);
03039
03040
03041
03042 if (priority_info_map)
03043 splay_tree_foreach (priority_info_map,
03044 generate_ctor_and_dtor_functions_for_priority,
03045 0);
03046 else
03047 {
03048 if (static_ctors)
03049 generate_ctor_or_dtor_function (true,
03050 DEFAULT_INIT_PRIORITY);
03051 if (static_dtors)
03052 generate_ctor_or_dtor_function (false,
03053 DEFAULT_INIT_PRIORITY);
03054 }
03055
03056
03057 if (priority_info_map)
03058 splay_tree_delete (priority_info_map);
03059
03060
03061
03062 pop_lang_context ();
03063
03064
03065
03066 walk_namespaces (wrapup_globals_for_namespace, &reconsider);
03067 if (pending_statics)
03068 check_global_declarations (&VARRAY_TREE (pending_statics, 0),
03069 pending_statics_used);
03070
03071 finish_repo ();
03072
03073
03074
03075 {
03076 int flags;
03077 FILE *stream = dump_begin (TDI_all, &flags);
03078
03079 if (stream)
03080 {
03081 dump_node (global_namespace, flags & ~TDF_SLIM, stream);
03082 dump_end (TDI_all, stream);
03083 }
03084 }
03085
03086 #ifdef SGI_MONGOOSE
03087
03088
03089 if (back_end_hook)
03090 (*back_end_hook) (global_namespace);
03091 #endif
03092
03093 timevar_pop (TV_VARCONST);
03094
03095 if (flag_detailed_statistics)
03096 {
03097 dump_tree_statistics ();
03098 dump_time_statistics ();
03099 }
03100 }
03101
03102
03103
03104
03105
03106
03107
03108
03109
03110
03111 tree
03112 reparse_absdcl_as_expr (type, decl)
03113 tree type, decl;
03114 {
03115
03116 if (TREE_OPERAND (decl, 0) == NULL_TREE)
03117 return build_functional_cast (type, NULL_TREE);
03118
03119
03120 decl = reparse_absdcl_as_expr (type, TREE_OPERAND (decl, 0));
03121
03122 return finish_call_expr (decl, NULL_TREE, false);
03123 }
03124
03125
03126
03127
03128
03129
03130
03131
03132
03133 tree
03134 reparse_absdcl_as_casts (decl, expr)
03135 tree decl, expr;
03136 {
03137 tree type;
03138 int non_void_p = 0;
03139
03140 if (TREE_CODE (expr) == CONSTRUCTOR
03141 && TREE_TYPE (expr) == 0)
03142 {
03143 type = groktypename (TREE_VALUE (CALL_DECLARATOR_PARMS (decl)));
03144 decl = TREE_OPERAND (decl, 0);
03145
03146 if (processing_template_decl)
03147 TREE_TYPE (expr) = type;
03148 else
03149 {
03150 expr = digest_init (type, expr, (tree *) 0);
03151 if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type))
03152 {
03153 int failure = complete_array_type (type, expr, 1);
03154 my_friendly_assert (!failure, 78);
03155 }
03156 }
03157 }
03158
03159 while (decl)
03160 {
03161 type = groktypename (TREE_VALUE (CALL_DECLARATOR_PARMS (decl)));
03162 decl = TREE_OPERAND (decl, 0);
03163 if (!VOID_TYPE_P (type))
03164 non_void_p = 1;
03165 expr = build_c_cast (type, expr);
03166 }
03167
03168 if (warn_old_style_cast && ! in_system_header
03169 && non_void_p && current_lang_name != lang_name_c)
03170 warning ("use of old-style cast");
03171
03172 return expr;
03173 }
03174
03175
03176
03177
03178 tree
03179 build_expr_from_tree (t)
03180 tree t;
03181 {
03182 if (t == NULL_TREE || t == error_mark_node)
03183 return t;
03184
03185 switch (TREE_CODE (t))
03186 {
03187 case IDENTIFIER_NODE:
03188 return do_identifier (t, 0, NULL_TREE);
03189
03190 case LOOKUP_EXPR:
03191 if (LOOKUP_EXPR_GLOBAL (t))
03192 {
03193 tree token = TREE_OPERAND (t, 0);
03194 return do_scoped_id (token, IDENTIFIER_GLOBAL_VALUE (token));
03195 }
03196 else
03197 return do_identifier (TREE_OPERAND (t, 0), 0, NULL_TREE);
03198
03199 case TEMPLATE_ID_EXPR:
03200 {
03201 tree template;
03202 tree args;
03203 tree object;
03204
03205 template = build_expr_from_tree (TREE_OPERAND (t, 0));
03206 args = build_expr_from_tree (TREE_OPERAND (t, 1));
03207
03208 if (TREE_CODE (template) == COMPONENT_REF)
03209 {
03210 object = TREE_OPERAND (template, 0);
03211 template = TREE_OPERAND (template, 1);
03212 }
03213 else
03214 object = NULL_TREE;
03215
03216 template = lookup_template_function (template, args);
03217 if (object)
03218 return build (COMPONENT_REF, TREE_TYPE (template),
03219 object, template);
03220 else
03221 return template;
03222 }
03223
03224 case INDIRECT_REF:
03225 return build_x_indirect_ref
03226 (build_expr_from_tree (TREE_OPERAND (t, 0)), "unary *");
03227
03228 case CAST_EXPR:
03229 return build_functional_cast
03230 (TREE_TYPE (t), build_expr_from_tree (TREE_OPERAND (t, 0)));
03231
03232 case REINTERPRET_CAST_EXPR:
03233 return build_reinterpret_cast
03234 (TREE_TYPE (t), build_expr_from_tree (TREE_OPERAND (t, 0)));
03235
03236 case CONST_CAST_EXPR:
03237 return build_const_cast
03238 (TREE_TYPE (t), build_expr_from_tree (TREE_OPERAND (t, 0)));
03239
03240 case DYNAMIC_CAST_EXPR:
03241 return build_dynamic_cast
03242 (TREE_TYPE (t), build_expr_from_tree (TREE_OPERAND (t, 0)));
03243
03244 case STATIC_CAST_EXPR:
03245 return build_static_cast
03246 (TREE_TYPE (t), build_expr_from_tree (TREE_OPERAND (t, 0)));
03247
03248 case PREDECREMENT_EXPR:
03249 case PREINCREMENT_EXPR:
03250 case POSTDECREMENT_EXPR:
03251 case POSTINCREMENT_EXPR:
03252 case NEGATE_EXPR:
03253 case BIT_NOT_EXPR:
03254 case ABS_EXPR:
03255 case TRUTH_NOT_EXPR:
03256 case ADDR_EXPR:
03257 case CONVERT_EXPR:
03258 case REALPART_EXPR:
03259 case IMAGPART_EXPR:
03260 if (TREE_TYPE (t))
03261 return t;
03262 return build_x_unary_op (TREE_CODE (t),
03263 build_expr_from_tree (TREE_OPERAND (t, 0)));
03264
03265 case PLUS_EXPR:
03266 case MINUS_EXPR:
03267 case MULT_EXPR:
03268 case TRUNC_DIV_EXPR:
03269 case CEIL_DIV_EXPR:
03270 case FLOOR_DIV_EXPR:
03271 case ROUND_DIV_EXPR:
03272 case EXACT_DIV_EXPR:
03273 case BIT_AND_EXPR:
03274 case BIT_ANDTC_EXPR:
03275 case BIT_IOR_EXPR:
03276 case BIT_XOR_EXPR:
03277 case TRUNC_MOD_EXPR:
03278 case FLOOR_MOD_EXPR:
03279 case TRUTH_ANDIF_EXPR:
03280 case TRUTH_ORIF_EXPR:
03281 case TRUTH_AND_EXPR:
03282 case TRUTH_OR_EXPR:
03283 case RSHIFT_EXPR:
03284 case LSHIFT_EXPR:
03285 case RROTATE_EXPR:
03286 case LROTATE_EXPR:
03287 case EQ_EXPR:
03288 case NE_EXPR:
03289 case MAX_EXPR:
03290 case MIN_EXPR:
03291 case LE_EXPR:
03292 case GE_EXPR:
03293 case LT_EXPR:
03294 case GT_EXPR:
03295 case MEMBER_REF:
03296 return build_x_binary_op
03297 (TREE_CODE (t),
03298 build_expr_from_tree (TREE_OPERAND (t, 0)),
03299 build_expr_from_tree (TREE_OPERAND (t, 1)));
03300
03301 case DOTSTAR_EXPR:
03302 return build_m_component_ref
03303 (build_expr_from_tree (TREE_OPERAND (t, 0)),
03304 build_expr_from_tree (TREE_OPERAND (t, 1)));
03305
03306 case SCOPE_REF:
03307 return build_offset_ref (TREE_OPERAND (t, 0), TREE_OPERAND (t, 1));
03308
03309 case ARRAY_REF:
03310 if (TREE_OPERAND (t, 0) == NULL_TREE)
03311
03312 return build_nt (ARRAY_REF, NULL_TREE,
03313 build_expr_from_tree (TREE_OPERAND (t, 1)));
03314 return grok_array_decl (build_expr_from_tree (TREE_OPERAND (t, 0)),
03315 build_expr_from_tree (TREE_OPERAND (t, 1)));
03316
03317 case SIZEOF_EXPR:
03318 case ALIGNOF_EXPR:
03319 {
03320 tree r = build_expr_from_tree (TREE_OPERAND (t, 0));
03321 if (!TYPE_P (r))
03322 return TREE_CODE (t) == SIZEOF_EXPR ? expr_sizeof (r) : c_alignof_expr (r);
03323 else
03324 return cxx_sizeof_or_alignof_type (r, TREE_CODE (t), true);
03325 }
03326
03327 case MODOP_EXPR:
03328 return build_x_modify_expr
03329 (build_expr_from_tree (TREE_OPERAND (t, 0)),
03330 TREE_CODE (TREE_OPERAND (t, 1)),
03331 build_expr_from_tree (TREE_OPERAND (t, 2)));
03332
03333 case ARROW_EXPR:
03334 return build_x_arrow
03335 (build_expr_from_tree (TREE_OPERAND (t, 0)));
03336
03337 case NEW_EXPR:
03338 return build_new
03339 (build_expr_from_tree (TREE_OPERAND (t, 0)),
03340 build_expr_from_tree (TREE_OPERAND (t, 1)),
03341 build_expr_from_tree (TREE_OPERAND (t, 2)),
03342 NEW_EXPR_USE_GLOBAL (t));
03343
03344 case DELETE_EXPR:
03345 return delete_sanity
03346 (build_expr_from_tree (TREE_OPERAND (t, 0)),
03347 build_expr_from_tree (TREE_OPERAND (t, 1)),
03348 DELETE_EXPR_USE_VEC (t), DELETE_EXPR_USE_GLOBAL (t));
03349
03350 case COMPOUND_EXPR:
03351 if (TREE_OPERAND (t, 1) == NULL_TREE)
03352 return build_x_compound_expr
03353 (build_expr_from_tree (TREE_OPERAND (t, 0)));
03354 else
03355 abort ();
03356
03357 case METHOD_CALL_EXPR:
03358 if (TREE_CODE (TREE_OPERAND (t, 0)) == SCOPE_REF)
03359 {
03360 tree ref = TREE_OPERAND (t, 0);
03361 tree name = TREE_OPERAND (ref, 1);
03362
03363 if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
03364 name = build_nt (TEMPLATE_ID_EXPR,
03365 TREE_OPERAND (name, 0),
03366 build_expr_from_tree (TREE_OPERAND (name, 1)));
03367
03368 return build_scoped_method_call
03369 (build_expr_from_tree (TREE_OPERAND (t, 1)),
03370 build_expr_from_tree (TREE_OPERAND (ref, 0)),
03371 name,
03372 build_expr_from_tree (TREE_OPERAND (t, 2)));
03373 }
03374 else
03375 {
03376 tree fn = TREE_OPERAND (t, 0);
03377
03378
03379
03380
03381
03382
03383
03384
03385
03386
03387 if (TREE_CODE (fn) == TEMPLATE_ID_EXPR)
03388 fn = lookup_template_function
03389 (TREE_OPERAND (fn, 0),
03390 build_expr_from_tree (TREE_OPERAND (fn, 1)));
03391
03392 return build_method_call
03393 (build_expr_from_tree (TREE_OPERAND (t, 1)),
03394 fn,
03395 build_expr_from_tree (TREE_OPERAND (t, 2)),
03396 NULL_TREE, LOOKUP_NORMAL);
03397 }
03398
03399 case CALL_EXPR:
03400 if (TREE_CODE (TREE_OPERAND (t, 0)) == SCOPE_REF)
03401 {
03402 tree ref = TREE_OPERAND (t, 0);
03403 tree name = TREE_OPERAND (ref, 1);
03404 tree fn, scope, args;
03405
03406 if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
03407 name = build_nt (TEMPLATE_ID_EXPR,
03408 TREE_OPERAND (name, 0),
03409 build_expr_from_tree (TREE_OPERAND (name, 1)));
03410
03411 scope = build_expr_from_tree (TREE_OPERAND (ref, 0));
03412 args = build_expr_from_tree (TREE_OPERAND (t, 1));
03413 fn = resolve_scoped_fn_name (scope, name);
03414
03415 return build_call_from_tree (fn, args, 1);
03416 }
03417 else
03418 {
03419 tree name = TREE_OPERAND (t, 0);
03420 tree id;
03421 tree args = build_expr_from_tree (TREE_OPERAND (t, 1));
03422 if (args != NULL_TREE && TREE_CODE (name) == LOOKUP_EXPR
03423 && !LOOKUP_EXPR_GLOBAL (name)
03424 && TREE_CODE ((id = TREE_OPERAND (name, 0))) == IDENTIFIER_NODE
03425 && (!current_class_type
03426 || !lookup_member (current_class_type, id, 0, 0)))
03427 {
03428
03429 name = do_identifier (id, 0, args);
03430 }
03431 else if (TREE_CODE (name) == TEMPLATE_ID_EXPR
03432 || ! really_overloaded_fn (name))
03433 name = build_expr_from_tree (name);
03434
03435 if (TREE_CODE (name) == OFFSET_REF)
03436 return build_offset_ref_call_from_tree (name, args);
03437 if (TREE_CODE (name) == COMPONENT_REF)
03438 return finish_object_call_expr (TREE_OPERAND (name, 1),
03439 TREE_OPERAND (name, 0),
03440 args);
03441 name = convert_from_reference (name);
03442 return build_call_from_tree (name, args,
03443 false);
03444 }
03445
03446 case COND_EXPR:
03447 return build_x_conditional_expr
03448 (build_expr_from_tree (TREE_OPERAND (t, 0)),
03449 build_expr_from_tree (TREE_OPERAND (t, 1)),
03450 build_expr_from_tree (TREE_OPERAND (t, 2)));
03451
03452 case PSEUDO_DTOR_EXPR:
03453 return (finish_pseudo_destructor_call_expr
03454 (build_expr_from_tree (TREE_OPERAND (t, 0)),
03455 build_expr_from_tree (TREE_OPERAND (t, 1)),
03456 build_expr_from_tree (TREE_OPERAND (t, 2))));
03457
03458 case TREE_LIST:
03459 {
03460 tree purpose, value, chain;
03461
03462 if (t == void_list_node)
03463 return t;
03464
03465 purpose = TREE_PURPOSE (t);
03466 if (purpose)
03467 purpose = build_expr_from_tree (purpose);
03468 value = TREE_VALUE (t);
03469 if (value)
03470 value = build_expr_from_tree (value);
03471 chain = TREE_CHAIN (t);
03472 if (chain && chain != void_type_node)
03473 chain = build_expr_from_tree (chain);
03474 return tree_cons (purpose, value, chain);
03475 }
03476
03477 case COMPONENT_REF:
03478 {
03479 tree object = build_expr_from_tree (TREE_OPERAND (t, 0));
03480 return finish_class_member_access_expr (object,
03481 TREE_OPERAND (t, 1));
03482 }
03483
03484 case THROW_EXPR:
03485 return build_throw (build_expr_from_tree (TREE_OPERAND (t, 0)));
03486
03487 case CONSTRUCTOR:
03488 {
03489 tree r;
03490 tree elts;
03491 tree type = TREE_TYPE (t);
03492 bool purpose_p;
03493
03494
03495 if (type && TYPE_PTRMEMFUNC_P (type))
03496 return t;
03497
03498 r = NULL_TREE;
03499
03500
03501
03502 purpose_p = !(type && IS_AGGR_TYPE (type));
03503 for (elts = CONSTRUCTOR_ELTS (t); elts; elts = TREE_CHAIN (elts))
03504 {
03505 tree purpose = TREE_PURPOSE (elts);
03506 tree value = TREE_VALUE (elts);
03507
03508 if (purpose && purpose_p)
03509 purpose = build_expr_from_tree (purpose);
03510 value = build_expr_from_tree (value);
03511 r = tree_cons (purpose, value, r);
03512 }
03513
03514 r = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (r));
03515 TREE_HAS_CONSTRUCTOR (r) = TREE_HAS_CONSTRUCTOR (t);
03516
03517 if (type)
03518 return digest_init (type, r, 0);
03519 return r;
03520 }
03521
03522 case TYPEID_EXPR:
03523 if (TYPE_P (TREE_OPERAND (t, 0)))
03524 return get_typeid (TREE_OPERAND (t, 0));
03525 return build_typeid (build_expr_from_tree (TREE_OPERAND (t, 0)));
03526
03527 case VAR_DECL:
03528 return convert_from_reference (t);
03529
03530 case VA_ARG_EXPR:
03531 return build_va_arg (build_expr_from_tree (TREE_OPERAND (t, 0)),
03532 TREE_TYPE (t));
03533
03534 default:
03535 return t;
03536 }
03537 }
03538
03539
03540
03541
03542
03543
03544 tree
03545 build_offset_ref_call_from_tree (tree fn, tree args)
03546 {
03547 tree object_addr;
03548
03549 my_friendly_assert (TREE_CODE (fn) == OFFSET_REF, 20020725);
03550
03551
03552
03553
03554
03555
03556
03557
03558
03559
03560
03561
03562
03563
03564
03565
03566
03567 if (TREE_CODE (TREE_OPERAND (fn, 1)) == FIELD_DECL)
03568 fn = resolve_offset_ref (fn);
03569 else
03570 {
03571 object_addr = build_unary_op (ADDR_EXPR, TREE_OPERAND (fn, 0), 0);
03572 fn = TREE_OPERAND (fn, 1);
03573 fn = get_member_function_from_ptrfunc (&object_addr, fn);
03574 args = tree_cons (NULL_TREE, object_addr, args);
03575 }
03576 return build_function_call (fn, args);
03577 }
03578
03579
03580
03581
03582
03583
03584
03585 tree
03586 build_call_from_tree (tree fn, tree args, bool disallow_virtual)
03587 {
03588 tree template_args;
03589 tree template_id;
03590 tree f;
03591
03592
03593 my_friendly_assert (TREE_CODE (fn) != OFFSET_REF, 20020725);
03594 my_friendly_assert (TREE_CODE (fn) != SCOPE_REF, 20020725);
03595
03596
03597
03598
03599
03600
03601 if (TREE_CODE (fn) == TEMPLATE_ID_EXPR)
03602 {
03603 template_id = fn;
03604 template_args = TREE_OPERAND (fn, 1);
03605 fn = TREE_OPERAND (fn, 0);
03606 }
03607 else
03608 {
03609 template_id = NULL_TREE;
03610 template_args = NULL_TREE;
03611 }
03612
03613 f = (TREE_CODE (fn) == OVERLOAD) ? get_first_fn (fn) : fn;
03614
03615
03616 if (current_class_type
03617 && ((TREE_CODE (f) == FUNCTION_DECL
03618 && DECL_FUNCTION_MEMBER_P (f))
03619 || (DECL_FUNCTION_TEMPLATE_P (f)
03620 && DECL_FUNCTION_MEMBER_P (f))))
03621 {
03622 f = lookup_member (current_class_type, DECL_NAME (f),
03623 1, 0);
03624 if (f)
03625 fn = f;
03626 }
03627
03628 if (template_id)
03629 {
03630 if (BASELINK_P (fn))
03631 BASELINK_FUNCTIONS (fn) = build_nt (TEMPLATE_ID_EXPR,
03632 BASELINK_FUNCTIONS (fn),
03633 template_args);
03634 else
03635 fn = template_id;
03636 }
03637
03638 return finish_call_expr (fn, args, disallow_virtual);
03639 }
03640
03641
03642
03643
03644
03645
03646
03647
03648 tree
03649 reparse_decl_as_expr (type, decl)
03650 tree type, decl;
03651 {
03652 decl = build_expr_from_tree (decl);
03653 if (type)
03654 return build_functional_cast (type, build_tree_list (NULL_TREE, decl));
03655 else
03656 return decl;
03657 }
03658
03659
03660
03661
03662
03663 tree
03664 finish_decl_parsing (decl)
03665 tree decl;
03666 {
03667 switch (TREE_CODE (decl))
03668 {
03669 case IDENTIFIER_NODE:
03670 return decl;
03671 case INDIRECT_REF:
03672 return make_pointer_declarator
03673 (NULL_TREE, finish_decl_parsing (TREE_OPERAND (decl, 0)));
03674 case ADDR_EXPR:
03675 return make_reference_declarator
03676 (NULL_TREE, finish_decl_parsing (TREE_OPERAND (decl, 0)));
03677 case BIT_NOT_EXPR:
03678 TREE_OPERAND (decl, 0) = finish_decl_parsing (TREE_OPERAND (decl, 0));
03679 return decl;
03680 case SCOPE_REF:
03681 push_nested_class (TREE_TYPE (TREE_OPERAND (decl, 0)), 3);
03682 TREE_COMPLEXITY (decl) = current_class_depth;
03683 return decl;
03684 case ARRAY_REF:
03685 TREE_OPERAND (decl, 0) = finish_decl_parsing (TREE_OPERAND (decl, 0));
03686 return decl;
03687 case TREE_LIST:
03688
03689 TREE_VALUE (decl) = finish_decl_parsing (TREE_VALUE (decl));
03690 return decl;
03691 case TEMPLATE_ID_EXPR:
03692 return decl;
03693 default:
03694 abort ();
03695 return NULL_TREE;
03696 }
03697 }
03698
03699
03700
03701
03702 bool
03703 is_ancestor (tree root, tree child)
03704 {
03705 my_friendly_assert ((TREE_CODE (root) == NAMESPACE_DECL
03706 || TREE_CODE (root) == FUNCTION_DECL
03707 || CLASS_TYPE_P (root)), 20030307);
03708 my_friendly_assert ((TREE_CODE (child) == NAMESPACE_DECL
03709 || TREE_CODE (root) == FUNCTION_DECL
03710 || CLASS_TYPE_P (child)),
03711 20030307);
03712
03713
03714 if (root == global_namespace)
03715 return true;
03716
03717 while (true)
03718 {
03719
03720 if (!child)
03721 return false;
03722
03723 if (root == child)
03724 return true;
03725
03726 if (TYPE_P (child))
03727 child = TYPE_NAME (child);
03728 child = DECL_CONTEXT (child);
03729 }
03730 }
03731
03732
03733
03734
03735 tree
03736 namespace_ancestor (ns1, ns2)
03737 tree ns1, ns2;
03738 {
03739 timevar_push (TV_NAME_LOOKUP);
03740 if (is_ancestor (ns1, ns2))
03741 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, ns1);
03742 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP,
03743 namespace_ancestor (CP_DECL_CONTEXT (ns1), ns2));
03744 }
03745
03746
03747
03748
03749 static void
03750 add_using_namespace (user, used, indirect)
03751 tree user;
03752 tree used;
03753 int indirect;
03754 {
03755 tree t;
03756 timevar_push (TV_NAME_LOOKUP);
03757
03758 if (user == used)
03759 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, (void)0);
03760 my_friendly_assert (TREE_CODE (user) == NAMESPACE_DECL, 380);
03761 my_friendly_assert (TREE_CODE (used) == NAMESPACE_DECL, 380);
03762
03763 t = purpose_member (used, DECL_NAMESPACE_USING (user));
03764 if (t != NULL_TREE)
03765 {
03766 if (!indirect)
03767
03768 TREE_INDIRECT_USING (t) = 0;
03769 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, (void)0);
03770 }
03771
03772
03773 DECL_NAMESPACE_USING (user)
03774 = tree_cons (used, namespace_ancestor (user, used),
03775 DECL_NAMESPACE_USING (user));
03776
03777 TREE_INDIRECT_USING (DECL_NAMESPACE_USING (user)) = indirect;
03778
03779
03780 DECL_NAMESPACE_USERS (used)
03781 = tree_cons (user, 0, DECL_NAMESPACE_USERS (used));
03782
03783
03784 for (t = DECL_NAMESPACE_USING (used); t; t = TREE_CHAIN (t))
03785
03786 add_using_namespace (user, TREE_PURPOSE (t), 1);
03787
03788
03789 for (t = DECL_NAMESPACE_USERS (user); t; t = TREE_CHAIN (t))
03790 add_using_namespace (TREE_PURPOSE (t), used, 1);
03791 timevar_pop (TV_NAME_LOOKUP);
03792 }
03793
03794
03795
03796
03797
03798
03799
03800
03801 static tree
03802 merge_functions (s1, s2)
03803 tree s1;
03804 tree s2;
03805 {
03806 for (; s2; s2 = OVL_NEXT (s2))
03807 {
03808 tree fn2 = OVL_CURRENT (s2);
03809 tree fns1;
03810
03811 for (fns1 = s1; fns1; fns1 = OVL_NEXT (fns1))
03812 {
03813 tree fn1 = OVL_CURRENT (fns1);
03814
03815
03816
03817
03818
03819 if (fn1 == fn2
03820 || (DECL_EXTERN_C_P (fn1) && DECL_EXTERN_C_P (fn2)
03821 && DECL_NAME (fn1) == DECL_NAME (fn2)))
03822 break;
03823 }
03824
03825
03826 if (!fns1)
03827 s1 = build_overload (fn2, s1);
03828 }
03829 return s1;
03830 }
03831
03832
03833
03834
03835
03836
03837
03838
03839
03840 static cxx_binding *
03841 ambiguous_decl (tree name, cxx_binding *old, cxx_binding *new, int flags)
03842 {
03843 tree val, type;
03844 my_friendly_assert (old != NULL, 393);
03845
03846 val = BINDING_VALUE (new);
03847 if (val)
03848 switch (TREE_CODE (val))
03849 {
03850 case TEMPLATE_DECL:
03851
03852
03853 if (LOOKUP_QUALIFIERS_ONLY (flags)
03854 && !DECL_CLASS_TEMPLATE_P (val))
03855 val = NULL_TREE;
03856 break;
03857 case TYPE_DECL:
03858 if (LOOKUP_NAMESPACES_ONLY (flags))
03859 val = NULL_TREE;
03860 break;
03861 case NAMESPACE_DECL:
03862 if (LOOKUP_TYPES_ONLY (flags))
03863 val = NULL_TREE;
03864 break;
03865 case FUNCTION_DECL:
03866
03867 if (LOOKUP_QUALIFIERS_ONLY (flags) || DECL_ANTICIPATED (val))
03868 val = NULL_TREE;
03869 break;
03870 default:
03871 if (LOOKUP_QUALIFIERS_ONLY (flags))
03872 val = NULL_TREE;
03873 }
03874
03875 if (!BINDING_VALUE (old))
03876 BINDING_VALUE (old) = val;
03877 else if (val && val != BINDING_VALUE (old))
03878 {
03879 if (is_overloaded_fn (BINDING_VALUE (old))
03880 && is_overloaded_fn (val))
03881 {
03882 BINDING_VALUE (old) = merge_functions (BINDING_VALUE (old),
03883 val);
03884 }
03885 else
03886 {
03887
03888 if (flags & LOOKUP_COMPLAIN)
03889 {
03890
03891
03892
03893 if (BINDING_VALUE (old) != error_mark_node)
03894 {
03895 error ("use of `%D' is ambiguous", name);
03896 cp_error_at (" first declared as `%#D' here",
03897 BINDING_VALUE (old));
03898 }
03899 cp_error_at (" also declared as `%#D' here", val);
03900 }
03901 BINDING_VALUE (old) = error_mark_node;
03902 }
03903 }
03904
03905 type = BINDING_TYPE (new);
03906 if (LOOKUP_NAMESPACES_ONLY (flags))
03907 type = NULL_TREE;
03908 if (!BINDING_TYPE (old))
03909 BINDING_TYPE (old) = type;
03910 else if (type && BINDING_TYPE (old) != type)
03911 {
03912 if (flags & LOOKUP_COMPLAIN)
03913 {
03914 error ("`%D' denotes an ambiguous type",name);
03915 cp_error_at (" first type here", BINDING_TYPE (old));
03916 cp_error_at (" other type here", type);
03917 }
03918 }
03919 return old;
03920 }
03921
03922
03923
03924
03925
03926
03927
03928
03929 bool
03930 lookup_using_namespace (tree name, cxx_binding *val, tree usings,
03931 tree scope, int flags, tree *spacesp)
03932 {
03933 tree iter;
03934 cxx_binding *val1;
03935 timevar_push (TV_NAME_LOOKUP);
03936
03937
03938 for (iter = usings; iter; iter = TREE_CHAIN (iter))
03939 if (TREE_VALUE (iter) == scope)
03940 {
03941 if (spacesp)
03942 *spacesp = tree_cons (TREE_PURPOSE (iter), NULL_TREE,
03943 *spacesp);
03944 val1 = cxx_scope_find_binding_for_name (TREE_PURPOSE (iter), name);
03945
03946 if (val1)
03947 val = ambiguous_decl (name, val, val1, flags);
03948 }
03949 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP,
03950 BINDING_VALUE (val) != error_mark_node);
03951 }
03952
03953
03954
03955
03956
03957
03958 bool
03959 qualified_lookup_using_namespace (tree name, tree scope, cxx_binding *result,
03960 int flags)
03961 {
03962
03963 tree seen = NULL_TREE;
03964
03965 tree todo = NULL_TREE;
03966 tree usings;
03967 timevar_push (TV_NAME_LOOKUP);
03968
03969 scope = ORIGINAL_NAMESPACE (scope);
03970 while (scope && result->value != error_mark_node)
03971 {
03972 cxx_binding *b = cxx_scope_find_binding_for_name (scope, name);
03973
03974
03975 if (b)
03976 {
03977 seen = tree_cons (scope, NULL_TREE, seen);
03978 result = ambiguous_decl (name, result, b, flags);
03979 }
03980 if (!BINDING_VALUE (result) && !BINDING_TYPE (result))
03981
03982 for (usings = DECL_NAMESPACE_USING (scope); usings;
03983 usings = TREE_CHAIN (usings))
03984
03985 if (!TREE_INDIRECT_USING (usings)
03986 && !purpose_member (TREE_PURPOSE (usings), seen))
03987 todo = tree_cons (TREE_PURPOSE (usings), NULL_TREE, todo);
03988 if (todo)
03989 {
03990 scope = TREE_PURPOSE (todo);
03991 todo = TREE_CHAIN (todo);
03992 }
03993 else
03994 scope = NULL_TREE;
03995 }
03996 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, result->value != error_mark_node);
03997 }
03998
03999
04000
04001
04002
04003
04004 void
04005 set_decl_namespace (decl, scope, friendp)
04006 tree decl;
04007 tree scope;
04008 int friendp;
04009 {
04010 tree old;
04011
04012
04013 scope = ORIGINAL_NAMESPACE (scope);
04014
04015
04016 if (!friendp && !is_ancestor (current_namespace, scope))
04017 error ("declaration of `%D' not in a namespace surrounding `%D'",
04018 decl, scope);
04019 DECL_CONTEXT (decl) = FROB_CONTEXT (scope);
04020 if (scope != current_namespace)
04021 {
04022
04023 old = namespace_binding (DECL_NAME (decl), scope);
04024 if (!old)
04025
04026 goto complain;
04027
04028 if (processing_explicit_instantiation)
04029 return;
04030 if (!is_overloaded_fn (decl))
04031
04032
04033
04034 return;
04035
04036 if (!is_overloaded_fn (old))
04037 goto complain;
04038 if (processing_template_decl || processing_specialization)
04039
04040
04041
04042
04043 return;
04044 for (; old; old = OVL_NEXT (old))
04045 if (decls_match (decl, OVL_CURRENT (old)))
04046 return;
04047 }
04048 else
04049 return;
04050 complain:
04051 error ("`%D' should have been declared inside `%D'",
04052 decl, scope);
04053 }
04054
04055
04056
04057 static tree
04058 decl_namespace (decl)
04059 tree decl;
04060 {
04061 timevar_push (TV_NAME_LOOKUP);
04062 if (TYPE_P (decl))
04063 decl = TYPE_STUB_DECL (decl);
04064 while (DECL_CONTEXT (decl))
04065 {
04066 decl = DECL_CONTEXT (decl);
04067 if (TREE_CODE (decl) == NAMESPACE_DECL)
04068 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl);
04069 if (TYPE_P (decl))
04070 decl = TYPE_STUB_DECL (decl);
04071 my_friendly_assert (DECL_P (decl), 390);
04072 }
04073
04074 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, global_namespace);
04075 }
04076
04077
04078
04079 tree
04080 current_decl_namespace ()
04081 {
04082 tree result;
04083
04084 if (decl_namespace_list)
04085 return TREE_PURPOSE (decl_namespace_list);
04086
04087 if (current_class_type)
04088 result = decl_namespace (TYPE_STUB_DECL (current_class_type));
04089 else if (current_function_decl)
04090 result = decl_namespace (current_function_decl);
04091 else
04092 result = current_namespace;
04093 return result;
04094 }
04095
04096
04097
04098 void
04099 push_decl_namespace (decl)
04100 tree decl;
04101 {
04102 if (TREE_CODE (decl) != NAMESPACE_DECL)
04103 decl = decl_namespace (decl);
04104 decl_namespace_list = tree_cons (ORIGINAL_NAMESPACE (decl),
04105 NULL_TREE, decl_namespace_list);
04106 }
04107
04108 void
04109 pop_decl_namespace ()
04110 {
04111 decl_namespace_list = TREE_CHAIN (decl_namespace_list);
04112 }
04113
04114
04115
04116 void
04117 push_scope (t)
04118 tree t;
04119 {
04120 if (TREE_CODE (t) == NAMESPACE_DECL)
04121 push_decl_namespace (t);
04122 else if (CLASS_TYPE_P (t))
04123 pushclass (t, 2);
04124 }
04125
04126
04127
04128 void
04129 pop_scope (t)
04130 tree t;
04131 {
04132 if (TREE_CODE (t) == NAMESPACE_DECL)
04133 pop_decl_namespace ();
04134 else if (CLASS_TYPE_P (t))
04135 popclass ();
04136 }
04137
04138
04139
04140
04141 struct arg_lookup
04142 {
04143 tree name;
04144 tree namespaces;
04145 tree classes;
04146 tree functions;
04147 };
04148
04149 static int arg_assoc PARAMS ((struct arg_lookup*, tree));
04150 static int arg_assoc_args PARAMS ((struct arg_lookup*, tree));
04151 static int arg_assoc_type PARAMS ((struct arg_lookup*, tree));
04152 static int add_function PARAMS ((struct arg_lookup *, tree));
04153 static int arg_assoc_namespace PARAMS ((struct arg_lookup *, tree));
04154 static int arg_assoc_class PARAMS ((struct arg_lookup *, tree));
04155 static int arg_assoc_template_arg PARAMS ((struct arg_lookup*, tree));
04156
04157
04158
04159
04160 static int
04161 add_function (k, fn)
04162 struct arg_lookup *k;
04163 tree fn;
04164 {
04165
04166
04167
04168
04169
04170
04171
04172
04173 if (!k->functions)
04174 k->functions = fn;
04175 else if (fn == k->functions)
04176 ;
04177 else if (is_overloaded_fn (k->functions) && is_overloaded_fn (fn))
04178 k->functions = build_overload (fn, k->functions);
04179 else
04180 {
04181 tree f1 = OVL_CURRENT (k->functions);
04182 tree f2 = fn;
04183 if (is_overloaded_fn (f1))
04184 {
04185 fn = f1; f1 = f2; f2 = fn;
04186 }
04187 cp_error_at ("`%D' is not a function,", f1);
04188 cp_error_at (" conflict with `%D'", f2);
04189 error (" in call to `%D'", k->name);
04190 return 1;
04191 }
04192
04193 return 0;
04194 }
04195
04196
04197
04198
04199 static int
04200 arg_assoc_namespace (k, scope)
04201 struct arg_lookup *k;
04202 tree scope;
04203 {
04204 tree value;
04205
04206 if (purpose_member (scope, k->namespaces))
04207 return 0;
04208 k->namespaces = tree_cons (scope, NULL_TREE, k->namespaces);
04209
04210 value = namespace_binding (k->name, scope);
04211 if (!value)
04212 return 0;
04213
04214 for (; value; value = OVL_NEXT (value))
04215 if (add_function (k, OVL_CURRENT (value)))
04216 return 1;
04217
04218 return 0;
04219 }
04220
04221
04222
04223
04224 static int
04225 arg_assoc_template_arg (k, arg)
04226 struct arg_lookup* k;
04227 tree arg;
04228 {
04229
04230
04231
04232
04233
04234
04235
04236
04237
04238
04239
04240
04241 if (TREE_CODE (arg) == TEMPLATE_TEMPLATE_PARM
04242 || TREE_CODE (arg) == UNBOUND_CLASS_TEMPLATE)
04243 return 0;
04244 else if (TREE_CODE (arg) == TEMPLATE_DECL)
04245 {
04246 tree ctx = CP_DECL_CONTEXT (arg);
04247
04248
04249 if (TREE_CODE (ctx) == NAMESPACE_DECL)
04250 return arg_assoc_namespace (k, ctx);
04251
04252 else
04253 return arg_assoc_class (k, ctx);
04254 }
04255
04256
04257 else if (TYPE_P (arg))
04258 return arg_assoc_type (k, arg);
04259
04260 else
04261 return 0;
04262 }
04263
04264
04265
04266
04267 static int
04268 arg_assoc_class (k, type)
04269 struct arg_lookup* k;
04270 tree type;
04271 {
04272 tree list, friends, context;
04273 int i;
04274
04275
04276
04277 if (!CLASS_TYPE_P (type))
04278 return 0;
04279
04280 if (purpose_member (type, k->classes))
04281 return 0;
04282 k->classes = tree_cons (type, NULL_TREE, k->classes);
04283
04284 context = decl_namespace (TYPE_MAIN_DECL (type));
04285 if (arg_assoc_namespace (k, context))
04286 return 1;
04287
04288
04289 for (i = 0; i < CLASSTYPE_N_BASECLASSES (type); i++)
04290 if (arg_assoc_class (k, TYPE_BINFO_BASETYPE (type, i)))
04291 return 1;
04292
04293
04294 for (list = DECL_FRIENDLIST (TYPE_MAIN_DECL (type)); list;
04295 list = TREE_CHAIN (list))
04296 if (k->name == TREE_PURPOSE (list))
04297 for (friends = TREE_VALUE (list); friends;
04298 friends = TREE_CHAIN (friends))
04299
04300
04301 if (TREE_PURPOSE (friends) == error_mark_node && TREE_VALUE (friends)
04302 && CP_DECL_CONTEXT (TREE_VALUE (friends)) == context)
04303 if (add_function (k, TREE_VALUE (friends)))
04304 return 1;
04305
04306
04307 if (CLASSTYPE_TEMPLATE_INFO (type))
04308 {
04309 list = INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (type));
04310 for (i = 0; i < TREE_VEC_LENGTH (list); ++i)
04311 arg_assoc_template_arg (k, TREE_VEC_ELT (list, i));
04312 }
04313
04314 return 0;
04315 }
04316
04317
04318
04319
04320 static int
04321 arg_assoc_type (k, type)
04322 struct arg_lookup *k;
04323 tree type;
04324 {
04325 switch (TREE_CODE (type))
04326 {
04327 case VOID_TYPE:
04328 case INTEGER_TYPE:
04329 case REAL_TYPE:
04330 case COMPLEX_TYPE:
04331 case VECTOR_TYPE:
04332 case CHAR_TYPE:
04333 case BOOLEAN_TYPE:
04334 return 0;
04335 case RECORD_TYPE:
04336 if (TYPE_PTRMEMFUNC_P (type))
04337 return arg_assoc_type (k, TYPE_PTRMEMFUNC_FN_TYPE (type));
04338 return arg_assoc_class (k, type);
04339 case POINTER_TYPE:
04340 case REFERENCE_TYPE:
04341 case ARRAY_TYPE:
04342 return arg_assoc_type (k, TREE_TYPE (type));
04343 case UNION_TYPE:
04344 case ENUMERAL_TYPE:
04345 return arg_assoc_namespace (k, decl_namespace (TYPE_MAIN_DECL (type)));
04346 case OFFSET_TYPE:
04347
04348 if (arg_assoc_type (k, TYPE_OFFSET_BASETYPE (type)))
04349 return 1;
04350 return arg_assoc_type (k, TREE_TYPE (type));
04351 case METHOD_TYPE:
04352
04353
04354 case FUNCTION_TYPE:
04355
04356 if (arg_assoc_args (k, TYPE_ARG_TYPES (type)))
04357 return 1;
04358
04359 return arg_assoc_type (k, TREE_TYPE (type));
04360 case TEMPLATE_TYPE_PARM:
04361 case BOUND_TEMPLATE_TEMPLATE_PARM:
04362 return 0;
04363 case TYPENAME_TYPE:
04364 return 0;
04365 case LANG_TYPE:
04366 if (type == unknown_type_node)
04367 return 0;
04368
04369 default:
04370 abort ();
04371 }
04372 return 0;
04373 }
04374
04375
04376
04377 static int
04378 arg_assoc_args (k, args)
04379 struct arg_lookup* k;
04380 tree args;
04381 {
04382 for (; args; args = TREE_CHAIN (args))
04383 if (arg_assoc (k, TREE_VALUE (args)))
04384 return 1;
04385 return 0;
04386 }
04387
04388
04389
04390 static int
04391 arg_assoc (k, n)
04392 struct arg_lookup* k;
04393 tree n;
04394 {
04395 if (n == error_mark_node)
04396 return 0;
04397
04398 if (TYPE_P (n))
04399 return arg_assoc_type (k, n);
04400
04401 if (! type_unknown_p (n))
04402 return arg_assoc_type (k, TREE_TYPE (n));
04403
04404 if (TREE_CODE (n) == ADDR_EXPR)
04405 n = TREE_OPERAND (n, 0);
04406 if (TREE_CODE (n) == COMPONENT_REF)
04407 n = TREE_OPERAND (n, 1);
04408 if (TREE_CODE (n) == OFFSET_REF)
04409 n = TREE_OPERAND (n, 1);
04410 while (TREE_CODE (n) == TREE_LIST)
04411 n = TREE_VALUE (n);
04412 if (TREE_CODE (n) == BASELINK)
04413 n = BASELINK_FUNCTIONS (n);
04414
04415 if (TREE_CODE (n) == FUNCTION_DECL)
04416 return arg_assoc_type (k, TREE_TYPE (n));
04417 if (TREE_CODE (n) == TEMPLATE_ID_EXPR)
04418 {
04419
04420
04421
04422
04423
04424 tree template = TREE_OPERAND (n, 0);
04425 tree args = TREE_OPERAND (n, 1);
04426 tree ctx;
04427 tree arg;
04428
04429 if (TREE_CODE (template) == COMPONENT_REF)
04430 template = TREE_OPERAND (template, 1);
04431
04432
04433
04434
04435
04436 template = OVL_CURRENT (template);
04437
04438 ctx = CP_DECL_CONTEXT (template);
04439
04440 if (TREE_CODE (ctx) == NAMESPACE_DECL)
04441 {
04442 if (arg_assoc_namespace (k, ctx) == 1)
04443 return 1;
04444 }
04445
04446 else if (arg_assoc_class (k, ctx) == 1)
04447 return 1;
04448
04449
04450 for (arg = args; arg != NULL_TREE; arg = TREE_CHAIN (arg))
04451 if (arg_assoc_template_arg (k, TREE_VALUE (arg)) == 1)
04452 return 1;
04453 }
04454 else
04455 {
04456 my_friendly_assert (TREE_CODE (n) == OVERLOAD, 980715);
04457
04458 for (; n; n = OVL_CHAIN (n))
04459 if (arg_assoc_type (k, TREE_TYPE (OVL_FUNCTION (n))))
04460 return 1;
04461 }
04462
04463 return 0;
04464 }
04465
04466
04467
04468
04469 tree
04470 lookup_arg_dependent (name, fns, args)
04471 tree name;
04472 tree fns;
04473 tree args;
04474 {
04475 struct arg_lookup k;
04476 tree fn = NULL_TREE;
04477
04478 if (fns == error_mark_node)
04479 fns = NULL_TREE;
04480
04481 timevar_push (TV_NAME_LOOKUP);
04482 k.name = name;
04483 k.functions = fns;
04484 k.classes = NULL_TREE;
04485
04486
04487
04488 if (fns)
04489 fn = OVL_CURRENT (fns);
04490 if (fn && TREE_CODE (fn) == FUNCTION_DECL && DECL_LOCAL_FUNCTION_P (fn))
04491 k.namespaces = NULL_TREE;
04492 else
04493 unqualified_namespace_lookup (name, 0, &k.namespaces);
04494
04495 arg_assoc_args (&k, args);
04496 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, k.functions);
04497 }
04498
04499
04500
04501 void
04502 do_namespace_alias (alias, namespace)
04503 tree alias, namespace;
04504 {
04505 if (TREE_CODE (namespace) != NAMESPACE_DECL)
04506 {
04507
04508 error ("unknown namespace `%D'", namespace);
04509 return;
04510 }
04511
04512 namespace = ORIGINAL_NAMESPACE (namespace);
04513
04514
04515 alias = build_lang_decl (NAMESPACE_DECL, alias, void_type_node);
04516 DECL_NAMESPACE_ALIAS (alias) = namespace;
04517 pushdecl (alias);
04518 }
04519
04520
04521
04522
04523 static tree
04524 validate_nonmember_using_decl (decl, scope, name)
04525 tree decl;
04526 tree *scope;
04527 tree *name;
04528 {
04529 if (TREE_CODE (decl) == SCOPE_REF)
04530 {
04531 *scope = TREE_OPERAND (decl, 0);
04532 *name = TREE_OPERAND (decl, 1);
04533
04534 if (!processing_template_decl)
04535 {
04536
04537
04538
04539 if(TREE_CODE (*scope) != NAMESPACE_DECL)
04540 {
04541 if (TYPE_P (*scope))
04542 error ("`%T' is not a namespace", *scope);
04543 else
04544 error ("`%D' is not a namespace", *scope);
04545 return NULL_TREE;
04546 }
04547
04548
04549
04550 if (TREE_CODE (*name) == TEMPLATE_ID_EXPR)
04551 {
04552 *name = TREE_OPERAND (*name, 0);
04553 error ("a using-declaration cannot specify a template-id. Try `using %D'", *name);
04554 return NULL_TREE;
04555 }
04556 }
04557 }
04558 else if (TREE_CODE (decl) == IDENTIFIER_NODE
04559 || TREE_CODE (decl) == TYPE_DECL
04560 || TREE_CODE (decl) == TEMPLATE_DECL)
04561 {
04562 *scope = global_namespace;
04563 *name = decl;
04564 }
04565 else if (TREE_CODE (decl) == NAMESPACE_DECL)
04566 {
04567 error ("namespace `%D' not allowed in using-declaration", decl);
04568 return NULL_TREE;
04569 }
04570 else
04571 abort ();
04572 if (DECL_P (*name))
04573 *name = DECL_NAME (*name);
04574
04575 return push_using_decl (*scope, *name);
04576 }
04577
04578
04579
04580 static void
04581 do_nonmember_using_decl (scope, name, oldval, oldtype, newval, newtype)
04582 tree scope, name;
04583 tree oldval, oldtype;
04584 tree *newval, *newtype;
04585 {
04586 cxx_binding decls;
04587
04588 *newval = *newtype = NULL_TREE;
04589 cxx_binding_clear (&decls);
04590 if (!qualified_lookup_using_namespace (name, scope, &decls, 0))
04591
04592 return;
04593
04594 if (!decls.value && !decls.type)
04595 {
04596 error ("`%D' not declared", name);
04597 return;
04598 }
04599
04600
04601 if (decls.value && is_overloaded_fn (decls.value))
04602 {
04603 tree tmp, tmp1;
04604
04605 if (oldval && !is_overloaded_fn (oldval))
04606 {
04607 if (!DECL_IMPLICIT_TYPEDEF_P (oldval))
04608 error ("`%D' is already declared in this scope", name);
04609 oldval = NULL_TREE;
04610 }
04611
04612 *newval = oldval;
04613 for (tmp = decls.value; tmp; tmp = OVL_NEXT (tmp))
04614 {
04615 tree new_fn = OVL_CURRENT (tmp);
04616
04617
04618
04619
04620
04621
04622
04623 for (tmp1 = oldval; tmp1; tmp1 = OVL_NEXT (tmp1))
04624 {
04625 tree old_fn = OVL_CURRENT (tmp1);
04626
04627 if (new_fn == old_fn)
04628
04629 break;
04630 else if (OVL_USED (tmp1))
04631 continue;
04632 else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (new_fn)),
04633 TYPE_ARG_TYPES (TREE_TYPE (old_fn))))
04634 {
04635
04636
04637
04638 if (decls_match (new_fn, old_fn))
04639 {
04640
04641
04642 if (DECL_ANTICIPATED (old_fn))
04643 DECL_ANTICIPATED (old_fn) = 0;
04644 break;
04645 }
04646 else if (!DECL_ANTICIPATED (old_fn))
04647 {
04648
04649
04650 error ("`%D' is already declared in this scope", name);
04651 break;
04652 }
04653
04654
04655
04656 }
04657 }
04658
04659
04660
04661
04662 if (tmp1)
04663 continue;
04664
04665 *newval = build_overload (OVL_CURRENT (tmp), *newval);
04666 if (TREE_CODE (*newval) != OVERLOAD)
04667 *newval = ovl_cons (*newval, NULL_TREE);
04668 OVL_USED (*newval) = 1;
04669 }
04670 }
04671 else
04672 {
04673 *newval = decls.value;
04674 if (oldval && !decls_match (*newval, oldval))
04675 error ("`%D' is already declared in this scope", name);
04676 }
04677
04678 *newtype = decls.type;
04679 if (oldtype && *newtype && !same_type_p (oldtype, *newtype))
04680 {
04681 error ("using declaration `%D' introduced ambiguous type `%T'",
04682 name, oldtype);
04683 return;
04684 }
04685 }
04686
04687
04688
04689 void
04690 do_toplevel_using_decl (decl)
04691 tree decl;
04692 {
04693 tree scope, name;
04694 tree oldval, oldtype, newval, newtype;
04695 cxx_binding *binding;
04696
04697 decl = validate_nonmember_using_decl (decl, &scope, &name);
04698 if (decl == NULL_TREE)
04699 return;
04700
04701
04702
04703 binding = binding_for_name (name, current_namespace);
04704
04705 oldval = BINDING_VALUE (binding);
04706 oldtype = BINDING_TYPE (binding);
04707
04708 do_nonmember_using_decl (scope, name, oldval, oldtype, &newval, &newtype);
04709
04710
04711 if (newval)
04712 BINDING_VALUE (binding) = newval;
04713 if (newtype)
04714 BINDING_TYPE (binding) = newtype;
04715 return;
04716 }
04717
04718
04719
04720 void
04721 do_local_using_decl (decl)
04722 tree decl;
04723 {
04724 tree scope, name;
04725 tree oldval, oldtype, newval, newtype;
04726
04727 decl = validate_nonmember_using_decl (decl, &scope, &name);
04728 if (decl == NULL_TREE)
04729 return;
04730
04731 if (building_stmt_tree ()
04732 && at_function_scope_p ())
04733 add_decl_stmt (decl);
04734
04735 oldval = lookup_name_current_level (name);
04736 oldtype = lookup_type_current_level (name);
04737
04738 do_nonmember_using_decl (scope, name, oldval, oldtype, &newval, &newtype);
04739
04740 if (newval)
04741 {
04742 if (is_overloaded_fn (newval))
04743 {
04744 tree fn, term;
04745
04746
04747
04748
04749
04750 if (oldval && TREE_CODE (oldval) == OVERLOAD)
04751 term = OVL_FUNCTION (oldval);
04752 else
04753 term = oldval;
04754 for (fn = newval; fn && OVL_CURRENT (fn) != term;
04755 fn = OVL_NEXT (fn))
04756 push_overloaded_decl (OVL_CURRENT (fn),
04757 PUSH_LOCAL | PUSH_USING);
04758 }
04759 else
04760 push_local_binding (name, newval, PUSH_USING);
04761 }
04762 if (newtype)
04763 set_identifier_type_value (name, newtype);
04764 }
04765
04766 tree
04767 do_class_using_decl (decl)
04768 tree decl;
04769 {
04770 tree name, value;
04771
04772 if (TREE_CODE (decl) != SCOPE_REF
04773 || !TYPE_P (TREE_OPERAND (decl, 0)))
04774 {
04775 error ("using-declaration for non-member at class scope");
04776 return NULL_TREE;
04777 }
04778 name = TREE_OPERAND (decl, 1);
04779 if (TREE_CODE (name) == BIT_NOT_EXPR)
04780 {
04781 error ("using-declaration for destructor");
04782 return NULL_TREE;
04783 }
04784 else if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
04785 {
04786 name = TREE_OPERAND (name, 0);
04787 error ("a using-declaration cannot specify a template-id. Try `using %T::%D'", TREE_OPERAND (decl, 0), name);
04788 return NULL_TREE;
04789 }
04790 if (TREE_CODE (name) == TYPE_DECL || TREE_CODE (name) == TEMPLATE_DECL)
04791 name = DECL_NAME (name);
04792 else if (BASELINK_P (name))
04793 {
04794 name = BASELINK_FUNCTIONS (name);
04795 if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
04796 name = TREE_OPERAND (name, 0);
04797 name = DECL_NAME (get_first_fn (name));
04798 }
04799
04800 my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 980716);
04801
04802 value = build_lang_decl (USING_DECL, name, void_type_node);
04803 DECL_INITIAL (value) = TREE_OPERAND (decl, 0);
04804 return value;
04805 }
04806
04807
04808
04809 void
04810 do_using_directive (namespace)
04811 tree namespace;
04812 {
04813 if (building_stmt_tree ())
04814 add_stmt (build_stmt (USING_STMT, namespace));
04815
04816
04817 if (TREE_CODE (namespace) == SCOPE_REF)
04818 namespace = TREE_OPERAND (namespace, 1);
04819 if (TREE_CODE (namespace) == IDENTIFIER_NODE)
04820 {
04821
04822 if (!processing_template_decl)
04823 error ("namespace `%T' undeclared", namespace);
04824 return;
04825 }
04826 if (TREE_CODE (namespace) != NAMESPACE_DECL)
04827 {
04828 if (!processing_template_decl)
04829 error ("`%T' is not a namespace", namespace);
04830 return;
04831 }
04832 namespace = ORIGINAL_NAMESPACE (namespace);
04833 if (!toplevel_bindings_p ())
04834 push_using_directive (namespace);
04835 else
04836
04837 add_using_namespace (current_namespace, namespace, 0);
04838 }
04839
04840 void
04841 check_default_args (x)
04842 tree x;
04843 {
04844 tree arg = TYPE_ARG_TYPES (TREE_TYPE (x));
04845 int saw_def = 0, i = 0 - (TREE_CODE (TREE_TYPE (x)) == METHOD_TYPE);
04846 for (; arg && arg != void_list_node; arg = TREE_CHAIN (arg), ++i)
04847 {
04848 if (TREE_PURPOSE (arg))
04849 saw_def = 1;
04850 else if (saw_def)
04851 {
04852 cp_error_at ("default argument missing for parameter %P of `%+#D'",
04853 i, x);
04854 break;
04855 }
04856 }
04857 }
04858
04859 void
04860 mark_used (decl)
04861 tree decl;
04862 {
04863 TREE_USED (decl) = 1;
04864 if (processing_template_decl || skip_evaluation)
04865 return;
04866
04867 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl)
04868 && !TREE_ASM_WRITTEN (decl))
04869
04870 defer_fn (decl);
04871
04872 assemble_external (decl);
04873
04874
04875 if (TREE_CODE (decl) == FUNCTION_DECL
04876 && DECL_NONSTATIC_MEMBER_FUNCTION_P (decl)
04877 && DECL_ARTIFICIAL (decl)
04878 && ! DECL_INITIAL (decl)
04879
04880 && current_function_decl)
04881 {
04882 synthesize_method (decl);
04883
04884
04885 return;
04886 }
04887
04888
04889
04890
04891
04892 if ((DECL_NON_THUNK_FUNCTION_P (decl) || TREE_CODE (decl) == VAR_DECL)
04893 && DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl)
04894 && (!DECL_EXPLICIT_INSTANTIATION (decl)
04895 || (TREE_CODE (decl) == FUNCTION_DECL && DECL_INLINE (decl))))
04896 {
04897 bool defer;
04898
04899
04900
04901
04902
04903
04904
04905
04906
04907 defer = (!flag_exceptions
04908 || TREE_CODE (decl) != FUNCTION_DECL
04909
04910
04911 || TREE_NOTHROW (decl)
04912 || !cfun
04913
04914
04915 || TREE_NOTHROW (current_function_decl)
04916
04917
04918
04919 || cp_function_chain->can_throw);
04920
04921 instantiate_decl (decl, defer);
04922 }
04923 }
04924
04925
04926
04927
04928
04929
04930
04931
04932
04933
04934 tree
04935 handle_class_head (tag_kind, scope, id, attributes, defn_p, new_type_p)
04936 enum tag_types tag_kind;
04937 tree scope, id, attributes;
04938 int defn_p;
04939 int *new_type_p;
04940 {
04941 tree decl = NULL_TREE;
04942 tree type;
04943 tree current = current_scope ();
04944 bool xrefd_p = false;
04945
04946 if (current == NULL_TREE)
04947 current = current_namespace;
04948
04949 *new_type_p = 0;
04950
04951 if (scope)
04952 {
04953 if (TREE_CODE (id) == TYPE_DECL)
04954
04955
04956 decl = TYPE_MAIN_DECL (TREE_TYPE (id));
04957 else if (DECL_CLASS_TEMPLATE_P (id))
04958 decl = DECL_TEMPLATE_RESULT (id);
04959 else
04960 {
04961 if (TYPE_P (scope))
04962 {
04963
04964
04965 decl = make_typename_type (scope, id, tf_error);
04966 if (decl != error_mark_node)
04967 decl = TYPE_MAIN_DECL (decl);
04968 else
04969 decl = NULL_TREE;
04970 }
04971 else if (scope == current)
04972 {
04973
04974
04975 if (pedantic)
04976 pedwarn ("extra qualification `%T::' on member `%D' ignored",
04977 scope, id);
04978 }
04979 else
04980 error ("`%T' does not have a class or union named `%D'",
04981 scope, id);
04982 }
04983 }
04984
04985 if (!decl)
04986 {
04987 decl = xref_tag (tag_kind, id, attributes, !defn_p);
04988 if (decl == error_mark_node)
04989 return error_mark_node;
04990 decl = TYPE_MAIN_DECL (decl);
04991 xrefd_p = true;
04992 }
04993
04994 type = TREE_TYPE (decl);
04995
04996 if (!TYPE_BINFO (type))
04997 {
04998 error ("`%T' is not a class or union type", decl);
04999 return error_mark_node;
05000 }
05001
05002
05003
05004
05005
05006
05007 if (TREE_CODE (type) == RECORD_TYPE
05008 && CLASSTYPE_IS_TEMPLATE (type)
05009 && processing_template_decl <= template_class_depth (current)
05010 && ! is_base_of_enclosing_class (type, current_class_type))
05011 {
05012 error ("template argument is required for `%T'", type);
05013 return error_mark_node;
05014 }
05015
05016 if (defn_p)
05017 {
05018
05019
05020
05021 tree context = CP_DECL_CONTEXT (decl);
05022
05023 if (IMPLICIT_TYPENAME_P (context))
05024 context = TREE_TYPE (context);
05025
05026
05027
05028 if (current && !is_ancestor (current, context))
05029 {
05030 error ("declaration of `%D' in `%D' which does not "
05031 "enclose `%D'", decl, current, CP_DECL_CONTEXT (decl));
05032 return NULL_TREE;
05033 }
05034
05035 *new_type_p = (current != context
05036 && TREE_CODE (context) != TEMPLATE_TYPE_PARM
05037 && TREE_CODE (context) != BOUND_TEMPLATE_TEMPLATE_PARM);
05038 if (*new_type_p)
05039 push_scope (context);
05040
05041 if (TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE)
05042
05043
05044 CLASSTYPE_DECLARED_CLASS (TREE_TYPE (decl))
05045 = (tag_kind == class_type);
05046
05047 if (!xrefd_p && PROCESSING_REAL_TEMPLATE_DECL_P ())
05048 decl = push_template_decl (decl);
05049 }
05050 else
05051 {
05052
05053
05054
05055
05056
05057
05058
05059
05060 if (IMPLICIT_TYPENAME_P (type))
05061 decl = TYPE_STUB_DECL (build_typename_type (TYPE_CONTEXT (type),
05062 TYPE_IDENTIFIER (type),
05063 TYPENAME_TYPE_FULLNAME (type),
05064 NULL_TREE));
05065 }
05066
05067 return decl;
05068 }
05069
05070
05071
05072
05073
05074
05075
05076
05077 tree
05078 handle_class_head_apparent_template (decl, new_type_p)
05079 tree decl;
05080 int *new_type_p;
05081 {
05082 tree context;
05083 tree current;
05084
05085 if (decl == error_mark_node)
05086 return decl;
05087
05088 current = current_scope ();
05089 if (current == NULL_TREE)
05090 current = current_namespace;
05091
05092 *new_type_p = 0;
05093
05094
05095
05096
05097 context = CP_DECL_CONTEXT (decl);
05098
05099 if (IMPLICIT_TYPENAME_P (context))
05100 context = TREE_TYPE (context);
05101
05102 *new_type_p = (current != context
05103 && TREE_CODE (context) != TEMPLATE_TYPE_PARM
05104 && TREE_CODE (context) != BOUND_TEMPLATE_TEMPLATE_PARM);
05105 if (*new_type_p)
05106 push_scope (context);
05107
05108 if (TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE)
05109
05110
05111 CLASSTYPE_DECLARED_CLASS (TREE_TYPE (decl))
05112 = (current_aggr == class_type_node);
05113
05114 return decl;
05115 }
05116
05117 #include "gt-cp-decl2.h"