This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Block scope using declarations of operators
- From: Richard Smith <richard at ex-parrot dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Wed, 10 Jul 2002 14:45:52 +0100 (BST)
- Subject: Block scope using declarations of operators
Gcc's C++ grammar does not accept block scope using declarations of
operators, e.g.
namespace NS
{
class A {};
bool operator==( const A &, const A & );
}
int main()
{
using NS::operator==; // get a parse error on this line
}
The following patch fixes this issue
diff -urpx diff_ignore gcc-3.1-clean/gcc/c-decl.c gcc-3.1/gcc/c-decl.c
--- gcc-3.1-clean/gcc/cp/parse.y Thu Jun 27 16:19:21 2002
+++ gcc-3.1/gcc/cp/parse.y Wed Jul 10 14:00:33 2002
@@ -567,6 +567,12 @@ namespace_using_decl:
{ $$ = build_nt (SCOPE_REF, global_namespace, $3); }
| USING global_scope namespace_qualifier identifier
{ $$ = build_nt (SCOPE_REF, $3, $4); }
+ | USING namespace_qualifier operator_name
+ { $$ = build_nt (SCOPE_REF, $2, $3); }
+ | USING global_scope operator_name
+ { $$ = build_nt (SCOPE_REF, global_namespace, $3); }
+ | USING global_scope namespace_qualifier operator_name
+ { $$ = build_nt (SCOPE_REF, $3, $4); }
;
using_directive:
--
Richard Smith