aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@gcc.gnu.org>2005-10-18 12:30:32 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2005-10-18 12:30:32 +0000
commitb77fe7b45f5a162d5d0f3cc64044281220076c04 (patch)
tree8c6ffe176818c794b78be35002d3b48a05a4cf5d /gcc/cp/class.c
parent6d7e9a3582b6ce807b1d380c757cf50e5f41ec65 (diff)
downloadgcc-b77fe7b45f5a162d5d0f3cc64044281220076c04.zip
gcc-b77fe7b45f5a162d5d0f3cc64044281220076c04.tar.gz
gcc-b77fe7b45f5a162d5d0f3cc64044281220076c04.tar.bz2
re PR c++/22604 (ICE after invalid covariant return)
cp: PR c++/22604 * class.c (update_vtable_entry_for_fn): Don't process invalid covariant overriders. PR c++/23118 * cp-tree.h (add_method): Add return value. * class.c (add_method): Return success indicator. * semantics.c (finish_member_declaration): Don't add an invalid method to the method list. testsuite: PR c++/23118 * g++.dg/overload/error2.C: New. PR c++/22604 * g++.dg/inherit/covariant14.C: New. From-SVN: r105549
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r--gcc/cp/class.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index b8254fe..ff5190a 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -879,9 +879,10 @@ modify_vtable_entry (tree t,
/* Add method METHOD to class TYPE. If USING_DECL is non-null, it is
- the USING_DECL naming METHOD. */
+ the USING_DECL naming METHOD. Returns true if the method could be
+ added to the method vec. */
-void
+bool
add_method (tree type, tree method, tree using_decl)
{
unsigned slot;
@@ -894,7 +895,7 @@ add_method (tree type, tree method, tree using_decl)
tree current_fns;
if (method == error_mark_node)
- return;
+ return false;
complete_p = COMPLETE_TYPE_P (type);
conv_p = DECL_CONV_FN_P (method);
@@ -1027,7 +1028,7 @@ add_method (tree type, tree method, tree using_decl)
{
if (DECL_CONTEXT (fn) == type)
/* Defer to the local function. */
- return;
+ return false;
if (DECL_CONTEXT (fn) == DECL_CONTEXT (method))
error ("repeated using declaration %q+D", using_decl);
else
@@ -1044,7 +1045,7 @@ add_method (tree type, tree method, tree using_decl)
declarations because that will confuse things if the
methods have inline definitions. In particular, we
will crash while processing the definitions. */
- return;
+ return false;
}
}
}
@@ -1069,6 +1070,7 @@ add_method (tree type, tree method, tree using_decl)
else
/* Replace the current slot. */
VEC_replace (tree, method_vec, slot, overload);
+ return true;
}
/* Subroutines of finish_struct. */
@@ -1980,7 +1982,9 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals,
if (POINTER_TYPE_P (over_return)
&& TREE_CODE (over_return) == TREE_CODE (base_return)
&& CLASS_TYPE_P (TREE_TYPE (over_return))
- && CLASS_TYPE_P (TREE_TYPE (base_return)))
+ && CLASS_TYPE_P (TREE_TYPE (base_return))
+ /* If the overrider is invalid, don't even try. */
+ && !DECL_INVALID_OVERRIDER_P (overrider_target))
{
/* If FN is a covariant thunk, we must figure out the adjustment
to the final base FN was converting to. As OVERRIDER_TARGET might