From baae602ec06edf60cca0dbda1f51870c77a00de8 Mon Sep 17 00:00:00 2001 From: Simon Martin Date: Sat, 27 Feb 2010 19:21:39 +0000 Subject: re PR c++/42054 (ICE with invalid template parameter) gcc/cp/ 2010-02-27 Simon Martin PR c++/42054 * pt.c (redeclare_class_template): Return false if there are erroneous template parameters. gcc/testsuite/ 2010-02-27 Simon Martin PR c++/42054: * g++.dg/parse/error37.C: New test. From-SVN: r157112 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 22 ++++++++++++---------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/error37.C | 5 +++++ 4 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/g++.dg/parse/error37.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f1fb47e..d814469 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-02-27 Simon Martin + + PR c++/42054 + * pt.c (redeclare_class_template): Return false if there are erroneous + template parameters. + 2010-02-24 Manuel López-Ibáñez * pt.c (push_tinst_level): Replace -ftemplate-depth- with diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 04cc159..6ec002b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4682,22 +4682,24 @@ redeclare_class_template (tree type, tree parms) continue; tmpl_parm = TREE_VALUE (TREE_VEC_ELT (tmpl_parms, i)); + if (tmpl_parm == error_mark_node) + return false; + parm = TREE_VALUE (TREE_VEC_ELT (parms, i)); tmpl_default = TREE_PURPOSE (TREE_VEC_ELT (tmpl_parms, i)); parm_default = TREE_PURPOSE (TREE_VEC_ELT (parms, i)); /* TMPL_PARM and PARM can be either TYPE_DECL, PARM_DECL, or TEMPLATE_DECL. */ - if (tmpl_parm != error_mark_node - && (TREE_CODE (tmpl_parm) != TREE_CODE (parm) - || (TREE_CODE (tmpl_parm) != TYPE_DECL - && !same_type_p (TREE_TYPE (tmpl_parm), TREE_TYPE (parm))) - || (TREE_CODE (tmpl_parm) != PARM_DECL - && (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (tmpl_parm)) - != TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (parm)))) - || (TREE_CODE (tmpl_parm) == PARM_DECL - && (TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (tmpl_parm)) - != TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (parm)))))) + if (TREE_CODE (tmpl_parm) != TREE_CODE (parm) + || (TREE_CODE (tmpl_parm) != TYPE_DECL + && !same_type_p (TREE_TYPE (tmpl_parm), TREE_TYPE (parm))) + || (TREE_CODE (tmpl_parm) != PARM_DECL + && (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (tmpl_parm)) + != TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (parm)))) + || (TREE_CODE (tmpl_parm) == PARM_DECL + && (TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (tmpl_parm)) + != TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (parm))))) { error ("template parameter %q+#D", tmpl_parm); error ("redeclared here as %q#D", parm); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 96b9ef1..9eeac55 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-02-27 Simon Martin + + PR c++/42054: + * g++.dg/parse/error37.C: New test. + 2010-02-27 Manuel López-Ibáñez PR c/24577 diff --git a/gcc/testsuite/g++.dg/parse/error37.C b/gcc/testsuite/g++.dg/parse/error37.C new file mode 100644 index 0000000..78617da --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error37.C @@ -0,0 +1,5 @@ +/* PR c++/42054 */ +/* { dg-do "compile" } */ + +template struct A; /* { dg-error "two or more" } */ +template struct A; /* { dg-error "two or more" } */ -- cgit v1.1