aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1999-08-02 22:59:03 +0000
committerJason Merrill <jason@gcc.gnu.org>1999-08-02 18:59:03 -0400
commita48328531e1ecafbbc767fae3c57c4127d999564 (patch)
tree3dbe2d6cc25848ae5fab98ac1d816d10103d3f43
parent1cb36a981d95f29f37fef511b88a04c48cfa90cc (diff)
downloadgcc-a48328531e1ecafbbc767fae3c57c4127d999564.zip
gcc-a48328531e1ecafbbc767fae3c57c4127d999564.tar.gz
gcc-a48328531e1ecafbbc767fae3c57c4127d999564.tar.bz2
class.c (mark_overriders): Fix order of args to overrides.
* 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. From-SVN: r28415
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/class.c45
2 files changed, 27 insertions, 24 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 675475e..9ba2082 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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.
+
1999-08-02 Richard Henderson <rth@cygnus.com>
* cp-tree.h (TYPE_PTRMEMFUNC_P): Check TYPE_LANG_SPECIFIC non-null.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 1b02b9a..4373f13 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -2923,18 +2923,18 @@ get_basefndecls (fndecl, t)
/* 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. */
+ no need to mark functions that are just hidden.
+
+ Subroutine of warn_hidden. */
static void
mark_overriders (fndecl, base_fndecls)
tree fndecl, base_fndecls;
{
- while (base_fndecls)
+ for (; base_fndecls; base_fndecls = TREE_CHAIN (base_fndecls))
{
- if (overrides (TREE_VALUE (base_fndecls), fndecl))
+ if (overrides (fndecl, TREE_VALUE (base_fndecls)))
TREE_PURPOSE (base_fndecls) = fndecl;
-
- base_fndecls = TREE_CHAIN (base_fndecls);
}
}
@@ -3022,8 +3022,15 @@ warn_hidden (t)
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)
+ /* 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
@@ -3038,38 +3045,28 @@ warn_hidden (t)
}
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)
+ for (; fns; fns = OVL_NEXT (fns))
{
- mark_overriders (fndecl, base_fndecls);
-
- fns = OVL_NEXT (fns);
- if (fns)
- fndecl = OVL_CURRENT (fns);
- else
- fndecl = NULL_TREE;
+ 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. */
- while (base_fndecls)
+ for (; base_fndecls; base_fndecls = TREE_CHAIN (base_fndecls))
{
- if (! overrides (TREE_VALUE (base_fndecls),
- TREE_PURPOSE (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));
}
-
- base_fndecls = TREE_CHAIN (base_fndecls);
}
}
}