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
}
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))
{
{
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);
}
}
}
fixup_inline_methods (tree type)
{
tree method = TYPE_METHODS (type);
+ VEC (tree) *friends;
+ unsigned ix;
if (method && TREE_CODE (method) == TREE_VEC)
{
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
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
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;
/* 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. */
/* 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) \
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;
}
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;
{
/* 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.
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));
}
\f
/* DEPTH-FIRST SEARCH ROUTINES. */
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))
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)
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",