Commit 867f133e by Ollie Wild Committed by Ollie Wild

re PR c++/8171 (Cannot compare pointer to member function of base and derived class)

	PR c++/8171

	gcc/cp/
	* typeck.c (build_binary_op): Add conversion of pointers to function
	members appearing as operands to the equality operators.

	gcc/testsuite/
	* g++.dg/conversion/ptrmem9.C: New test.

From-SVN: r130554
parent c23ebce2
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
......
......@@ -3394,9 +3394,9 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
}
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. */
......@@ -3407,6 +3407,16 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
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))
......
2007-12-01 Ollie Wild <aaw@google.com>
PR c++/8171
* g++.dg/conversion/ptrmem9.C: New test.
2007-11-30 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/34291
// 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 "" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment