Block scope using declarations of operators

Richard Smith richard@ex-parrot.com
Wed Jul 10 08:35:00 GMT 2002


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



More information about the Gcc mailing list