[C++ PATCH] Fix final overrider diagnostics (PR c++/21983)
Jakub Jelinek
jakub@redhat.com
Mon Sep 5 15:16:00 GMT 2005
Hi!
Since http://gcc.gnu.org/ml/gcc-patches/2002-11/msg00535.html
find_final_overrider is called not only from update_vtable_entry_for_fn,
but also possibly several times from add_vcall_offset.
But as it is find_final_overrider that issues the diagnostics,
the same error is printed multiple times (in the testcase below
4 times).
My understanding is that update_vtable_entry_for_fn will call
find_final_overrider for each virtual function once, so it should be
enough to warn there (it was certainly enough in GCC 3.2.x).
Ok for HEAD/4.0/3.4 if testing succeeds?
2005-09-05 Jakub Jelinek <jakub@redhat.com>
PR c++/21983
* class.c (find_final_overrider): Move diagnostic about no unique final
overrider to...
(update_vtable_entry_for_fn): ... here.
--- gcc/cp/class.c.jj 2005-08-16 16:24:16.000000000 +0200
+++ gcc/cp/class.c 2005-09-05 17:03:08.000000000 +0200
@@ -1906,11 +1906,7 @@ find_final_overrider (tree derived, tree
/* If there was no winner, issue an error message. */
if (!ffod.candidates || TREE_CHAIN (ffod.candidates))
- {
- error ("no unique final overrider for %qD in %qT", fn,
- BINFO_TYPE (derived));
- return error_mark_node;
- }
+ return error_mark_node;
return ffod.candidates;
}
@@ -1970,7 +1966,10 @@ update_vtable_entry_for_fn (tree t, tree
/* Find the final overrider. */
overrider = find_final_overrider (TYPE_BINFO (t), b, target_fn);
if (overrider == error_mark_node)
- return;
+ {
+ error ("no unique final overrider for %qD in %qT", target_fn, t);
+ return;
+ }
overrider_target = overrider_fn = TREE_PURPOSE (overrider);
/* Check for adjusting covariant return types. */
--- gcc/testsuite/g++.dg/warn/pr21983.C.jj 2005-09-05 17:06:42.000000000 +0200
+++ gcc/testsuite/g++.dg/warn/pr21983.C 2005-09-05 17:08:06.000000000 +0200
@@ -0,0 +1,7 @@
+// PR c++/21983
+// { dg-do compile }
+
+struct B { virtual void foo () = 0; };
+struct D1 : public virtual B { virtual void foo () {} };
+struct D2 : public virtual B { virtual void foo () {} };
+struct D : public D1, public D2 { }; // { dg-warning "no unique final overrider" }
Jakub
More information about the Gcc-patches
mailing list