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));
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)
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;
&& (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));