Commit 329745f7 by Jason Merrill Committed by Jason Merrill

class.c (build_vtable_entry): Use int_fits_type_p.

	* class.c (build_vtable_entry): Use int_fits_type_p.
	(build_vtable): Pass a signed offset to build_vtable_entry.
	(prepare_fresh_vtable, modify_one_vtable, fixup_vtable_deltas1,
	set_rtti_entry): Likewise.

From-SVN: r19964
parent 697073d9
1998-05-22 Jason Merrill <jason@yorick.cygnus.com>
* class.c (build_vtable_entry): Use int_fits_type_p.
(build_vtable): Pass a signed offset to build_vtable_entry.
(prepare_fresh_vtable, modify_one_vtable, fixup_vtable_deltas1,
set_rtti_entry): Likewise.
1998-05-22 Per Bothner <bothner@cygnus.com> 1998-05-22 Per Bothner <bothner@cygnus.com>
* cp-tree.h: Add comments documenting which LANG_FLAGS are used. * cp-tree.h: Add comments documenting which LANG_FLAGS are used.
......
...@@ -450,15 +450,11 @@ build_vtable_entry (delta, pfn) ...@@ -450,15 +450,11 @@ build_vtable_entry (delta, pfn)
build_expr_list (NULL_TREE, pfn))); build_expr_list (NULL_TREE, pfn)));
tree entry = build (CONSTRUCTOR, vtable_entry_type, NULL_TREE, elems); tree entry = build (CONSTRUCTOR, vtable_entry_type, NULL_TREE, elems);
/* DELTA is constructed by `size_int', which means it may be an /* DELTA used to be constructed by `size_int' and/or size_binop,
unsigned quantity on some platforms. Therefore, we cannot use which caused overflow problems when it was negative. That should
`int_fits_type_p', because when DELTA is really negative, be fixed now. */
`force_fit_type' will make it look like a very large number. */
if (! int_fits_type_p (delta, delta_type_node))
if ((TREE_INT_CST_LOW (TYPE_MAX_VALUE (delta_type_node))
< TREE_INT_CST_LOW (delta))
|| (TREE_INT_CST_LOW (delta)
< TREE_INT_CST_LOW (TYPE_MIN_VALUE (delta_type_node))))
{ {
if (flag_huge_objects) if (flag_huge_objects)
sorry ("object size exceeds built-in limit for virtual function table implementation"); sorry ("object size exceeds built-in limit for virtual function table implementation");
...@@ -663,11 +659,11 @@ set_rtti_entry (virtuals, offset, type) ...@@ -663,11 +659,11 @@ set_rtti_entry (virtuals, offset, type)
tree voff = build1 (NOP_EXPR, vfunc_ptr_type_node, offset); tree voff = build1 (NOP_EXPR, vfunc_ptr_type_node, offset);
TREE_CONSTANT (voff) = 1; TREE_CONSTANT (voff) = 1;
TREE_VALUE (virtuals) = build_vtable_entry (size_zero_node, voff); TREE_VALUE (virtuals) = build_vtable_entry (integer_zero_node, voff);
/* The second slot is for the tdesc pointer when thunks are used. */ /* The second slot is for the tdesc pointer when thunks are used. */
TREE_VALUE (TREE_CHAIN (virtuals)) TREE_VALUE (TREE_CHAIN (virtuals))
= build_vtable_entry (size_zero_node, vfn); = build_vtable_entry (integer_zero_node, vfn);
} }
} }
...@@ -692,7 +688,7 @@ build_vtable (binfo, type) ...@@ -692,7 +688,7 @@ build_vtable (binfo, type)
/* Now do rtti stuff. */ /* Now do rtti stuff. */
offset = get_derived_offset (TYPE_BINFO (type), NULL_TREE); offset = get_derived_offset (TYPE_BINFO (type), NULL_TREE);
offset = size_binop (MINUS_EXPR, size_zero_node, offset); offset = ssize_binop (MINUS_EXPR, integer_zero_node, offset);
set_rtti_entry (virtuals, offset, type); set_rtti_entry (virtuals, offset, type);
} }
else else
...@@ -884,7 +880,7 @@ prepare_fresh_vtable (binfo, for_type) ...@@ -884,7 +880,7 @@ prepare_fresh_vtable (binfo, for_type)
offset = BINFO_OFFSET (binfo); offset = BINFO_OFFSET (binfo);
set_rtti_entry (BINFO_VIRTUALS (binfo), set_rtti_entry (BINFO_VIRTUALS (binfo),
size_binop (MINUS_EXPR, signed_size_zero_node, offset), ssize_binop (MINUS_EXPR, integer_zero_node, offset),
for_type); for_type);
#ifdef GATHER_STATISTICS #ifdef GATHER_STATISTICS
...@@ -2327,7 +2323,7 @@ modify_one_vtable (binfo, t, fndecl, pfn) ...@@ -2327,7 +2323,7 @@ modify_one_vtable (binfo, t, fndecl, pfn)
base_offset = size_binop (PLUS_EXPR, base_offset = size_binop (PLUS_EXPR,
get_derived_offset (binfo, DECL_CONTEXT (current_fndecl)), get_derived_offset (binfo, DECL_CONTEXT (current_fndecl)),
BINFO_OFFSET (binfo)); BINFO_OFFSET (binfo));
this_offset = size_binop (MINUS_EXPR, offset, base_offset); this_offset = ssize_binop (MINUS_EXPR, offset, base_offset);
/* Make sure we can modify the derived association with immunity. */ /* Make sure we can modify the derived association with immunity. */
if (TREE_USED (binfo)) if (TREE_USED (binfo))
...@@ -2424,9 +2420,10 @@ fixup_vtable_deltas1 (binfo, t) ...@@ -2424,9 +2420,10 @@ fixup_vtable_deltas1 (binfo, t)
Also, we want just the delta between the most base class Also, we want just the delta between the most base class
that we derived this vfield from and us. */ that we derived this vfield from and us. */
base_offset = size_binop (PLUS_EXPR, base_offset = size_binop (PLUS_EXPR,
get_derived_offset (binfo, DECL_CONTEXT (fndecl)), get_derived_offset (binfo,
DECL_CONTEXT (fndecl)),
BINFO_OFFSET (binfo)); BINFO_OFFSET (binfo));
this_offset = size_binop (MINUS_EXPR, offset, base_offset); this_offset = ssize_binop (MINUS_EXPR, offset, base_offset);
if (! tree_int_cst_equal (this_offset, delta)) if (! tree_int_cst_equal (this_offset, delta))
{ {
...@@ -3986,7 +3983,7 @@ finish_struct_1 (t, warn_anon) ...@@ -3986,7 +3983,7 @@ finish_struct_1 (t, warn_anon)
/* The first slot is for the rtti offset. */ /* The first slot is for the rtti offset. */
pending_virtuals = tree_cons (NULL_TREE, NULL_TREE, pending_virtuals); pending_virtuals = tree_cons (NULL_TREE, NULL_TREE, pending_virtuals);
set_rtti_entry (pending_virtuals, size_zero_node, t); set_rtti_entry (pending_virtuals, integer_zero_node, t);
build_vtable (NULL_TREE, t); build_vtable (NULL_TREE, t);
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment