summaryrefslogtreecommitdiffstats
path: root/gcc
diff options
context:
space:
mode:
authoraaw <aaw@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-01 08:56:55 +0000
committeraaw <aaw@138bc75d-0d04-0410-961f-82ee72b054a4>2007-12-01 08:56:55 +0000
commit6a57f3916cc2baf53bd1fb642014d0047a59abaa (patch)
treef21ad738b7b0305e3f87dff48b61d0d0961b1a69 /gcc
parentc55910da14e3ac1f66b94d910f4bc65973326e21 (diff)
downloadppe42-gcc-6a57f3916cc2baf53bd1fb642014d0047a59abaa.tar.gz
ppe42-gcc-6a57f3916cc2baf53bd1fb642014d0047a59abaa.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130554 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck.c14
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/conversion/ptrmem9.C26
4 files changed, 49 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b8f1e889de9..494c98f418a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index c43eb793584..6a3405a6c36 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -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))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3c09a8db698..272cba92c14 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/g++.dg/conversion/ptrmem9.C b/gcc/testsuite/g++.dg/conversion/ptrmem9.C
new file mode 100644
index 00000000000..2ccd6837c47
--- /dev/null
+++ b/gcc/testsuite/g++.dg/conversion/ptrmem9.C
@@ -0,0 +1,26 @@
+// 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 "" }
+}
OpenPOWER on IntegriCloud