aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-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 1f05b73..1106f86 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 d6c813d..f873558 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 c0205a4..c744759 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 6e415c3..26af1f4 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 0000000..6526a2a
--- /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 0000000..7d264fb
--- /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 0000000..bef9b91
--- /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;
+