public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Block scope using declarations of operators
@ 2002-07-10  8:35 Richard Smith
  2002-07-10  8:54 ` Gabriel Dos Reis
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Smith @ 2002-07-10  8:35 UTC (permalink / raw)
  To: gcc


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-07-10 22:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-10  8:35 Block scope using declarations of operators Richard Smith
2002-07-10  8:54 ` Gabriel Dos Reis
2002-07-10  8:56   ` Richard Smith
2002-07-10  9:16     ` Gabriel Dos Reis
2002-07-10 17:02       ` Mark Mitchell
2002-07-10 21:26         ` Gabriel Dos Reis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).