* [C++ diagnostic] Handle MEMBER_REF/DOTSTAR_EXPR in C++ dump_expr (PR c++/33844)
@ 2007-10-26 17:59 Jakub Jelinek
2007-10-26 18:22 ` Paolo Carlini
0 siblings, 1 reply; 8+ messages in thread
From: Jakub Jelinek @ 2007-10-26 17:59 UTC (permalink / raw)
To: Mark Mitchell, Jason Merrill; +Cc: gcc-patches
Hi!
pp_cxx_expression already handles these two (though incorrectly for
MEMBER_REF), but dump_expr does not.
Ok for trunk?
2007-10-26 Jakub Jelinek <jakub@redhat.com>
PR c++/33844
* cxx-pretty-print.c (pp_cxx_pm_expression) <case MEMBER_REF>: Print
->* rather than .*.
* error.c (dump_expr): Handle MEMBER_REF and DOTSTAR_EXPR.
* g++.dg/other/ptrmem8.C: New test.
--- gcc/cp/cxx-pretty-print.c.jj 2007-10-26 17:59:48.000000000 +0200
+++ gcc/cp/cxx-pretty-print.c 2007-10-26 18:07:13.000000000 +0200
@@ -814,7 +814,10 @@ pp_cxx_pm_expression (cxx_pretty_printer
case MEMBER_REF:
case DOTSTAR_EXPR:
pp_cxx_pm_expression (pp, TREE_OPERAND (t, 0));
- pp_cxx_dot (pp);
+ if (TREE_CODE (t) == MEMBER_REF)
+ pp_cxx_arrow (pp);
+ else
+ pp_cxx_dot (pp);
pp_star(pp);
pp_cxx_cast_expression (pp, TREE_OPERAND (t, 1));
break;
--- gcc/cp/error.c.jj 2007-10-26 16:20:28.000000000 +0200
+++ gcc/cp/error.c 2007-10-26 18:06:15.000000000 +0200
@@ -2052,6 +2052,11 @@ dump_expr (tree t, int flags)
pp_cxx_offsetof_expression (cxx_pp, t);
break;
+ case MEMBER_REF:
+ case DOTSTAR_EXPR:
+ pp_multiplicative_expression (cxx_pp, t);
+ break;
+
case DELETE_EXPR:
case VEC_DELETE_EXPR:
pp_cxx_delete_expression (cxx_pp, t);
--- gcc/testsuite/g++.dg/other/ptrmem8.C.jj 2007-10-26 18:08:53.000000000 +0200
+++ gcc/testsuite/g++.dg/other/ptrmem8.C 2007-10-26 18:14:30.000000000 +0200
@@ -0,0 +1,16 @@
+// PR c++/33844
+// { dg-do compile }
+
+struct A {};
+
+template<int> void foo(void (A::* f)())
+{
+ A a;
+ &(a.*f); // { dg-error "invalid use of\[^\n\]*\\.\\*\[^\n\]*to form|qualified-id is required" }
+}
+
+template<int> void bar(void (A::* f)())
+{
+ A *p;
+ &(p->*f); // { dg-error "invalid use of\[^\n\]*->\\*\[^\n\]*to form|qualified-id is required" }
+}
Jakub
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [C++ diagnostic] Handle MEMBER_REF/DOTSTAR_EXPR in C++ dump_expr (PR c++/33844)
2007-10-26 17:59 [C++ diagnostic] Handle MEMBER_REF/DOTSTAR_EXPR in C++ dump_expr (PR c++/33844) Jakub Jelinek
@ 2007-10-26 18:22 ` Paolo Carlini
2007-10-26 19:02 ` Gabriel Dos Reis
0 siblings, 1 reply; 8+ messages in thread
From: Paolo Carlini @ 2007-10-26 18:22 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Mark Mitchell, Jason Merrill, gcc-patches
Hi,
> --- gcc/testsuite/g++.dg/other/ptrmem8.C.jj 2007-10-26 18:08:53.000000000 +0200
> +++ gcc/testsuite/g++.dg/other/ptrmem8.C 2007-10-26 18:14:30.000000000 +0200
> @@ -0,0 +1,16 @@
> +// PR c++/33844
> +// { dg-do compile }
> +
> +struct A {};
> +
> +template<int> void foo(void (A::* f)())
> +{
> + A a;
> + &(a.*f); // { dg-error "invalid use of\[^\n\]*\\.\\*\[^\n\]*to form|qualified-id is required" }
> +}
> +
> +template<int> void bar(void (A::* f)())
> +{
> + A *p;
> + &(p->*f); // { dg-error "invalid use of\[^\n\]*->\\*\[^\n\]*to form|qualified-id is required" }
> +}
>
In the output I'm seeing:
‘foo::a.*foo::f'
and
‘foo::p->*foo::f’
are we really sure we want to qualify with foo:: like that?
Thanks,
Paolo.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [C++ diagnostic] Handle MEMBER_REF/DOTSTAR_EXPR in C++ dump_expr (PR c++/33844)
2007-10-26 18:22 ` Paolo Carlini
@ 2007-10-26 19:02 ` Gabriel Dos Reis
2007-10-26 20:06 ` Jakub Jelinek
0 siblings, 1 reply; 8+ messages in thread
From: Gabriel Dos Reis @ 2007-10-26 19:02 UTC (permalink / raw)
To: Paolo Carlini; +Cc: Jakub Jelinek, Mark Mitchell, Jason Merrill, gcc-patches
Paolo Carlini <pcarlini@suse.de> writes:
| Hi,
| > --- gcc/testsuite/g++.dg/other/ptrmem8.C.jj 2007-10-26 18:08:53.000000000 +0200
| > +++ gcc/testsuite/g++.dg/other/ptrmem8.C 2007-10-26 18:14:30.000000000 +0200
| > @@ -0,0 +1,16 @@
| > +// PR c++/33844
| > +// { dg-do compile }
| > +
| > +struct A {};
| > +
| > +template<int> void foo(void (A::* f)())
| > +{
| > + A a;
| > + &(a.*f); // { dg-error "invalid use of\[^\n\]*\\.\\*\[^\n\]*to form|qualified-id is required" }
| > +}
| > +
| > +template<int> void bar(void (A::* f)())
| > +{
| > + A *p;
| > + &(p->*f); // { dg-error "invalid use of\[^\n\]*->\\*\[^\n\]*to form|qualified-id is required" }
| > +}
| >
| In the output I'm seeing:
|
| foo::a.*foo::f'
|
| and
|
| foo::p->*foo::f
|
| are we really sure we want to qualify with foo:: like that?
No, one would need to set a `scope' cutoff.
-- Gaby
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [C++ diagnostic] Handle MEMBER_REF/DOTSTAR_EXPR in C++ dump_expr (PR c++/33844)
2007-10-26 19:02 ` Gabriel Dos Reis
@ 2007-10-26 20:06 ` Jakub Jelinek
2007-10-26 20:37 ` Gabriel Dos Reis
0 siblings, 1 reply; 8+ messages in thread
From: Jakub Jelinek @ 2007-10-26 20:06 UTC (permalink / raw)
To: Gabriel Dos Reis; +Cc: Paolo Carlini, Mark Mitchell, Jason Merrill, gcc-patches
On Fri, Oct 26, 2007 at 01:34:02PM -0500, Gabriel Dos Reis wrote:
> No, one would need to set a `scope' cutoff.
So should reinit_cxx_pp set enclosing_scope to current_function_decl
instead of 0?
Jakub
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [C++ diagnostic] Handle MEMBER_REF/DOTSTAR_EXPR in C++ dump_expr (PR c++/33844)
2007-10-26 20:06 ` Jakub Jelinek
@ 2007-10-26 20:37 ` Gabriel Dos Reis
2007-10-27 11:54 ` Jakub Jelinek
0 siblings, 1 reply; 8+ messages in thread
From: Gabriel Dos Reis @ 2007-10-26 20:37 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Paolo Carlini, Mark Mitchell, Jason Merrill, gcc-patches
On Fri, 26 Oct 2007, Jakub Jelinek wrote:
| On Fri, Oct 26, 2007 at 01:34:02PM -0500, Gabriel Dos Reis wrote:
| > No, one would need to set a `scope' cutoff.
|
| So should reinit_cxx_pp set enclosing_scope to current_function_decl
| instead of 0?
Yes, try it out if it works.
-- Gaby
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [C++ diagnostic] Handle MEMBER_REF/DOTSTAR_EXPR in C++ dump_expr (PR c++/33844)
2007-10-26 20:37 ` Gabriel Dos Reis
@ 2007-10-27 11:54 ` Jakub Jelinek
2007-10-27 12:00 ` Paolo Carlini
2007-10-27 13:52 ` Gabriel Dos Reis
0 siblings, 2 replies; 8+ messages in thread
From: Jakub Jelinek @ 2007-10-27 11:54 UTC (permalink / raw)
To: Gabriel Dos Reis; +Cc: Paolo Carlini, Mark Mitchell, Jason Merrill, gcc-patches
On Fri, Oct 26, 2007 at 03:05:09PM -0500, Gabriel Dos Reis wrote:
> On Fri, 26 Oct 2007, Jakub Jelinek wrote:
>
> | On Fri, Oct 26, 2007 at 01:34:02PM -0500, Gabriel Dos Reis wrote:
> | > No, one would need to set a `scope' cutoff.
> |
> | So should reinit_cxx_pp set enclosing_scope to current_function_decl
> | instead of 0?
>
> Yes, try it out if it works.
With the additional patch below other/ptrmem8.C reports:
/usr/src/gcc/gcc/testsuite/g++.dg/other/ptrmem8.C: In function 'void foo(void (A::*)())':
/usr/src/gcc/gcc/testsuite/g++.dg/other/ptrmem8.C:9: error: invalid use of 'a.*f' to form a pointer-to-member-function
/usr/src/gcc/gcc/testsuite/g++.dg/other/ptrmem8.C:9: note: a qualified-id is required
/usr/src/gcc/gcc/testsuite/g++.dg/other/ptrmem8.C: In function 'void bar(void (A::*)())':
/usr/src/gcc/gcc/testsuite/g++.dg/other/ptrmem8.C:15: error: invalid use of 'p->*f' to form a pointer-to-member-function
/usr/src/gcc/gcc/testsuite/g++.dg/other/ptrmem8.C:15: note: a qualified-id is required
and no regressions appear in regression testing.
Ok to commit both patches to the trunk?
2007-10-27 Jakub Jelinek <jakub@redhat.com>
* error.c (reinit_cxx_pp): Initialize cxx_pp->enclosing_scope
to current_function_decl rather than 0.
--- gcc/cp/error.c.jj 2007-10-26 18:06:15.000000000 +0200
+++ gcc/cp/error.c 2007-10-27 11:52:10.000000000 +0200
@@ -2107,7 +2107,7 @@ reinit_cxx_pp (void)
pp_base (cxx_pp)->padding = pp_none;
pp_indentation (cxx_pp) = 0;
pp_needs_newline (cxx_pp) = false;
- cxx_pp->enclosing_scope = 0;
+ cxx_pp->enclosing_scope = current_function_decl;
}
Jakub
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [C++ diagnostic] Handle MEMBER_REF/DOTSTAR_EXPR in C++ dump_expr (PR c++/33844)
2007-10-27 11:54 ` Jakub Jelinek
@ 2007-10-27 12:00 ` Paolo Carlini
2007-10-27 13:52 ` Gabriel Dos Reis
1 sibling, 0 replies; 8+ messages in thread
From: Paolo Carlini @ 2007-10-27 12:00 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
> 2007-10-27 Jakub Jelinek <jakub@redhat.com>
>
> * error.c (reinit_cxx_pp): Initialize cxx_pp->enclosing_scope
> to current_function_decl rather than 0.
>
Thanks Jakub for this, really an unrelated issue, but time to fix it!
Paolo.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [C++ diagnostic] Handle MEMBER_REF/DOTSTAR_EXPR in C++ dump_expr (PR c++/33844)
2007-10-27 11:54 ` Jakub Jelinek
2007-10-27 12:00 ` Paolo Carlini
@ 2007-10-27 13:52 ` Gabriel Dos Reis
1 sibling, 0 replies; 8+ messages in thread
From: Gabriel Dos Reis @ 2007-10-27 13:52 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Paolo Carlini, Mark Mitchell, Jason Merrill, gcc-patches
Jakub Jelinek <jakub@redhat.com> writes:
| On Fri, Oct 26, 2007 at 03:05:09PM -0500, Gabriel Dos Reis wrote:
| > On Fri, 26 Oct 2007, Jakub Jelinek wrote:
| >
| > | On Fri, Oct 26, 2007 at 01:34:02PM -0500, Gabriel Dos Reis wrote:
| > | > No, one would need to set a `scope' cutoff.
| > |
| > | So should reinit_cxx_pp set enclosing_scope to current_function_decl
| > | instead of 0?
| >
| > Yes, try it out if it works.
|
| With the additional patch below other/ptrmem8.C reports:
| /usr/src/gcc/gcc/testsuite/g++.dg/other/ptrmem8.C: In function 'void foo(void (A::*)())':
| /usr/src/gcc/gcc/testsuite/g++.dg/other/ptrmem8.C:9: error: invalid use of 'a.*f' to form a pointer-to-member-function
| /usr/src/gcc/gcc/testsuite/g++.dg/other/ptrmem8.C:9: note: a qualified-id is required
| /usr/src/gcc/gcc/testsuite/g++.dg/other/ptrmem8.C: In function 'void bar(void (A::*)())':
| /usr/src/gcc/gcc/testsuite/g++.dg/other/ptrmem8.C:15: error: invalid use of 'p->*f' to form a pointer-to-member-function
| /usr/src/gcc/gcc/testsuite/g++.dg/other/ptrmem8.C:15: note: a qualified-id is required
| and no regressions appear in regression testing.
| Ok to commit both patches to the trunk?
Thanks!
-- Gaby
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-10-27 13:09 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-26 17:59 [C++ diagnostic] Handle MEMBER_REF/DOTSTAR_EXPR in C++ dump_expr (PR c++/33844) Jakub Jelinek
2007-10-26 18:22 ` Paolo Carlini
2007-10-26 19:02 ` Gabriel Dos Reis
2007-10-26 20:06 ` Jakub Jelinek
2007-10-26 20:37 ` Gabriel Dos Reis
2007-10-27 11:54 ` Jakub Jelinek
2007-10-27 12:00 ` Paolo Carlini
2007-10-27 13:52 ` 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).