Commit 9221325f by Giovanni Bajo

re PR c++/7841 (gcc accepts illegal member function syntax for template classes)

	PR c++/7841
	* parser.c (cp_parser_direct_declarator): Reject constructor named
	as qualified template-id.

	PR c++/7841
	* g++.old-deja/g++.pt/ctor2.C: Add error mark.

From-SVN: r82741
parent aa07e14d
2004-06-08 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/7841
* parser.c (cp_parser_direct_declarator): Reject constructor named
as qualified template-id.
2004-06-07 Mark Mitchell <mark@codesourcery.com>
PR c++/15815
......
......@@ -10766,6 +10766,16 @@ cp_parser_direct_declarator (cp_parser* parser,
&& same_type_p (TREE_TYPE (unqualified_name),
class_type)))
*ctor_dtor_or_conv_p = -1;
if (TREE_CODE (declarator) == SCOPE_REF
&& TREE_CODE (unqualified_name) == TYPE_DECL
&& CLASSTYPE_USE_TEMPLATE (TREE_TYPE (unqualified_name)))
{
error ("invalid use of constructor as a template");
inform ("use `%T::%D' instead of `%T::%T' to name the "
"constructor in a qualified name", class_type,
DECL_NAME (TYPE_TI_TEMPLATE (class_type)),
class_type, class_type);
}
}
handle_declarator:;
......
2004-06-08 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/7841
* g++.old-deja/g++.pt/ctor2.C: Add error mark.
2004-06-07 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.dg/union-1.c: New test.
......
......@@ -8,6 +8,6 @@ struct A {
};
template <class T>
A<T>::A<T>()
A<T>::A<T>() // { dg-error "invalid use of constructor|qualified name" }
{
}
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