aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Martin <simartin@users.sourceforge.net>2010-02-27 19:21:39 +0000
committerSimon Martin <simartin@gcc.gnu.org>2010-02-27 19:21:39 +0000
commitbaae602ec06edf60cca0dbda1f51870c77a00de8 (patch)
treeb0c851700db62542c8e1f00e04066905d40b4447
parent84167094317240e29200a021c344ce378c42cda5 (diff)
downloadgcc-baae602ec06edf60cca0dbda1f51870c77a00de8.zip
gcc-baae602ec06edf60cca0dbda1f51870c77a00de8.tar.gz
gcc-baae602ec06edf60cca0dbda1f51870c77a00de8.tar.bz2
re PR c++/42054 (ICE with invalid template parameter)
gcc/cp/ 2010-02-27 Simon Martin <simartin@users.sourceforge.net> PR c++/42054 * pt.c (redeclare_class_template): Return false if there are erroneous template parameters. gcc/testsuite/ 2010-02-27 Simon Martin <simartin@users.sourceforge.net> PR c++/42054: * g++.dg/parse/error37.C: New test. From-SVN: r157112
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c22
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/error37.C5
4 files changed, 28 insertions, 10 deletions
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 <simartin@users.sourceforge.net>
+
+ PR c++/42054
+ * pt.c (redeclare_class_template): Return false if there are erroneous
+ template parameters.
+
2010-02-24 Manuel López-Ibáñez <manu@gcc.gnu.org>
* 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 <simartin@users.sourceforge.net>
+
+ PR c++/42054:
+ * g++.dg/parse/error37.C: New test.
+
2010-02-27 Manuel López-Ibáñez <manu@gcc.gnu.org>
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<int int> struct A; /* { dg-error "two or more" } */
+template<int int> struct A; /* { dg-error "two or more" } */