From: Kriang Lerdsuwanakij Date: Sun, 25 Jan 2004 15:08:20 +0000 (+0000) Subject: re PR c++/13797 (ICE on invalid template parameter) X-Git-Tag: releases/gcc-3.3.3~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b4de06ecdb5c4a1c232325aa293bd7b5f33d94f;p=thirdparty%2Fgcc.git re PR c++/13797 (ICE on invalid template parameter) PR c++/13797 * pt.c (instantiate_class_template): Add an error_mark_node check. (tsubst_decl) : Likewise. Backport from mainline 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. * g++.dg/template/nontype4.C: New test. * g++.dg/template/nontype5.C: Likewise. * g++.dg/template/memclass1.C: New test. From-SVN: r76562 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 225c02d5cf43..b7511b3d914f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,18 @@ +2004-01-25 Kriang Lerdsuwanakij + + PR c++/13797 + * pt.c (instantiate_class_template): Add an error_mark_node + check. + (tsubst_decl) : Likewise. + + Backport from mainline + 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. + 2004-01-21 Gabriel Dos Reis Backport from mainline diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e64ed166b3e3..0caecaf4cae6 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1,6 +1,6 @@ /* Handle parameterized types (templates) for GNU C++. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002 Free Software Foundation, Inc. + 2001, 2002, 2004 Free Software Foundation, Inc. Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing. Rewritten by Jason Merrill (jason@cygnus.com). @@ -4255,6 +4255,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 @@ -5462,7 +5471,9 @@ instantiate_class_template (type) tree newtag; newtag = tsubst (tag, args, tf_error, NULL_TREE); - my_friendly_assert (newtag != error_mark_node, 20010206); + if (newtag == error_mark_node) + continue; + if (TREE_CODE (newtag) != ENUMERAL_TYPE) { if (TYPE_LANG_SPECIFIC (tag) && CLASSTYPE_IS_TEMPLATE (tag)) @@ -6001,6 +6012,9 @@ tsubst_decl (t, args, type, complain) if (TREE_CODE (decl) == TYPE_DECL) { tree new_type = tsubst (TREE_TYPE (t), args, complain, in_decl); + if (new_type == error_mark_node) + return error_mark_node; + TREE_TYPE (r) = new_type; CLASSTYPE_TI_TEMPLATE (new_type) = r; DECL_TEMPLATE_RESULT (r) = TYPE_MAIN_DECL (new_type); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f60b1c350381..866586168a80 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2004-01-25 Kriang Lerdsuwanakij + + PR c++/13797 + * g++.dg/template/nontype4.C: New test. + * g++.dg/template/nontype5.C: Likewise. + + PR c++/10555, c++/10576 + * g++.dg/template/memclass1.C: New test. + 2004-01-11 Jakub Jelinek PR middle-end/13392 diff --git a/gcc/testsuite/g++.dg/template/memclass1.C b/gcc/testsuite/g++.dg/template/memclass1.C index c49ed724d6f7..65921b31337d 100644 --- a/gcc/testsuite/g++.dg/template/memclass1.C +++ b/gcc/testsuite/g++.dg/template/memclass1.C @@ -12,7 +12,7 @@ template struct A template struct C { - typedef typename A::template B X; // { dg-error "declared|invalid" } + typedef typename A::template B X; // { dg-error "mismatch|expected" } }; -C c; +C c; // { dg-error "instantiated" }