Commit 849da744 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (vtbl_ptr_type_node): New variable.

	* cp-tree.h (vtbl_ptr_type_node): New variable.
	* class.c (build_vtbl_ref): Don't indirect through the vptr; it's
	already of the right type.
	(finish_struct_1): Make the vptr be of type vtbl_ptr_type_node.
	Simplify code to grow vtable.
	* decl.c (vtbl_ptr_type_node): Define.
	(init_decl_processing): Initialize it.

From-SVN: r22879
parent 4c2f8346
1998-10-07 Mark Mitchell <mark@markmitchell.com>
* cp-tree.h (vtbl_ptr_type_node): New variable.
* class.c (build_vtbl_ref): Don't indirect through the vptr; it's
already of the right type.
(finish_struct_1): Make the vptr be of type vtbl_ptr_type_node.
Simplify code to grow vtable.
* decl.c (vtbl_ptr_type_node): Define.
(init_decl_processing): Initialize it.
1998-10-06 Mark Mitchell <mark@markmitchell.com>
* cp-tree.def (PTRMEM_CST): New tree node.
......
......@@ -501,8 +501,7 @@ build_vtbl_ref (instance, idx)
basetype = TREE_TYPE (basetype);
if (instance == current_class_ref)
vtbl = build_indirect_ref (build_vfield_ref (instance, basetype),
NULL_PTR);
vtbl = build_vfield_ref (instance, basetype);
else
{
if (optimize)
......@@ -542,8 +541,7 @@ build_vtbl_ref (instance, idx)
|| TREE_CODE (instance) == VAR_DECL))
vtbl = TYPE_BINFO_VTABLE (basetype);
else
vtbl = build_indirect_ref (build_vfield_ref (instance, basetype),
NULL_PTR);
vtbl = build_vfield_ref (instance, basetype);
}
assemble_external (vtbl);
......@@ -3782,7 +3780,7 @@ finish_struct_1 (t, warn_anon)
/* We build this decl with ptr_type_node, and
change the type when we know what it should be. */
vfield = build_lang_field_decl (FIELD_DECL, get_vfield_name (t),
ptr_type_node);
vtbl_ptr_type_node);
/* If you change any of the below, take a look at all the
other VFIELD_BASEs and VTABLE_BASEs in the code, and change
them too. */
......@@ -4090,38 +4088,15 @@ finish_struct_1 (t, warn_anon)
/* Now lay out the virtual function table. */
if (has_virtual)
{
tree atype, itype;
/* Use size_int so values are memoized in common cases. */
tree itype = build_index_type (size_int (has_virtual));
tree atype = build_array_type (vtable_entry_type, itype);
if (TREE_TYPE (vfield) == ptr_type_node)
{
/* We must create a pointer to this table because
the one inherited from base class does not exist.
We will fill in the type when we know what it
should really be. Use `size_int' so values are memoized
in common cases. */
itype = build_index_type (size_int (has_virtual));
atype = build_array_type (vtable_entry_type, itype);
layout_type (atype);
TREE_TYPE (vfield) = build_pointer_type (atype);
}
else
{
atype = TREE_TYPE (TREE_TYPE (vfield));
if (has_virtual != TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (atype))))
{
/* We must extend (or create) the boundaries on this array,
because we picked up virtual functions from multiple
base classes. */
itype = build_index_type (size_int (has_virtual));
atype = build_array_type (vtable_entry_type, itype);
layout_type (atype);
vfield = copy_node (vfield);
TREE_TYPE (vfield) = build_pointer_type (atype);
}
}
layout_type (atype);
CLASSTYPE_VFIELD (t) = vfield;
/* We may have to grow the vtable. */
if (TREE_TYPE (TYPE_BINFO_VTABLE (t)) != atype)
{
TREE_TYPE (TYPE_BINFO_VTABLE (t)) = atype;
......
......@@ -1931,8 +1931,10 @@ extern tree opaque_type_node, signature_type_node;
#define vfunc_ptr_type_node \
(flag_vtable_thunks ? vtable_entry_type : ptr_type_node)
/* Array type `(void *)[]' */
/* The type of a vtbl, i.e., an array of vtable entries. */
extern tree vtbl_type_node;
/* The type of a class vtbl pointer, i.e., a pointer to a vtable entry. */
extern tree vtbl_ptr_type_node;
extern tree delta_type_node;
extern tree std_node;
......
......@@ -329,6 +329,7 @@ tree sigtable_entry_type;
/* Array type `vtable_entry_type[]' */
tree vtbl_type_node;
tree vtbl_ptr_type_node;
/* namespace std */
tree std_node;
......@@ -6148,6 +6149,9 @@ init_decl_processing ()
layout_type (vtbl_type_node);
vtbl_type_node = cp_build_type_variant (vtbl_type_node, 1, 0);
record_builtin_type (RID_MAX, NULL_PTR, vtbl_type_node);
vtbl_ptr_type_node = build_pointer_type (vtable_entry_type);
layout_type (vtbl_ptr_type_node);
record_builtin_type (RID_MAX, NULL_PTR, vtbl_ptr_type_node);
/* Simplify life by making a "sigtable_entry_type". Give its
fields names so that the debugger can use them. */
......
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