Much fallout from PR 27668
Lee Millward
lee.millward@codesourcery.com
Mon Aug 7 20:54:00 GMT 2006
Hi Volker,
When Mark approved the patch he predicted there would be some fallout,
I've been keeping a lookout for any new regressions which have
resulted from my patch and trying to fix them as I come across them.
I've attached a patch which I'm currently running through a
bootstrap/regression test. It fixes 28637, 28638 and 28640 and
partially fixes the remaining two by adding in checks for
error_mark_node highlighted by the test cases. With this patch the two
remaining PRs (28639 and 28641) now both ICE in instantiate_decl, in
exactly the same place where the ICE for PR c++/24791 occurs.
Cheers,
Lee.
:ADDPATCH c++
cp/
2006-08-07 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.
testsuite/
2006-08-07 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.
-------------- next part --------------
Index: gcc/testsuite/g++.dg/template/void3.C
===================================================================
--- gcc/testsuite/g++.dg/template/void3.C (revision 0)
+++ gcc/testsuite/g++.dg/template/void3.C (revision 0)
@@ -0,0 +1,5 @@
+//PR c++/28637
+
+template<void> struct A {}; // { dg-error "not a valid type" }
+A<0> a;
+
Index: gcc/testsuite/g++.dg/template/void4.C
===================================================================
--- gcc/testsuite/g++.dg/template/void4.C (revision 0)
+++ gcc/testsuite/g++.dg/template/void4.C (revision 0)
@@ -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;
Index: gcc/testsuite/g++.dg/template/void5.C
===================================================================
--- gcc/testsuite/g++.dg/template/void5.C (revision 0)
+++ gcc/testsuite/g++.dg/template/void5.C (revision 0)
@@ -0,0 +1,5 @@
+//PR c++/28640
+
+template<void> struct A; // { dg-error "not a valid type" }
+template<int> struct A;
+
Index: gcc/cp/error.c
===================================================================
--- gcc/cp/error.c (revision 116000)
+++ gcc/cp/error.c (working copy)
@@ -1242,7 +1242,12 @@ dump_template_parms (tree info, int prim
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)
+ continue;
+
+ parm = TREE_VALUE (TREE_VEC_ELT (parms, ix));
if (ix)
pp_separate_with_comma (cxx_pp);
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c (revision 116000)
+++ gcc/cp/pt.c (working copy)
@@ -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, tre
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 par
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
More information about the Gcc-patches
mailing list