re PR c++/28637 (ICE on invalid template parameter)

2006-08-09  Lee Millward  <lee.millward@codesourcery.com>

       PR c++/28637
       * pt.c (coerce_template_parms): Copy across the
       invalid template arguments to the new template inner arguments.
       (retrieve_specialization): Robustify.

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

       PR c++/28638
       * pt.c (coerce_template_template_parms): Robustify.
       
       * g++.dg/template/void4.C: New test.

       PR c++/28639
       * error.c (dump_template_parms): Robustify.

       PR c++/28640
       * pt.c (redeclare_class_template): Robustify

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

       PR c++/28641
       * pt.c (type_unification_real): Robustify.

From-SVN: r116043
This commit is contained in:
Lee Millward 2006-08-09 18:43:06 +00:00 committed by Lee Millward
parent cef6b86c00
commit 2d8ba2c76b
7 changed files with 83 additions and 7 deletions

View file

@ -1,3 +1,22 @@
2006-08-09 Lee Millward <lee.millward@codesourcery.com>
PR c++/28637
* pt.c (coerce_template_parms): Copy across the
invalid template arguments to the new template inner arguments.
(retrieve_specialization): Robustify.
PR c++/28638
* pt.c (coerce_template_template_parms): Robustify.
PR c++/28639
* error.c (dump_template_parms): Robustify.
PR c++/28640
* pt.c (redeclare_class_template): Robustify.
PR c++/28641
* pt.c (type_unification_real): Robustify.
2006-08-03 Lee Millward <lee.millward@codesourcery.com>
PR c++/28347

View file

@ -1242,7 +1242,15 @@ dump_template_parms (tree info, int primary, int flags)
for (ix = 0; ix != len; ix++)
{
tree parm = TREE_VALUE (TREE_VEC_ELT (parms, ix));
tree parm;
if (TREE_VEC_ELT (parms, ix) == error_mark_node)
{
pp_identifier (cxx_pp, "<template parameter error>");
continue;
}
parm = TREE_VALUE (TREE_VEC_ELT (parms, ix));
if (ix)
pp_separate_with_comma (cxx_pp);

View file

@ -816,6 +816,9 @@ static tree
retrieve_specialization (tree tmpl, tree args,
bool class_specializations_p)
{
if (args == error_mark_node)
return NULL_TREE;
gcc_assert (TREE_CODE (tmpl) == TEMPLATE_DECL);
/* There should be as many levels of arguments as there are
@ -3320,10 +3323,19 @@ redeclare_class_template (tree type, tree parms)
for (i = 0; i < TREE_VEC_LENGTH (tmpl_parms); ++i)
{
tree tmpl_parm = TREE_VALUE (TREE_VEC_ELT (tmpl_parms, i));
tree parm = TREE_VALUE (TREE_VEC_ELT (parms, i));
tree tmpl_default = TREE_PURPOSE (TREE_VEC_ELT (tmpl_parms, i));
tree parm_default = TREE_PURPOSE (TREE_VEC_ELT (parms, i));
tree tmpl_parm;
tree parm;
tree tmpl_default;
tree parm_default;
if (TREE_VEC_ELT (tmpl_parms, i) == error_mark_node
|| TREE_VEC_ELT (parms, i) == error_mark_node)
continue;
tmpl_parm = TREE_VALUE (TREE_VEC_ELT (tmpl_parms, i));
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. */
@ -3785,7 +3797,8 @@ coerce_template_template_parms (tree parm_parms,
for (i = 0; i < nparms; ++i)
{
if (TREE_VEC_ELT (parm_parms, i) == error_mark_node)
if (TREE_VEC_ELT (parm_parms, i) == error_mark_node
|| TREE_VEC_ELT (arg_parms, i) == error_mark_node)
continue;
parm = TREE_VALUE (TREE_VEC_ELT (parm_parms, i));
@ -4073,7 +4086,10 @@ coerce_template_parms (tree parms,
parm = TREE_VEC_ELT (parms, i);
if (parm == error_mark_node)
{
TREE_VEC_ELT (new_inner_args, i) = error_mark_node;
continue;
}
/* Calculate the Ith argument. */
if (i < nargs)
@ -9788,7 +9804,12 @@ type_unification_real (tree tparms,
for (i = 0; i < ntparms; i++)
if (!TREE_VEC_ELT (targs, i))
{
tree tparm = TREE_VALUE (TREE_VEC_ELT (tparms, i));
tree tparm;
if (TREE_VEC_ELT (tparms, i) == error_mark_node)
continue;
tparm = TREE_VALUE (TREE_VEC_ELT (tparms, i));
/* If this is an undeduced nontype parameter that depends on
a type parameter, try another pass; its type may have been

View file

@ -1,3 +1,14 @@
2006-08-09 Lee Millward <lee.millward@codesourcery.com>
PR c++/28637
* g++.dg/template/void3.C: New test.
PR c++/28638
* g++.dg/template/void4.C: New test.
` PR c++/28640
* g++.dg/template/void5.C: New test.
2006-08-07 Danny Smith <dannysmith@users.sourceforge.net>
* g++.dg/ext/visibility/class1.C (dg-require-visibility): Move

View file

@ -0,0 +1,5 @@
//PR c++/28637
template<void> struct A {}; // { dg-error "not a valid type" }
A<0> a;

View file

@ -0,0 +1,7 @@
//PR c++/28638
template<void> struct A; // { dg-error "not a valid type" }
template<template<int> class> struct B {};
B<A> b;

View file

@ -0,0 +1,5 @@
//PR c++/28640
template<void> struct A; // { dg-error "not a valid type" }
template<int> struct A;