From: Giovanni Bajo Date: Tue, 15 Jun 2004 00:24:47 +0000 (+0000) Subject: re PR c++/15947 (Puzzling error message for wrong destructor declaration in template... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4e0f4df508db6bccfdca88a2bcf26e03317d4c71;p=gcc.git re PR c++/15947 (Puzzling error message for wrong destructor declaration in template class) PR c++/15947 * parser.c (cp_parser_template_name): Ctors/dtors never need a template keyword to disambiguate. PR c++/15947 * g++.dg/parse/dtor4.C: New test. From-SVN: r83154 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d99aef0a8fd..7148f222edc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-06-14 Giovanni Bajo + + PR c++/15947 + * parser.c (cp_parser_template_name): Ctors/dtors never need a + template keyword to disambiguate. + 2004-06-14 Mark Mitchell PR c++/15096 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 2f57d9d7a36..af732d99267 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8286,14 +8286,17 @@ cp_parser_template_name (cp_parser* parser, if (is_declaration && !template_keyword_p && parser->scope && TYPE_P (parser->scope) - && dependent_type_p (parser->scope)) + && dependent_type_p (parser->scope) + /* Do not do this for dtors (or ctors), since they never + need the template keyword before their name. */ + && !constructor_name_p (identifier, parser->scope)) { ptrdiff_t start; cp_token* token; /* Explain what went wrong. */ error ("non-template `%D' used as template", identifier); - error ("(use `%T::template %D' to indicate that it is a template)", - parser->scope, identifier); + inform ("use `%T::template %D' to indicate that it is a template", + parser->scope, identifier); /* If parsing tentatively, find the location of the "<" token. */ if (cp_parser_parsing_tentatively (parser) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9c8a040da2d..7ec7738ddee 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-06-14 Giovanni Bajo + + PR c++/15947 + * g++.dg/parse/dtor4.C: New test. + 2004-06-14 Jeff Law * gcc.c-torture/compile/20040614-1.c: New test. diff --git a/gcc/testsuite/g++.dg/parse/dtor4.C b/gcc/testsuite/g++.dg/parse/dtor4.C new file mode 100644 index 00000000000..729ee2fa130 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/dtor4.C @@ -0,0 +1,10 @@ +// { dg-do compile } +// Contributed by Paul Koning +// PR c++/15947: Accept destructor as template in qualified-id + +template struct X { + ~X(); +}; + +template +X::~X(){}