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
This commit is contained in:
Zhenqiang Chen 2012-09-25 06:37:29 +00:00 committed by Bin Cheng
parent 21a8ccc02f
commit 20265464cc
2 changed files with 23 additions and 12 deletions

View file

@ -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.

View file

@ -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