Commit 86cfdb4e by Trevor Saunders Committed by Trevor Saunders

remove tree_list from warn_hidden ()

cp/

	* class.c (warn_hidden): Use auto_vec<tree> instead of tree_list to
	hold base_fndecls.
	(get_basefndecls): Adjust.

From-SVN: r219212
parent f7d47c8a
2015-01-05 Trevor Saunders <tsaunders@mozilla.com>
* class.c (warn_hidden): Use auto_vec<tree> instead of tree_list to
hold base_fndecls.
(get_basefndecls): Adjust.
2015-01-05 Jakub Jelinek <jakub@redhat.com> 2015-01-05 Jakub Jelinek <jakub@redhat.com>
Update copyright years. Update copyright years.
......
...@@ -129,7 +129,7 @@ vec<tree, va_gc> *local_classes; ...@@ -129,7 +129,7 @@ vec<tree, va_gc> *local_classes;
static tree get_vfield_name (tree); static tree get_vfield_name (tree);
static void finish_struct_anon (tree); static void finish_struct_anon (tree);
static tree get_vtable_name (tree); static tree get_vtable_name (tree);
static tree get_basefndecls (tree, tree); static void get_basefndecls (tree, tree, vec<tree> *);
static int build_primary_vtable (tree, tree); static int build_primary_vtable (tree, tree);
static int build_secondary_vtable (tree); static int build_secondary_vtable (tree);
static void finish_vtbls (tree); static void finish_vtbls (tree);
...@@ -2751,16 +2751,16 @@ modify_all_vtables (tree t, tree virtuals) ...@@ -2751,16 +2751,16 @@ modify_all_vtables (tree t, tree virtuals)
/* Get the base virtual function declarations in T that have the /* Get the base virtual function declarations in T that have the
indicated NAME. */ indicated NAME. */
static tree static void
get_basefndecls (tree name, tree t) get_basefndecls (tree name, tree t, vec<tree> *base_fndecls)
{ {
tree methods; tree methods;
tree base_fndecls = NULL_TREE;
int n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (t)); int n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (t));
int i; int i;
/* Find virtual functions in T with the indicated NAME. */ /* Find virtual functions in T with the indicated NAME. */
i = lookup_fnfields_1 (t, name); i = lookup_fnfields_1 (t, name);
bool found_decls = false;
if (i != -1) if (i != -1)
for (methods = (*CLASSTYPE_METHOD_VEC (t))[i]; for (methods = (*CLASSTYPE_METHOD_VEC (t))[i];
methods; methods;
...@@ -2770,20 +2770,20 @@ get_basefndecls (tree name, tree t) ...@@ -2770,20 +2770,20 @@ get_basefndecls (tree name, tree t)
if (TREE_CODE (method) == FUNCTION_DECL if (TREE_CODE (method) == FUNCTION_DECL
&& DECL_VINDEX (method)) && DECL_VINDEX (method))
base_fndecls = tree_cons (NULL_TREE, method, base_fndecls); {
base_fndecls->safe_push (method);
found_decls = true;
}
} }
if (base_fndecls) if (found_decls)
return base_fndecls; return;
for (i = 0; i < n_baseclasses; i++) for (i = 0; i < n_baseclasses; i++)
{ {
tree basetype = BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (t), i)); tree basetype = BINFO_TYPE (BINFO_BASE_BINFO (TYPE_BINFO (t), i));
base_fndecls = chainon (get_basefndecls (name, basetype), get_basefndecls (name, basetype, base_fndecls);
base_fndecls);
} }
return base_fndecls;
} }
/* If this declaration supersedes the declaration of /* If this declaration supersedes the declaration of
...@@ -2845,7 +2845,6 @@ warn_hidden (tree t) ...@@ -2845,7 +2845,6 @@ warn_hidden (tree t)
tree fn; tree fn;
tree name; tree name;
tree fndecl; tree fndecl;
tree base_fndecls;
tree base_binfo; tree base_binfo;
tree binfo; tree binfo;
int j; int j;
...@@ -2854,19 +2853,18 @@ warn_hidden (tree t) ...@@ -2854,19 +2853,18 @@ warn_hidden (tree t)
have the same name. Figure out what name that is. */ have the same name. Figure out what name that is. */
name = DECL_NAME (OVL_CURRENT (fns)); name = DECL_NAME (OVL_CURRENT (fns));
/* There are no possibly hidden functions yet. */ /* There are no possibly hidden functions yet. */
base_fndecls = NULL_TREE; auto_vec<tree, 20> base_fndecls;
/* Iterate through all of the base classes looking for possibly /* Iterate through all of the base classes looking for possibly
hidden functions. */ hidden functions. */
for (binfo = TYPE_BINFO (t), j = 0; for (binfo = TYPE_BINFO (t), j = 0;
BINFO_BASE_ITERATE (binfo, j, base_binfo); j++) BINFO_BASE_ITERATE (binfo, j, base_binfo); j++)
{ {
tree basetype = BINFO_TYPE (base_binfo); tree basetype = BINFO_TYPE (base_binfo);
base_fndecls = chainon (get_basefndecls (name, basetype), get_basefndecls (name, basetype, &base_fndecls);
base_fndecls);
} }
/* If there are no functions to hide, continue. */ /* If there are no functions to hide, continue. */
if (!base_fndecls) if (base_fndecls.is_empty ())
continue; continue;
/* Remove any overridden functions. */ /* Remove any overridden functions. */
...@@ -2876,28 +2874,27 @@ warn_hidden (tree t) ...@@ -2876,28 +2874,27 @@ warn_hidden (tree t)
if (TREE_CODE (fndecl) == FUNCTION_DECL if (TREE_CODE (fndecl) == FUNCTION_DECL
&& DECL_VINDEX (fndecl)) && DECL_VINDEX (fndecl))
{ {
tree *prev = &base_fndecls;
while (*prev)
/* If the method from the base class has the same /* If the method from the base class has the same
signature as the method from the derived class, it signature as the method from the derived class, it
has been overridden. */ has been overridden. */
if (same_signature_p (fndecl, TREE_VALUE (*prev))) for (size_t k = 0; k < base_fndecls.length (); k++)
*prev = TREE_CHAIN (*prev); if (base_fndecls[k]
else && same_signature_p (fndecl, base_fndecls[k]))
prev = &TREE_CHAIN (*prev); base_fndecls[k] = NULL_TREE;
} }
} }
/* Now give a warning for all base functions without overriders, /* Now give a warning for all base functions without overriders,
as they are hidden. */ as they are hidden. */
while (base_fndecls) size_t k;
{ tree base_fndecl;
/* Here we know it is a hider, and no overrider exists. */ FOR_EACH_VEC_ELT (base_fndecls, k, base_fndecl)
warning (OPT_Woverloaded_virtual, "%q+D was hidden", TREE_VALUE (base_fndecls)); if (base_fndecl)
warning (OPT_Woverloaded_virtual, " by %q+D", fns); {
base_fndecls = TREE_CHAIN (base_fndecls); /* Here we know it is a hider, and no overrider exists. */
} warning (OPT_Woverloaded_virtual, "%q+D was hidden", base_fndecl);
warning (OPT_Woverloaded_virtual, " by %q+D", fns);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment