From: Giovanni Bajo Date: Tue, 8 Jun 2004 03:24:37 +0000 (+0000) Subject: re PR c++/7841 (gcc accepts illegal member function syntax for template classes) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9221325f10a58e13a35dfac007c6b5c906760679;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8fff9b00470..365bcd1fba5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-06-08 Giovanni Bajo + + PR c++/7841 + * parser.c (cp_parser_direct_declarator): Reject constructor named + as qualified template-id. + 2004-06-07 Mark Mitchell PR c++/15815 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d094d306ee8..a90dabd0c8c 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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:; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 055cd69bf8e..069783a6ca1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-06-08 Giovanni Bajo + + PR c++/7841 + * g++.old-deja/g++.pt/ctor2.C: Add error mark. + 2004-06-07 Eric Botcazou * gcc.dg/union-1.c: New test. diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ctor2.C b/gcc/testsuite/g++.old-deja/g++.pt/ctor2.C index e7dbfb77324..46039ace817 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/ctor2.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/ctor2.C @@ -8,6 +8,6 @@ struct A { }; template -A::A() +A::A() // { dg-error "invalid use of constructor|qualified name" } { }