diff options
author | Zhenqiang Chen <zhenqiang.chen@linaro.org> | 2012-09-25 06:37:29 +0000 |
---|---|---|
committer | Bin Cheng <amker@gcc.gnu.org> | 2012-09-25 06:37:29 +0000 |
commit | 20265464cc416a33f25b14078e60633db024bcea (patch) | |
tree | da1a729c7d5bb69c881824399b9e0e13fbfb9a26 | |
parent | 21a8ccc02f643458b82780ac1b884f8454b89871 (diff) | |
download | gcc-20265464cc416a33f25b14078e60633db024bcea.zip gcc-20265464cc416a33f25b14078e60633db024bcea.tar.gz gcc-20265464cc416a33f25b14078e60633db024bcea.tar.bz2 |
re PR target/50970 (Function pointer dereferenced twice in if statement on Arm cpu)
PR c++/50970
* typeck.c (cp_build_binary_op): Check side effects before generating
pfn and delta related expressions.
From-SVN: r191692
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 29 |
2 files changed, 23 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c03f66a..ba1f775c0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-09-25 Zhenqiang Chen <zhenqiang.chen@linaro.org> + + PR c++/50970 + * typeck.c (cp_build_binary_op): Check side effects before generating + pfn and delta related expressions. + 2012-09-24 Lawrence Crowl <crowl@google.com> * init.c (build_new_1): Change to new double_int API. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index ad4b090..884f7d0 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4159,18 +4159,23 @@ cp_build_binary_op (location_t location, if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta) { - tree pfn0 = pfn_from_ptrmemfunc (op0); - tree delta0 = delta_from_ptrmemfunc (op0); - tree e1 = cp_build_binary_op (location, - EQ_EXPR, - pfn0, - build_zero_cst (TREE_TYPE (pfn0)), - complain); - tree e2 = cp_build_binary_op (location, - BIT_AND_EXPR, - delta0, - integer_one_node, - complain); + tree pfn0, delta0, e1, e2; + + if (TREE_SIDE_EFFECTS (op0)) + op0 = save_expr (op0); + + pfn0 = pfn_from_ptrmemfunc (op0); + delta0 = delta_from_ptrmemfunc (op0); + e1 = cp_build_binary_op (location, + EQ_EXPR, + pfn0, + build_zero_cst (TREE_TYPE (pfn0)), + complain); + e2 = cp_build_binary_op (location, + BIT_AND_EXPR, + delta0, + integer_one_node, + complain); if ((complain & tf_warning) && c_inhibit_evaluation_warnings == 0 |