From: Josh Conner Date: Fri, 28 Oct 2005 17:58:59 +0000 (+0000) Subject: re PR c++/22153 (ICE on invalid template specialization) X-Git-Tag: releases/gcc-4.1.0~1179 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7e2a12d3e4b115dce045eacf757f5c5bf61ad271;p=thirdparty%2Fgcc.git re PR c++/22153 (ICE on invalid template specialization) PR c++/22153 * cp/parser.c (cp_parser_member_declaration): Detect and handle a template specialization. * testsuite/g++.dg/template/crash38.C: New test. * testsuite/g++.dg/parse/explicit1.C: Change expected errors. From-SVN: r105944 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d2ec158c9058..fed864d7f08e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2005-10-28 Josh Conner + + PR c++/22153 + * parser.c (cp_parser_member_declaration): Detect and handle + a template specialization. + 2005-10-28 Andrew Pinski PR C++/23426 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 25f25ce69ec6..a065c2569acb 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -13240,8 +13240,13 @@ cp_parser_member_declaration (cp_parser* parser) /* Check for a template-declaration. */ if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TEMPLATE)) { - /* Parse the template-declaration. */ - cp_parser_template_declaration (parser, /*member_p=*/true); + /* An explicit specialization here is an error condition, and we + expect the specialization handler to detect and report this. */ + if (cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_LESS + && cp_lexer_peek_nth_token (parser->lexer, 3)->type == CPP_GREATER) + cp_parser_explicit_specialization (parser); + else + cp_parser_template_declaration (parser, /*member_p=*/true); return; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bd5ff267abcd..85a10d838196 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2005-10-28 Josh Conner + + PR c++/22153 + * g++.dg/template/crash38.C: New test. + * g++.dg/parse/explicit1.C: Change expected errors. + 2005-10-28 Andrew Pinski PR C++/23426 diff --git a/gcc/testsuite/g++.dg/crash38.C b/gcc/testsuite/g++.dg/crash38.C new file mode 100644 index 000000000000..d36ced473abf --- /dev/null +++ b/gcc/testsuite/g++.dg/crash38.C @@ -0,0 +1,10 @@ +// { dg-do compile } + +// PR c++/22153 + +template void foo(); + +template struct A +{ + template<> friend void foo<0>(); // { dg-error "" } +}; diff --git a/gcc/testsuite/g++.dg/parse/explicit1.C b/gcc/testsuite/g++.dg/parse/explicit1.C index ced2adc3dc09..35358749e1d0 100644 --- a/gcc/testsuite/g++.dg/parse/explicit1.C +++ b/gcc/testsuite/g++.dg/parse/explicit1.C @@ -7,5 +7,5 @@ struct foo { template void bar (T &t) {} - template<> void bar(double &t) {} // { dg-error "explicit|non-namespace|member" } + template<> void bar(double &t) {} // { dg-error "non-namespace|template|function" } };