From 88e98cfeb7a9d048923a59132053082699dec968 Mon Sep 17 00:00:00 2001 From: Kriang Lerdsuwanakij Date: Fri, 9 May 2003 15:10:28 +0000 Subject: [PATCH] PR c++/10555, c++/10576 PR c++/10555, c++/10576 * pt.c (lookup_template_class): Handle class template with multiple levels of parameters when one of the levels contain errors. * g++.dg/template/memclass1.C: New test. From-SVN: r66634 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/pt.c | 9 +++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/memclass1.C | 18 ++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/memclass1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b826fff..65cc247 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2003-05-09 Kriang Lerdsuwanakij + + PR c++/10555, c++/10576 + * pt.c (lookup_template_class): Handle class template with + multiple levels of parameters when one of the levels contain + errors. + 2003-05-08 Jason Merrill * init.c (build_new_1): Don't reuse a TARGET_EXPR in an diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7cabe5a..0354826 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4251,6 +4251,15 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope, complain) tree a = coerce_template_parms (TREE_VALUE (t), arglist, template, complain, /*require_all_args=*/1); + + /* Don't process further if one of the levels fails. */ + if (a == error_mark_node) + { + /* Restore the ARGLIST to its full size. */ + TREE_VEC_LENGTH (arglist) = saved_depth; + POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node); + } + SET_TMPL_ARGS_LEVEL (bound_args, i, a); /* We temporarily reduce the length of the ARGLIST so diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5039b54..bfddd4d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-05-09 Kriang Lerdsuwanakij + + PR c++/10555, c++/10576 + * g++.dg/template/memclass1.C: New test. + 2003-05-08 DJ Delorie * gcc.c-torture/execute/20020404-1.x: New, skip for 16-bit diff --git a/gcc/testsuite/g++.dg/template/memclass1.C b/gcc/testsuite/g++.dg/template/memclass1.C new file mode 100644 index 0000000..d4ce969 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/memclass1.C @@ -0,0 +1,18 @@ +// { dg-do compile } + +// Origin: Volker Reichelt + +// PR c++/10555: ICE for member class template when one of the +// template argument levels contains errors. + +template struct A +{ + template struct B; +}; + +template struct C +{ + typedef typename A::template B X; // { dg-error "declared|invalid" } +}; + +C c; // { dg-error "instantiated" } -- 2.7.4