diff options
author | Mark Mitchell <mark@codesourcery.com> | 1999-04-05 01:34:46 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 1999-04-04 21:34:46 -0400 |
commit | b5d9b9ab00c982b667c5df009b555464ca765765 (patch) | |
tree | 64ce3c34b845ac980442f297e1dc4089316a91ca | |
parent | 2a97a8001815a314b7c3bc08e660c4dec1b8c847 (diff) | |
download | gcc-b5d9b9ab00c982b667c5df009b555464ca765765.zip gcc-b5d9b9ab00c982b667c5df009b555464ca765765.tar.gz gcc-b5d9b9ab00c982b667c5df009b555464ca765765.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 40 |
2 files changed, 33 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 813cc21..e341bc2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +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> * class.c (maybe_fixup_vptrs, build_class_init_list): Lose. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 28161b1..a4060c0 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1599,22 +1599,38 @@ check_template_shadow (decl) { 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) decl = OVL_CURRENT (decl); olddecl = IDENTIFIER_VALUE (DECL_NAME (decl)); - if (current_template_parms && olddecl) - { - /* 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 && DECL_TEMPLATE_PARM_P (olddecl) - && ! TEMPLATE_PARMS_FOR_INLINE (current_template_parms)) - { - cp_error_at ("declaration of `%#D'", decl); - cp_error_at (" shadows template parm `%#D'", olddecl); - } - } + /* If there's no previous binding for this name, we're not shadowing + anything, let alone a template parameter. */ + if (!olddecl) + return; + + /* If we're not shadowing a template parameter, we're done. Note + that OLDDECL might be an OVERLOAD (or perhaps even an + ERROR_MARK), so we can't just blithely assume it to be a _DECL + node. */ + 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, |