Commit baae602e by Simon Martin Committed by Simon Martin

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
parent 84167094
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> 2010-02-24 Manuel López-Ibáñez <manu@gcc.gnu.org>
* pt.c (push_tinst_level): Replace -ftemplate-depth- with * pt.c (push_tinst_level): Replace -ftemplate-depth- with
......
...@@ -4682,22 +4682,24 @@ redeclare_class_template (tree type, tree parms) ...@@ -4682,22 +4682,24 @@ redeclare_class_template (tree type, tree parms)
continue; continue;
tmpl_parm = TREE_VALUE (TREE_VEC_ELT (tmpl_parms, i)); 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)); parm = TREE_VALUE (TREE_VEC_ELT (parms, i));
tmpl_default = TREE_PURPOSE (TREE_VEC_ELT (tmpl_parms, i)); tmpl_default = TREE_PURPOSE (TREE_VEC_ELT (tmpl_parms, i));
parm_default = TREE_PURPOSE (TREE_VEC_ELT (parms, i)); parm_default = TREE_PURPOSE (TREE_VEC_ELT (parms, i));
/* TMPL_PARM and PARM can be either TYPE_DECL, PARM_DECL, or /* TMPL_PARM and PARM can be either TYPE_DECL, PARM_DECL, or
TEMPLATE_DECL. */ TEMPLATE_DECL. */
if (tmpl_parm != error_mark_node if (TREE_CODE (tmpl_parm) != TREE_CODE (parm)
&& (TREE_CODE (tmpl_parm) != TREE_CODE (parm) || (TREE_CODE (tmpl_parm) != TYPE_DECL
|| (TREE_CODE (tmpl_parm) != TYPE_DECL && !same_type_p (TREE_TYPE (tmpl_parm), TREE_TYPE (parm)))
&& !same_type_p (TREE_TYPE (tmpl_parm), TREE_TYPE (parm))) || (TREE_CODE (tmpl_parm) != PARM_DECL
|| (TREE_CODE (tmpl_parm) != PARM_DECL && (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (tmpl_parm))
&& (TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (tmpl_parm)) != TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (parm))))
!= TEMPLATE_TYPE_PARAMETER_PACK (TREE_TYPE (parm)))) || (TREE_CODE (tmpl_parm) == PARM_DECL
|| (TREE_CODE (tmpl_parm) == PARM_DECL && (TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (tmpl_parm))
&& (TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (tmpl_parm)) != TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (parm)))))
!= TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (parm))))))
{ {
error ("template parameter %q+#D", tmpl_parm); error ("template parameter %q+#D", tmpl_parm);
error ("redeclared here as %q#D", parm); error ("redeclared here as %q#D", parm);
......
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> 2010-02-27 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/24577 PR c/24577
......
/* 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" } */
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