aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@gcc.gnu.org>1998-08-24 11:57:09 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>1998-08-24 11:57:09 +0000
commit2450bb7d4d5a5ee5958d6f21d936032d32a875a1 (patch)
tree4456d8191cf128efb64885b454636e64e1b79fdb
parent22a7be536556ba3c95cc1c0a739ace2382405447 (diff)
downloadgcc-2450bb7d4d5a5ee5958d6f21d936032d32a875a1.zip
gcc-2450bb7d4d5a5ee5958d6f21d936032d32a875a1.tar.gz
gcc-2450bb7d4d5a5ee5958d6f21d936032d32a875a1.tar.bz2
cp-tree.h: Declare.
� 1998-08-24 Benjamin Kosnik <bkoz@cygnus.com> * cp-tree.h: Declare. * pt.c (decl_template_parm_p): New function. * decl.c (pushdecl): Check decls for redeclaring template parms. (xref_tag): Make redeclaration an error, print decl. * decl2.c (grokfield): Check field_decls for redeclaration as well. From-SVN: r21943
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/decl.c17
-rw-r--r--gcc/cp/decl2.c13
3 files changed, 28 insertions, 3 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 26e39a9..b73fb53 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -2837,6 +2837,7 @@ extern int more_specialized_class PROTO((tree, tree));
extern void do_pushlevel PROTO((void));
extern int is_member_template PROTO((tree));
extern int comp_template_parms PROTO((tree, tree));
+extern int decl_template_parm_p PROTO((tree));
extern int template_class_depth PROTO((tree));
extern int is_specialization_of PROTO((tree, tree));
extern int comp_template_args PROTO((tree, tree));
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 8c3a32b..f232fdd 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -3669,6 +3669,16 @@ pushdecl (x)
if (warnstring)
warning (warnstring, IDENTIFIER_POINTER (name));
}
+ /* Check to see if decl redeclares a template parameter. */
+ 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_at (" previously declared here `%#D'", oldlocal);
+ }
+ }
}
if (TREE_CODE (x) == FUNCTION_DECL)
@@ -11480,11 +11490,12 @@ xref_tag (code_type_node, name, binfo, globalize)
if (! globalize)
{
- if (pedantic && t && (TREE_CODE (t) == TEMPLATE_TYPE_PARM
+ if (t && (TREE_CODE (t) == TEMPLATE_TYPE_PARM
|| TREE_CODE (t) == TEMPLATE_TEMPLATE_PARM))
{
- cp_pedwarn ("redeclaration of template type-parameter `%T'", name);
- cp_pedwarn_at (" previously declared here", t);
+ cp_error ("redeclaration of template type-parameter `%T'", name);
+ cp_error_at (" previously declared here `%#D'",
+ TEMPLATE_TYPE_DECL (t));
}
if (t && TYPE_CONTEXT (t) && got_type)
ref = t;
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 9333d8d..b8c4370 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1761,6 +1761,19 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
&& (TREE_CODE (value) == VAR_DECL || TREE_CODE (value) == FUNCTION_DECL))
value = push_template_decl (value);
+ /* Check to see if a field redeclares a template parameter. */
+ if (current_template_parms
+ && TREE_CODE (declarator) == IDENTIFIER_NODE
+ && IDENTIFIER_LOCAL_VALUE (declarator))
+ {
+ tree olddecl = IDENTIFIER_LOCAL_VALUE (declarator);
+ if (decl_template_parm_p (olddecl))
+ {
+ cp_error ("redeclaration of template parameter `%T'", declarator);
+ cp_error_at (" previously declared here `%#D'", olddecl);
+ }
+ }
+
if (attrlist)
cplus_decl_attributes (value, TREE_PURPOSE (attrlist),
TREE_VALUE (attrlist));