+2007-12-01 Ollie Wild <aaw@google.com>
+
+ PR c++/8171
+ * typeck.c (build_binary_op): Add conversion of pointers to function
+ members appearing as operands to the equality operators.
+
2007-11-30 Jakub Jelinek <jakub@redhat.com>
PR c++/34275
}
else if (TYPE_PTRMEMFUNC_P (type1) && null_ptr_cst_p (op0))
return cp_build_binary_op (code, op1, op0);
- else if (TYPE_PTRMEMFUNC_P (type0) && TYPE_PTRMEMFUNC_P (type1)
- && same_type_p (type0, type1))
+ else if (TYPE_PTRMEMFUNC_P (type0) && TYPE_PTRMEMFUNC_P (type1))
{
+ tree type;
/* E will be the final comparison. */
tree e;
/* E1 and E2 are for scratch. */
tree delta0;
tree delta1;
+ type = composite_pointer_type (type0, type1, op0, op1, "comparison");
+
+ if (!same_type_p (TREE_TYPE (op0), type))
+ op0 = cp_convert_and_check (type, op0);
+ if (!same_type_p (TREE_TYPE (op1), type))
+ op1 = cp_convert_and_check (type, op1);
+
+ if (op0 == error_mark_node || op1 == error_mark_node)
+ return error_mark_node;
+
if (TREE_SIDE_EFFECTS (op0))
op0 = save_expr (op0);
if (TREE_SIDE_EFFECTS (op1))
--- /dev/null
+// Copyright (C) 2007 Free Software Foundation
+// Contributed by Ollie Wild <aaw@google.com>
+// { dg-do compile }
+
+// Test implicit conversion of pointers to member functions appearing as
+// operands of the equality operators.
+
+struct B { };
+
+struct BV { };
+
+struct D : B, virtual BV { };
+
+struct C { };
+
+void f ()
+{
+ void (D::*pd) () = 0;
+ void (B::*pb) () = 0;
+ void (BV::*pbv) () = 0;
+ void (C::*pc) () = 0;
+
+ pd == pb;
+ pd == pbv; // { dg-error "" }
+ pd == pc; // { dg-error "" }
+}