re PR c++/15025 (accepts redeclaration of template as non-template)

PR c++/15025
	* decl.c (xref_tag): Issue errors about redeclaring template
	classes as non-template classes.

	PR c++/15025
	* g++.dg/template/redecl1.C: New test.

From-SVN: r82172
This commit is contained in:
Mark Mitchell 2004-05-23 21:06:56 +00:00 committed by Mark Mitchell
parent f746161e4f
commit 9ce1594a3e
4 changed files with 22 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2004-05-23 Mark Mitchell <mark@codesourcery.com>
PR c++/15025
* decl.c (xref_tag): Issue errors about redeclaring template
classes as non-template classes.
2004-05-23 Mark Mitchell <mark@codesourcery.com>
PR c++/14821

View File

@ -9407,6 +9407,13 @@ xref_tag (enum tag_types tag_code, tree name,
{
if (!globalize && processing_template_decl && IS_AGGR_TYPE (t))
redeclare_class_template (t, current_template_parms);
else if (!processing_template_decl
&& CLASS_TYPE_P (t)
&& CLASSTYPE_IS_TEMPLATE (t))
{
error ("redeclaration of `%T' as a non-template", t);
t = error_mark_node;
}
}
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);

View File

@ -1,3 +1,8 @@
2004-05-23 Mark Mitchell <mark@codesourcery.com>
PR c++/15025
* g++.dg/template/redecl1.C: New test.
2004-05-23 Mark Mitchell <mark@codesourcery.com>
PR c++/14821

View File

@ -0,0 +1,4 @@
// PR c++/15025
template <int> struct X;
struct X {}; // { dg-error "" }