Commit 2649701f by Kriang Lerdsuwanakij Committed by Kriang Lerdsuwanakij

re PR c++/14428 (incompatible template declarations accepted)

	PR c++/14428
	* pt.c (redeclare_class_template): Check the type of non-type and
	template template parameter.

	* g++.dg/template/redecl2.C: New test.

From-SVN: r86550
parent 0cc4be67
2004-08-25 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/14428
* pt.c (redeclare_class_template): Check the type of non-type and
template template parameter.
2004-08-25 Nathan Sidwell <nathan@codesourcery.com> 2004-08-25 Nathan Sidwell <nathan@codesourcery.com>
......
...@@ -3157,7 +3157,11 @@ redeclare_class_template (tree type, tree parms) ...@@ -3157,7 +3157,11 @@ redeclare_class_template (tree type, tree parms)
tree tmpl_default = TREE_PURPOSE (TREE_VEC_ELT (tmpl_parms, i)); tree tmpl_default = TREE_PURPOSE (TREE_VEC_ELT (tmpl_parms, i));
tree parm_default = TREE_PURPOSE (TREE_VEC_ELT (parms, i)); tree parm_default = TREE_PURPOSE (TREE_VEC_ELT (parms, i));
if (TREE_CODE (tmpl_parm) != TREE_CODE (parm)) /* TMPL_PARM and PARM can be either TYPE_DECL, PARM_DECL, or
TEMPLATE_DECL. */
if (TREE_CODE (tmpl_parm) != TREE_CODE (parm)
|| (TREE_CODE (tmpl_parm) != TYPE_DECL
&& !same_type_p (TREE_TYPE (tmpl_parm), TREE_TYPE (parm))))
{ {
cp_error_at ("template parameter `%#D'", tmpl_parm); cp_error_at ("template parameter `%#D'", tmpl_parm);
error ("redeclared here as `%#D'", parm); error ("redeclared here as `%#D'", parm);
......
2004-08-25 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/14428
* g++.dg/template/redecl2.C: New test.
2004-08-24 Bud Davis <bdavis9659@comcast.net> 2004-08-24 Bud Davis <bdavis9659@comcast.net>
PR fortran/17143 PR fortran/17143
......
// { dg-do compile }
// Origin: heinlein@informatik.uni-ulm.de
// PR c++/14428: Redeclaration of class template with wrong
// non-type template parameter.
template <int i> struct X; // { dg-error "template parameter" }
template <int* p> struct X; // { dg-error "redeclared here" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment