57 lines
1.7 KiB
Diff
57 lines
1.7 KiB
Diff
2007-10-27 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/error.c (revision 129681)
|
|
+++ gcc/cp/error.c (revision 129682)
|
|
@@ -1891,6 +1891,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;
|
|
+
|
|
/* This list is incomplete, but should suffice for now.
|
|
It is very important that `sorry' does not call
|
|
`report_error_function'. That could cause an infinite loop. */
|
|
--- gcc/cp/cxx-pretty-print.c (revision 129681)
|
|
+++ gcc/cp/cxx-pretty-print.c (revision 129682)
|
|
@@ -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/testsuite/g++.dg/other/ptrmem8.C (revision 0)
|
|
+++ gcc/testsuite/g++.dg/other/ptrmem8.C (revision 129682)
|
|
@@ -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" }
|
|
+}
|