1 /* Language-dependent node constructors for parse phase of GNU compiler.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
4 Hacked by Michael Tiemann (tiemann@cygnus.com)
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
25 #include "coretypes.h"
33 #include "insn-config.h"
34 #include "integrate.h"
35 #include "tree-inline.h"
38 static tree bot_manip
PARAMS ((tree
*, int *, void *));
39 static tree bot_replace
PARAMS ((tree
*, int *, void *));
40 static tree build_cplus_array_type_1
PARAMS ((tree
, tree
));
41 static int list_hash_eq
PARAMS ((const void *, const void *));
42 static hashval_t list_hash_pieces
PARAMS ((tree
, tree
, tree
));
43 static hashval_t list_hash
PARAMS ((const void *));
44 static cp_lvalue_kind lvalue_p_1
PARAMS ((tree
, int, int));
45 static tree no_linkage_helper
PARAMS ((tree
*, int *, void *));
46 static tree mark_local_for_remap_r
PARAMS ((tree
*, int *, void *));
47 static tree cp_unsave_r
PARAMS ((tree
*, int *, void *));
48 static tree build_target_expr
PARAMS ((tree
, tree
));
49 static tree count_trees_r
PARAMS ((tree
*, int *, void *));
50 static tree verify_stmt_tree_r
PARAMS ((tree
*, int *, void *));
51 static tree find_tree_r
PARAMS ((tree
*, int *, void *));
53 static tree handle_java_interface_attribute
PARAMS ((tree
*, tree
, tree
, int, bool *));
54 static tree handle_com_interface_attribute
PARAMS ((tree
*, tree
, tree
, int, bool *));
55 static tree handle_init_priority_attribute
PARAMS ((tree
*, tree
, tree
, int, bool *));
57 /* If REF is an lvalue, returns the kind of lvalue that REF is.
58 Otherwise, returns clk_none. If TREAT_CLASS_RVALUES_AS_LVALUES is
59 nonzero, rvalues of class type are considered lvalues. */
62 lvalue_p_1 (ref
, treat_class_rvalues_as_lvalues
, allow_cast_as_lvalue
)
64 int treat_class_rvalues_as_lvalues
;
65 int allow_cast_as_lvalue
;
67 cp_lvalue_kind op1_lvalue_kind
= clk_none
;
68 cp_lvalue_kind op2_lvalue_kind
= clk_none
;
70 if (TREE_CODE (TREE_TYPE (ref
)) == REFERENCE_TYPE
)
73 if (ref
== current_class_ptr
)
76 switch (TREE_CODE (ref
))
78 /* preincrements and predecrements are valid lvals, provided
79 what they refer to are valid lvals. */
80 case PREINCREMENT_EXPR
:
81 case PREDECREMENT_EXPR
:
85 case WITH_CLEANUP_EXPR
:
88 return lvalue_p_1 (TREE_OPERAND (ref
, 0),
89 treat_class_rvalues_as_lvalues
,
90 allow_cast_as_lvalue
);
93 if (allow_cast_as_lvalue
)
94 return lvalue_p_1 (TREE_OPERAND (ref
, 0),
95 treat_class_rvalues_as_lvalues
,
96 allow_cast_as_lvalue
);
101 op1_lvalue_kind
= lvalue_p_1 (TREE_OPERAND (ref
, 0),
102 treat_class_rvalues_as_lvalues
,
103 allow_cast_as_lvalue
);
105 /* The "field" can be a FUNCTION_DECL or an OVERLOAD in some
107 && TREE_CODE (TREE_OPERAND (ref
, 1)) == FIELD_DECL
108 && DECL_C_BIT_FIELD (TREE_OPERAND (ref
, 1)))
110 /* Clear the ordinary bit. If this object was a class
111 rvalue we want to preserve that information. */
112 op1_lvalue_kind
&= ~clk_ordinary
;
113 /* The lvalue is for a btifield. */
114 op1_lvalue_kind
|= clk_bitfield
;
116 return op1_lvalue_kind
;
122 if (TREE_READONLY (ref
) && ! TREE_STATIC (ref
)
123 && DECL_LANG_SPECIFIC (ref
)
124 && DECL_IN_AGGR_P (ref
))
130 if (TREE_CODE (TREE_TYPE (ref
)) != METHOD_TYPE
)
134 /* A currently unresolved scope ref. */
138 if (TREE_CODE (TREE_OPERAND (ref
, 1)) == FUNCTION_DECL
)
143 op1_lvalue_kind
= lvalue_p_1 (TREE_OPERAND (ref
, 0),
144 treat_class_rvalues_as_lvalues
,
145 allow_cast_as_lvalue
);
146 op2_lvalue_kind
= lvalue_p_1 (TREE_OPERAND (ref
, 1),
147 treat_class_rvalues_as_lvalues
,
148 allow_cast_as_lvalue
);
152 op1_lvalue_kind
= lvalue_p_1 (TREE_OPERAND (ref
, 1),
153 treat_class_rvalues_as_lvalues
,
154 allow_cast_as_lvalue
);
155 op2_lvalue_kind
= lvalue_p_1 (TREE_OPERAND (ref
, 2),
156 treat_class_rvalues_as_lvalues
,
157 allow_cast_as_lvalue
);
164 return lvalue_p_1 (TREE_OPERAND (ref
, 1),
165 treat_class_rvalues_as_lvalues
,
166 allow_cast_as_lvalue
);
169 return treat_class_rvalues_as_lvalues
? clk_class
: clk_none
;
173 /* Any class-valued call would be wrapped in a TARGET_EXPR. */
177 /* All functions (except non-static-member functions) are
179 return (DECL_NONSTATIC_MEMBER_FUNCTION_P (ref
)
180 ? clk_none
: clk_ordinary
);
186 /* If one operand is not an lvalue at all, then this expression is
188 if (!op1_lvalue_kind
|| !op2_lvalue_kind
)
191 /* Otherwise, it's an lvalue, and it has all the odd properties
192 contributed by either operand. */
193 op1_lvalue_kind
= op1_lvalue_kind
| op2_lvalue_kind
;
194 /* It's not an ordinary lvalue if it involves either a bit-field or
196 if ((op1_lvalue_kind
& ~clk_ordinary
) != clk_none
)
197 op1_lvalue_kind
&= ~clk_ordinary
;
198 return op1_lvalue_kind
;
201 /* If REF is an lvalue, returns the kind of lvalue that REF is.
202 Otherwise, returns clk_none. Lvalues can be assigned, unless they
203 have TREE_READONLY, or unless they are FUNCTION_DECLs. Lvalues can
204 have their address taken, unless they have DECL_REGISTER. */
210 return lvalue_p_1 (ref
, /*treat_class_rvalues_as_lvalues=*/ 0, /*cast*/ 1);
213 /* Returns the kind of lvalue that REF is, in the sense of
214 [basic.lval]. This function should really be named lvalue_p; it
215 computes the C++ definition of lvalue. */
218 real_non_cast_lvalue_p (tree ref
)
220 return lvalue_p_1 (ref
,
221 /*treat_class_rvalues_as_lvalues=*/0,
222 /*allow_cast_as_lvalue=*/0);
225 /* This differs from real_lvalue_p in that class rvalues are
226 considered lvalues. */
233 (lvalue_p_1 (ref
, /*class rvalue ok*/ 1, /*cast*/ 1) != clk_none
);
237 non_cast_lvalue_p (ref
)
241 (lvalue_p_1 (ref
, /*class rvalue ok*/ 1, /*cast*/ 0) != clk_none
);
244 /* Return nonzero if REF is an lvalue valid for this language;
245 otherwise, print an error message and return zero. */
248 lvalue_or_else (ref
, string
)
252 int ret
= lvalue_p_1 (ref
, /* class rvalue ok */ 1, /* cast ok */ 1);
253 int win
= (ret
!= clk_none
);
255 error ("non-lvalue in %s", string
);
260 non_cast_lvalue_or_else (ref
, string
)
264 int ret
= lvalue_p_1 (ref
, /* class rvalue ok */ 1, /* cast ok */ 0);
265 int win
= (ret
!= clk_none
);
267 error ("non-lvalue in %s", string
);
271 /* Build a TARGET_EXPR, initializing the DECL with the VALUE. */
274 build_target_expr (decl
, value
)
280 t
= build (TARGET_EXPR
, TREE_TYPE (decl
), decl
, value
,
281 cxx_maybe_build_cleanup (decl
), NULL_TREE
);
282 /* We always set TREE_SIDE_EFFECTS so that expand_expr does not
283 ignore the TARGET_EXPR. If there really turn out to be no
284 side-effects, then the optimizer should be able to get rid of
285 whatever code is generated anyhow. */
286 TREE_SIDE_EFFECTS (t
) = 1;
291 /* INIT is a CALL_EXPR which needs info about its target.
292 TYPE is the type that this initialization should appear to have.
294 Build an encapsulation of the initialization to perform
295 and return it so that it can be processed by language-independent
296 and language-specific expression expanders. */
299 build_cplus_new (type
, init
)
308 /* Make sure that we're not trying to create an instance of an
310 abstract_virtuals_error (NULL_TREE
, type
);
312 if (TREE_CODE (init
) != CALL_EXPR
&& TREE_CODE (init
) != AGGR_INIT_EXPR
)
313 return convert (type
, init
);
315 fn
= TREE_OPERAND (init
, 0);
316 is_ctor
= (TREE_CODE (fn
) == ADDR_EXPR
317 && TREE_CODE (TREE_OPERAND (fn
, 0)) == FUNCTION_DECL
318 && DECL_CONSTRUCTOR_P (TREE_OPERAND (fn
, 0)));
320 slot
= build (VAR_DECL
, type
);
321 DECL_ARTIFICIAL (slot
) = 1;
322 DECL_CONTEXT (slot
) = current_function_decl
;
323 layout_decl (slot
, 0);
325 /* We split the CALL_EXPR into its function and its arguments here.
326 Then, in expand_expr, we put them back together. The reason for
327 this is that this expression might be a default argument
328 expression. In that case, we need a new temporary every time the
329 expression is used. That's what break_out_target_exprs does; it
330 replaces every AGGR_INIT_EXPR with a copy that uses a fresh
331 temporary slot. Then, expand_expr builds up a call-expression
332 using the new slot. */
334 /* If we don't need to use a constructor to create an object of this
335 type, don't mess with AGGR_INIT_EXPR. */
336 if (is_ctor
|| TREE_ADDRESSABLE (type
))
338 rval
= build (AGGR_INIT_EXPR
, type
, fn
, TREE_OPERAND (init
, 1), slot
);
339 TREE_SIDE_EFFECTS (rval
) = 1;
340 AGGR_INIT_VIA_CTOR_P (rval
) = is_ctor
;
345 rval
= build_target_expr (slot
, rval
);
350 /* Build a TARGET_EXPR using INIT to initialize a new temporary of the
354 build_target_expr_with_type (init
, type
)
361 if (TREE_CODE (init
) == TARGET_EXPR
)
364 slot
= build (VAR_DECL
, type
);
365 DECL_ARTIFICIAL (slot
) = 1;
366 DECL_CONTEXT (slot
) = current_function_decl
;
367 layout_decl (slot
, 0);
368 rval
= build_target_expr (slot
, init
);
373 /* Like build_target_expr_with_type, but use the type of INIT. */
376 get_target_expr (init
)
379 return build_target_expr_with_type (init
, TREE_TYPE (init
));
382 /* Recursively perform a preorder search EXP for CALL_EXPRs, making
383 copies where they are found. Returns a deep copy all nodes transitively
384 containing CALL_EXPRs. */
387 break_out_calls (exp
)
390 register tree t1
, t2
= NULL_TREE
;
391 register enum tree_code code
;
392 register int changed
= 0;
395 if (exp
== NULL_TREE
)
398 code
= TREE_CODE (exp
);
400 if (code
== CALL_EXPR
)
401 return copy_node (exp
);
403 /* Don't try and defeat a save_expr, as it should only be done once. */
404 if (code
== SAVE_EXPR
)
407 switch (TREE_CODE_CLASS (code
))
412 case 'c': /* a constant */
413 case 't': /* a type node */
414 case 'x': /* something random, like an identifier or an ERROR_MARK. */
417 case 'd': /* A decl node */
420 case 'b': /* A block node */
422 /* Don't know how to handle these correctly yet. Must do a
423 break_out_calls on all DECL_INITIAL values for local variables,
424 and also break_out_calls on all sub-blocks and sub-statements. */
429 case 'e': /* an expression */
430 case 'r': /* a reference */
431 case 's': /* an expression with side effects */
432 for (i
= TREE_CODE_LENGTH (code
) - 1; i
>= 0; i
--)
434 t1
= break_out_calls (TREE_OPERAND (exp
, i
));
435 if (t1
!= TREE_OPERAND (exp
, i
))
437 exp
= copy_node (exp
);
438 TREE_OPERAND (exp
, i
) = t1
;
443 case '<': /* a comparison expression */
444 case '2': /* a binary arithmetic expression */
445 t2
= break_out_calls (TREE_OPERAND (exp
, 1));
446 if (t2
!= TREE_OPERAND (exp
, 1))
448 case '1': /* a unary arithmetic expression */
449 t1
= break_out_calls (TREE_OPERAND (exp
, 0));
450 if (t1
!= TREE_OPERAND (exp
, 0))
454 if (TREE_CODE_LENGTH (code
) == 1)
455 return build1 (code
, TREE_TYPE (exp
), t1
);
457 return build (code
, TREE_TYPE (exp
), t1
, t2
);
464 /* Construct, lay out and return the type of methods belonging to class
465 BASETYPE and whose arguments are described by ARGTYPES and whose values
466 are described by RETTYPE. If each type exists already, reuse it. */
469 build_cplus_method_type (basetype
, rettype
, argtypes
)
470 tree basetype
, rettype
, argtypes
;
476 /* Make a node of the sort we want. */
477 t
= make_node (METHOD_TYPE
);
479 TYPE_METHOD_BASETYPE (t
) = TYPE_MAIN_VARIANT (basetype
);
480 TREE_TYPE (t
) = rettype
;
481 ptype
= build_pointer_type (basetype
);
483 /* The actual arglist for this function includes a "hidden" argument
484 which is "this". Put it into the list of argument types. */
485 argtypes
= tree_cons (NULL_TREE
, ptype
, argtypes
);
486 TYPE_ARG_TYPES (t
) = argtypes
;
487 TREE_SIDE_EFFECTS (argtypes
) = 1; /* Mark first argtype as "artificial". */
489 /* If we already have such a type, use the old one and free this one.
490 Note that it also frees up the above cons cell if found. */
491 hashcode
= TYPE_HASH (basetype
) + TYPE_HASH (rettype
) +
492 type_hash_list (argtypes
);
494 t
= type_hash_canon (hashcode
, t
);
496 if (!COMPLETE_TYPE_P (t
))
503 build_cplus_array_type_1 (elt_type
, index_type
)
509 if (elt_type
== error_mark_node
|| index_type
== error_mark_node
)
510 return error_mark_node
;
512 /* Don't do the minimal thing just because processing_template_decl is
513 set; we want to give string constants the right type immediately, so
514 we don't have to fix them up at instantiation time. */
515 if ((processing_template_decl
516 && index_type
&& TYPE_MAX_VALUE (index_type
)
517 && TREE_CODE (TYPE_MAX_VALUE (index_type
)) != INTEGER_CST
)
518 || uses_template_parms (elt_type
)
519 || (index_type
&& uses_template_parms (index_type
)))
521 t
= make_node (ARRAY_TYPE
);
522 TREE_TYPE (t
) = elt_type
;
523 TYPE_DOMAIN (t
) = index_type
;
526 t
= build_array_type (elt_type
, index_type
);
528 /* Push these needs up so that initialization takes place
530 TYPE_NEEDS_CONSTRUCTING (t
)
531 = TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (elt_type
));
532 TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t
)
533 = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TYPE_MAIN_VARIANT (elt_type
));
538 build_cplus_array_type (elt_type
, index_type
)
543 int type_quals
= cp_type_quals (elt_type
);
544 int cv_quals
= type_quals
& (TYPE_QUAL_CONST
|TYPE_QUAL_VOLATILE
);
545 int other_quals
= type_quals
& ~(TYPE_QUAL_CONST
|TYPE_QUAL_VOLATILE
);
548 elt_type
= cp_build_qualified_type (elt_type
, other_quals
);
550 t
= build_cplus_array_type_1 (elt_type
, index_type
);
553 t
= cp_build_qualified_type (t
, cv_quals
);
558 /* Make a variant of TYPE, qualified with the TYPE_QUALS. Handles
559 arrays correctly. In particular, if TYPE is an array of T's, and
560 TYPE_QUALS is non-empty, returns an array of qualified T's.
562 FLAGS determines how to deal with illformed qualifications. If
563 tf_ignore_bad_quals is set, then bad qualifications are dropped
564 (this is permitted if TYPE was introduced via a typedef or template
565 type parameter). If bad qualifications are dropped and tf_warning
566 is set, then a warning is issued for non-const qualifications. If
567 tf_ignore_bad_quals is not set and tf_error is not set, we
568 return error_mark_node. Otherwise, we issue an error, and ignore
571 Qualification of a reference type is valid when the reference came
572 via a typedef or template type argument. [dcl.ref] No such
573 dispensation is provided for qualifying a function type. [dcl.fct]
574 DR 295 queries this and the proposed resolution brings it into line
575 with qualifiying a reference. We implement the DR. We also behave
576 in a similar manner for restricting non-pointer types. */
579 cp_build_qualified_type_real (type
, type_quals
, complain
)
582 tsubst_flags_t complain
;
585 int bad_quals
= TYPE_UNQUALIFIED
;
586 /* We keep bad function qualifiers separate, so that we can decide
587 whether to implement DR 295 or not. DR 295 break existing code,
588 unfortunately. Remove this variable to implement the defect
590 int bad_func_quals
= TYPE_UNQUALIFIED
;
592 if (type
== error_mark_node
)
595 if (type_quals
== cp_type_quals (type
))
598 /* A reference, fucntion or method type shall not be cv qualified.
599 [dcl.ref], [dct.fct] */
600 if (type_quals
& (TYPE_QUAL_CONST
| TYPE_QUAL_VOLATILE
)
601 && (TREE_CODE (type
) == REFERENCE_TYPE
602 || TREE_CODE (type
) == FUNCTION_TYPE
603 || TREE_CODE (type
) == METHOD_TYPE
))
605 bad_quals
|= type_quals
& (TYPE_QUAL_CONST
| TYPE_QUAL_VOLATILE
);
606 if (TREE_CODE (type
) != REFERENCE_TYPE
)
607 bad_func_quals
|= type_quals
& (TYPE_QUAL_CONST
| TYPE_QUAL_VOLATILE
);
608 type_quals
&= ~(TYPE_QUAL_CONST
| TYPE_QUAL_VOLATILE
);
611 /* A restrict-qualified type must be a pointer (or reference)
612 to object or incomplete type. */
613 if ((type_quals
& TYPE_QUAL_RESTRICT
)
614 && TREE_CODE (type
) != TEMPLATE_TYPE_PARM
615 && TREE_CODE (type
) != TYPENAME_TYPE
616 && !POINTER_TYPE_P (type
))
618 bad_quals
|= TYPE_QUAL_RESTRICT
;
619 type_quals
&= ~TYPE_QUAL_RESTRICT
;
622 if (bad_quals
== TYPE_UNQUALIFIED
)
624 else if (!(complain
& (tf_error
| tf_ignore_bad_quals
)))
625 return error_mark_node
;
626 else if (bad_func_quals
&& !(complain
& tf_error
))
627 return error_mark_node
;
630 if (complain
& tf_ignore_bad_quals
)
631 /* We're not going to warn about constifying things that can't
633 bad_quals
&= ~TYPE_QUAL_CONST
;
634 bad_quals
|= bad_func_quals
;
637 tree bad_type
= build_qualified_type (ptr_type_node
, bad_quals
);
639 if (!(complain
& tf_ignore_bad_quals
)
641 error ("`%V' qualifiers cannot be applied to `%T'",
646 if (TREE_CODE (type
) == ARRAY_TYPE
)
648 /* In C++, the qualification really applies to the array element
649 type. Obtain the appropriately qualified element type. */
652 = cp_build_qualified_type_real (TREE_TYPE (type
),
656 if (element_type
== error_mark_node
)
657 return error_mark_node
;
659 /* See if we already have an identically qualified type. */
660 for (t
= TYPE_MAIN_VARIANT (type
); t
; t
= TYPE_NEXT_VARIANT (t
))
661 if (cp_type_quals (t
) == type_quals
662 && TYPE_NAME (t
) == TYPE_NAME (type
)
663 && TYPE_CONTEXT (t
) == TYPE_CONTEXT (type
))
668 /* Make a new array type, just like the old one, but with the
669 appropriately qualified element type. */
670 t
= build_type_copy (type
);
671 TREE_TYPE (t
) = element_type
;
674 /* Even if we already had this variant, we update
675 TYPE_NEEDS_CONSTRUCTING and TYPE_HAS_NONTRIVIAL_DESTRUCTOR in case
676 they changed since the variant was originally created.
678 This seems hokey; if there is some way to use a previous
679 variant *without* coming through here,
680 TYPE_NEEDS_CONSTRUCTING will never be updated. */
681 TYPE_NEEDS_CONSTRUCTING (t
)
682 = TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (element_type
));
683 TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t
)
684 = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TYPE_MAIN_VARIANT (element_type
));
687 else if (TYPE_PTRMEMFUNC_P (type
))
689 /* For a pointer-to-member type, we can't just return a
690 cv-qualified version of the RECORD_TYPE. If we do, we
691 haven't changed the field that contains the actual pointer to
692 a method, and so TYPE_PTRMEMFUNC_FN_TYPE will be wrong. */
695 t
= TYPE_PTRMEMFUNC_FN_TYPE (type
);
696 t
= cp_build_qualified_type_real (t
, type_quals
, complain
);
697 return build_ptrmemfunc_type (t
);
700 /* Retrieve (or create) the appropriately qualified variant. */
701 result
= build_qualified_type (type
, type_quals
);
703 /* If this was a pointer-to-method type, and we just made a copy,
704 then we need to unshare the record that holds the cached
705 pointer-to-member-function type, because these will be distinct
706 between the unqualified and qualified types. */
708 && TREE_CODE (type
) == POINTER_TYPE
709 && TREE_CODE (TREE_TYPE (type
)) == METHOD_TYPE
)
710 TYPE_LANG_SPECIFIC (result
) = NULL
;
715 /* Returns the canonical version of TYPE. In other words, if TYPE is
716 a typedef, returns the underlying type. The cv-qualification of
717 the type returned matches the type input; they will always be
721 canonical_type_variant (t
)
724 return cp_build_qualified_type (TYPE_MAIN_VARIANT (t
), cp_type_quals (t
));
727 /* Makes new binfos for the indirect bases under BINFO. T is the most
728 derived TYPE. PREV is the previous binfo, whose TREE_CHAIN we make
729 point to this binfo. We return the last BINFO created.
731 The CLASSTYPE_VBASECLASSES list of T is constructed in reverse
732 order (pre-order, depth-first, right-to-left). You must nreverse it.
734 The BINFO_INHERITANCE of a virtual base class points to the binfo
735 og the most derived type.
737 The binfo's TREE_CHAIN is set to inheritance graph order, but bases
738 for non-class types are not included (i.e. those which are
739 dependent bases in non-instantiated templates). */
742 copy_base_binfos (binfo
, t
, prev
)
745 tree binfos
= BINFO_BASETYPES (binfo
);
749 TREE_CHAIN (prev
) = binfo
;
752 if (binfos
== NULL_TREE
)
755 n
= TREE_VEC_LENGTH (binfos
);
757 /* Now copy the structure beneath BINFO. */
758 for (ix
= 0; ix
!= n
; ix
++)
760 tree base_binfo
= TREE_VEC_ELT (binfos
, ix
);
761 tree new_binfo
= NULL_TREE
;
763 if (!CLASS_TYPE_P (BINFO_TYPE (base_binfo
)))
765 my_friendly_assert (binfo
== TYPE_BINFO (t
), 20030204);
767 new_binfo
= base_binfo
;
768 TREE_CHAIN (prev
) = new_binfo
;
770 BINFO_INHERITANCE_CHAIN (new_binfo
) = binfo
;
771 BINFO_DEPENDENT_BASE_P (new_binfo
) = 1;
773 else if (TREE_VIA_VIRTUAL (base_binfo
))
775 new_binfo
= purpose_member (BINFO_TYPE (base_binfo
),
776 CLASSTYPE_VBASECLASSES (t
));
778 new_binfo
= TREE_VALUE (new_binfo
);
783 new_binfo
= make_binfo (BINFO_OFFSET (base_binfo
),
784 base_binfo
, NULL_TREE
,
785 BINFO_VIRTUALS (base_binfo
));
786 prev
= copy_base_binfos (new_binfo
, t
, prev
);
787 if (TREE_VIA_VIRTUAL (base_binfo
))
789 CLASSTYPE_VBASECLASSES (t
)
790 = tree_cons (BINFO_TYPE (new_binfo
), new_binfo
,
791 CLASSTYPE_VBASECLASSES (t
));
792 TREE_VIA_VIRTUAL (new_binfo
) = 1;
793 BINFO_INHERITANCE_CHAIN (new_binfo
) = TYPE_BINFO (t
);
796 BINFO_INHERITANCE_CHAIN (new_binfo
) = binfo
;
798 TREE_VEC_ELT (binfos
, ix
) = new_binfo
;
805 /* Hashing of lists so that we don't make duplicates.
806 The entry point is `list_hash_canon'. */
808 /* Now here is the hash table. When recording a list, it is added
809 to the slot whose index is the hash code mod the table size.
810 Note that the hash table is used for several kinds of lists.
811 While all these live in the same table, they are completely independent,
812 and the hash code is computed differently for each of these. */
814 static GTY ((param_is (union tree_node
))) htab_t list_hash_table
;
823 /* Compare ENTRY (an entry in the hash table) with DATA (a list_proxy
824 for a node we are thinking about adding). */
827 list_hash_eq (entry
, data
)
831 tree t
= (tree
) entry
;
832 struct list_proxy
*proxy
= (struct list_proxy
*) data
;
834 return (TREE_VALUE (t
) == proxy
->value
835 && TREE_PURPOSE (t
) == proxy
->purpose
836 && TREE_CHAIN (t
) == proxy
->chain
);
839 /* Compute a hash code for a list (chain of TREE_LIST nodes
840 with goodies in the TREE_PURPOSE, TREE_VALUE, and bits of the
841 TREE_COMMON slots), by adding the hash codes of the individual entries. */
844 list_hash_pieces (purpose
, value
, chain
)
849 hashval_t hashcode
= 0;
852 hashcode
+= TYPE_HASH (chain
);
855 hashcode
+= TYPE_HASH (value
);
859 hashcode
+= TYPE_HASH (purpose
);
865 /* Hash an already existing TREE_LIST. */
872 return list_hash_pieces (TREE_PURPOSE (t
),
877 /* Given list components PURPOSE, VALUE, AND CHAIN, return the canonical
878 object for an identical list if one already exists. Otherwise, build a
879 new one, and record it as the canonical object. */
882 hash_tree_cons (purpose
, value
, chain
)
883 tree purpose
, value
, chain
;
887 struct list_proxy proxy
;
889 /* Hash the list node. */
890 hashcode
= list_hash_pieces (purpose
, value
, chain
);
891 /* Create a proxy for the TREE_LIST we would like to create. We
892 don't actually create it so as to avoid creating garbage. */
893 proxy
.purpose
= purpose
;
896 /* See if it is already in the table. */
897 slot
= htab_find_slot_with_hash (list_hash_table
, &proxy
, hashcode
,
899 /* If not, create a new node. */
901 *slot
= (PTR
) tree_cons (purpose
, value
, chain
);
905 /* Constructor for hashed lists. */
908 hash_tree_chain (value
, chain
)
911 return hash_tree_cons (NULL_TREE
, value
, chain
);
914 /* Similar, but used for concatenating two lists. */
917 hash_chainon (list1
, list2
)
924 if (TREE_CHAIN (list1
) == NULL_TREE
)
925 return hash_tree_chain (TREE_VALUE (list1
), list2
);
926 return hash_tree_chain (TREE_VALUE (list1
),
927 hash_chainon (TREE_CHAIN (list1
), list2
));
930 /* Build an association between TYPE and some parameters:
932 OFFSET is the offset added to `this' to convert it to a pointer
935 BINFO is the base binfo to use, if we are deriving from one. This
936 is necessary, as we want specialized parent binfos from base
937 classes, so that the VTABLE_NAMEs of bases are for the most derived
938 type, instead of the simple type.
940 VTABLE is the virtual function table with which to initialize
941 sub-objects of type TYPE.
943 VIRTUALS are the virtual functions sitting in VTABLE. */
946 make_binfo (offset
, binfo
, vtable
, virtuals
)
948 tree vtable
, virtuals
;
950 tree new_binfo
= make_tree_vec (BINFO_LANG_ELTS
);
953 if (TREE_CODE (binfo
) == TREE_VEC
)
955 type
= BINFO_TYPE (binfo
);
956 BINFO_DEPENDENT_BASE_P (new_binfo
) = BINFO_DEPENDENT_BASE_P (binfo
);
962 BINFO_DEPENDENT_BASE_P (new_binfo
) = 1;
965 TREE_TYPE (new_binfo
) = TYPE_MAIN_VARIANT (type
);
966 BINFO_OFFSET (new_binfo
) = offset
;
967 BINFO_VTABLE (new_binfo
) = vtable
;
968 BINFO_VIRTUALS (new_binfo
) = virtuals
;
970 if (binfo
&& !BINFO_DEPENDENT_BASE_P (binfo
)
971 && BINFO_BASETYPES (binfo
) != NULL_TREE
)
973 BINFO_BASETYPES (new_binfo
) = copy_node (BINFO_BASETYPES (binfo
));
974 /* We do not need to copy the accesses, as they are read only. */
975 BINFO_BASEACCESSES (new_binfo
) = BINFO_BASEACCESSES (binfo
);
987 fprintf (stderr
, "type \"%s\", offset = " HOST_WIDE_INT_PRINT_DEC
989 TYPE_NAME_STRING (BINFO_TYPE (elem
)),
990 TREE_INT_CST_LOW (BINFO_OFFSET (elem
)));
991 debug_tree (BINFO_TYPE (elem
));
992 if (BINFO_VTABLE (elem
))
993 fprintf (stderr
, "vtable decl \"%s\"\n",
994 IDENTIFIER_POINTER (DECL_NAME (get_vtbl_decl_for_binfo (elem
))));
996 fprintf (stderr
, "no vtable decl yet\n");
997 fprintf (stderr
, "virtuals:\n");
998 virtuals
= BINFO_VIRTUALS (elem
);
1003 tree fndecl
= TREE_VALUE (virtuals
);
1004 fprintf (stderr
, "%s [%ld =? %ld]\n",
1005 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
)),
1006 (long) n
, (long) TREE_INT_CST_LOW (DECL_VINDEX (fndecl
)));
1008 virtuals
= TREE_CHAIN (virtuals
);
1017 if (TREE_CODE (t
) == FUNCTION_DECL
)
1019 else if (TREE_CODE (t
) == OVERLOAD
)
1021 for (i
= 0; t
; t
= OVL_CHAIN (t
))
1031 is_overloaded_fn (x
)
1034 /* A baselink is also considered an overloaded function. */
1035 if (TREE_CODE (x
) == OFFSET_REF
)
1036 x
= TREE_OPERAND (x
, 1);
1038 x
= BASELINK_FUNCTIONS (x
);
1039 return (TREE_CODE (x
) == FUNCTION_DECL
1040 || TREE_CODE (x
) == TEMPLATE_ID_EXPR
1041 || DECL_FUNCTION_TEMPLATE_P (x
)
1042 || TREE_CODE (x
) == OVERLOAD
);
1046 really_overloaded_fn (x
)
1049 /* A baselink is also considered an overloaded function. */
1050 if (TREE_CODE (x
) == OFFSET_REF
)
1051 x
= TREE_OPERAND (x
, 1);
1053 x
= BASELINK_FUNCTIONS (x
);
1055 return ((TREE_CODE (x
) == OVERLOAD
&& OVL_CHAIN (x
))
1056 || DECL_FUNCTION_TEMPLATE_P (OVL_CURRENT (x
))
1057 || TREE_CODE (x
) == TEMPLATE_ID_EXPR
);
1064 my_friendly_assert (is_overloaded_fn (from
), 9);
1065 /* A baselink is also considered an overloaded function. */
1066 if (BASELINK_P (from
))
1067 from
= BASELINK_FUNCTIONS (from
);
1068 return OVL_CURRENT (from
);
1071 /* Returns nonzero if T is a ->* or .* expression that refers to a
1078 return (TREE_CODE (t
) == OFFSET_REF
1079 && TYPE_PTRMEMFUNC_P (TREE_TYPE (TREE_OPERAND (t
, 1))));
1082 /* Return a new OVL node, concatenating it with the old one. */
1085 ovl_cons (decl
, chain
)
1089 tree result
= make_node (OVERLOAD
);
1090 TREE_TYPE (result
) = unknown_type_node
;
1091 OVL_FUNCTION (result
) = decl
;
1092 TREE_CHAIN (result
) = chain
;
1097 /* Build a new overloaded function. If this is the first one,
1098 just return it; otherwise, ovl_cons the _DECLs */
1101 build_overload (decl
, chain
)
1105 if (! chain
&& TREE_CODE (decl
) != TEMPLATE_DECL
)
1107 if (chain
&& TREE_CODE (chain
) != OVERLOAD
)
1108 chain
= ovl_cons (chain
, NULL_TREE
);
1109 return ovl_cons (decl
, chain
);
1113 is_aggr_type_2 (t1
, t2
)
1116 if (TREE_CODE (t1
) != TREE_CODE (t2
))
1118 return IS_AGGR_TYPE (t1
) && IS_AGGR_TYPE (t2
);
1121 #define PRINT_RING_SIZE 4
1124 cxx_printable_name (decl
, v
)
1128 static tree decl_ring
[PRINT_RING_SIZE
];
1129 static char *print_ring
[PRINT_RING_SIZE
];
1130 static int ring_counter
;
1133 /* Only cache functions. */
1135 || TREE_CODE (decl
) != FUNCTION_DECL
1136 || DECL_LANG_SPECIFIC (decl
) == 0)
1137 return lang_decl_name (decl
, v
);
1139 /* See if this print name is lying around. */
1140 for (i
= 0; i
< PRINT_RING_SIZE
; i
++)
1141 if (decl_ring
[i
] == decl
)
1142 /* yes, so return it. */
1143 return print_ring
[i
];
1145 if (++ring_counter
== PRINT_RING_SIZE
)
1148 if (current_function_decl
!= NULL_TREE
)
1150 if (decl_ring
[ring_counter
] == current_function_decl
)
1152 if (ring_counter
== PRINT_RING_SIZE
)
1154 if (decl_ring
[ring_counter
] == current_function_decl
)
1158 if (print_ring
[ring_counter
])
1159 free (print_ring
[ring_counter
]);
1161 print_ring
[ring_counter
] = xstrdup (lang_decl_name (decl
, v
));
1162 decl_ring
[ring_counter
] = decl
;
1163 return print_ring
[ring_counter
];
1166 /* Build the FUNCTION_TYPE or METHOD_TYPE which may throw exceptions
1167 listed in RAISES. */
1170 build_exception_variant (type
, raises
)
1174 tree v
= TYPE_MAIN_VARIANT (type
);
1175 int type_quals
= TYPE_QUALS (type
);
1177 for (; v
; v
= TYPE_NEXT_VARIANT (v
))
1178 if (TYPE_QUALS (v
) == type_quals
1179 && comp_except_specs (raises
, TYPE_RAISES_EXCEPTIONS (v
), 1))
1182 /* Need to build a new variant. */
1183 v
= build_type_copy (type
);
1184 TYPE_RAISES_EXCEPTIONS (v
) = raises
;
1188 /* Given a TEMPLATE_TEMPLATE_PARM node T, create a new
1189 BOUND_TEMPLATE_TEMPLATE_PARM bound with NEWARGS as its template
1193 bind_template_template_parm (t
, newargs
)
1197 tree decl
= TYPE_NAME (t
);
1200 t2
= make_aggr_type (BOUND_TEMPLATE_TEMPLATE_PARM
);
1201 decl
= build_decl (TYPE_DECL
, DECL_NAME (decl
), NULL_TREE
);
1203 /* These nodes have to be created to reflect new TYPE_DECL and template
1205 TEMPLATE_TYPE_PARM_INDEX (t2
) = copy_node (TEMPLATE_TYPE_PARM_INDEX (t
));
1206 TEMPLATE_PARM_DECL (TEMPLATE_TYPE_PARM_INDEX (t2
)) = decl
;
1207 TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (t2
)
1208 = tree_cons (TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL (t
),
1209 newargs
, NULL_TREE
);
1211 TREE_TYPE (decl
) = t2
;
1212 TYPE_NAME (t2
) = decl
;
1213 TYPE_STUB_DECL (t2
) = decl
;
1219 /* Called from count_trees via walk_tree. */
1222 count_trees_r (tp
, walk_subtrees
, data
)
1223 tree
*tp ATTRIBUTE_UNUSED
;
1224 int *walk_subtrees ATTRIBUTE_UNUSED
;
1231 /* Debugging function for measuring the rough complexity of a tree
1239 walk_tree_without_duplicates (&t
, count_trees_r
, &n_trees
);
1243 /* Called from verify_stmt_tree via walk_tree. */
1246 verify_stmt_tree_r (tp
, walk_subtrees
, data
)
1248 int *walk_subtrees ATTRIBUTE_UNUSED
;
1252 htab_t
*statements
= (htab_t
*) data
;
1255 if (!STATEMENT_CODE_P (TREE_CODE (t
)))
1258 /* If this statement is already present in the hash table, then
1259 there is a circularity in the statement tree. */
1260 if (htab_find (*statements
, t
))
1263 slot
= htab_find_slot (*statements
, t
, INSERT
);
1269 /* Debugging function to check that the statement T has not been
1270 corrupted. For now, this function simply checks that T contains no
1274 verify_stmt_tree (t
)
1278 statements
= htab_create (37, htab_hash_pointer
, htab_eq_pointer
, NULL
);
1279 walk_tree (&t
, verify_stmt_tree_r
, &statements
, NULL
);
1280 htab_delete (statements
);
1283 /* Called from find_tree via walk_tree. */
1286 find_tree_r (tp
, walk_subtrees
, data
)
1288 int *walk_subtrees ATTRIBUTE_UNUSED
;
1291 if (*tp
== (tree
) data
)
1297 /* Returns X if X appears in the tree structure rooted at T. */
1304 return walk_tree_without_duplicates (&t
, find_tree_r
, x
);
1307 /* Passed to walk_tree. Checks for the use of types with no linkage. */
1310 no_linkage_helper (tp
, walk_subtrees
, data
)
1312 int *walk_subtrees ATTRIBUTE_UNUSED
;
1313 void *data ATTRIBUTE_UNUSED
;
1318 && (CLASS_TYPE_P (t
) || TREE_CODE (t
) == ENUMERAL_TYPE
)
1319 && (decl_function_context (TYPE_MAIN_DECL (t
))
1320 || TYPE_ANONYMOUS_P (t
)))
1325 /* Check if the type T depends on a type with no linkage and if so, return
1329 no_linkage_check (t
)
1332 /* There's no point in checking linkage on template functions; we
1333 can't know their complete types. */
1334 if (processing_template_decl
)
1337 t
= walk_tree_without_duplicates (&t
, no_linkage_helper
, NULL
);
1338 if (t
!= error_mark_node
)
1343 #ifdef GATHER_STATISTICS
1344 extern int depth_reached
;
1348 cxx_print_statistics ()
1350 print_search_statistics ();
1351 print_class_statistics ();
1352 #ifdef GATHER_STATISTICS
1353 fprintf (stderr
, "maximum template instantiation depth reached: %d\n",
1358 /* Return, as an INTEGER_CST node, the number of elements for TYPE
1359 (which is an ARRAY_TYPE). This counts only elements of the top
1363 array_type_nelts_top (type
)
1366 return fold (build (PLUS_EXPR
, sizetype
,
1367 array_type_nelts (type
),
1371 /* Return, as an INTEGER_CST node, the number of elements for TYPE
1372 (which is an ARRAY_TYPE). This one is a recursive count of all
1373 ARRAY_TYPEs that are clumped together. */
1376 array_type_nelts_total (type
)
1379 tree sz
= array_type_nelts_top (type
);
1380 type
= TREE_TYPE (type
);
1381 while (TREE_CODE (type
) == ARRAY_TYPE
)
1383 tree n
= array_type_nelts_top (type
);
1384 sz
= fold (build (MULT_EXPR
, sizetype
, sz
, n
));
1385 type
= TREE_TYPE (type
);
1390 /* Called from break_out_target_exprs via mapcar. */
1393 bot_manip (tp
, walk_subtrees
, data
)
1398 splay_tree target_remap
= ((splay_tree
) data
);
1401 if (TREE_CONSTANT (t
))
1403 /* There can't be any TARGET_EXPRs or their slot variables below
1404 this point. We used to check !TREE_SIDE_EFFECTS, but then we
1405 failed to copy an ADDR_EXPR of the slot VAR_DECL. */
1409 if (TREE_CODE (t
) == TARGET_EXPR
)
1413 if (TREE_CODE (TREE_OPERAND (t
, 1)) == AGGR_INIT_EXPR
)
1415 mark_used (TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (t
, 1), 0), 0));
1417 (TREE_TYPE (t
), break_out_target_exprs (TREE_OPERAND (t
, 1)));
1421 u
= build_target_expr_with_type
1422 (break_out_target_exprs (TREE_OPERAND (t
, 1)), TREE_TYPE (t
));
1425 /* Map the old variable to the new one. */
1426 splay_tree_insert (target_remap
,
1427 (splay_tree_key
) TREE_OPERAND (t
, 0),
1428 (splay_tree_value
) TREE_OPERAND (u
, 0));
1430 /* Replace the old expression with the new version. */
1432 /* We don't have to go below this point; the recursive call to
1433 break_out_target_exprs will have handled anything below this
1438 else if (TREE_CODE (t
) == CALL_EXPR
)
1439 mark_used (TREE_OPERAND (TREE_OPERAND (t
, 0), 0));
1441 /* Make a copy of this node. */
1442 return copy_tree_r (tp
, walk_subtrees
, NULL
);
1445 /* Replace all remapped VAR_DECLs in T with their new equivalents.
1446 DATA is really a splay-tree mapping old variables to new
1450 bot_replace (t
, walk_subtrees
, data
)
1452 int *walk_subtrees ATTRIBUTE_UNUSED
;
1455 splay_tree target_remap
= ((splay_tree
) data
);
1457 if (TREE_CODE (*t
) == VAR_DECL
)
1459 splay_tree_node n
= splay_tree_lookup (target_remap
,
1460 (splay_tree_key
) *t
);
1462 *t
= (tree
) n
->value
;
1468 /* When we parse a default argument expression, we may create
1469 temporary variables via TARGET_EXPRs. When we actually use the
1470 default-argument expression, we make a copy of the expression, but
1471 we must replace the temporaries with appropriate local versions. */
1474 break_out_target_exprs (t
)
1477 static int target_remap_count
;
1478 static splay_tree target_remap
;
1480 if (!target_remap_count
++)
1481 target_remap
= splay_tree_new (splay_tree_compare_pointers
,
1482 /*splay_tree_delete_key_fn=*/NULL
,
1483 /*splay_tree_delete_value_fn=*/NULL
);
1484 walk_tree (&t
, bot_manip
, target_remap
, NULL
);
1485 walk_tree (&t
, bot_replace
, target_remap
, NULL
);
1487 if (!--target_remap_count
)
1489 splay_tree_delete (target_remap
);
1490 target_remap
= NULL
;
1496 /* Obstack used for allocating nodes in template function and variable
1499 /* Similar to `build_nt', except that we set TREE_COMPLEXITY to be the
1500 current line number. */
1503 build_min_nt (enum tree_code code
, ...)
1506 register int length
;
1512 t
= make_node (code
);
1513 length
= TREE_CODE_LENGTH (code
);
1514 TREE_COMPLEXITY (t
) = input_line
;
1516 for (i
= 0; i
< length
; i
++)
1518 tree x
= va_arg (p
, tree
);
1519 TREE_OPERAND (t
, i
) = x
;
1526 /* Similar to `build', except we set TREE_COMPLEXITY to the current
1530 build_min (enum tree_code code
, tree tt
, ...)
1533 register int length
;
1539 t
= make_node (code
);
1540 length
= TREE_CODE_LENGTH (code
);
1542 TREE_COMPLEXITY (t
) = input_line
;
1544 for (i
= 0; i
< length
; i
++)
1546 tree x
= va_arg (p
, tree
);
1547 TREE_OPERAND (t
, i
) = x
;
1554 /* Returns an INTEGER_CST (of type `int') corresponding to I.
1555 Multiple calls with the same value of I may or may not yield the
1556 same node; therefore, callers should never modify the node
1559 static GTY(()) tree shared_int_cache
[256];
1562 build_shared_int_cst (i
)
1566 return build_int_2 (i
, 0);
1568 if (!shared_int_cache
[i
])
1569 shared_int_cache
[i
] = build_int_2 (i
, 0);
1571 return shared_int_cache
[i
];
1578 if (TREE_CODE (t
) == TYPE_DECL
)
1581 return TYPE_STUB_DECL (t
);
1582 if (t
== error_mark_node
)
1587 /* Stop compiler from complaining control reaches end of non-void function. */
1591 /* Return first vector element whose BINFO_TYPE is ELEM.
1592 Return 0 if ELEM is not in VEC. VEC may be NULL_TREE. */
1595 vec_binfo_member (elem
, vec
)
1601 for (i
= 0; i
< TREE_VEC_LENGTH (vec
); ++i
)
1602 if (same_type_p (elem
, BINFO_TYPE (TREE_VEC_ELT (vec
, i
))))
1603 return TREE_VEC_ELT (vec
, i
);
1608 /* Returns the namespace that contains DECL, whether directly or
1612 decl_namespace_context (decl
)
1617 if (TREE_CODE (decl
) == NAMESPACE_DECL
)
1619 else if (TYPE_P (decl
))
1620 decl
= CP_DECL_CONTEXT (TYPE_MAIN_DECL (decl
));
1622 decl
= CP_DECL_CONTEXT (decl
);
1626 /* Return truthvalue of whether T1 is the same tree structure as T2.
1627 Return 1 if they are the same.
1628 Return 0 if they are understandably different.
1629 Return -1 if either contains tree structure not understood by
1633 cp_tree_equal (t1
, t2
)
1636 register enum tree_code code1
, code2
;
1641 if (t1
== 0 || t2
== 0)
1644 code1
= TREE_CODE (t1
);
1645 code2
= TREE_CODE (t2
);
1647 if (code1
== NOP_EXPR
|| code1
== CONVERT_EXPR
|| code1
== NON_LVALUE_EXPR
)
1649 if (code2
== NOP_EXPR
|| code2
== CONVERT_EXPR
|| code2
== NON_LVALUE_EXPR
)
1650 return cp_tree_equal (TREE_OPERAND (t1
, 0), TREE_OPERAND (t2
, 0));
1652 return cp_tree_equal (TREE_OPERAND (t1
, 0), t2
);
1654 else if (code2
== NOP_EXPR
|| code2
== CONVERT_EXPR
1655 || code2
== NON_LVALUE_EXPR
)
1656 return cp_tree_equal (t1
, TREE_OPERAND (t2
, 0));
1664 return TREE_INT_CST_LOW (t1
) == TREE_INT_CST_LOW (t2
)
1665 && TREE_INT_CST_HIGH (t1
) == TREE_INT_CST_HIGH (t2
);
1668 return REAL_VALUES_EQUAL (TREE_REAL_CST (t1
), TREE_REAL_CST (t2
));
1671 return TREE_STRING_LENGTH (t1
) == TREE_STRING_LENGTH (t2
)
1672 && !memcmp (TREE_STRING_POINTER (t1
), TREE_STRING_POINTER (t2
),
1673 TREE_STRING_LENGTH (t1
));
1676 /* We need to do this when determining whether or not two
1677 non-type pointer to member function template arguments
1679 if (!(same_type_p (TREE_TYPE (t1
), TREE_TYPE (t2
))
1680 /* The first operand is RTL. */
1681 && TREE_OPERAND (t1
, 0) == TREE_OPERAND (t2
, 0)))
1683 return cp_tree_equal (TREE_OPERAND (t1
, 1), TREE_OPERAND (t2
, 1));
1686 cmp
= cp_tree_equal (TREE_PURPOSE (t1
), TREE_PURPOSE (t2
));
1689 cmp
= cp_tree_equal (TREE_VALUE (t1
), TREE_VALUE (t2
));
1692 return cp_tree_equal (TREE_CHAIN (t1
), TREE_CHAIN (t2
));
1695 return cp_tree_equal (TREE_OPERAND (t1
, 0), TREE_OPERAND (t2
, 0));
1698 cmp
= cp_tree_equal (TREE_OPERAND (t1
, 0), TREE_OPERAND (t2
, 0));
1701 return simple_cst_list_equal (TREE_OPERAND (t1
, 1), TREE_OPERAND (t2
, 1));
1704 /* Special case: if either target is an unallocated VAR_DECL,
1705 it means that it's going to be unified with whatever the
1706 TARGET_EXPR is really supposed to initialize, so treat it
1707 as being equivalent to anything. */
1708 if ((TREE_CODE (TREE_OPERAND (t1
, 0)) == VAR_DECL
1709 && DECL_NAME (TREE_OPERAND (t1
, 0)) == NULL_TREE
1710 && !DECL_RTL_SET_P (TREE_OPERAND (t1
, 0)))
1711 || (TREE_CODE (TREE_OPERAND (t2
, 0)) == VAR_DECL
1712 && DECL_NAME (TREE_OPERAND (t2
, 0)) == NULL_TREE
1713 && !DECL_RTL_SET_P (TREE_OPERAND (t2
, 0))))
1716 cmp
= cp_tree_equal (TREE_OPERAND (t1
, 0), TREE_OPERAND (t2
, 0));
1719 return cp_tree_equal (TREE_OPERAND (t1
, 1), TREE_OPERAND (t2
, 1));
1721 case WITH_CLEANUP_EXPR
:
1722 cmp
= cp_tree_equal (TREE_OPERAND (t1
, 0), TREE_OPERAND (t2
, 0));
1725 return cp_tree_equal (TREE_OPERAND (t1
, 1), TREE_OPERAND (t1
, 1));
1728 if (TREE_OPERAND (t1
, 1) == TREE_OPERAND (t2
, 1))
1729 return cp_tree_equal (TREE_OPERAND (t1
, 0), TREE_OPERAND (t2
, 0));
1738 case TEMPLATE_PARM_INDEX
:
1739 return (TEMPLATE_PARM_IDX (t1
) == TEMPLATE_PARM_IDX (t2
)
1740 && TEMPLATE_PARM_LEVEL (t1
) == TEMPLATE_PARM_LEVEL (t2
)
1741 && same_type_p (TREE_TYPE (TEMPLATE_PARM_DECL (t1
)),
1742 TREE_TYPE (TEMPLATE_PARM_DECL (t2
))));
1746 if (TREE_CODE (TREE_OPERAND (t1
, 0)) != TREE_CODE (TREE_OPERAND (t2
, 0)))
1748 if (TYPE_P (TREE_OPERAND (t1
, 0)))
1749 return same_type_p (TREE_OPERAND (t1
, 0), TREE_OPERAND (t2
, 0));
1753 /* Two pointer-to-members are the same if they point to the same
1754 field or function in the same class. */
1755 return (PTRMEM_CST_MEMBER (t1
) == PTRMEM_CST_MEMBER (t2
)
1756 && same_type_p (PTRMEM_CST_CLASS (t1
), PTRMEM_CST_CLASS (t2
)));
1762 switch (TREE_CODE_CLASS (code1
))
1774 for (i
= 0; i
< TREE_CODE_LENGTH (code1
); ++i
)
1776 cmp
= cp_tree_equal (TREE_OPERAND (t1
, i
), TREE_OPERAND (t2
, i
));
1784 return same_type_p (t1
, t2
) ? 1 : 0;
1790 /* Build a wrapper around a 'struct z_candidate' so we can use it as a
1794 build_zc_wrapper (ptr
)
1795 struct z_candidate
*ptr
;
1797 tree t
= make_node (WRAPPER
);
1798 WRAPPER_ZC (t
) = ptr
;
1802 /* The type of ARG when used as an lvalue. */
1808 tree type
= TREE_TYPE (arg
);
1809 if (TREE_CODE (arg
) == OVERLOAD
)
1810 type
= unknown_type_node
;
1814 /* The type of ARG for printing error messages; denote lvalues with
1821 tree type
= TREE_TYPE (arg
);
1822 if (TREE_CODE (type
) == ARRAY_TYPE
)
1824 else if (real_lvalue_p (arg
))
1825 type
= build_reference_type (lvalue_type (arg
));
1826 else if (IS_AGGR_TYPE (type
))
1827 type
= lvalue_type (arg
);
1832 /* Does FUNCTION use a variable-length argument list? */
1835 varargs_function_p (function
)
1838 tree parm
= TYPE_ARG_TYPES (TREE_TYPE (function
));
1839 for (; parm
; parm
= TREE_CHAIN (parm
))
1840 if (TREE_VALUE (parm
) == void_type_node
)
1845 /* Returns 1 if decl is a member of a class. */
1851 const tree ctx
= DECL_CONTEXT (decl
);
1852 return (ctx
&& TYPE_P (ctx
));
1855 /* Create a placeholder for member access where we don't actually have an
1856 object that the access is against. */
1859 build_dummy_object (type
)
1862 tree decl
= build1 (NOP_EXPR
, build_pointer_type (type
), void_zero_node
);
1863 return build_indirect_ref (decl
, NULL
);
1866 /* We've gotten a reference to a member of TYPE. Return *this if appropriate,
1867 or a dummy object otherwise. If BINFOP is non-0, it is filled with the
1868 binfo path from current_class_type to TYPE, or 0. */
1871 maybe_dummy_object (type
, binfop
)
1878 if (current_class_type
1879 && (binfo
= lookup_base (current_class_type
, type
,
1880 ba_ignore
| ba_quiet
, NULL
)))
1881 context
= current_class_type
;
1884 /* Reference from a nested class member function. */
1886 binfo
= TYPE_BINFO (type
);
1892 if (current_class_ref
&& context
== current_class_type
1893 /* Kludge: Make sure that current_class_type is actually
1894 correct. It might not be if we're in the middle of
1895 tsubst_default_argument. */
1896 && same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (current_class_ref
)),
1897 current_class_type
))
1898 decl
= current_class_ref
;
1900 decl
= build_dummy_object (context
);
1905 /* Returns 1 if OB is a placeholder object, or a pointer to one. */
1908 is_dummy_object (ob
)
1911 if (TREE_CODE (ob
) == INDIRECT_REF
)
1912 ob
= TREE_OPERAND (ob
, 0);
1913 return (TREE_CODE (ob
) == NOP_EXPR
1914 && TREE_OPERAND (ob
, 0) == void_zero_node
);
1917 /* Returns 1 iff type T is a POD type, as defined in [basic.types]. */
1923 t
= strip_array_types (t
);
1925 if (t
== error_mark_node
)
1927 if (INTEGRAL_TYPE_P (t
))
1928 return 1; /* integral, character or enumeral type */
1929 if (FLOAT_TYPE_P (t
))
1932 return 1; /* pointer to non-member */
1933 if (TYPE_PTRMEM_P (t
))
1934 return 1; /* pointer to member object */
1935 if (TYPE_PTRMEMFUNC_P (t
))
1936 return 1; /* pointer to member function */
1938 if (! CLASS_TYPE_P (t
))
1939 return 0; /* other non-class type (reference or function) */
1940 if (CLASSTYPE_NON_POD_P (t
))
1945 /* Returns 1 iff zero initialization of type T means actually storing
1952 t
= strip_array_types (t
);
1954 if (t
== error_mark_node
)
1957 /* NULL pointers to data members are initialized with -1. */
1958 if (TYPE_PTRMEM_P (t
))
1961 /* Classes that contain types that can't be zero-initialized, cannot
1962 be zero-initialized themselves. */
1963 if (CLASS_TYPE_P (t
) && CLASSTYPE_NON_ZERO_INIT_P (t
))
1969 /* Table of valid C++ attributes. */
1970 const struct attribute_spec cxx_attribute_table
[] =
1972 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
1973 { "java_interface", 0, 0, false, false, false, handle_java_interface_attribute
},
1974 { "com_interface", 0, 0, false, false, false, handle_com_interface_attribute
},
1975 { "init_priority", 1, 1, true, false, false, handle_init_priority_attribute
},
1976 { NULL
, 0, 0, false, false, false, NULL
}
1979 /* Handle a "java_interface" attribute; arguments as in
1980 struct attribute_spec.handler. */
1982 handle_java_interface_attribute (node
, name
, args
, flags
, no_add_attrs
)
1985 tree args ATTRIBUTE_UNUSED
;
1990 || !CLASS_TYPE_P (*node
)
1991 || !TYPE_FOR_JAVA (*node
))
1993 error ("`%s' attribute can only be applied to Java class definitions",
1994 IDENTIFIER_POINTER (name
));
1995 *no_add_attrs
= true;
1998 if (!(flags
& (int) ATTR_FLAG_TYPE_IN_PLACE
))
1999 *node
= build_type_copy (*node
);
2000 TYPE_JAVA_INTERFACE (*node
) = 1;
2005 /* Handle a "com_interface" attribute; arguments as in
2006 struct attribute_spec.handler. */
2008 handle_com_interface_attribute (node
, name
, args
, flags
, no_add_attrs
)
2011 tree args ATTRIBUTE_UNUSED
;
2012 int flags ATTRIBUTE_UNUSED
;
2017 *no_add_attrs
= true;
2020 || !CLASS_TYPE_P (*node
)
2021 || *node
!= TYPE_MAIN_VARIANT (*node
))
2023 warning ("`%s' attribute can only be applied to class definitions",
2024 IDENTIFIER_POINTER (name
));
2029 warning ("`%s' is obsolete; g++ vtables are now COM-compatible by default",
2030 IDENTIFIER_POINTER (name
));
2035 /* Handle an "init_priority" attribute; arguments as in
2036 struct attribute_spec.handler. */
2038 handle_init_priority_attribute (node
, name
, args
, flags
, no_add_attrs
)
2042 int flags ATTRIBUTE_UNUSED
;
2045 tree initp_expr
= TREE_VALUE (args
);
2047 tree type
= TREE_TYPE (decl
);
2050 STRIP_NOPS (initp_expr
);
2052 if (!initp_expr
|| TREE_CODE (initp_expr
) != INTEGER_CST
)
2054 error ("requested init_priority is not an integer constant");
2055 *no_add_attrs
= true;
2059 pri
= TREE_INT_CST_LOW (initp_expr
);
2061 type
= strip_array_types (type
);
2063 if (decl
== NULL_TREE
2064 || TREE_CODE (decl
) != VAR_DECL
2065 || !TREE_STATIC (decl
)
2066 || DECL_EXTERNAL (decl
)
2067 || (TREE_CODE (type
) != RECORD_TYPE
2068 && TREE_CODE (type
) != UNION_TYPE
)
2069 /* Static objects in functions are initialized the
2070 first time control passes through that
2071 function. This is not precise enough to pin down an
2072 init_priority value, so don't allow it. */
2073 || current_function_decl
)
2075 error ("can only use `%s' attribute on file-scope definitions of objects of class type",
2076 IDENTIFIER_POINTER (name
));
2077 *no_add_attrs
= true;
2081 if (pri
> MAX_INIT_PRIORITY
|| pri
<= 0)
2083 error ("requested init_priority is out of range");
2084 *no_add_attrs
= true;
2088 /* Check for init_priorities that are reserved for
2089 language and runtime support implementations.*/
2090 if (pri
<= MAX_RESERVED_INIT_PRIORITY
)
2093 ("requested init_priority is reserved for internal use");
2096 if (SUPPORTS_INIT_PRIORITY
)
2098 DECL_INIT_PRIORITY (decl
) = pri
;
2103 error ("`%s' attribute is not supported on this platform",
2104 IDENTIFIER_POINTER (name
));
2105 *no_add_attrs
= true;
2110 /* Return a new PTRMEM_CST of the indicated TYPE. The MEMBER is the
2111 thing pointed to by the constant. */
2114 make_ptrmem_cst (type
, member
)
2118 tree ptrmem_cst
= make_node (PTRMEM_CST
);
2119 /* If would seem a great convenience if make_node would set
2120 TREE_CONSTANT for things of class `c', but it does not. */
2121 TREE_CONSTANT (ptrmem_cst
) = 1;
2122 TREE_TYPE (ptrmem_cst
) = type
;
2123 PTRMEM_CST_MEMBER (ptrmem_cst
) = member
;
2127 /* Apply FUNC to all language-specific sub-trees of TP in a pre-order
2128 traversal. Called from walk_tree(). */
2131 cp_walk_subtrees (tp
, walk_subtrees_p
, func
, data
, htab
)
2133 int *walk_subtrees_p
;
2138 enum tree_code code
= TREE_CODE (*tp
);
2141 #define WALK_SUBTREE(NODE) \
2144 result = walk_tree (&(NODE), func, data, htab); \
2150 /* Not one of the easy cases. We must explicitly go through the
2155 case TEMPLATE_TEMPLATE_PARM
:
2156 case BOUND_TEMPLATE_TEMPLATE_PARM
:
2157 case UNBOUND_CLASS_TEMPLATE
:
2158 case TEMPLATE_PARM_INDEX
:
2159 case TEMPLATE_TYPE_PARM
:
2163 /* None of thse have subtrees other than those already walked
2165 *walk_subtrees_p
= 0;
2169 WALK_SUBTREE (TREE_TYPE (*tp
));
2170 *walk_subtrees_p
= 0;
2174 WALK_SUBTREE (TREE_PURPOSE (*tp
));
2178 WALK_SUBTREE (OVL_FUNCTION (*tp
));
2179 WALK_SUBTREE (OVL_CHAIN (*tp
));
2180 *walk_subtrees_p
= 0;
2184 if (TYPE_PTRMEMFUNC_P (*tp
))
2185 WALK_SUBTREE (TYPE_PTRMEMFUNC_FN_TYPE (*tp
));
2192 /* We didn't find what we were looking for. */
2198 /* Decide whether there are language-specific reasons to not inline a
2199 function as a tree. */
2202 cp_cannot_inline_tree_fn (fnp
)
2207 /* We can inline a template instantiation only if it's fully
2209 if (DECL_TEMPLATE_INFO (fn
)
2210 && TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (fn
)))
2212 fn
= *fnp
= instantiate_decl (fn
, /*defer_ok=*/0);
2213 if (TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (fn
)))
2217 if (!DECL_INLINE (fn
))
2220 if (flag_really_no_inline
2221 && lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn
)) == NULL
)
2224 /* Don't auto-inline anything that might not be bound within
2225 this unit of translation. */
2226 if (!DECL_DECLARED_INLINE_P (fn
) && !(*targetm
.binds_local_p
) (fn
))
2228 DECL_UNINLINABLE (fn
) = 1;
2232 if (varargs_function_p (fn
))
2234 DECL_UNINLINABLE (fn
) = 1;
2238 if (! function_attribute_inlinable_p (fn
))
2240 DECL_UNINLINABLE (fn
) = 1;
2247 /* Add any pending functions other than the current function (already
2248 handled by the caller), that thus cannot be inlined, to FNS_P, then
2249 return the latest function added to the array, PREV_FN. */
2252 cp_add_pending_fn_decls (fns_p
, prev_fn
)
2256 varray_type
*fnsp
= (varray_type
*)fns_p
;
2257 struct saved_scope
*s
;
2259 for (s
= scope_chain
; s
; s
= s
->prev
)
2260 if (s
->function_decl
&& s
->function_decl
!= prev_fn
)
2262 VARRAY_PUSH_TREE (*fnsp
, s
->function_decl
);
2263 prev_fn
= s
->function_decl
;
2269 /* Determine whether a tree node is an OVERLOAD node. Used to decide
2270 whether to copy a node or to preserve its chain when inlining a
2274 cp_is_overload_p (t
)
2277 return TREE_CODE (t
) == OVERLOAD
;
2280 /* Determine whether VAR is a declaration of an automatic variable in
2284 cp_auto_var_in_fn_p (var
, fn
)
2287 return (DECL_P (var
) && DECL_CONTEXT (var
) == fn
2288 && nonstatic_local_decl_p (var
));
2291 /* Tell whether a declaration is needed for the RESULT of a function
2292 FN being inlined into CALLER or if the top node of target_exprs is
2296 cp_copy_res_decl_for_inlining (result
, fn
, caller
, decl_map_
,
2297 need_decl
, return_slot_addr
)
2298 tree result
, fn
, caller
;
2301 tree return_slot_addr
;
2303 splay_tree decl_map
= (splay_tree
)decl_map_
;
2306 /* If FN returns an aggregate then the caller will always pass the
2307 address of the return slot explicitly. If we were just to
2308 create a new VAR_DECL here, then the result of this function
2309 would be copied (bitwise) into the variable initialized by the
2310 TARGET_EXPR. That's incorrect, so we must transform any
2311 references to the RESULT into references to the target. */
2313 /* We should have an explicit return slot iff the return type is
2314 TREE_ADDRESSABLE. See simplify_aggr_init_expr. */
2315 if (TREE_ADDRESSABLE (TREE_TYPE (result
))
2316 != (return_slot_addr
!= NULL_TREE
))
2319 *need_decl
= !return_slot_addr
;
2320 if (return_slot_addr
)
2322 var
= build_indirect_ref (return_slot_addr
, "");
2323 if (! same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (var
),
2324 TREE_TYPE (result
)))
2327 /* Otherwise, make an appropriate copy. */
2329 var
= copy_decl_for_inlining (result
, fn
, caller
);
2331 if (DECL_SAVED_FUNCTION_DATA (fn
))
2333 tree nrv
= DECL_SAVED_FUNCTION_DATA (fn
)->x_return_value
;
2336 /* We have a named return value; copy the name and source
2337 position so we can get reasonable debugging information, and
2338 register the return variable as its equivalent. */
2339 if (TREE_CODE (var
) == VAR_DECL
)
2341 DECL_NAME (var
) = DECL_NAME (nrv
);
2342 DECL_SOURCE_LOCATION (var
) = DECL_SOURCE_LOCATION (nrv
);
2343 DECL_ABSTRACT_ORIGIN (var
) = DECL_ORIGIN (nrv
);
2344 /* Don't lose initialization info. */
2345 DECL_INITIAL (var
) = DECL_INITIAL (nrv
);
2346 /* Don't forget that it needs to go in the stack. */
2347 TREE_ADDRESSABLE (var
) = TREE_ADDRESSABLE (nrv
);
2350 splay_tree_insert (decl_map
,
2351 (splay_tree_key
) nrv
,
2352 (splay_tree_value
) var
);
2359 /* Record that we're about to start inlining FN, and return nonzero if
2360 that's OK. Used for lang_hooks.tree_inlining.start_inlining. */
2363 cp_start_inlining (fn
)
2366 if (DECL_TEMPLATE_INSTANTIATION (fn
))
2367 return push_tinst_level (fn
);
2372 /* Record that we're done inlining FN. Used for
2373 lang_hooks.tree_inlining.end_inlining. */
2376 cp_end_inlining (fn
)
2377 tree fn ATTRIBUTE_UNUSED
;
2379 if (DECL_TEMPLATE_INSTANTIATION (fn
))
2383 /* Initialize tree.c. */
2388 list_hash_table
= htab_create_ggc (31, list_hash
, list_hash_eq
, NULL
);
2391 /* Called via walk_tree. If *TP points to a DECL_STMT for a local
2392 declaration, copies the declaration and enters it in the splay_tree
2393 pointed to by DATA (which is really a `splay_tree *'). */
2396 mark_local_for_remap_r (tp
, walk_subtrees
, data
)
2398 int *walk_subtrees ATTRIBUTE_UNUSED
;
2402 splay_tree st
= (splay_tree
) data
;
2406 if (TREE_CODE (t
) == DECL_STMT
2407 && nonstatic_local_decl_p (DECL_STMT_DECL (t
)))
2408 decl
= DECL_STMT_DECL (t
);
2409 else if (TREE_CODE (t
) == LABEL_STMT
)
2410 decl
= LABEL_STMT_LABEL (t
);
2411 else if (TREE_CODE (t
) == TARGET_EXPR
2412 && nonstatic_local_decl_p (TREE_OPERAND (t
, 0)))
2413 decl
= TREE_OPERAND (t
, 0);
2414 else if (TREE_CODE (t
) == CASE_LABEL
)
2415 decl
= CASE_LABEL_DECL (t
);
2424 copy
= copy_decl_for_inlining (decl
,
2425 DECL_CONTEXT (decl
),
2426 DECL_CONTEXT (decl
));
2428 /* Remember the copy. */
2429 splay_tree_insert (st
,
2430 (splay_tree_key
) decl
,
2431 (splay_tree_value
) copy
);
2437 /* Called via walk_tree when an expression is unsaved. Using the
2438 splay_tree pointed to by ST (which is really a `splay_tree'),
2439 remaps all local declarations to appropriate replacements. */
2442 cp_unsave_r (tp
, walk_subtrees
, data
)
2447 splay_tree st
= (splay_tree
) data
;
2450 /* Only a local declaration (variable or label). */
2451 if (nonstatic_local_decl_p (*tp
))
2453 /* Lookup the declaration. */
2454 n
= splay_tree_lookup (st
, (splay_tree_key
) *tp
);
2456 /* If it's there, remap it. */
2458 *tp
= (tree
) n
->value
;
2460 else if (TREE_CODE (*tp
) == SAVE_EXPR
)
2461 remap_save_expr (tp
, st
, current_function_decl
, walk_subtrees
);
2464 copy_tree_r (tp
, walk_subtrees
, NULL
);
2466 /* Do whatever unsaving is required. */
2467 unsave_expr_1 (*tp
);
2470 /* Keep iterating. */
2474 /* Called whenever an expression needs to be unsaved. */
2477 cxx_unsave_expr_now (tp
)
2482 /* Create a splay-tree to map old local variable declarations to new
2484 st
= splay_tree_new (splay_tree_compare_pointers
, NULL
, NULL
);
2486 /* Walk the tree once figuring out what needs to be remapped. */
2487 walk_tree (&tp
, mark_local_for_remap_r
, st
, NULL
);
2489 /* Walk the tree again, copying, remapping, and unsaving. */
2490 walk_tree (&tp
, cp_unsave_r
, st
, NULL
);
2493 splay_tree_delete (st
);
2498 /* Returns the kind of special function that DECL (a FUNCTION_DECL)
2499 is. Note that sfk_none is zero, so this function can be used as a
2500 predicate to test whether or not DECL is a special function. */
2502 special_function_kind
2503 special_function_p (decl
)
2506 /* Rather than doing all this stuff with magic names, we should
2507 probably have a field of type `special_function_kind' in
2508 DECL_LANG_SPECIFIC. */
2509 if (DECL_COPY_CONSTRUCTOR_P (decl
))
2510 return sfk_copy_constructor
;
2511 if (DECL_CONSTRUCTOR_P (decl
))
2512 return sfk_constructor
;
2513 if (DECL_OVERLOADED_OPERATOR_P (decl
) == NOP_EXPR
)
2514 return sfk_assignment_operator
;
2515 if (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl
))
2516 return sfk_destructor
;
2517 if (DECL_COMPLETE_DESTRUCTOR_P (decl
))
2518 return sfk_complete_destructor
;
2519 if (DECL_BASE_DESTRUCTOR_P (decl
))
2520 return sfk_base_destructor
;
2521 if (DECL_DELETING_DESTRUCTOR_P (decl
))
2522 return sfk_deleting_destructor
;
2523 if (DECL_CONV_FN_P (decl
))
2524 return sfk_conversion
;
2529 /* Returns true if and only if NODE is a name, i.e., a node created
2530 by the parser when processing an id-expression. */
2535 if (TREE_CODE (node
) == TEMPLATE_ID_EXPR
)
2536 node
= TREE_OPERAND (node
, 0);
2537 return (/* An ordinary unqualified name. */
2538 TREE_CODE (node
) == IDENTIFIER_NODE
2539 /* A destructor name. */
2540 || TREE_CODE (node
) == BIT_NOT_EXPR
2541 /* A qualified name. */
2542 || TREE_CODE (node
) == SCOPE_REF
);
2545 /* Returns nonzero if TYPE is a character type, including wchar_t. */
2551 return (same_type_p (type
, char_type_node
)
2552 || same_type_p (type
, unsigned_char_type_node
)
2553 || same_type_p (type
, signed_char_type_node
)
2554 || same_type_p (type
, wchar_type_node
));
2557 /* Returns the kind of linkage associated with the indicated DECL. Th
2558 value returned is as specified by the language standard; it is
2559 independent of implementation details regarding template
2560 instantiation, etc. For example, it is possible that a declaration
2561 to which this function assigns external linkage would not show up
2562 as a global symbol when you run `nm' on the resulting object file. */
2568 /* This function doesn't attempt to calculate the linkage from first
2569 principles as given in [basic.link]. Instead, it makes use of
2570 the fact that we have already set TREE_PUBLIC appropriately, and
2571 then handles a few special cases. Ideally, we would calculate
2572 linkage first, and then transform that into a concrete
2575 /* Things that don't have names have no linkage. */
2576 if (!DECL_NAME (decl
))
2579 /* Things that are TREE_PUBLIC have external linkage. */
2580 if (TREE_PUBLIC (decl
))
2583 /* Some things that are not TREE_PUBLIC have external linkage, too.
2584 For example, on targets that don't have weak symbols, we make all
2585 template instantiations have internal linkage (in the object
2586 file), but the symbols should still be treated as having external
2587 linkage from the point of view of the language. */
2588 if (DECL_LANG_SPECIFIC (decl
) && DECL_COMDAT (decl
))
2591 /* Things in local scope do not have linkage, if they don't have
2593 if (decl_function_context (decl
))
2596 /* Everything else has internal linkage. */
2600 /* EXP is an expression that we want to pre-evaluate. Returns via INITP an
2601 expression to perform the pre-evaluation, and returns directly an
2602 expression to use the precalculated result. */
2605 stabilize_expr (exp
, initp
)
2611 if (!TREE_SIDE_EFFECTS (exp
))
2613 init_expr
= void_zero_node
;
2615 else if (!real_lvalue_p (exp
)
2616 || !TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (exp
)))
2618 init_expr
= get_target_expr (exp
);
2619 exp
= TARGET_EXPR_SLOT (init_expr
);
2623 exp
= build_unary_op (ADDR_EXPR
, exp
, 1);
2624 init_expr
= get_target_expr (exp
);
2625 exp
= TARGET_EXPR_SLOT (init_expr
);
2626 exp
= build_indirect_ref (exp
, 0);
2633 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
2634 /* Complain that some language-specific thing hanging off a tree
2635 node has been accessed improperly. */
2638 lang_check_failed (file
, line
, function
)
2641 const char *function
;
2643 internal_error ("lang_* check: failed in %s, at %s:%d",
2644 function
, trim_filename (file
), line
);
2646 #endif /* ENABLE_TREE_CHECKING */
2648 #include "gt-cp-tree.h"