Commit fee7654e by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (lang_type): Replace abstract_virtuals with pure_virtuals.

	* cp-tree.h (lang_type): Replace abstract_virtuals with pure_virtuals.
	(CLASSTYPE_ABSTRACT_VIRTUALS): Rename to ...
	(CLASSTYPE_PURE_VIRTUALS): ... this.
	(lang_decl_flags): Replace abstract_virtual with pure_virtual.
	(DECL_ABSTRACT_VIRTUAL_P): Rename to ...
	(DECL_PURE_VIRTUAL_P): ... this.
	(get_abstract_virtuals): Rename to ...
	(get_pure_virtuals): ... this.
	* call.c (build_new_method_call): Replace DECL_PURE_VIRTUAL_P with
	DECL_ABSTRACT_VIRTUAL_P.  Replace CLASSTYPE_ABSTRACT_VIRTUALS with
	CLASSTYPE_PURE_VIRTUALS.
	* class.c (build_vtable_entry): Likewise.
	(finish_struct_bits): Likewise.  Call get_pure_virtuals, not
	get_abstract_virtuals.
	(build_vtbl_initializer): Likewise.
	(override_one_vtable): Likewise.
	(check_methods): Likewise.
	* decl.c (duplicate_decls): Likewise.
	(redeclaration_error_message): Likewise.
	(lang_mark_tree): Likewise.
	* decl2.c (grok_function_init): Likewise.
	(import_export_vtable): Likewise.
	(import_expor_class): Likewise.
	* typeck2.c (abstract_virtuals_error): Likewise.
	* xref.c (GNU_xref_member): Likewise.
	* search.c (get_abstract_virtuals): Rename to get_pure_virtuals.

From-SVN: r31114
parent 0430641b
1999-12-28 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (lang_type): Replace abstract_virtuals with pure_virtuals.
(CLASSTYPE_ABSTRACT_VIRTUALS): Rename to ...
(CLASSTYPE_PURE_VIRTUALS): ... this.
(lang_decl_flags): Replace abstract_virtual with pure_virtual.
(DECL_ABSTRACT_VIRTUAL_P): Rename to ...
(DECL_PURE_VIRTUAL_P): ... this.
(get_abstract_virtuals): Rename to ...
(get_pure_virtuals): ... this.
* call.c (build_new_method_call): Replace DECL_PURE_VIRTUAL_P with
DECL_ABSTRACT_VIRTUAL_P. Replace CLASSTYPE_ABSTRACT_VIRTUALS with
CLASSTYPE_PURE_VIRTUALS.
* class.c (build_vtable_entry): Likewise.
(finish_struct_bits): Likewise. Call get_pure_virtuals, not
get_abstract_virtuals.
(build_vtbl_initializer): Likewise.
(override_one_vtable): Likewise.
(check_methods): Likewise.
* decl.c (duplicate_decls): Likewise.
(redeclaration_error_message): Likewise.
(lang_mark_tree): Likewise.
* decl2.c (grok_function_init): Likewise.
(import_export_vtable): Likewise.
(import_expor_class): Likewise.
* typeck2.c (abstract_virtuals_error): Likewise.
* xref.c (GNU_xref_member): Likewise.
* search.c (get_abstract_virtuals): Rename to get_pure_virtuals.
1999-12-26 Zack Weinberg <zack@wolery.cumb.org> 1999-12-26 Zack Weinberg <zack@wolery.cumb.org>
* cp-tree.h: Replace ENABLE_CHECKING with ENABLE_TREE_CHECKING * cp-tree.h: Replace ENABLE_CHECKING with ENABLE_TREE_CHECKING
......
...@@ -4319,11 +4319,11 @@ build_new_method_call (instance, name, args, basetype_path, flags) ...@@ -4319,11 +4319,11 @@ build_new_method_call (instance, name, args, basetype_path, flags)
return error_mark_node; return error_mark_node;
} }
if (DECL_ABSTRACT_VIRTUAL_P (cand->fn) if (DECL_PURE_VIRTUAL_P (cand->fn)
&& instance == current_class_ref && instance == current_class_ref
&& DECL_CONSTRUCTOR_P (current_function_decl) && DECL_CONSTRUCTOR_P (current_function_decl)
&& ! (flags & LOOKUP_NONVIRTUAL) && ! (flags & LOOKUP_NONVIRTUAL)
&& value_member (cand->fn, CLASSTYPE_ABSTRACT_VIRTUALS (basetype))) && value_member (cand->fn, CLASSTYPE_PURE_VIRTUALS (basetype)))
cp_error ("abstract virtual `%#D' called from constructor", cand->fn); cp_error ("abstract virtual `%#D' called from constructor", cand->fn);
if (TREE_CODE (TREE_TYPE (cand->fn)) == METHOD_TYPE if (TREE_CODE (TREE_TYPE (cand->fn)) == METHOD_TYPE
&& is_dummy_object (instance_ptr)) && is_dummy_object (instance_ptr))
......
...@@ -389,7 +389,7 @@ build_vtable_entry (delta, pfn) ...@@ -389,7 +389,7 @@ build_vtable_entry (delta, pfn)
if (flag_vtable_thunks) if (flag_vtable_thunks)
{ {
HOST_WIDE_INT idelta = TREE_INT_CST_LOW (delta); HOST_WIDE_INT idelta = TREE_INT_CST_LOW (delta);
if (idelta && ! DECL_ABSTRACT_VIRTUAL_P (TREE_OPERAND (pfn, 0))) if (idelta && ! DECL_PURE_VIRTUAL_P (TREE_OPERAND (pfn, 0)))
{ {
pfn = build1 (ADDR_EXPR, vtable_entry_type, pfn = build1 (ADDR_EXPR, vtable_entry_type,
make_thunk (pfn, idelta)); make_thunk (pfn, idelta));
...@@ -1786,17 +1786,15 @@ finish_struct_bits (t, max_has_virtual) ...@@ -1786,17 +1786,15 @@ finish_struct_bits (t, max_has_virtual)
} }
if (n_baseclasses && max_has_virtual) if (n_baseclasses && max_has_virtual)
{ /* For a class w/o baseclasses, `finish_struct' has set
/* For a class w/o baseclasses, `finish_struct' has set CLASS_TYPE_ABSTRACT_VIRTUALS correctly (by
CLASS_TYPE_ABSTRACT_VIRTUALS correctly (by definition). Similarly definition). Similarly for a class whose base classes do not
for a class who's base classes do not have vtables. When neither have vtables. When neither of these is true, we might have
of these is true, we might have removed abstract virtuals (by removed abstract virtuals (by providing a definition), added
providing a definition), added some (by declaring new ones), or some (by declaring new ones), or redeclared ones from a base
redeclared ones from a base class. We need to recalculate what's class. We need to recalculate what's really an abstract virtual
really an abstract virtual at this point (by looking in the at this point (by looking in the vtables). */
vtables). */ get_pure_virtuals (t);
CLASSTYPE_ABSTRACT_VIRTUALS (t) = get_abstract_virtuals (t);
}
if (n_baseclasses) if (n_baseclasses)
{ {
...@@ -2251,7 +2249,7 @@ build_vtbl_initializer (binfo) ...@@ -2251,7 +2249,7 @@ build_vtbl_initializer (binfo)
/* You can't call an abstract virtual function; it's abstract. /* You can't call an abstract virtual function; it's abstract.
So, we replace these functions with __pure_virtual. */ So, we replace these functions with __pure_virtual. */
if (DECL_ABSTRACT_VIRTUAL_P (fn)) if (DECL_PURE_VIRTUAL_P (fn))
fn = abort_fndecl; fn = abort_fndecl;
/* Package up that information for the vtable. */ /* Package up that information for the vtable. */
...@@ -2806,8 +2804,8 @@ override_one_vtable (binfo, old, t) ...@@ -2806,8 +2804,8 @@ override_one_vtable (binfo, old, t)
copy_lang_decl (fndecl); copy_lang_decl (fndecl);
DECL_NEEDS_FINAL_OVERRIDER_P (fndecl) = 1; DECL_NEEDS_FINAL_OVERRIDER_P (fndecl) = 1;
/* Make sure we search for it later. */ /* Make sure we search for it later. */
if (! CLASSTYPE_ABSTRACT_VIRTUALS (t)) if (! CLASSTYPE_PURE_VIRTUALS (t))
CLASSTYPE_ABSTRACT_VIRTUALS (t) = error_mark_node; CLASSTYPE_PURE_VIRTUALS (t) = error_mark_node;
/* We can use integer_zero_node, as we will core dump /* We can use integer_zero_node, as we will core dump
if this is used anyway. */ if this is used anyway. */
...@@ -3922,7 +3920,7 @@ check_methods (t) ...@@ -3922,7 +3920,7 @@ check_methods (t)
DECL_FIELD_SIZE (x) = 0; DECL_FIELD_SIZE (x) = 0;
check_for_override (x, t); check_for_override (x, t);
if (DECL_ABSTRACT_VIRTUAL_P (x) && ! DECL_VINDEX (x)) if (DECL_PURE_VIRTUAL_P (x) && ! DECL_VINDEX (x))
cp_error_at ("initializer specified for non-virtual method `%D'", x); cp_error_at ("initializer specified for non-virtual method `%D'", x);
/* The name of the field is the original field name /* The name of the field is the original field name
...@@ -3930,9 +3928,9 @@ check_methods (t) ...@@ -3930,9 +3928,9 @@ check_methods (t)
if (DECL_VINDEX (x)) if (DECL_VINDEX (x))
{ {
TYPE_POLYMORPHIC_P (t) = 1; TYPE_POLYMORPHIC_P (t) = 1;
if (DECL_ABSTRACT_VIRTUAL_P (x)) if (DECL_PURE_VIRTUAL_P (x))
CLASSTYPE_ABSTRACT_VIRTUALS (t) CLASSTYPE_PURE_VIRTUALS (t)
= tree_cons (NULL_TREE, x, CLASSTYPE_ABSTRACT_VIRTUALS (t)); = tree_cons (NULL_TREE, x, CLASSTYPE_PURE_VIRTUALS (t));
} }
} }
} }
......
...@@ -1240,7 +1240,7 @@ struct lang_type ...@@ -1240,7 +1240,7 @@ struct lang_type
union tree_node *size; union tree_node *size;
union tree_node *abstract_virtuals; union tree_node *pure_virtuals;
union tree_node *friend_classes; union tree_node *friend_classes;
union tree_node *rtti; union tree_node *rtti;
...@@ -1428,7 +1428,7 @@ struct lang_type ...@@ -1428,7 +1428,7 @@ struct lang_type
/* A cons list of virtual functions which cannot be inherited by /* A cons list of virtual functions which cannot be inherited by
derived classes. When deriving from this type, the derived derived classes. When deriving from this type, the derived
class must provide its own definition for each of these functions. */ class must provide its own definition for each of these functions. */
#define CLASSTYPE_ABSTRACT_VIRTUALS(NODE) (TYPE_LANG_SPECIFIC(NODE)->abstract_virtuals) #define CLASSTYPE_PURE_VIRTUALS(NODE) (TYPE_LANG_SPECIFIC(NODE)->pure_virtuals)
/* Nonzero means that this aggr type has been `closed' by a semicolon. */ /* Nonzero means that this aggr type has been `closed' by a semicolon. */
#define CLASSTYPE_GOT_SEMICOLON(NODE) (TYPE_LANG_SPECIFIC (NODE)->got_semicolon) #define CLASSTYPE_GOT_SEMICOLON(NODE) (TYPE_LANG_SPECIFIC (NODE)->got_semicolon)
...@@ -1612,7 +1612,7 @@ struct lang_decl_flags ...@@ -1612,7 +1612,7 @@ struct lang_decl_flags
unsigned static_function : 1; unsigned static_function : 1;
unsigned const_memfunc : 1; unsigned const_memfunc : 1;
unsigned volatile_memfunc : 1; unsigned volatile_memfunc : 1;
unsigned abstract_virtual : 1; unsigned pure_virtual : 1;
unsigned constructor_for_vbase_attr : 1; unsigned constructor_for_vbase_attr : 1;
unsigned mutable_flag : 1; unsigned mutable_flag : 1;
...@@ -1780,9 +1780,9 @@ struct lang_decl ...@@ -1780,9 +1780,9 @@ struct lang_decl
constructor. */ constructor. */
#define DECL_NONCONVERTING_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.nonconverting) #define DECL_NONCONVERTING_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.nonconverting)
/* Nonzero for FUNCTION_DECL means that this member function /* Nonzero for FUNCTION_DECL means that this member function is a pure
exists as part of an abstract class's interface. */ virtual function. */
#define DECL_ABSTRACT_VIRTUAL_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.abstract_virtual) #define DECL_PURE_VIRTUAL_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.pure_virtual)
/* Nonzero for FUNCTION_DECL means that this member function /* Nonzero for FUNCTION_DECL means that this member function
must be overridden by derived classes. */ must be overridden by derived classes. */
...@@ -3868,7 +3868,7 @@ extern tree lookup_fnfields PROTO((tree, tree, int)); ...@@ -3868,7 +3868,7 @@ extern tree lookup_fnfields PROTO((tree, tree, int));
extern tree lookup_member PROTO((tree, tree, int, int)); extern tree lookup_member PROTO((tree, tree, int, int));
extern tree lookup_nested_tag PROTO((tree, tree)); extern tree lookup_nested_tag PROTO((tree, tree));
extern tree get_matching_virtual PROTO((tree, tree, int)); extern tree get_matching_virtual PROTO((tree, tree, int));
extern tree get_abstract_virtuals PROTO((tree)); extern void get_pure_virtuals PROTO((tree));
extern tree init_vbase_pointers PROTO((tree, tree)); extern tree init_vbase_pointers PROTO((tree, tree));
extern void expand_indirect_vtbls_init PROTO((tree, tree, tree)); extern void expand_indirect_vtbls_init PROTO((tree, tree, tree));
extern void clear_search_slots PROTO((tree)); extern void clear_search_slots PROTO((tree));
......
...@@ -3247,7 +3247,7 @@ duplicate_decls (newdecl, olddecl) ...@@ -3247,7 +3247,7 @@ duplicate_decls (newdecl, olddecl)
DECL_PENDING_INLINE_INFO (newdecl) = DECL_PENDING_INLINE_INFO (olddecl); DECL_PENDING_INLINE_INFO (newdecl) = DECL_PENDING_INLINE_INFO (olddecl);
DECL_STATIC_CONSTRUCTOR (newdecl) |= DECL_STATIC_CONSTRUCTOR (olddecl); DECL_STATIC_CONSTRUCTOR (newdecl) |= DECL_STATIC_CONSTRUCTOR (olddecl);
DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl); DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl);
DECL_ABSTRACT_VIRTUAL_P (newdecl) |= DECL_ABSTRACT_VIRTUAL_P (olddecl); DECL_PURE_VIRTUAL_P (newdecl) |= DECL_PURE_VIRTUAL_P (olddecl);
DECL_VIRTUAL_P (newdecl) |= DECL_VIRTUAL_P (olddecl); DECL_VIRTUAL_P (newdecl) |= DECL_VIRTUAL_P (olddecl);
DECL_NEEDS_FINAL_OVERRIDER_P (newdecl) |= DECL_NEEDS_FINAL_OVERRIDER_P (olddecl); DECL_NEEDS_FINAL_OVERRIDER_P (newdecl) |= DECL_NEEDS_FINAL_OVERRIDER_P (olddecl);
DECL_THIS_STATIC (newdecl) |= DECL_THIS_STATIC (olddecl); DECL_THIS_STATIC (newdecl) |= DECL_THIS_STATIC (olddecl);
...@@ -4523,7 +4523,7 @@ redeclaration_error_message (newdecl, olddecl) ...@@ -4523,7 +4523,7 @@ redeclaration_error_message (newdecl, olddecl)
/* If this is a pure function, its olddecl will actually be /* If this is a pure function, its olddecl will actually be
the original initialization to `0' (which we force to call the original initialization to `0' (which we force to call
abort()). Don't complain about redefinition in this case. */ abort()). Don't complain about redefinition in this case. */
if (DECL_LANG_SPECIFIC (olddecl) && DECL_ABSTRACT_VIRTUAL_P (olddecl)) if (DECL_LANG_SPECIFIC (olddecl) && DECL_PURE_VIRTUAL_P (olddecl))
return 0; return 0;
/* If both functions come from different namespaces, this is not /* If both functions come from different namespaces, this is not
...@@ -14519,7 +14519,7 @@ lang_mark_tree (t) ...@@ -14519,7 +14519,7 @@ lang_mark_tree (t)
ggc_mark_tree (lt->tags); ggc_mark_tree (lt->tags);
ggc_mark_tree (lt->search_slot); ggc_mark_tree (lt->search_slot);
ggc_mark_tree (lt->size); ggc_mark_tree (lt->size);
ggc_mark_tree (lt->abstract_virtuals); ggc_mark_tree (lt->pure_virtuals);
ggc_mark_tree (lt->friend_classes); ggc_mark_tree (lt->friend_classes);
ggc_mark_tree (lt->rtti); ggc_mark_tree (lt->rtti);
ggc_mark_tree (lt->methods); ggc_mark_tree (lt->methods);
......
...@@ -1880,7 +1880,7 @@ grok_function_init (decl, init) ...@@ -1880,7 +1880,7 @@ grok_function_init (decl, init)
DECL_RTL (decl) = DECL_RTL (abort_fndecl); DECL_RTL (decl) = DECL_RTL (abort_fndecl);
} }
#endif #endif
DECL_ABSTRACT_VIRTUAL_P (decl) = 1; DECL_PURE_VIRTUAL_P (decl) = 1;
if (DECL_NAME (decl) == ansi_opname [(int) MODIFY_EXPR]) if (DECL_NAME (decl) == ansi_opname [(int) MODIFY_EXPR])
{ {
tree parmtype tree parmtype
...@@ -2420,7 +2420,7 @@ import_export_vtable (decl, type, final) ...@@ -2420,7 +2420,7 @@ import_export_vtable (decl, type, final)
method = TREE_CHAIN (method)) method = TREE_CHAIN (method))
if (DECL_VINDEX (method) != NULL_TREE if (DECL_VINDEX (method) != NULL_TREE
&& ! DECL_THIS_INLINE (method) && ! DECL_THIS_INLINE (method)
&& ! DECL_ABSTRACT_VIRTUAL_P (method)) && ! DECL_PURE_VIRTUAL_P (method))
{ {
found = 1; found = 1;
break; break;
...@@ -2489,7 +2489,7 @@ import_export_class (ctype) ...@@ -2489,7 +2489,7 @@ import_export_class (ctype)
{ {
if (DECL_VINDEX (method) != NULL_TREE if (DECL_VINDEX (method) != NULL_TREE
&& !DECL_THIS_INLINE (method) && !DECL_THIS_INLINE (method)
&& !DECL_ABSTRACT_VIRTUAL_P (method)) && !DECL_PURE_VIRTUAL_P (method))
{ {
import_export = (DECL_REALLY_EXTERN (method) ? -1 : 1); import_export = (DECL_REALLY_EXTERN (method) ? -1 : 1);
break; break;
......
...@@ -2138,7 +2138,7 @@ get_abstract_virtuals_1 (binfo, do_self, abstract_virtuals) ...@@ -2138,7 +2138,7 @@ get_abstract_virtuals_1 (binfo, do_self, abstract_virtuals)
while (virtuals) while (virtuals)
{ {
tree base_fndecl = TREE_VALUE (virtuals); tree base_fndecl = TREE_VALUE (virtuals);
if (DECL_ABSTRACT_VIRTUAL_P (base_fndecl)) if (DECL_PURE_VIRTUAL_P (base_fndecl))
abstract_virtuals = tree_cons (NULL_TREE, base_fndecl, abstract_virtuals = tree_cons (NULL_TREE, base_fndecl,
abstract_virtuals); abstract_virtuals);
virtuals = TREE_CHAIN (virtuals); virtuals = TREE_CHAIN (virtuals);
...@@ -2147,12 +2147,10 @@ get_abstract_virtuals_1 (binfo, do_self, abstract_virtuals) ...@@ -2147,12 +2147,10 @@ get_abstract_virtuals_1 (binfo, do_self, abstract_virtuals)
return abstract_virtuals; return abstract_virtuals;
} }
/* Return the list of virtual functions which are abstract in type TYPE. /* Set CLASSTYPE_PURE_VIRTUALS for TYPE. */
This information is cached, and so must be built on a
non-temporary obstack. */
tree void
get_abstract_virtuals (type) get_pure_virtuals (type)
tree type; tree type;
{ {
tree vbases; tree vbases;
...@@ -2173,13 +2171,14 @@ get_abstract_virtuals (type) ...@@ -2173,13 +2171,14 @@ get_abstract_virtuals (type)
tree base_fndecl = TREE_VALUE (virtuals); tree base_fndecl = TREE_VALUE (virtuals);
if (DECL_NEEDS_FINAL_OVERRIDER_P (base_fndecl)) if (DECL_NEEDS_FINAL_OVERRIDER_P (base_fndecl))
cp_error ("`%#D' needs a final overrider", base_fndecl); cp_error ("`%#D' needs a final overrider", base_fndecl);
else if (DECL_ABSTRACT_VIRTUAL_P (base_fndecl)) else if (DECL_PURE_VIRTUAL_P (base_fndecl))
abstract_virtuals = tree_cons (NULL_TREE, base_fndecl, abstract_virtuals = tree_cons (NULL_TREE, base_fndecl,
abstract_virtuals); abstract_virtuals);
virtuals = TREE_CHAIN (virtuals); virtuals = TREE_CHAIN (virtuals);
} }
} }
return nreverse (abstract_virtuals);
CLASSTYPE_PURE_VIRTUALS (type) = nreverse (abstract_virtuals);
} }
static tree static tree
......
...@@ -136,10 +136,10 @@ abstract_virtuals_error (decl, type) ...@@ -136,10 +136,10 @@ abstract_virtuals_error (decl, type)
tree u; tree u;
tree tu; tree tu;
if (!CLASS_TYPE_P (type) || !CLASSTYPE_ABSTRACT_VIRTUALS (type)) if (!CLASS_TYPE_P (type) || !CLASSTYPE_PURE_VIRTUALS (type))
return 0; return 0;
u = CLASSTYPE_ABSTRACT_VIRTUALS (type); u = CLASSTYPE_PURE_VIRTUALS (type);
if (decl) if (decl)
{ {
if (TREE_CODE (decl) == RESULT_DECL) if (TREE_CODE (decl) == RESULT_DECL)
......
...@@ -608,7 +608,7 @@ GNU_xref_member(cls, fld) ...@@ -608,7 +608,7 @@ GNU_xref_member(cls, fld)
confg = 1; confg = 1;
pure = 0; pure = 0;
if (TREE_CODE (fld) == FUNCTION_DECL && DECL_ABSTRACT_VIRTUAL_P(fld)) if (TREE_CODE (fld) == FUNCTION_DECL && DECL_PURE_VIRTUAL_P(fld))
pure = 1; pure = 1;
d = IDENTIFIER_POINTER(cls); d = IDENTIFIER_POINTER(cls);
......
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