Commit 940ab2e0 by Nathan Sidwell Committed by Nathan Sidwell

class.c (warn_hidden): Don't barf on non-functions.

	* class.c (warn_hidden): Don't barf on non-functions.
	* decl2.c (check_classfn): Likewise.  Check template match earlier.

From-SVN: r251795
parent 1887fb46
2017-09-06 Nathan Sidwell <nathan@acm.org>
* class.c (warn_hidden): Don't barf on non-functions.
* decl2.c (check_classfn): Likewise. Check template match earlier.
* name-lookup.c (count_fields): Rename to ...
(count_class_fields): ... here. Take a class, don't count
NULL-named fields.
......
......@@ -2818,17 +2818,19 @@ check_for_override (tree decl, tree ctype)
static void
warn_hidden (tree t)
{
vec<tree, va_gc> *method_vec = CLASSTYPE_METHOD_VEC (t);
tree fns;
/* We go through each separately named virtual function. */
for (int i = 0; vec_safe_iterate (method_vec, i, &fns); ++i)
if (vec<tree, va_gc> *method_vec = CLASSTYPE_METHOD_VEC (t))
for (unsigned ix = method_vec->length (); ix--;)
{
tree fns = (*method_vec)[ix];
if (!OVL_P (fns))
continue;
tree name = OVL_NAME (fns);
auto_vec<tree, 20> base_fndecls;
tree base_binfo;
tree binfo;
int j;
unsigned j;
/* Iterate through all of the base classes looking for possibly
hidden functions. */
......@@ -2862,9 +2864,8 @@ warn_hidden (tree t)
/* Now give a warning for all base functions without overriders,
as they are hidden. */
size_t k;
tree base_fndecl;
FOR_EACH_VEC_ELT (base_fndecls, k, base_fndecl)
FOR_EACH_VEC_ELT (base_fndecls, j, base_fndecl)
if (base_fndecl)
{
/* Here we know it is a hider, and no overrider exists. */
......@@ -6981,7 +6982,7 @@ unreverse_member_declarations (tree t)
/* For the TYPE_FIELDS, only the non TYPE_DECLs are in reverse
order, so we can't just use nreverse. Due to stat_hack
chicanery in finish_member_declarations. */
chicanery in finish_member_declaration. */
prev = NULL_TREE;
for (x = TYPE_FIELDS (t);
x && TREE_CODE (x) != TYPE_DECL;
......
......@@ -611,6 +611,15 @@ check_classfn (tree ctype, tree function, tree template_parms)
for (ovl_iterator iter (fns); !matched && iter; ++iter)
{
tree fndecl = *iter;
/* A member template definition only matches a member template
declaration. */
if (is_template != (TREE_CODE (fndecl) == TEMPLATE_DECL))
continue;
if (!DECL_DECLARES_FUNCTION_P (fndecl))
continue;
tree p1 = TYPE_ARG_TYPES (TREE_TYPE (function));
tree p2 = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
......@@ -625,11 +634,6 @@ check_classfn (tree ctype, tree function, tree template_parms)
&& TREE_CODE (TREE_TYPE (function)) == METHOD_TYPE)
p1 = TREE_CHAIN (p1);
/* A member template definition only matches a member template
declaration. */
if (is_template != (TREE_CODE (fndecl) == TEMPLATE_DECL))
continue;
/* ref-qualifier or absence of same must match. */
if (type_memfn_rqual (TREE_TYPE (function))
!= type_memfn_rqual (TREE_TYPE (fndecl)))
......
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