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
This commit is contained in:
parent
0cc4be6760
commit
2649701fbb
4 changed files with 25 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
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>
|
||||
|
||||
|
||||
|
|
|
@ -3157,7 +3157,11 @@ redeclare_class_template (tree type, tree parms)
|
|||
tree tmpl_default = TREE_PURPOSE (TREE_VEC_ELT (tmpl_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);
|
||||
error ("redeclared here as `%#D'", parm);
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
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>
|
||||
|
||||
PR fortran/17143
|
||||
|
|
9
gcc/testsuite/g++.dg/template/redecl2.C
Normal file
9
gcc/testsuite/g++.dg/template/redecl2.C
Normal file
|
@ -0,0 +1,9 @@
|
|||
// { 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" }
|
Loading…
Add table
Reference in a new issue