Hi,
I tested on x86_64-linux the below patchlet for a long standing
accepts-invalid. Is it ok for mainline? Or do we want a different error
message? A somehow tighter check?
Thanks,
Paolo.
//////////////////
/cp
2011-06-09 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/29003
* decl.c (grokdeclarator): Reject operator names in typedefs.
/testsuite
2011-06-09 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/29003
* g++.dg/parse/error38.C: New.
Index: testsuite/g++.dg/parse/error38.C
===================================================================
--- testsuite/g++.dg/parse/error38.C (revision 0)
+++ testsuite/g++.dg/parse/error38.C (revision 0)
@@ -0,0 +1,3 @@
+// PR c++/29003
+
+typedef int operator !(); // { dg-error "not allowed" }
Index: cp/decl.c
===================================================================
--- cp/decl.c (revision 174838)
+++ cp/decl.c (working copy)
@@ -8441,6 +8441,13 @@ grokdeclarator (const cp_declarator *declarator,
return error_mark_node;
}
+ if (dname && IDENTIFIER_OPNAME_P (dname)
+ && declspecs->specs[(int)ds_typedef])
+ {
+ error ("operator name is not allowed");
+ return error_mark_node;
+ }
+
/* Anything declared one level down from the top level
must be one of the parameters of a function
(because the body is at least two levels down). */