Commit 4e0f4df5 by Giovanni Bajo

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
parent 6fb25ec0
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> 2004-06-14 Mark Mitchell <mark@codesourcery.com>
PR c++/15096 PR c++/15096
......
...@@ -8286,13 +8286,16 @@ cp_parser_template_name (cp_parser* parser, ...@@ -8286,13 +8286,16 @@ cp_parser_template_name (cp_parser* parser,
if (is_declaration if (is_declaration
&& !template_keyword_p && !template_keyword_p
&& parser->scope && TYPE_P (parser->scope) && 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; ptrdiff_t start;
cp_token* token; cp_token* token;
/* Explain what went wrong. */ /* Explain what went wrong. */
error ("non-template `%D' used as template", identifier); error ("non-template `%D' used as template", identifier);
error ("(use `%T::template %D' to indicate that it is a template)", inform ("use `%T::template %D' to indicate that it is a template",
parser->scope, identifier); parser->scope, identifier);
/* If parsing tentatively, find the location of the "<" /* If parsing tentatively, find the location of the "<"
token. */ token. */
......
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> 2004-06-14 Jeff Law <law@redhat.com>
* gcc.c-torture/compile/20040614-1.c: New test. * gcc.c-torture/compile/20040614-1.c: New test.
......
// { 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>(){}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment