This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
(C++) patch to -Woverloaded-virtuals
- To: gcc-patches at gcc dot gnu dot org
- Subject: (C++) patch to -Woverloaded-virtuals
- From: Jason Merrill <jason at cygnus dot com>
- Date: Mon, 2 Aug 1999 15:58:47 -0700
warn_hidden was assuming that all overloads of a given name would be
virtual or non-virtual, which broke g++.other/virtual6.C.
1999-08-02 Jason Merrill <jason@yorick.cygnus.com>
* class.c (mark_overriders): Fix order of args to overrides.
(warn_hidden): Likewise. Fix for having virtual and non-virtual
functions with the same name.
Index: class.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/class.c,v
retrieving revision 1.169
diff -c -p -r1.169 class.c
*** class.c 1999/07/27 20:17:13 1.169
--- class.c 1999/08/02 22:57:14
*************** get_basefndecls (fndecl, t)
*** 2923,2940 ****
/* Mark the functions that have been hidden with their overriders.
Since we start out with all functions already marked with a hider,
! no need to mark functions that are just hidden. */
static void
mark_overriders (fndecl, base_fndecls)
tree fndecl, base_fndecls;
{
! while (base_fndecls)
{
! if (overrides (TREE_VALUE (base_fndecls), fndecl))
TREE_PURPOSE (base_fndecls) = fndecl;
-
- base_fndecls = TREE_CHAIN (base_fndecls);
}
}
--- 2923,2940 ----
/* Mark the functions that have been hidden with their overriders.
Since we start out with all functions already marked with a hider,
! no need to mark functions that are just hidden.
+ Subroutine of warn_hidden. */
+
static void
mark_overriders (fndecl, base_fndecls)
tree fndecl, base_fndecls;
{
! for (; base_fndecls; base_fndecls = TREE_CHAIN (base_fndecls))
{
! if (overrides (fndecl, TREE_VALUE (base_fndecls)))
TREE_PURPOSE (base_fndecls) = fndecl;
}
}
*************** warn_hidden (t)
*** 3021,3029 ****
tree base_fndecls = NULL_TREE;
tree binfos = BINFO_BASETYPES (TYPE_BINFO (t));
int i, n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0;
! fndecl = OVL_CURRENT (fns);
! if (DECL_VINDEX (fndecl) == NULL_TREE)
continue;
/* First we get a list of all possible functions that might be
--- 3021,3036 ----
tree base_fndecls = NULL_TREE;
tree binfos = BINFO_BASETYPES (TYPE_BINFO (t));
int i, n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ /* First see if we have any virtual functions in this batch. */
+ for (; fns; fns = OVL_NEXT (fns))
+ {
+ fndecl = OVL_CURRENT (fns);
+ if (DECL_VINDEX (fndecl))
+ break;
+ }
! if (fns == NULL_TREE)
continue;
/* First we get a list of all possible functions that might be
*************** warn_hidden (t)
*** 3038,3075 ****
}
fns = OVL_NEXT (fns);
- if (fns)
- fndecl = OVL_CURRENT (fns);
- else
- fndecl = NULL_TREE;
/* ...then mark up all the base functions with overriders, preferring
overriders to hiders. */
if (base_fndecls)
! while (fndecl)
{
! mark_overriders (fndecl, base_fndecls);
!
! fns = OVL_NEXT (fns);
! if (fns)
! fndecl = OVL_CURRENT (fns);
! else
! fndecl = NULL_TREE;
}
/* Now give a warning for all base functions without overriders,
as they are hidden. */
! while (base_fndecls)
{
! if (! overrides (TREE_VALUE (base_fndecls),
! TREE_PURPOSE (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'", TREE_PURPOSE (base_fndecls));
}
-
- base_fndecls = TREE_CHAIN (base_fndecls);
}
}
}
--- 3045,3072 ----
}
fns = OVL_NEXT (fns);
/* ...then mark up all the base functions with overriders, preferring
overriders to hiders. */
if (base_fndecls)
! for (; fns; fns = OVL_NEXT (fns))
{
! fndecl = OVL_CURRENT (fns);
! if (DECL_VINDEX (fndecl))
! mark_overriders (fndecl, base_fndecls);
}
/* Now give a warning for all base functions without overriders,
as they are hidden. */
! for (; base_fndecls; base_fndecls = TREE_CHAIN (base_fndecls))
{
! if (! overrides (TREE_PURPOSE (base_fndecls),
! TREE_VALUE (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'", TREE_PURPOSE (base_fndecls));
}
}
}
}