re PR c++/7841 (gcc accepts illegal member function syntax for template classes)
authorGiovanni Bajo <giovannibajo@gcc.gnu.org>
Tue, 8 Jun 2004 03:24:37 +0000 (03:24 +0000)
committerGiovanni Bajo <giovannibajo@gcc.gnu.org>
Tue, 8 Jun 2004 03:24:37 +0000 (03:24 +0000)
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
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.pt/ctor2.C

index 8fff9b00470f2bba33a87069a04c536fa824a946..365bcd1fba576ce1df7c5822105eb1a68fbd4d7c 100644 (file)
@@ -1,3 +1,9 @@
+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
index d094d306ee8c7267e634415e563eb0d1bad0b190..a90dabd0c8ca55d209ee7cb7ad3fb7b3a9767691 100644 (file)
@@ -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:;
index 055cd69bf8ed118396aefc87c5973f809a892606..069783a6ca1021144fcb7fd951bd8c172d8ebe95 100644 (file)
@@ -1,3 +1,8 @@
+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.
index e7dbfb77324283f2c01e7ff60032243d1872617f..46039ace81724c419a256b874f80a1af1808dcdd 100644 (file)
@@ -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" }
 {
 }