aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@gcc.gnu.org>1998-09-03 14:07:51 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>1998-09-03 14:07:51 +0000
commita0d9f322521bf9754fd701fcf43656c975968d74 (patch)
treead752fe453e170963d2ee1143d7d05a25d7160a5 /gcc
parent343a4a0e15fe6669d3c9cc3ed8b8cacb01eb7a2c (diff)
downloadgcc-a0d9f322521bf9754fd701fcf43656c975968d74.zip
gcc-a0d9f322521bf9754fd701fcf43656c975968d74.tar.gz
gcc-a0d9f322521bf9754fd701fcf43656c975968d74.tar.bz2
decl.c (pushdecl_class_level): Add warning here.
P 1998-09-03 Benjamin Kosnik <bkoz@rhino.cygnus.com> * decl.c (pushdecl_class_level): Add warning here. (pushdecl): Tweak. From-SVN: r22210
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/decl.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 2abcd1a..6fb4c14 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -3671,12 +3671,12 @@ pushdecl (x)
warning (warnstring, IDENTIFIER_POINTER (name));
}
/* Check to see if decl redeclares a template parameter. */
- if (oldlocal && (current_class_type || current_function_decl )
+ if (oldlocal && (current_class_type || current_function_decl)
&& current_template_parms)
{
if (decl_template_parm_p (oldlocal))
{
- cp_error ("redeclaration of template parameter `%T'", name);
+ cp_error ("re-using name of template parameter `%T' in this scope", name);
cp_error_at (" previously declared here `%#D'", oldlocal);
}
}
@@ -3812,10 +3812,10 @@ pushdecl_class_level (x)
{
/* A name N used in a class S shall refer to the same declaration
in its context and when re-evaluated in the completed scope of S.
-
Types, enums, and static vars are checked here; other
members are checked in finish_struct. */
tree icv = IDENTIFIER_CLASS_VALUE (name);
+ tree ilv = IDENTIFIER_LOCAL_VALUE (name);
if (icv && icv != x
&& flag_optional_diags
@@ -3829,6 +3829,18 @@ pushdecl_class_level (x)
cp_pedwarn_at ("conflicts with previous use in class as `%#D'",
icv);
}
+
+ /* Check to see if decl redeclares a template parameter. */
+ if (ilv && ! decls_match (ilv, x)
+ && (current_class_type || current_function_decl)
+ && current_template_parms)
+ {
+ if (decl_template_parm_p (ilv))
+ {
+ cp_error ("re-using name of template parameter `%T' in this scope", name);
+ cp_error_at (" previously declared here `%#D'", ilv);
+ }
+ }
}
push_class_level_binding (name, x);