From 9221325f10a58e13a35dfac007c6b5c906760679 Mon Sep 17 00:00:00 2001 From: Giovanni Bajo Date: Tue, 8 Jun 2004 03:24:37 +0000 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 10 ++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.old-deja/g++.pt/ctor2.C | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) 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" } { } -- 2.30.2