From ebb1abc3e45a4b8d83779a134d341c871d960332 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 22 Dec 2000 18:31:55 -0500 Subject: [PATCH] * typeck.c (build_binary_op): Fix pmf comparison logic. From-SVN: r38471 --- gcc/cp/ChangeLog | 4 ++-- gcc/cp/typeck.c | 37 ++++++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 51fbec9b4f4..6054868d0d8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,10 +1,10 @@ 2000-12-22 Jason Merrill + * typeck.c (build_binary_op): Fix pmf comparison logic. + * call.c (joust): Use DECL_NONSTATIC_MEMBER_FUNCTION_P, not DECL_STATIC_FUNCTION_P. - * typeck.c (build_binary_op): Fix pmf comparison logic. - * semantics.c (genrtl_finish_function): Don't try to jump to return_label unless it exists. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 8de99f6d3ab..23efc90a9ef 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3648,6 +3648,11 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) tree e1; tree e2; + if (TREE_SIDE_EFFECTS (op0)) + op0 = save_expr (op0); + if (TREE_SIDE_EFFECTS (op1)) + op1 = save_expr (op1); + if (flag_new_abi) { /* We generate: @@ -3670,7 +3675,7 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) delta1 = build_component_ref (op1, delta_identifier, NULL_TREE, 0); e1 = cp_build_binary_op (EQ_EXPR, delta0, delta1); - e2 = cp_build_binary_op (NE_EXPR, + e2 = cp_build_binary_op (EQ_EXPR, pfn0, cp_convert (TREE_TYPE (pfn0), integer_zero_node)); @@ -3683,13 +3688,19 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) /* The code we generate for the test is: (op0.index == op1.index - && ((op1.index != -1 && op0.delta2 == op1.delta2) - || op0.pfn == op1.pfn)) */ + && op0.delta == op1.delta + && (op1.index == -1 ? op0.pfn == op1.pfn + : op0.delta2 == op1.delta2)) */ tree index0 = build_component_ref (op0, index_identifier, NULL_TREE, 0); - tree index1 = save_expr (build_component_ref (op1, index_identifier, - NULL_TREE, 0)); + tree index1 + = save_expr (build_component_ref (op1, index_identifier, + NULL_TREE, 0)); + tree delta0 = build_component_ref (op0, delta_identifier, + NULL_TREE, 0); + tree delta1 = build_component_ref (op1, delta_identifier, + NULL_TREE, 0); tree pfn0 = PFN_FROM_PTRMEMFUNC (op0); tree pfn1 = PFN_FROM_PTRMEMFUNC (op1); tree delta20 = DELTA2_FROM_PTRMEMFUNC (op0); @@ -3698,17 +3709,17 @@ build_binary_op (code, orig_op0, orig_op1, convert_p) tree integer_neg_one_node = cp_build_binary_op (MINUS_EXPR, integer_zero_node, integer_one_node); - e1 = cp_build_binary_op (EQ_EXPR, index0, index1); - e2 = cp_build_binary_op (NE_EXPR, index1, integer_neg_one_node); - e2 = cp_build_binary_op (TRUTH_ANDIF_EXPR, e2, - cp_build_binary_op (EQ_EXPR, - delta20, delta21)); + e1 = cp_build_binary_op (EQ_EXPR, index1, integer_neg_one_node); /* We can't use build_binary_op for this cmp because it would get confused by the ptr to method types and think we want pmfs. */ - e3 = build (EQ_EXPR, boolean_type_node, pfn0, pfn1); - e2 = cp_build_binary_op (TRUTH_ORIF_EXPR, e2, e3); - e = cp_build_binary_op (TRUTH_ANDIF_EXPR, e1, e2); + e2 = build (EQ_EXPR, boolean_type_node, pfn0, pfn1); + e3 = cp_build_binary_op (EQ_EXPR, delta20, delta21); + e = build_conditional_expr (e1, e2, e3); + e1 = cp_build_binary_op (EQ_EXPR, index0, index1); + e = cp_build_binary_op (TRUTH_ANDIF_EXPR, e1, e); + e1 = cp_build_binary_op (EQ_EXPR, delta0, delta1); + e = cp_build_binary_op (TRUTH_ANDIF_EXPR, e1, e); } if (code == EQ_EXPR) return e;