aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog1
-rw-r--r--gcc/cp/call.c18
-rw-r--r--gcc/cp/class.c19
-rw-r--r--gcc/cp/cp-tree.h13
-rw-r--r--gcc/cp/decl.c4
-rw-r--r--gcc/cp/search.c10
-rw-r--r--gcc/cp/typeck2.c28
7 files changed, 48 insertions, 45 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 34f011a..4a82c08 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index c08fb74..f7701ab 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -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))
{
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index d31295a..a92bb8e 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -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
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 22ac165..433403c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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) \
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e56023b..8047f9e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
}
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index f547e6c..c68fc3c 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -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. */
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 548d089..44f6483 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -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",