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

* Re: Block scope using declarations of operators
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Gabriel Dos Reis @ 2002-07-10  8:54 UTC (permalink / raw)
  To: Richard Smith; +Cc: gcc

Richard Smith <richard@ex-parrot.com> writes:

| Gcc's C++ grammar does not accept block scope using declarations of
| operators, e.g.

This is a long standing misbehaviour in GCC (already present the 2.95
series).  Although serious, I'm not sure it qualifies as a regression.

Thanks,

-- Gaby

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

* Re: Block scope using declarations of operators
  2002-07-10  8:54 ` Gabriel Dos Reis
@ 2002-07-10  8:56   ` Richard Smith
  2002-07-10  9:16     ` Gabriel Dos Reis
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Smith @ 2002-07-10  8:56 UTC (permalink / raw)
  To: Gabriel Dos Reis; +Cc: gcc



On 10 Jul 2002, Gabriel Dos Reis wrote:

> Richard Smith <richard@ex-parrot.com> writes:
>
> | Gcc's C++ grammar does not accept block scope using declarations of
> | operators, e.g.
>
> This is a long standing misbehaviour in GCC (already present the 2.95
> series).

Yes, I'd noticed that too, although I couldn't find a PR for it.

Are there any particular reasons why it hadn't been fixed yet?  Or is it
just lack of time/enthusiasm.  Unless I'm missing something the fix ought
to be quite straight-forward.

> Although serious, I'm not sure it qualifies as a regression.

Yes, I agree.  Development for 3.2 is only in stage 2, so might it be
appropriate to apply it there?

--
Richard Smith



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

* Re: Block scope using declarations of operators
  2002-07-10  8:56   ` Richard Smith
@ 2002-07-10  9:16     ` Gabriel Dos Reis
  2002-07-10 17:02       ` Mark Mitchell
  0 siblings, 1 reply; 6+ messages in thread
From: Gabriel Dos Reis @ 2002-07-10  9:16 UTC (permalink / raw)
  To: Richard Smith; +Cc: gcc

Richard Smith <richard@ex-parrot.com> writes:

| On 10 Jul 2002, Gabriel Dos Reis wrote:
| 
| > Richard Smith <richard@ex-parrot.com> writes:
| >
| > | Gcc's C++ grammar does not accept block scope using declarations of
| > | operators, e.g.
| >
| > This is a long standing misbehaviour in GCC (already present the 2.95
| > series).
| 
| Yes, I'd noticed that too, although I couldn't find a PR for it.
| 
| Are there any particular reasons why it hadn't been fixed yet?  Or is it
| just lack of time/enthusiasm.  Unless I'm missing something the fix ought
| to be quite straight-forward.

I got caught by that misbehaviour in the past, but didn't put it on the
top on my TODO list.  I think it was fixed by lack of time, not lack
of enthusiasm.

| > Although serious, I'm not sure it qualifies as a regression.
| 
| Yes, I agree.  Development for 3.2 is only in stage 2, so might it be
| appropriate to apply it there?


Yes, I think 3.2 should be the right place.  After 3.1.1 release, we
might raise the issue again for 3.1.x, but it is Mark's call.

-- Gaby

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

* Re: Block scope using declarations of operators
  2002-07-10  9:16     ` Gabriel Dos Reis
@ 2002-07-10 17:02       ` Mark Mitchell
  2002-07-10 21:26         ` Gabriel Dos Reis
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Mitchell @ 2002-07-10 17:02 UTC (permalink / raw)
  To: Gabriel Dos Reis, Richard Smith; +Cc: gcc

> Yes, I think 3.2 should be the right place.  After 3.1.1 release, we
> might raise the issue again for 3.1.x, but it is Mark's call.

This is not appropriate for the 3.1 branch, but it's fine for 3.2 if
we think it's the right patch.  Martin did a lot of that work; Martin,
are you out there anywhere still?

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com

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

* Re: Block scope using declarations of operators
  2002-07-10 17:02       ` Mark Mitchell
@ 2002-07-10 21:26         ` Gabriel Dos Reis
  0 siblings, 0 replies; 6+ messages in thread
From: Gabriel Dos Reis @ 2002-07-10 21:26 UTC (permalink / raw)
  To: Mark Mitchell; +Cc: Richard Smith, gcc

Mark Mitchell <mark@codesourcery.com> writes:

| > Yes, I think 3.2 should be the right place.  After 3.1.1 release, we
| > might raise the issue again for 3.1.x, but it is Mark's call.
| 
| This is not appropriate for the 3.1 branch, but it's fine for 3.2 if
| we think it's the right patch.

I have to confess that I didn't evaluate the correctness and
robustness of the patch.  I failed to make it clear that I was just
suggesting that fixing that misbehaviour should be done on 3.2.

Robustness and correctness will come later -- once I'm done with the
PPC/varargs thingy.

Thanks,

-- Gaby

^ 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).