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
This commit is contained in:
Giovanni Bajo 2004-06-15 00:24:47 +00:00
parent 6fb25ec080
commit 4e0f4df508
4 changed files with 27 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2004-06-14 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/15947
* parser.c (cp_parser_template_name): Ctors/dtors never need a
template keyword to disambiguate.
2004-06-14 Mark Mitchell <mark@codesourcery.com>
PR c++/15096

View File

@ -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)

View File

@ -1,3 +1,8 @@
2004-06-14 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/15947
* g++.dg/parse/dtor4.C: New test.
2004-06-14 Jeff Law <law@redhat.com>
* gcc.c-torture/compile/20040614-1.c: New test.

View File

@ -0,0 +1,10 @@
// { dg-do compile }
// Contributed by Paul Koning <pkoning at equallogic dot com>
// PR c++/15947: Accept destructor as template in qualified-id
template <int N> struct X {
~X();
};
template <int N>
X<N>::~X<N>(){}