From: Alexandre Oliva Date: Tue, 1 Feb 2005 07:04:00 +0000 (+0000) Subject: re PR c++/18757 (ICE (on invalid) in get_innermost_template_args) X-Git-Tag: releases/gcc-3.4.4~254 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9db257305320758f79c7dc5d8b6d4ba844713a8f;p=thirdparty%2Fgcc.git re PR c++/18757 (ICE (on invalid) in get_innermost_template_args) gcc/cp/ChangeLog: PR c++/18757 PR c++/19366 PR c++/19499 * parser.c (cp_parser_template_id): Revert 2004-12-09's patch. Issue an error when creating the template id. * pt.c (fn_type_unification): Return early if the explicit template arg list is an error_mark_node. gcc/testsuite/ChangeLog: * g++.dg/parse/typename7.C: Adjust error messages. From-SVN: r94528 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 869878c9d154..01dc50a5fb26 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2005-02-01 Alexandre Oliva + + PR c++/18757 + PR c++/19366 + PR c++/19499 + * parser.c (cp_parser_template_id): Revert 2004-12-09's patch. + Issue an error when creating the template id. + * pt.c (fn_type_unification): Return early if the explicit + template arg list is an error_mark_node. + 2005-01-27 J"orn Rennecke PR c++/18370 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 46d6bbf157f4..867896b444ab 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8015,7 +8015,7 @@ cp_parser_template_id (cp_parser *parser, the effort required to do the parse, nor will we issue duplicate error messages about problems during instantiation of the template. */ - if (start_of_id >= 0 && !cp_parser_error_occurred (parser)) + if (start_of_id >= 0) { cp_token *token; @@ -8031,6 +8031,13 @@ cp_parser_template_id (cp_parser *parser, token->keyword = RID_MAX; /* Purge all subsequent tokens. */ cp_lexer_purge_tokens_after (parser->lexer, token); + + /* ??? Can we actually assume that, if template_id == + error_mark_node, we will have issued a diagnostic to the + user, as opposed to simply marking the tentative parse as + failed? */ + if (cp_parser_error_occurred (parser) && template_id != error_mark_node) + error ("parse error in template argument list"); } pop_deferring_access_checks (); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 8472bbb698f3..5409fd31436b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8935,6 +8935,9 @@ fn_type_unification (tree fn, tree converted_args; bool incomplete; + if (explicit_targs == error_mark_node) + return 1; + converted_args = (coerce_template_parms (DECL_INNERMOST_TEMPLATE_PARMS (fn), explicit_targs, NULL_TREE, tf_none, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a923a6a7fbbf..ee8ddc8bea8a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-02-01 Alexandre Oliva + + * g++.dg/parse/typename7.C: Adjust error messages. + 2005-01-26 Ulrich Weigand Backport from mainline: diff --git a/gcc/testsuite/g++.dg/parse/typename7.C b/gcc/testsuite/g++.dg/parse/typename7.C index 211931781394..56fcc7436a4a 100644 --- a/gcc/testsuite/g++.dg/parse/typename7.C +++ b/gcc/testsuite/g++.dg/parse/typename7.C @@ -9,23 +9,23 @@ struct A { template void foo(int); template void bar(T t) { - this->foo(t); } // { dg-error "expected" } + this->foo(t); } // { dg-error "expected|parse error|no matching" } template void bad(T t) { - foo(t); } // { dg-error "expected" } + foo(t); } // { dg-error "expected|parse error" } }; template struct B { void bar(T t) { - A().bar(t); } // { dg-error "expected" } + A().bar(t); } // { dg-error "expected|parse error|no matching" } void bad(T t) { B::bar(t); } // { dg-error "invalid|not a template" } }; void baz() { - A().bar(0); - A().bad(0); - B().bar(0); + A().bar(0); + A().bad(0); + B().bar(0); }