This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ diagnostic] Handle MEMBER_REF/DOTSTAR_EXPR in C++ dump_expr (PR c++/33844)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]