Commit b5d9b9ab by Mark Mitchell Committed by Jason Merrill

pt.c (check_template_shadow): Don't treat OVERLOADs as _DECL nodes.

	* pt.c (check_template_shadow): Don't treat OVERLOADs as _DECL
	nodes.  Tidy.

From-SVN: r26188
parent 2a97a800
1999-04-04 Mark Mitchell <mark@codesourcery.com>
* pt.c (check_template_shadow): Don't treat OVERLOADs as _DECL
nodes. Tidy.
1999-04-03 Jason Merrill <jason@yorick.cygnus.com> 1999-04-03 Jason Merrill <jason@yorick.cygnus.com>
* class.c (maybe_fixup_vptrs, build_class_init_list): Lose. * class.c (maybe_fixup_vptrs, build_class_init_list): Lose.
......
...@@ -1599,22 +1599,38 @@ check_template_shadow (decl) ...@@ -1599,22 +1599,38 @@ check_template_shadow (decl)
{ {
tree olddecl; tree olddecl;
/* If we're not in a template, we can't possibly shadow a template
parameter. */
if (!current_template_parms)
return;
/* Figure out what we're shadowing. */
if (TREE_CODE (decl) == OVERLOAD) if (TREE_CODE (decl) == OVERLOAD)
decl = OVL_CURRENT (decl); decl = OVL_CURRENT (decl);
olddecl = IDENTIFIER_VALUE (DECL_NAME (decl)); olddecl = IDENTIFIER_VALUE (DECL_NAME (decl));
if (current_template_parms && olddecl) /* If there's no previous binding for this name, we're not shadowing
{ anything, let alone a template parameter. */
/* We check for decl != olddecl to avoid bogus errors for using a if (!olddecl)
name inside a class. We check TPFI to avoid duplicate errors for return;
inline member templates. */
if (decl != olddecl && DECL_TEMPLATE_PARM_P (olddecl) /* If we're not shadowing a template parameter, we're done. Note
&& ! TEMPLATE_PARMS_FOR_INLINE (current_template_parms)) that OLDDECL might be an OVERLOAD (or perhaps even an
{ ERROR_MARK), so we can't just blithely assume it to be a _DECL
cp_error_at ("declaration of `%#D'", decl); node. */
cp_error_at (" shadows template parm `%#D'", olddecl); if (TREE_CODE_CLASS (TREE_CODE (olddecl)) != 'd'
} || !DECL_TEMPLATE_PARM_P (olddecl))
} return;
/* We check for decl != olddecl to avoid bogus errors for using a
name inside a class. We check TPFI to avoid duplicate errors for
inline member templates. */
if (decl == olddecl
|| TEMPLATE_PARMS_FOR_INLINE (current_template_parms))
return;
cp_error_at ("declaration of `%#D'", decl);
cp_error_at (" shadows template parm `%#D'", olddecl);
} }
/* Return a new TEMPLATE_PARM_INDEX with the indicated INDEX, LEVEL, /* Return a new TEMPLATE_PARM_INDEX with the indicated INDEX, LEVEL,
......
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