This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Possible fix for c++/7780: -Woverloaded-virtual generatingfalse-positives
- From: Loren Osborn <linux_dr at yahoo dot com>
- To: gcc-gnats at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: 01 Sep 2002 22:53:34 -0700
- Subject: Possible fix for c++/7780: -Woverloaded-virtual generatingfalse-positives
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7780
I have a possible fix for PR/7780... This is my first time hacking gcc, so
all feedback is very welcome. I also submitted another bug (PR/7714) and I
would appreciate any insights you could offer WRT it also.
Thank you,
-Loren Osborn
Software Developer
Index: gcc/cp/class.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.465
diff -u -r1.465 class.c
--- gcc/cp/class.c 27 Aug 2002 22:14:47 -0000 1.465
+++ gcc/cp/class.c 2 Sep 2002 05:50:43 -0000
@@ -2741,12 +2741,16 @@
tree fndecl;
tree base_fndecls;
int j;
+ int matches_found;
+ int all_found_matches;
/* All functions in this slot in the CLASSTYPE_METHOD_VEC will
have the same name. Figure out what name that is. */
name = DECL_NAME (OVL_CURRENT (TREE_VEC_ELT (method_vec, i)));
/* There are no possibly hidden functions yet. */
base_fndecls = NULL_TREE;
+ matches_found = 0;
+ all_found_matches = 1;
/* Iterate through all of the base classes looking for possibly
hidden functions. */
for (j = 0; j < CLASSTYPE_N_BASECLASSES (t); j++)
@@ -2767,15 +2771,21 @@
if (DECL_VINDEX (fndecl))
{
tree *prev = &base_fndecls;
+ matches_found = 0;
while (*prev)
/* If the method from the base class has the same
signature as the method from the derived class, it
has been overridden. */
if (same_signature_p (fndecl, TREE_VALUE (*prev)))
+ {
*prev = TREE_CHAIN (*prev);
+ matches_found ++ ;
+ }
else
prev = &TREE_CHAIN (*prev);
+ if(matches_found == 0)
+ all_found_matches = 0;
}
}
@@ -2783,10 +2793,13 @@
as they are hidden. */
while (base_fndecls)
{
- /* Here we know it is a hider, and no overrider exists. */
- cp_warning_at ("`%D' was hidden", TREE_VALUE (base_fndecls));
- cp_warning_at (" by `%D'",
+ if (all_found_matches == 0)
+ {
+ /* Here we know it is a hider, and no overrider exists. */
+ cp_warning_at ("`%D' was hidden", TREE_VALUE (base_fndecls));
+ cp_warning_at (" by `%D'",
OVL_CURRENT (TREE_VEC_ELT (method_vec, i)));
+ }
base_fndecls = TREE_CHAIN (base_fndecls);
}
}