1 /* Language-dependent node constructors for parse phase of GNU compiler.
2 Copyright (C) 1987, 1988, 1992, 1993 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@cygnus.com)
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
28 #define CEIL(x,y) (((x) + (y) - 1) / (y))
30 /* Return nonzero if REF is an lvalue valid for this language.
31 Lvalues can be assigned, unless they have TREE_READONLY.
32 Lvalues can have their address taken, unless they have DECL_REGISTER. */
38 register enum tree_code code
= TREE_CODE (ref
);
40 if (language_lvalue_valid (ref
))
43 /* preincrements and predecrements are valid lvals, provided
44 what they refer to are valid lvals. */
45 case PREINCREMENT_EXPR
:
46 case PREDECREMENT_EXPR
:
49 return lvalue_p (TREE_OPERAND (ref
, 0));
55 if (TREE_READONLY (ref
) && ! TREE_STATIC (ref
)
56 && DECL_LANG_SPECIFIC (ref
)
57 && DECL_IN_AGGR_P (ref
))
64 if (TREE_CODE (TREE_TYPE (ref
)) != FUNCTION_TYPE
65 && TREE_CODE (TREE_TYPE (ref
)) != METHOD_TYPE
)
70 case WITH_CLEANUP_EXPR
:
74 if (TREE_CODE (TREE_TYPE (ref
)) == REFERENCE_TYPE
75 /* unary_complex_lvalue knows how to deal with this case. */
76 || TREE_ADDRESSABLE (TREE_TYPE (ref
)))
80 /* A currently unresolved scope ref. */
82 my_friendly_abort (103);
84 if (TREE_CODE (TREE_OPERAND (ref
, 1)) == FUNCTION_DECL
)
86 return lvalue_p (TREE_OPERAND (ref
, 0))
87 && lvalue_p (TREE_OPERAND (ref
, 1));
91 /* ANSI C++ June 5 1992 WP 5.4.14. The result of a cast to a
92 reference is an lvalue. */
93 if (TREE_CODE (TREE_TYPE (ref
)) == REFERENCE_TYPE
)
98 return (lvalue_p (TREE_OPERAND (ref
, 1))
99 && lvalue_p (TREE_OPERAND (ref
, 2)));
104 /* Return nonzero if REF is an lvalue valid for this language;
105 otherwise, print an error message and return zero. */
108 lvalue_or_else (ref
, string
)
112 int win
= lvalue_p (ref
);
114 error ("invalid lvalue in %s", string
);
118 /* INIT is a CALL_EXPR which needs info about its target.
119 TYPE is the type that this initialization should appear to have.
121 Build an encapsulation of the initialization to perform
122 and return it so that it can be processed by language-independent
123 and language-specific expression expanders.
125 If WITH_CLEANUP_P is nonzero, we build a cleanup for this expression.
126 Otherwise, cleanups are not built here. For example, when building
127 an initialization for a stack slot, since the called function handles
128 the cleanup, we would not want to do it here. */
130 build_cplus_new (type
, init
, with_cleanup_p
)
135 tree slot
= build (VAR_DECL
, type
);
136 tree rval
= build (NEW_EXPR
, type
,
137 TREE_OPERAND (init
, 0), TREE_OPERAND (init
, 1), slot
);
138 TREE_SIDE_EFFECTS (rval
) = 1;
139 TREE_ADDRESSABLE (rval
) = 1;
140 rval
= build (TARGET_EXPR
, type
, slot
, rval
, 0);
141 TREE_SIDE_EFFECTS (rval
) = 1;
142 TREE_ADDRESSABLE (rval
) = 1;
144 if (with_cleanup_p
&& TYPE_NEEDS_DESTRUCTOR (type
))
146 TREE_OPERAND (rval
, 2) = error_mark_node
;
147 rval
= build (WITH_CLEANUP_EXPR
, type
, rval
, 0,
148 build_delete (TYPE_POINTER_TO (type
),
149 build_unary_op (ADDR_EXPR
, slot
, 0),
151 LOOKUP_NORMAL
|LOOKUP_DESTRUCTOR
, 0));
152 TREE_SIDE_EFFECTS (rval
) = 1;
153 TREE_ADDRESSABLE (rval
) = 1;
158 /* Recursively search EXP for CALL_EXPRs that need cleanups and replace
159 these CALL_EXPRs with tree nodes that will perform the cleanups. */
162 break_out_cleanups (exp
)
167 if (TREE_CODE (tmp
) == CALL_EXPR
168 && TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (tmp
)))
169 return build_cplus_new (TREE_TYPE (tmp
), tmp
, 1);
171 while (TREE_CODE (tmp
) == NOP_EXPR
172 || TREE_CODE (tmp
) == CONVERT_EXPR
173 || TREE_CODE (tmp
) == NON_LVALUE_EXPR
)
175 if (TREE_CODE (TREE_OPERAND (tmp
, 0)) == CALL_EXPR
176 && TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (TREE_OPERAND (tmp
, 0))))
178 TREE_OPERAND (tmp
, 0)
179 = build_cplus_new (TREE_TYPE (TREE_OPERAND (tmp
, 0)),
180 TREE_OPERAND (tmp
, 0), 1);
184 tmp
= TREE_OPERAND (tmp
, 0);
189 /* Recursively perform a preorder search EXP for CALL_EXPRs, making
190 copies where they are found. Returns a deep copy all nodes transitively
191 containing CALL_EXPRs. */
194 break_out_calls (exp
)
197 register tree t1
, t2
;
198 register enum tree_code code
;
199 register int changed
= 0;
202 if (exp
== NULL_TREE
)
205 code
= TREE_CODE (exp
);
207 if (code
== CALL_EXPR
)
208 return copy_node (exp
);
210 /* Don't try and defeat a save_expr, as it should only be done once. */
211 if (code
== SAVE_EXPR
)
214 switch (TREE_CODE_CLASS (code
))
219 case 'c': /* a constant */
220 case 't': /* a type node */
221 case 'x': /* something random, like an identifier or an ERROR_MARK. */
224 case 'd': /* A decl node */
225 t1
= break_out_calls (DECL_INITIAL (exp
));
226 if (t1
!= DECL_INITIAL (exp
))
228 exp
= copy_node (exp
);
229 DECL_INITIAL (exp
) = t1
;
233 case 'b': /* A block node */
235 /* Don't know how to handle these correctly yet. Must do a
236 break_out_calls on all DECL_INITIAL values for local variables,
237 and also break_out_calls on all sub-blocks and sub-statements. */
242 case 'e': /* an expression */
243 case 'r': /* a reference */
244 case 's': /* an expression with side effects */
245 for (i
= tree_code_length
[(int) code
] - 1; i
>= 0; i
--)
247 t1
= break_out_calls (TREE_OPERAND (exp
, i
));
248 if (t1
!= TREE_OPERAND (exp
, i
))
250 exp
= copy_node (exp
);
251 TREE_OPERAND (exp
, i
) = t1
;
256 case '<': /* a comparison expression */
257 case '2': /* a binary arithmetic expression */
258 t2
= break_out_calls (TREE_OPERAND (exp
, 1));
259 if (t2
!= TREE_OPERAND (exp
, 1))
261 case '1': /* a unary arithmetic expression */
262 t1
= break_out_calls (TREE_OPERAND (exp
, 0));
263 if (t1
!= TREE_OPERAND (exp
, 0))
267 if (tree_code_length
[(int) code
] == 1)
268 return build1 (code
, TREE_TYPE (exp
), t1
);
270 return build (code
, TREE_TYPE (exp
), t1
, t2
);
277 extern struct obstack
*current_obstack
;
278 extern struct obstack permanent_obstack
, class_obstack
;
279 extern struct obstack
*saveable_obstack
;
281 /* Here is how primitive or already-canonicalized types' hash
282 codes are made. MUST BE CONSISTENT WITH tree.c !!! */
283 #define TYPE_HASH(TYPE) ((HOST_WIDE_INT) (TYPE) & 0777777)
285 /* Construct, lay out and return the type of methods belonging to class
286 BASETYPE and whose arguments are described by ARGTYPES and whose values
287 are described by RETTYPE. If each type exists already, reuse it. */
289 build_cplus_method_type (basetype
, rettype
, argtypes
)
290 tree basetype
, rettype
, argtypes
;
296 /* Make a node of the sort we want. */
297 t
= make_node (METHOD_TYPE
);
299 TYPE_METHOD_BASETYPE (t
) = TYPE_MAIN_VARIANT (basetype
);
300 TREE_TYPE (t
) = rettype
;
301 if (IS_SIGNATURE (basetype
))
302 ptype
= build_signature_pointer_type (TYPE_MAIN_VARIANT (basetype
),
303 TYPE_READONLY (basetype
),
304 TYPE_VOLATILE (basetype
));
307 ptype
= build_pointer_type (basetype
);
309 /* it is wrong to flag the object the pointer points to as readonly
310 when flag_this_is_variable is 0. */
311 ptype
= build_type_variant (ptype
, flag_this_is_variable
<= 0, 0);
313 ptype
= build_type_variant (ptype
, 0, 0);
316 /* The actual arglist for this function includes a "hidden" argument
317 which is "this". Put it into the list of argument types. */
319 argtypes
= tree_cons (NULL_TREE
, ptype
, argtypes
);
320 TYPE_ARG_TYPES (t
) = argtypes
;
321 TREE_SIDE_EFFECTS (argtypes
) = 1; /* Mark first argtype as "artificial". */
323 /* If we already have such a type, use the old one and free this one.
324 Note that it also frees up the above cons cell if found. */
325 hashcode
= TYPE_HASH (basetype
) + TYPE_HASH (rettype
) + type_hash_list (argtypes
);
326 t
= type_hash_canon (hashcode
, t
);
328 if (TYPE_SIZE (t
) == 0)
335 build_cplus_staticfn_type (basetype
, rettype
, argtypes
)
336 tree basetype
, rettype
, argtypes
;
341 /* Make a node of the sort we want. */
342 t
= make_node (FUNCTION_TYPE
);
344 TYPE_METHOD_BASETYPE (t
) = TYPE_MAIN_VARIANT (basetype
);
345 TREE_TYPE (t
) = rettype
;
347 /* The actual arglist for this function includes a "hidden" argument
348 which is "this". Put it into the list of argument types. */
350 TYPE_ARG_TYPES (t
) = argtypes
;
352 /* If we already have such a type, use the old one and free this one.
353 Note that it also frees up the above cons cell if found. */
354 hashcode
= TYPE_HASH (basetype
) + TYPE_HASH (rettype
) + type_hash_list (argtypes
);
355 t
= type_hash_canon (hashcode
, t
);
357 if (TYPE_SIZE (t
) == 0)
364 build_cplus_array_type (elt_type
, index_type
)
368 register struct obstack
*ambient_obstack
= current_obstack
;
369 register struct obstack
*ambient_saveable_obstack
= saveable_obstack
;
372 /* We need a new one. If both ELT_TYPE and INDEX_TYPE are permanent,
373 make this permanent too. */
374 if (TREE_PERMANENT (elt_type
)
375 && (index_type
== 0 || TREE_PERMANENT (index_type
)))
377 current_obstack
= &permanent_obstack
;
378 saveable_obstack
= &permanent_obstack
;
381 t
= build_array_type (elt_type
, index_type
);
383 /* Push these needs up so that initialization takes place
385 TYPE_NEEDS_CONSTRUCTING (t
) = TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (elt_type
));
386 TYPE_NEEDS_DESTRUCTOR (t
) = TYPE_NEEDS_DESTRUCTOR (TYPE_MAIN_VARIANT (elt_type
));
387 current_obstack
= ambient_obstack
;
388 saveable_obstack
= ambient_saveable_obstack
;
392 /* Add OFFSET to all base types of T.
394 OFFSET, which is a type offset, is number of bytes.
396 Note that we don't have to worry about having two paths to the
397 same base type, since this type owns its association list. */
399 propagate_binfo_offsets (binfo
, offset
)
403 tree binfos
= BINFO_BASETYPES (binfo
);
404 int i
, n_baselinks
= binfos
? TREE_VEC_LENGTH (binfos
) : 0;
406 for (i
= 0; i
< n_baselinks
; /* note increment is done in the loop. */)
408 tree base_binfo
= TREE_VEC_ELT (binfos
, i
);
410 if (TREE_VIA_VIRTUAL (base_binfo
))
415 tree base_binfos
= BINFO_BASETYPES (base_binfo
);
418 for (j
= i
+1; j
< n_baselinks
; j
++)
419 if (! TREE_VIA_VIRTUAL (TREE_VEC_ELT (binfos
, j
)))
421 /* The next basetype offset must take into account the space
422 between the classes, not just the size of each class. */
423 delta
= size_binop (MINUS_EXPR
,
424 BINFO_OFFSET (TREE_VEC_ELT (binfos
, j
)),
425 BINFO_OFFSET (base_binfo
));
430 if (BINFO_OFFSET_ZEROP (base_binfo
))
431 BINFO_OFFSET (base_binfo
) = offset
;
433 BINFO_OFFSET (base_binfo
)
434 = size_binop (PLUS_EXPR
, BINFO_OFFSET (base_binfo
), offset
);
436 BINFO_OFFSET (base_binfo
) = offset
;
441 tree chain
= NULL_TREE
;
443 /* Now unshare the structure beneath BASE_BINFO. */
444 for (k
= TREE_VEC_LENGTH (base_binfos
)-1;
447 tree base_base_binfo
= TREE_VEC_ELT (base_binfos
, k
);
448 if (! TREE_VIA_VIRTUAL (base_base_binfo
))
449 TREE_VEC_ELT (base_binfos
, k
)
450 = make_binfo (BINFO_OFFSET (base_base_binfo
),
452 BINFO_VTABLE (base_base_binfo
),
453 BINFO_VIRTUALS (base_base_binfo
),
455 chain
= TREE_VEC_ELT (base_binfos
, k
);
456 TREE_VIA_PUBLIC (chain
) = TREE_VIA_PUBLIC (base_base_binfo
);
457 TREE_VIA_PROTECTED (chain
) = TREE_VIA_PROTECTED (base_base_binfo
);
459 /* Now propagate the offset to the base types. */
460 propagate_binfo_offsets (base_binfo
, offset
);
463 /* Go to our next class that counts for offset propagation. */
466 offset
= size_binop (PLUS_EXPR
, offset
, delta
);
471 /* Compute the actual offsets that our virtual base classes
472 will have *for this type*. This must be performed after
473 the fields are laid out, since virtual baseclasses must
474 lay down at the end of the record.
476 Returns the maximum number of virtual functions any of the virtual
477 baseclasses provide. */
479 layout_vbasetypes (rec
, max
)
483 /* Get all the virtual base types that this type uses.
484 The TREE_VALUE slot holds the virtual baseclass type. */
485 tree vbase_types
= get_vbase_types (rec
);
487 #ifdef STRUCTURE_SIZE_BOUNDARY
488 unsigned record_align
= MAX (STRUCTURE_SIZE_BOUNDARY
, TYPE_ALIGN (rec
));
490 unsigned record_align
= MAX (BITS_PER_UNIT
, TYPE_ALIGN (rec
));
493 /* Record size so far is CONST_SIZE + VAR_SIZE bits,
494 where CONST_SIZE is an integer
495 and VAR_SIZE is a tree expression.
496 If VAR_SIZE is null, the size is just CONST_SIZE.
497 Naturally we try to avoid using VAR_SIZE. */
498 register unsigned const_size
= 0;
499 register tree var_size
= 0;
500 int nonvirtual_const_size
;
501 tree nonvirtual_var_size
;
503 CLASSTYPE_VBASECLASSES (rec
) = vbase_types
;
505 if (TREE_CODE (TYPE_SIZE (rec
)) == INTEGER_CST
)
506 const_size
= TREE_INT_CST_LOW (TYPE_SIZE (rec
));
508 var_size
= TYPE_SIZE (rec
);
510 nonvirtual_const_size
= const_size
;
511 nonvirtual_var_size
= var_size
;
515 tree basetype
= BINFO_TYPE (vbase_types
);
519 offset
= integer_zero_node
;
521 offset
= size_int ((const_size
+ BITS_PER_UNIT
- 1) / BITS_PER_UNIT
);
523 if (CLASSTYPE_VSIZE (basetype
) > max
)
524 max
= CLASSTYPE_VSIZE (basetype
);
525 BINFO_OFFSET (vbase_types
) = offset
;
527 if (TREE_CODE (TYPE_SIZE (basetype
)) == INTEGER_CST
)
528 const_size
+= MAX (record_align
,
529 TREE_INT_CST_LOW (TYPE_SIZE (basetype
))
530 - TREE_INT_CST_LOW (CLASSTYPE_VBASE_SIZE (basetype
)));
531 else if (var_size
== 0)
532 var_size
= TYPE_SIZE (basetype
);
534 var_size
= size_binop (PLUS_EXPR
, var_size
, TYPE_SIZE (basetype
));
536 vbase_types
= TREE_CHAIN (vbase_types
);
539 if (const_size
!= nonvirtual_const_size
)
541 CLASSTYPE_VBASE_SIZE (rec
)
542 = size_int (const_size
- nonvirtual_const_size
);
543 TYPE_SIZE (rec
) = size_int (const_size
);
546 /* Now propagate offset information throughout the lattice
547 under the vbase type. */
548 for (vbase_types
= CLASSTYPE_VBASECLASSES (rec
); vbase_types
;
549 vbase_types
= TREE_CHAIN (vbase_types
))
551 tree base_binfos
= BINFO_BASETYPES (vbase_types
);
555 tree chain
= NULL_TREE
;
557 /* Now unshare the structure beneath BASE_BINFO. */
559 for (j
= TREE_VEC_LENGTH (base_binfos
)-1;
562 tree base_base_binfo
= TREE_VEC_ELT (base_binfos
, j
);
563 if (! TREE_VIA_VIRTUAL (base_base_binfo
))
564 TREE_VEC_ELT (base_binfos
, j
)
565 = make_binfo (BINFO_OFFSET (base_base_binfo
),
567 BINFO_VTABLE (base_base_binfo
),
568 BINFO_VIRTUALS (base_base_binfo
),
570 chain
= TREE_VEC_ELT (base_binfos
, j
);
571 TREE_VIA_PUBLIC (chain
) = TREE_VIA_PUBLIC (base_base_binfo
);
572 TREE_VIA_PROTECTED (chain
) = TREE_VIA_PROTECTED (base_base_binfo
);
575 propagate_binfo_offsets (vbase_types
, BINFO_OFFSET (vbase_types
));
582 /* Lay out the base types of a record type, REC.
583 Tentatively set the size and alignment of REC
584 according to the base types alone.
586 Offsets for immediate nonvirtual baseclasses are also computed here.
588 TYPE_BINFO (REC) should be NULL_TREE on entry, and this routine
589 creates a list of base_binfos in TYPE_BINFO (REC) from BINFOS.
591 Returns list of virtual base classes in a FIELD_DECL chain. */
593 layout_basetypes (rec
, binfos
)
596 /* Chain to hold all the new FIELD_DECLs which point at virtual
598 tree vbase_decls
= NULL_TREE
;
600 #ifdef STRUCTURE_SIZE_BOUNDARY
601 unsigned record_align
= MAX (STRUCTURE_SIZE_BOUNDARY
, TYPE_ALIGN (rec
));
603 unsigned record_align
= MAX (BITS_PER_UNIT
, TYPE_ALIGN (rec
));
606 /* Record size so far is CONST_SIZE + VAR_SIZE bits, where CONST_SIZE is
607 an integer and VAR_SIZE is a tree expression. If VAR_SIZE is null,
608 the size is just CONST_SIZE. Naturally we try to avoid using
609 VAR_SIZE. And so far, we've been sucessful. */
611 register tree var_size
= 0;
614 register unsigned const_size
= 0;
615 int i
, n_baseclasses
= binfos
? TREE_VEC_LENGTH (binfos
) : 0;
617 /* Handle basetypes almost like fields, but record their
618 offsets differently. */
620 for (i
= 0; i
< n_baseclasses
; i
++)
622 int inc
, desired_align
, int_vbase_size
;
623 register tree base_binfo
= TREE_VEC_ELT (binfos
, i
);
624 register tree basetype
= BINFO_TYPE (base_binfo
);
627 if (TYPE_SIZE (basetype
) == 0)
630 /* This error is now reported in xref_tag, thus giving better
631 location information. */
632 error_with_aggr_type (base_binfo
,
633 "base class `%s' has incomplete type");
635 TREE_VIA_PUBLIC (base_binfo
) = 1;
636 TREE_VIA_PROTECTED (base_binfo
) = 0;
637 TREE_VIA_VIRTUAL (base_binfo
) = 0;
639 /* Should handle this better so that
642 class B: private A { virtual void F(); };
644 does not dump core when compiled. */
645 my_friendly_abort (121);
650 /* All basetypes are recorded in the association list of the
653 if (TREE_VIA_VIRTUAL (base_binfo
))
656 char *name
= (char *)alloca (TYPE_NAME_LENGTH (basetype
)
657 + sizeof (VBASE_NAME
) + 1);
659 /* The offset for a virtual base class is only used in computing
660 virtual function tables and for initializing virtual base
661 pointers. It is built once `get_vbase_types' is called. */
663 /* If this basetype can come from another vbase pointer
664 without an additional indirection, we will share
665 that pointer. If an indirection is involved, we
666 make our own pointer. */
667 for (j
= 0; j
< n_baseclasses
; j
++)
669 tree other_base_binfo
= TREE_VEC_ELT (binfos
, j
);
670 if (! TREE_VIA_VIRTUAL (other_base_binfo
)
671 && binfo_member (basetype
,
672 CLASSTYPE_VBASECLASSES (BINFO_TYPE (other_base_binfo
))))
675 sprintf (name
, VBASE_NAME_FORMAT
, TYPE_NAME_STRING (basetype
));
676 decl
= build_lang_decl (FIELD_DECL
, get_identifier (name
),
677 build_pointer_type (basetype
));
678 /* If you change any of the below, take a look at all the
679 other VFIELD_BASEs and VTABLE_BASEs in the code, and change
681 DECL_ASSEMBLER_NAME (decl
) = get_identifier (VTABLE_BASE
);
682 DECL_VIRTUAL_P (decl
) = 1;
683 DECL_FIELD_CONTEXT (decl
) = rec
;
684 DECL_CLASS_CONTEXT (decl
) = rec
;
685 DECL_FCONTEXT (decl
) = basetype
;
686 DECL_FIELD_SIZE (decl
) = 0;
687 DECL_ALIGN (decl
) = TYPE_ALIGN (ptr_type_node
);
688 TREE_CHAIN (decl
) = vbase_decls
;
689 BINFO_VPTR_FIELD (base_binfo
) = decl
;
692 if (warn_nonvdtor
&& TYPE_HAS_DESTRUCTOR (basetype
)
693 && DECL_VINDEX (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (basetype
), 0)) == NULL_TREE
)
695 warning_with_decl (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (basetype
), 0),
696 "destructor `%s' non-virtual");
697 warning ("in inheritance relationship `%s: virtual %s'",
698 TYPE_NAME_STRING (rec
),
699 TYPE_NAME_STRING (basetype
));
702 /* The space this decl occupies has already been accounted for. */
707 offset
= integer_zero_node
;
710 /* Give each base type the alignment it wants. */
711 const_size
= CEIL (const_size
, TYPE_ALIGN (basetype
))
712 * TYPE_ALIGN (basetype
);
713 offset
= size_int ((const_size
+ BITS_PER_UNIT
- 1) / BITS_PER_UNIT
);
716 /* bpk: Disabled this check until someone is willing to
717 claim it as theirs and explain exactly what circumstances
718 warrant the warning. */
719 if (warn_nonvdtor
&& TYPE_HAS_DESTRUCTOR (basetype
)
720 && DECL_VINDEX (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (basetype
), 0)) == NULL_TREE
)
722 warning_with_decl (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (basetype
), 0),
723 "destructor `%s' non-virtual");
724 warning ("in inheritance relationship `%s:%s %s'",
725 TYPE_NAME_STRING (rec
),
726 TREE_VIA_VIRTUAL (base_binfo
) ? " virtual" : "",
727 TYPE_NAME_STRING (basetype
));
731 BINFO_OFFSET (base_binfo
) = offset
;
732 if (CLASSTYPE_VSIZE (basetype
))
734 BINFO_VTABLE (base_binfo
) = TYPE_BINFO_VTABLE (basetype
);
735 BINFO_VIRTUALS (base_binfo
) = TYPE_BINFO_VIRTUALS (basetype
);
737 TREE_CHAIN (base_binfo
) = TYPE_BINFO (rec
);
738 TYPE_BINFO (rec
) = base_binfo
;
740 /* Add only the amount of storage not present in
741 the virtual baseclasses. */
743 int_vbase_size
= TREE_INT_CST_LOW (CLASSTYPE_VBASE_SIZE (basetype
));
744 if (TREE_INT_CST_LOW (TYPE_SIZE (basetype
)) > int_vbase_size
)
746 inc
= MAX (record_align
,
747 (TREE_INT_CST_LOW (TYPE_SIZE (basetype
))
750 /* Record must have at least as much alignment as any field. */
751 desired_align
= TYPE_ALIGN (basetype
);
752 record_align
= MAX (record_align
, desired_align
);
759 CLASSTYPE_SIZE (rec
) = size_int (const_size
);
761 CLASSTYPE_SIZE (rec
) = integer_zero_node
;
762 CLASSTYPE_ALIGN (rec
) = record_align
;
767 /* Hashing of lists so that we don't make duplicates.
768 The entry point is `list_hash_canon'. */
770 /* Each hash table slot is a bucket containing a chain
771 of these structures. */
775 struct list_hash
*next
; /* Next structure in the bucket. */
776 int hashcode
; /* Hash code of this list. */
777 tree list
; /* The list recorded here. */
780 /* Now here is the hash table. When recording a list, it is added
781 to the slot whose index is the hash code mod the table size.
782 Note that the hash table is used for several kinds of lists.
783 While all these live in the same table, they are completely independent,
784 and the hash code is computed differently for each of these. */
786 #define TYPE_HASH_SIZE 59
787 struct list_hash
*list_hash_table
[TYPE_HASH_SIZE
];
789 /* Compute a hash code for a list (chain of TREE_LIST nodes
790 with goodies in the TREE_PURPOSE, TREE_VALUE, and bits of the
791 TREE_COMMON slots), by adding the hash codes of the individual entries. */
797 register int hashcode
= 0;
799 if (TREE_CHAIN (list
))
800 hashcode
+= TYPE_HASH (TREE_CHAIN (list
));
802 if (TREE_VALUE (list
))
803 hashcode
+= TYPE_HASH (TREE_VALUE (list
));
806 if (TREE_PURPOSE (list
))
807 hashcode
+= TYPE_HASH (TREE_PURPOSE (list
));
813 /* Look in the type hash table for a type isomorphic to TYPE.
814 If one is found, return it. Otherwise return 0. */
817 list_hash_lookup (hashcode
, list
)
821 register struct list_hash
*h
;
822 for (h
= list_hash_table
[hashcode
% TYPE_HASH_SIZE
]; h
; h
= h
->next
)
823 if (h
->hashcode
== hashcode
824 && TREE_VIA_VIRTUAL (h
->list
) == TREE_VIA_VIRTUAL (list
)
825 && TREE_VIA_PUBLIC (h
->list
) == TREE_VIA_PUBLIC (list
)
826 && TREE_VIA_PROTECTED (h
->list
) == TREE_VIA_PROTECTED (list
)
827 && TREE_PURPOSE (h
->list
) == TREE_PURPOSE (list
)
828 && TREE_VALUE (h
->list
) == TREE_VALUE (list
)
829 && TREE_CHAIN (h
->list
) == TREE_CHAIN (list
))
831 my_friendly_assert (TREE_TYPE (h
->list
) == TREE_TYPE (list
), 299);
837 /* Add an entry to the list-hash-table
838 for a list TYPE whose hash code is HASHCODE. */
841 list_hash_add (hashcode
, list
)
845 register struct list_hash
*h
;
847 h
= (struct list_hash
*) obstack_alloc (&class_obstack
, sizeof (struct list_hash
));
848 h
->hashcode
= hashcode
;
850 h
->next
= list_hash_table
[hashcode
% TYPE_HASH_SIZE
];
851 list_hash_table
[hashcode
% TYPE_HASH_SIZE
] = h
;
854 /* Given TYPE, and HASHCODE its hash code, return the canonical
855 object for an identical list if one already exists.
856 Otherwise, return TYPE, and record it as the canonical object
857 if it is a permanent object.
859 To use this function, first create a list of the sort you want.
860 Then compute its hash code from the fields of the list that
861 make it different from other similar lists.
862 Then call this function and use the value.
863 This function frees the list you pass in if it is a duplicate. */
865 /* Set to 1 to debug without canonicalization. Never set by program. */
866 int debug_no_list_hash
= 0;
869 list_hash_canon (hashcode
, list
)
875 if (debug_no_list_hash
)
878 t1
= list_hash_lookup (hashcode
, list
);
881 obstack_free (&class_obstack
, list
);
885 /* If this is a new list, record it for later reuse. */
886 list_hash_add (hashcode
, list
);
892 hash_tree_cons (via_public
, via_virtual
, via_protected
, purpose
, value
, chain
)
893 int via_public
, via_virtual
, via_protected
;
894 tree purpose
, value
, chain
;
896 struct obstack
*ambient_obstack
= current_obstack
;
900 current_obstack
= &class_obstack
;
901 t
= tree_cons (purpose
, value
, chain
);
902 TREE_VIA_PUBLIC (t
) = via_public
;
903 TREE_VIA_PROTECTED (t
) = via_protected
;
904 TREE_VIA_VIRTUAL (t
) = via_virtual
;
905 hashcode
= list_hash (t
);
906 t
= list_hash_canon (hashcode
, t
);
907 current_obstack
= ambient_obstack
;
911 /* Constructor for hashed lists. */
913 hash_tree_chain (value
, chain
)
916 struct obstack
*ambient_obstack
= current_obstack
;
920 current_obstack
= &class_obstack
;
921 t
= tree_cons (NULL_TREE
, value
, chain
);
922 hashcode
= list_hash (t
);
923 t
= list_hash_canon (hashcode
, t
);
924 current_obstack
= ambient_obstack
;
928 /* Similar, but used for concatenating two lists. */
930 hash_chainon (list1
, list2
)
937 if (TREE_CHAIN (list1
) == NULL_TREE
)
938 return hash_tree_chain (TREE_VALUE (list1
), list2
);
939 return hash_tree_chain (TREE_VALUE (list1
),
940 hash_chainon (TREE_CHAIN (list1
), list2
));
944 get_identifier_list (value
)
947 tree list
= IDENTIFIER_AS_LIST (value
);
948 if (list
!= NULL_TREE
949 && (TREE_CODE (list
) != TREE_LIST
950 || TREE_VALUE (list
) != value
))
952 else if (IDENTIFIER_HAS_TYPE_VALUE (value
)
953 && TREE_CODE (IDENTIFIER_TYPE_VALUE (value
)) == RECORD_TYPE
954 && IDENTIFIER_TYPE_VALUE (value
)
955 == TYPE_MAIN_VARIANT (IDENTIFIER_TYPE_VALUE (value
)))
957 tree type
= IDENTIFIER_TYPE_VALUE (value
);
959 if (TYPE_PTRMEMFUNC_P (type
))
961 else if (type
== current_class_type
)
962 /* Don't mess up the constructor name. */
963 list
= tree_cons (NULL_TREE
, value
, NULL_TREE
);
967 /* This will return the correct thing for regular types,
968 nested types, and templates. Yay! */
969 if (TYPE_NESTED_NAME (type
))
970 id
= TYPE_NESTED_NAME (type
);
972 id
= TYPE_IDENTIFIER (type
);
974 if (CLASSTYPE_ID_AS_LIST (type
) == NULL_TREE
)
975 CLASSTYPE_ID_AS_LIST (type
)
976 = perm_tree_cons (NULL_TREE
, id
, NULL_TREE
);
977 list
= CLASSTYPE_ID_AS_LIST (type
);
984 get_decl_list (value
)
987 tree list
= NULL_TREE
;
989 if (TREE_CODE (value
) == IDENTIFIER_NODE
)
990 list
= get_identifier_list (value
);
991 else if (TREE_CODE (value
) == RECORD_TYPE
992 && TYPE_LANG_SPECIFIC (value
))
993 list
= CLASSTYPE_AS_LIST (value
);
995 if (list
!= NULL_TREE
)
997 my_friendly_assert (TREE_CHAIN (list
) == NULL_TREE
, 301);
1001 return build_decl_list (NULL_TREE
, value
);
1004 /* Look in the type hash table for a type isomorphic to
1005 `build_tree_list (NULL_TREE, VALUE)'.
1006 If one is found, return it. Otherwise return 0. */
1009 list_hash_lookup_or_cons (value
)
1012 register int hashcode
= TYPE_HASH (value
);
1013 register struct list_hash
*h
;
1014 struct obstack
*ambient_obstack
;
1015 tree list
= NULL_TREE
;
1017 if (TREE_CODE (value
) == IDENTIFIER_NODE
)
1018 list
= get_identifier_list (value
);
1019 else if (TREE_CODE (value
) == TYPE_DECL
1020 && TREE_CODE (TREE_TYPE (value
)) == RECORD_TYPE
1021 && TYPE_LANG_SPECIFIC (TREE_TYPE (value
)))
1022 list
= CLASSTYPE_ID_AS_LIST (TREE_TYPE (value
));
1023 else if (TREE_CODE (value
) == RECORD_TYPE
1024 && TYPE_LANG_SPECIFIC (value
))
1025 list
= CLASSTYPE_AS_LIST (value
);
1027 if (list
!= NULL_TREE
)
1029 my_friendly_assert (TREE_CHAIN (list
) == NULL_TREE
, 302);
1033 if (debug_no_list_hash
)
1034 return hash_tree_chain (value
, NULL_TREE
);
1036 for (h
= list_hash_table
[hashcode
% TYPE_HASH_SIZE
]; h
; h
= h
->next
)
1037 if (h
->hashcode
== hashcode
1038 && TREE_VIA_VIRTUAL (h
->list
) == 0
1039 && TREE_VIA_PUBLIC (h
->list
) == 0
1040 && TREE_VIA_PROTECTED (h
->list
) == 0
1041 && TREE_PURPOSE (h
->list
) == 0
1042 && TREE_VALUE (h
->list
) == value
)
1044 my_friendly_assert (TREE_TYPE (h
->list
) == 0, 303);
1045 my_friendly_assert (TREE_CHAIN (h
->list
) == 0, 304);
1049 ambient_obstack
= current_obstack
;
1050 current_obstack
= &class_obstack
;
1051 list
= build_tree_list (NULL_TREE
, value
);
1052 list_hash_add (hashcode
, list
);
1053 current_obstack
= ambient_obstack
;
1057 /* Build an association between TYPE and some parameters:
1059 OFFSET is the offset added to `this' to convert it to a pointer
1062 BINFO is the base binfo to use, if we are deriving from one. This
1063 is necessary, as we want specialized parent binfos from base
1064 classes, so that the VTABLE_NAMEs of bases are for the most derived
1065 type, instead of of the simple type.
1067 VTABLE is the virtual function table with which to initialize
1068 sub-objects of type TYPE.
1070 VIRTUALS are the virtual functions sitting in VTABLE.
1072 CHAIN are more associations we must retain. */
1075 make_binfo (offset
, binfo
, vtable
, virtuals
, chain
)
1077 tree vtable
, virtuals
;
1080 tree new_binfo
= make_tree_vec (6);
1083 if (TREE_CODE (binfo
) == TREE_VEC
)
1084 type
= BINFO_TYPE (binfo
);
1088 binfo
= TYPE_BINFO (binfo
);
1091 TREE_CHAIN (new_binfo
) = chain
;
1093 TREE_USED (new_binfo
) = TREE_USED (chain
);
1095 TREE_TYPE (new_binfo
) = TYPE_MAIN_VARIANT (type
);
1096 BINFO_OFFSET (new_binfo
) = offset
;
1097 BINFO_VTABLE (new_binfo
) = vtable
;
1098 BINFO_VIRTUALS (new_binfo
) = virtuals
;
1099 BINFO_VPTR_FIELD (new_binfo
) = NULL_TREE
;
1101 if (binfo
&& BINFO_BASETYPES (binfo
) != NULL_TREE
)
1102 BINFO_BASETYPES (new_binfo
) = copy_node (BINFO_BASETYPES (binfo
));
1110 tree binfo
= copy_list (list
);
1114 TREE_USED (binfo
) = 0;
1115 if (BINFO_BASETYPES (binfo
))
1116 BINFO_BASETYPES (binfo
) = copy_node (BINFO_BASETYPES (binfo
));
1117 binfo
= TREE_CHAIN (binfo
);
1122 /* Return the binfo value for ELEM in TYPE. */
1125 binfo_value (elem
, type
)
1129 if (get_base_distance (elem
, type
, 0, (tree
*)0) == -2)
1130 compiler_error ("base class `%s' ambiguous in binfo_value",
1131 TYPE_NAME_STRING (elem
));
1133 return TYPE_BINFO (type
);
1134 if (TREE_CODE (elem
) == RECORD_TYPE
&& TYPE_BINFO (elem
) == type
)
1136 return get_binfo (elem
, type
, 0);
1143 register tree prev
= 0, tmp
, next
;
1144 for (tmp
= path
; tmp
; tmp
= next
)
1146 next
= BINFO_INHERITANCE_CHAIN (tmp
);
1147 BINFO_INHERITANCE_CHAIN (tmp
) = prev
;
1154 virtual_member (elem
, list
)
1161 for (t
= list
; t
; t
= TREE_CHAIN (t
))
1162 if (elem
== BINFO_TYPE (t
))
1165 for (t
= list
; t
; t
= TREE_CHAIN (t
))
1167 tree binfos
= BINFO_BASETYPES (t
);
1170 if (binfos
!= NULL_TREE
)
1171 for (i
= TREE_VEC_LENGTH (binfos
)-1; i
>= 0; i
--)
1173 nval
= binfo_value (elem
, BINFO_TYPE (TREE_VEC_ELT (binfos
, i
)));
1176 if (rval
&& BINFO_OFFSET (nval
) != BINFO_OFFSET (rval
))
1177 my_friendly_abort (104);
1185 /* Return the offset (as an INTEGER_CST) for ELEM in LIST.
1186 INITIAL_OFFSET is the value to add to the offset that ELEM's
1187 binfo entry in LIST provides.
1189 Returns NULL if ELEM does not have an binfo value in LIST. */
1192 virtual_offset (elem
, list
, initial_offset
)
1195 tree initial_offset
;
1200 for (vb
= list
; vb
; vb
= TREE_CHAIN (vb
))
1201 if (elem
== BINFO_TYPE (vb
))
1202 return size_binop (PLUS_EXPR
, initial_offset
, BINFO_OFFSET (vb
));
1204 for (vb
= list
; vb
; vb
= TREE_CHAIN (vb
))
1206 tree binfos
= BINFO_BASETYPES (vb
);
1209 if (binfos
== NULL_TREE
)
1212 for (i
= TREE_VEC_LENGTH (binfos
)-1; i
>= 0; i
--)
1214 nval
= binfo_value (elem
, BINFO_TYPE (TREE_VEC_ELT (binfos
, i
)));
1217 if (rval
&& BINFO_OFFSET (nval
) != BINFO_OFFSET (rval
))
1218 my_friendly_abort (105);
1219 offset
= BINFO_OFFSET (vb
);
1224 if (rval
== NULL_TREE
)
1226 return size_binop (PLUS_EXPR
, offset
, BINFO_OFFSET (rval
));
1236 fprintf (stderr
, "type \"%s\"; offset = %d\n",
1237 TYPE_NAME_STRING (BINFO_TYPE (elem
)),
1238 TREE_INT_CST_LOW (BINFO_OFFSET (elem
)));
1239 fprintf (stderr
, "vtable type:\n");
1240 debug_tree (BINFO_TYPE (elem
));
1241 if (BINFO_VTABLE (elem
))
1242 fprintf (stderr
, "vtable decl \"%s\"\n", IDENTIFIER_POINTER (DECL_NAME (BINFO_VTABLE (elem
))));
1244 fprintf (stderr
, "no vtable decl yet\n");
1245 fprintf (stderr
, "virtuals:\n");
1246 virtuals
= BINFO_VIRTUALS (elem
);
1249 virtuals
= TREE_CHAIN (virtuals
);
1251 virtuals
= TREE_CHAIN (virtuals
);
1256 tree fndecl
= TREE_OPERAND (FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (virtuals
)), 0);
1257 fprintf (stderr
, "%s [%d =? %d]\n",
1258 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
)),
1259 i
, TREE_INT_CST_LOW (DECL_VINDEX (fndecl
)));
1260 virtuals
= TREE_CHAIN (virtuals
);
1265 /* Return the length of a chain of nodes chained through DECL_CHAIN.
1266 We expect a null pointer to mark the end of the chain.
1267 This is the Lisp primitive `length'. */
1270 decl_list_length (t
)
1274 register int len
= 0;
1276 my_friendly_assert (TREE_CODE (t
) == FUNCTION_DECL
1277 || TREE_CODE (t
) == TEMPLATE_DECL
, 300);
1278 for (tail
= t
; tail
; tail
= DECL_CHAIN (tail
))
1288 if (TREE_CODE (t
) == FUNCTION_DECL
)
1291 return decl_list_length (TREE_VALUE (t
));
1294 /* Like value_member, but for DECL_CHAINs. */
1296 decl_value_member (elem
, list
)
1303 list
= DECL_CHAIN (list
);
1309 is_overloaded_fn (x
)
1312 if (TREE_CODE (x
) == FUNCTION_DECL
)
1315 if (TREE_CODE (x
) == TREE_LIST
1316 && (TREE_CODE (TREE_VALUE (x
)) == FUNCTION_DECL
1317 || TREE_CODE (TREE_VALUE (x
)) == TEMPLATE_DECL
))
1324 really_overloaded_fn (x
)
1327 if (TREE_CODE (x
) == TREE_LIST
1328 && (TREE_CODE (TREE_VALUE (x
)) == FUNCTION_DECL
1329 || TREE_CODE (TREE_VALUE (x
)) == TEMPLATE_DECL
))
1339 if (TREE_CODE (from
) == FUNCTION_DECL
)
1342 my_friendly_assert (TREE_CODE (from
) == TREE_LIST
, 9);
1344 return TREE_VALUE (from
);
1348 fnaddr_from_vtable_entry (entry
)
1351 if (flag_vtable_thunks
)
1354 if (TREE_CODE (func
) == ADDR_EXPR
)
1355 func
= TREE_OPERAND (func
, 0);
1356 if (TREE_CODE (func
) == THUNK_DECL
)
1357 return DECL_INITIAL (func
);
1362 return TREE_VALUE (TREE_CHAIN (TREE_CHAIN (CONSTRUCTOR_ELTS (entry
))));
1366 set_fnaddr_from_vtable_entry (entry
, value
)
1369 if (flag_vtable_thunks
)
1372 TREE_VALUE (TREE_CHAIN (TREE_CHAIN (CONSTRUCTOR_ELTS (entry
)))) = value
;
1376 function_arg_chain (t
)
1379 return TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (t
)));
1383 promotes_to_aggr_type (t
, code
)
1385 enum tree_code code
;
1387 if (TREE_CODE (t
) == code
)
1389 return IS_AGGR_TYPE (t
);
1393 is_aggr_type_2 (t1
, t2
)
1396 if (TREE_CODE (t1
) != TREE_CODE (t2
))
1398 return IS_AGGR_TYPE (t1
) && IS_AGGR_TYPE (t2
);
1401 /* Give message using types TYPE1 and TYPE2 as arguments.
1402 PFN is the function which will print the message;
1403 S is the format string for PFN to use. */
1405 message_2_types (pfn
, s
, type1
, type2
)
1410 tree name1
= TYPE_NAME (type1
);
1411 tree name2
= TYPE_NAME (type2
);
1412 if (TREE_CODE (name1
) == TYPE_DECL
)
1413 name1
= DECL_NAME (name1
);
1414 if (TREE_CODE (name2
) == TYPE_DECL
)
1415 name2
= DECL_NAME (name2
);
1416 (*pfn
) (s
, IDENTIFIER_POINTER (name1
), IDENTIFIER_POINTER (name2
));
1419 #define PRINT_RING_SIZE 4
1422 lang_printable_name (decl
)
1425 static tree decl_ring
[PRINT_RING_SIZE
];
1426 static char *print_ring
[PRINT_RING_SIZE
];
1427 static int ring_counter
;
1430 /* Only cache functions. */
1431 if (TREE_CODE (decl
) != FUNCTION_DECL
1432 || DECL_LANG_SPECIFIC (decl
) == 0)
1433 return decl_as_string (decl
, 1);
1435 /* See if this print name is lying around. */
1436 for (i
= 0; i
< PRINT_RING_SIZE
; i
++)
1437 if (decl_ring
[i
] == decl
)
1438 /* yes, so return it. */
1439 return print_ring
[i
];
1441 if (++ring_counter
== PRINT_RING_SIZE
)
1444 if (current_function_decl
!= NULL_TREE
)
1446 if (decl_ring
[ring_counter
] == current_function_decl
)
1448 if (ring_counter
== PRINT_RING_SIZE
)
1450 if (decl_ring
[ring_counter
] == current_function_decl
)
1451 my_friendly_abort (106);
1454 if (print_ring
[ring_counter
])
1455 free (print_ring
[ring_counter
]);
1458 int print_ret_type_p
1459 = (!DECL_CONSTRUCTOR_P (decl
)
1460 && !DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (decl
)));
1462 char *name
= (char *)decl_as_string (decl
, print_ret_type_p
);
1463 print_ring
[ring_counter
] = (char *)malloc (strlen (name
) + 1);
1464 strcpy (print_ring
[ring_counter
], name
);
1465 decl_ring
[ring_counter
] = decl
;
1467 return print_ring
[ring_counter
];
1470 /* Comparison function for sorting identifiers in RAISES lists.
1471 Note that because IDENTIFIER_NODEs are unique, we can sort
1472 them by address, saving an indirection. */
1477 return (HOST_WIDE_INT
)TREE_VALUE (*p1
) - (HOST_WIDE_INT
)TREE_VALUE (*p2
);
1480 /* Build the FUNCTION_TYPE or METHOD_TYPE which may raise exceptions
1481 listed in RAISES. */
1483 build_exception_variant (ctype
, type
, raises
)
1488 tree v
= TYPE_MAIN_VARIANT (type
);
1490 tree
*a
= (tree
*)alloca ((list_length (raises
)+1) * sizeof (tree
));
1491 int constp
= TYPE_READONLY (type
);
1492 int volatilep
= TYPE_VOLATILE (type
);
1494 if (raises
&& TREE_CHAIN (raises
))
1496 for (i
= 0, t
= raises
; t
; t
= TREE_CHAIN (t
), i
++)
1498 /* NULL terminator for list. */
1500 qsort (a
, i
, sizeof (tree
), id_cmp
);
1502 TREE_CHAIN (a
[i
]) = a
[i
+1];
1508 return build_type_variant (v
, constp
, volatilep
);
1512 cname
= TYPE_NAME (ctype
);
1513 if (TREE_CODE (cname
) == TYPE_DECL
)
1514 cname
= DECL_NAME (cname
);
1519 for (t
= raises
; t
; t
= TREE_CHAIN (t
))
1521 /* See that all the exceptions we are thinking about
1522 raising have been declared. */
1523 tree this_cname
= lookup_exception_cname (ctype
, cname
, t
);
1524 tree decl
= lookup_exception_object (this_cname
, TREE_VALUE (t
), 1);
1526 if (decl
== NULL_TREE
)
1527 decl
= lookup_exception_object (this_cname
, TREE_VALUE (t
), 0);
1528 /* Place canonical exception decl into TREE_TYPE of RAISES list. */
1529 TREE_TYPE (t
) = decl
;
1532 for (v
= TYPE_NEXT_VARIANT (v
); v
; v
= TYPE_NEXT_VARIANT (v
))
1534 if (TYPE_READONLY (v
) != constp
1535 || TYPE_VOLATILE (v
) != volatilep
)
1539 t2
= TYPE_RAISES_EXCEPTIONS (v
);
1542 if (TREE_TYPE (t
) == TREE_TYPE (t2
))
1545 t2
= TREE_CHAIN (t2
);
1551 /* List of exceptions raised matches previously found list.
1553 @@ Nice to free up storage used in consing up the
1554 @@ list of exceptions raised. */
1558 /* Need to build a new variant. */
1559 v
= copy_node (type
);
1560 TYPE_NEXT_VARIANT (v
) = TYPE_NEXT_VARIANT (type
);
1561 TYPE_NEXT_VARIANT (type
) = v
;
1562 if (raises
&& ! TREE_PERMANENT (raises
))
1564 push_obstacks_nochange ();
1565 end_temporary_allocation ();
1566 raises
= copy_list (raises
);
1569 TYPE_RAISES_EXCEPTIONS (v
) = raises
;
1573 /* Subroutine of copy_to_permanent
1575 Assuming T is a node build bottom-up, make it all exist on
1576 permanent obstack, if it is not permanent already. */
1581 enum tree_code code
;
1583 if (t
== NULL_TREE
|| TREE_PERMANENT (t
))
1586 switch (code
= TREE_CODE (t
))
1589 return error_mark_node
;
1598 tree chain
= TREE_CHAIN (t
);
1600 TREE_CHAIN (t
) = make_deep_copy (chain
);
1601 TREE_TYPE (t
) = make_deep_copy (TREE_TYPE (t
));
1602 DECL_INITIAL (t
) = make_deep_copy (DECL_INITIAL (t
));
1603 DECL_SIZE (t
) = make_deep_copy (DECL_SIZE (t
));
1609 tree chain
= TREE_CHAIN (t
);
1611 TREE_PURPOSE (t
) = make_deep_copy (TREE_PURPOSE (t
));
1612 TREE_VALUE (t
) = make_deep_copy (TREE_VALUE (t
));
1613 TREE_CHAIN (t
) = make_deep_copy (chain
);
1619 int len
= TREE_VEC_LENGTH (t
);
1623 TREE_VEC_ELT (t
, len
) = make_deep_copy (TREE_VEC_ELT (t
, len
));
1630 return copy_node (t
);
1636 TREE_OPERAND (t
, 0) = make_deep_copy (TREE_OPERAND (t
, 0));
1637 TREE_OPERAND (t
, 1) = make_deep_copy (TREE_OPERAND (t
, 1));
1638 TREE_OPERAND (t
, 2) = make_deep_copy (TREE_OPERAND (t
, 2));
1643 TREE_OPERAND (t
, 0) = make_deep_copy (TREE_OPERAND (t
, 0));
1650 case TRUNC_DIV_EXPR
:
1651 case TRUNC_MOD_EXPR
:
1659 case BIT_ANDTC_EXPR
:
1660 case TRUTH_ANDIF_EXPR
:
1661 case TRUTH_ORIF_EXPR
:
1669 case FLOOR_DIV_EXPR
:
1670 case ROUND_DIV_EXPR
:
1672 case FLOOR_MOD_EXPR
:
1673 case ROUND_MOD_EXPR
:
1675 case PREDECREMENT_EXPR
:
1676 case PREINCREMENT_EXPR
:
1677 case POSTDECREMENT_EXPR
:
1678 case POSTINCREMENT_EXPR
:
1681 TREE_OPERAND (t
, 0) = make_deep_copy (TREE_OPERAND (t
, 0));
1682 TREE_OPERAND (t
, 1) = make_deep_copy (TREE_OPERAND (t
, 1));
1690 case TRUTH_NOT_EXPR
:
1694 TREE_OPERAND (t
, 0) = make_deep_copy (TREE_OPERAND (t
, 0));
1697 /* This list is incomplete, but should suffice for now.
1698 It is very important that `sorry' does not call
1699 `report_error_function'. That could cause an infinite loop. */
1701 sorry ("initializer contains unrecognized tree code");
1702 return error_mark_node
;
1705 my_friendly_abort (107);
1710 /* Assuming T is a node built bottom-up, make it all exist on
1711 permanent obstack, if it is not permanent already. */
1713 copy_to_permanent (t
)
1716 register struct obstack
*ambient_obstack
= current_obstack
;
1717 register struct obstack
*ambient_saveable_obstack
= saveable_obstack
;
1719 if (t
== NULL_TREE
|| TREE_PERMANENT (t
))
1722 saveable_obstack
= &permanent_obstack
;
1723 current_obstack
= saveable_obstack
;
1725 t
= make_deep_copy (t
);
1727 current_obstack
= ambient_obstack
;
1728 saveable_obstack
= ambient_saveable_obstack
;
1734 print_lang_statistics ()
1736 extern struct obstack maybepermanent_obstack
;
1737 print_obstack_statistics ("class_obstack", &class_obstack
);
1738 print_obstack_statistics ("permanent_obstack", &permanent_obstack
);
1739 print_obstack_statistics ("maybepermanent_obstack", &maybepermanent_obstack
);
1740 print_search_statistics ();
1741 print_class_statistics ();
1744 /* This is used by the `assert' macro. It is provided in libgcc.a,
1745 which `cc' doesn't know how to link. Note that the C++ front-end
1746 no longer actually uses the `assert' macro (instead, it calls
1747 my_friendly_assert). But all of the back-end files still need this. */
1749 __eprintf (string
, expression
, line
, filename
)
1752 const char *expression
;
1754 const char *filename
;
1762 fprintf (stderr
, string
, expression
, line
, filename
);
1767 /* Return, as an INTEGER_CST node, the number of elements for
1768 TYPE (which is an ARRAY_TYPE). This counts only elements of the top array. */
1771 array_type_nelts_top (type
)
1774 return fold (build (PLUS_EXPR
, integer_type_node
,
1775 array_type_nelts (type
),
1779 /* Return, as an INTEGER_CST node, the number of elements for
1780 TYPE (which is an ARRAY_TYPE). This one is a recursive count of all
1781 ARRAY_TYPEs that are clumped together. */
1784 array_type_nelts_total (type
)
1787 tree sz
= array_type_nelts_top (type
);
1788 type
= TREE_TYPE (type
);
1789 while (TREE_CODE (type
) == ARRAY_TYPE
)
1791 tree n
= array_type_nelts_top (type
);
1792 sz
= fold (build (MULT_EXPR
, integer_type_node
, sz
, n
));
1793 type
= TREE_TYPE (type
);