Commit 585b44d3 by Nathan Sidwell

cp-tree.h (struct lang_type_class): Make pure_virtuals a VEC(tree).

	* cp-tree.h (struct lang_type_class): Make pure_virtuals a
	VEC(tree).
	(CLASSTYPE_INLINE_FRIENDS, CLASSTYPE_PURE_VIRTUALS): Update
	comments.
	* call.c (build_new_method_call): Don't confirm a pure virtual is
	in CLASSTYPE_PURE_VIRTUALS.  Reorder checks. Make it a warning.
	* class.c (check_methods): CLASSTYPE_INLINE_FRIENDS is a VEC(tree).
	(fixup_inline_methods, finish_struct): Likewise.
	* decl.c (finish_method): Likewise.
	* search.c (dfs_get_pure_virtuals, get_pure_virtuals):
	CLASSTYPE_PURE_VIRTUALS is a VEC(tree).
	* typeck2.c (abstract_virtuals_error): Likewise. Truncate the
	vector to avoid repeating the list in error messages.

From-SVN: r87592
parent 45f17969
......@@ -433,7 +433,6 @@
2004-09-13 Kenneth Zadeck <Kenneth.Zadeck@NaturalBridge.com>
* tree-ssa-operands.c (get_call_expr_operands): Added parm to
add_call_clobber_ops and add_call_read_ops.
(add_call_clobber_ops, add_call_read_ops): Added code to reduce
......
......@@ -5312,16 +5312,18 @@ build_new_method_call (tree instance, tree fns, tree args,
}
else
{
if (DECL_PURE_VIRTUAL_P (cand->fn)
if (!(flags & LOOKUP_NONVIRTUAL)
&& DECL_PURE_VIRTUAL_P (cand->fn)
&& instance == current_class_ref
&& (DECL_CONSTRUCTOR_P (current_function_decl)
|| DECL_DESTRUCTOR_P (current_function_decl))
&& ! (flags & LOOKUP_NONVIRTUAL)
&& value_member (cand->fn, CLASSTYPE_PURE_VIRTUALS (basetype)))
error ((DECL_CONSTRUCTOR_P (current_function_decl) ?
"abstract virtual `%#D' called from constructor"
: "abstract virtual `%#D' called from destructor"),
cand->fn);
|| DECL_DESTRUCTOR_P (current_function_decl)))
/* This is not an error, it is runtime undefined
behaviour. */
warning ((DECL_CONSTRUCTOR_P (current_function_decl) ?
"abstract virtual `%#D' called from constructor"
: "abstract virtual `%#D' called from destructor"),
cand->fn);
if (TREE_CODE (TREE_TYPE (cand->fn)) == METHOD_TYPE
&& is_dummy_object (instance_ptr))
{
......
......@@ -3750,8 +3750,7 @@ check_methods (tree t)
{
TYPE_POLYMORPHIC_P (t) = 1;
if (DECL_PURE_VIRTUAL_P (x))
CLASSTYPE_PURE_VIRTUALS (t)
= tree_cons (NULL_TREE, x, CLASSTYPE_PURE_VIRTUALS (t));
VEC_safe_push (tree, CLASSTYPE_PURE_VIRTUALS (t), x);
}
}
}
......@@ -4281,6 +4280,8 @@ static void
fixup_inline_methods (tree type)
{
tree method = TYPE_METHODS (type);
VEC (tree) *friends;
unsigned ix;
if (method && TREE_CODE (method) == TREE_VEC)
{
......@@ -4297,11 +4298,10 @@ fixup_inline_methods (tree type)
fixup_pending_inline (method);
/* Do friends. */
for (method = CLASSTYPE_INLINE_FRIENDS (type);
method;
method = TREE_CHAIN (method))
fixup_pending_inline (TREE_VALUE (method));
CLASSTYPE_INLINE_FRIENDS (type) = NULL_TREE;
for (friends = CLASSTYPE_INLINE_FRIENDS (type), ix = 0;
VEC_iterate (tree, friends, ix, method); ix++)
fixup_pending_inline (method);
CLASSTYPE_INLINE_FRIENDS (type) = NULL;
}
/* Add OFFSET to all base types of BINFO which is a base in the
......@@ -5183,11 +5183,10 @@ finish_struct (tree t, tree attributes)
the PARM_DECLS. Note that while the type is being defined,
CLASSTYPE_PURE_VIRTUALS contains the list of the inline friends
(see CLASSTYPE_INLINE_FRIENDS) so we need to clear it. */
CLASSTYPE_PURE_VIRTUALS (t) = NULL_TREE;
CLASSTYPE_PURE_VIRTUALS (t) = NULL;
for (x = TYPE_METHODS (t); x; x = TREE_CHAIN (x))
if (DECL_PURE_VIRTUAL_P (x))
CLASSTYPE_PURE_VIRTUALS (t)
= tree_cons (NULL_TREE, x, CLASSTYPE_PURE_VIRTUALS (t));
VEC_safe_push (tree, CLASSTYPE_PURE_VIRTUALS (t), x);
complete_vars (t);
}
else
......
......@@ -1039,7 +1039,7 @@ struct lang_type_class GTY(())
VEC (tree) *vbases;
binding_table nested_udts;
tree as_base;
tree pure_virtuals;
VEC (tree) *pure_virtuals;
tree friend_classes;
VEC (tree) * GTY((reorder ("resort_type_method_vec"))) methods;
tree key_method;
......@@ -1096,7 +1096,8 @@ struct lang_type GTY(())
/* Fields used for storing information before the class is defined.
After the class is defined, these fields hold other information. */
/* List of friends which were defined inline in this class definition. */
/* VEC(tree) of friends which were defined inline in this class
definition. */
#define CLASSTYPE_INLINE_FRIENDS(NODE) CLASSTYPE_PURE_VIRTUALS (NODE)
/* Nonzero for _CLASSTYPE means that operator delete is defined. */
......@@ -1303,12 +1304,14 @@ struct lang_type GTY(())
/* True if this a Java interface type, declared with
'__attribute__ ((java_interface))'. */
#define TYPE_JAVA_INTERFACE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->java_interface)
#define TYPE_JAVA_INTERFACE(NODE) \
(LANG_TYPE_CLASS_CHECK (NODE)->java_interface)
/* A cons list of virtual functions which cannot be inherited by
/* A VEC(tree) of virtual functions which cannot be inherited by
derived classes. When deriving from this type, the derived
class must provide its own definition for each of these functions. */
#define CLASSTYPE_PURE_VIRTUALS(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->pure_virtuals)
#define CLASSTYPE_PURE_VIRTUALS(NODE) \
(LANG_TYPE_CLASS_CHECK (NODE)->pure_virtuals)
/* Nonzero means that this type has an X() constructor. */
#define TYPE_HAS_DEFAULT_CONSTRUCTOR(NODE) \
......
......@@ -10673,8 +10673,8 @@ finish_method (tree decl)
for String.cc in libg++. */
if (DECL_FRIEND_P (fndecl))
{
CLASSTYPE_INLINE_FRIENDS (current_class_type)
= tree_cons (NULL_TREE, fndecl, CLASSTYPE_INLINE_FRIENDS (current_class_type));
VEC_safe_push (tree, CLASSTYPE_INLINE_FRIENDS (current_class_type),
fndecl);
decl = void_type_node;
}
......
......@@ -1875,9 +1875,8 @@ dfs_get_pure_virtuals (tree binfo, void *data)
virtuals;
virtuals = TREE_CHAIN (virtuals))
if (DECL_PURE_VIRTUAL_P (BV_FN (virtuals)))
CLASSTYPE_PURE_VIRTUALS (type)
= tree_cons (NULL_TREE, BV_FN (virtuals),
CLASSTYPE_PURE_VIRTUALS (type));
VEC_safe_push (tree, CLASSTYPE_PURE_VIRTUALS (type),
BV_FN (virtuals));
}
BINFO_MARKED (binfo) = 1;
......@@ -1892,7 +1891,7 @@ get_pure_virtuals (tree type)
{
/* Clear the CLASSTYPE_PURE_VIRTUALS list; whatever is already there
is going to be overridden. */
CLASSTYPE_PURE_VIRTUALS (type) = NULL_TREE;
CLASSTYPE_PURE_VIRTUALS (type) = NULL;
/* Now, run through all the bases which are not primary bases, and
collect the pure virtual functions. We look at the vtable in
each class to determine what pure virtual functions are present.
......@@ -1901,9 +1900,6 @@ get_pure_virtuals (tree type)
pure virtuals in the base class. */
dfs_walk (TYPE_BINFO (type), dfs_get_pure_virtuals, unmarkedp, type);
dfs_walk (TYPE_BINFO (type), dfs_unmark, markedp, type);
/* Put the pure virtuals in dfs order. */
CLASSTYPE_PURE_VIRTUALS (type) = nreverse (CLASSTYPE_PURE_VIRTUALS (type));
}
/* DEPTH-FIRST SEARCH ROUTINES. */
......
......@@ -235,9 +235,8 @@ complete_type_check_abstract (tree type)
int
abstract_virtuals_error (tree decl, tree type)
{
tree u;
tree tu;
VEC (tree) *pure;
/* This function applies only to classes. Any other entity can never
be abstract. */
if (!CLASS_TYPE_P (type))
......@@ -275,15 +274,15 @@ abstract_virtuals_error (tree decl, tree type)
return 0;
}
if (!CLASSTYPE_PURE_VIRTUALS (type))
return 0;
if (!TYPE_SIZE (type))
/* TYPE is being defined, and during that time
CLASSTYPE_PURE_VIRTUALS holds the inline friends. */
return 0;
u = CLASSTYPE_PURE_VIRTUALS (type);
pure = CLASSTYPE_PURE_VIRTUALS (type);
if (!pure)
return 0;
if (decl)
{
if (TREE_CODE (decl) == RESULT_DECL)
......@@ -316,15 +315,20 @@ abstract_virtuals_error (tree decl, tree type)
error ("cannot allocate an object of abstract type `%T'", type);
/* Only go through this once. */
if (TREE_PURPOSE (u) == NULL_TREE)
if (VEC_length (tree, pure))
{
TREE_PURPOSE (u) = error_mark_node;
unsigned ix;
tree fn;
inform ("%J because the following virtual functions are pure "
"within `%T':", TYPE_MAIN_DECL (type), type);
for (tu = u; tu; tu = TREE_CHAIN (tu))
inform ("%J\t%#D", TREE_VALUE (tu), TREE_VALUE (tu));
for (ix = 0; VEC_iterate (tree, pure, ix, fn); ix++)
inform ("%J\t%#D", fn, fn);
/* Now truncate the vector. This leaves it non-null, so we know
there are pure virtuals, but empty so we don't list them out
again. */
VEC_truncate (tree, pure, 0);
}
else
inform ("%J since type `%T' has pure virtual functions",
......
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