diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d2ec158c905..fed864d7f08 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 25f25ce69ec..a065c2569ac 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 bd5ff267abc..85a10d83819 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 00000000000..d36ced473ab --- /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 ced2adc3dc0..35358749e1d 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" } };