summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlmillward <lmillward@138bc75d-0d04-0410-961f-82ee72b054a4>2006-08-09 18:43:06 +0000
committerlmillward <lmillward@138bc75d-0d04-0410-961f-82ee72b054a4>2006-08-09 18:43:06 +0000
commit6f32df61628a88355a00959ad22e60c0ccccd9ce (patch)
treeba6a351afa64d05f3f2c625dcbef7f1651b2475e
parent3a1af93034f967f91b4f9a56987603cf6b4f360f (diff)
downloadppe42-gcc-6f32df61628a88355a00959ad22e60c0ccccd9ce.tar.gz
ppe42-gcc-6f32df61628a88355a00959ad22e60c0ccccd9ce.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116043 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog19
-rw-r--r--gcc/cp/error.c10
-rw-r--r--gcc/cp/pt.c33
-rw-r--r--gcc/testsuite/ChangeLog11
-rw-r--r--gcc/testsuite/g++.dg/template/void3.C5
-rw-r--r--gcc/testsuite/g++.dg/template/void4.C7
-rw-r--r--gcc/testsuite/g++.dg/template/void5.C5
7 files changed, 83 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1f05b730aa8..1106f86b0c7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index d6c813da7a7..f87355893cb 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -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);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c0205a419c7..c744759899b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6e415c3f341..26af1f4959c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/g++.dg/template/void3.C b/gcc/testsuite/g++.dg/template/void3.C
new file mode 100644
index 00000000000..6526a2a47be
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/void3.C
@@ -0,0 +1,5 @@
+//PR c++/28637
+
+template<void> struct A {}; // { dg-error "not a valid type" }
+A<0> a;
+
diff --git a/gcc/testsuite/g++.dg/template/void4.C b/gcc/testsuite/g++.dg/template/void4.C
new file mode 100644
index 00000000000..7d264fbf10b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/void4.C
@@ -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;
diff --git a/gcc/testsuite/g++.dg/template/void5.C b/gcc/testsuite/g++.dg/template/void5.C
new file mode 100644
index 00000000000..bef9b91f680
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/void5.C
@@ -0,0 +1,5 @@
+//PR c++/28640
+
+template<void> struct A; // { dg-error "not a valid type" }
+template<int> struct A;
+
OpenPOWER on IntegriCloud