re PR c++/91987 (-fstrict-eval-order issues)
authorJakub Jelinek <jakub@redhat.com>
Fri, 11 Oct 2019 07:36:07 +0000 (09:36 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 11 Oct 2019 07:36:07 +0000 (09:36 +0200)
commit1a37b6d9a7e57c71b1bfe449ebd275eb408117fb
treefe29653bb010efc768398510adcd8af902405b71
parent1e99e6fe6bb61ad2011030324cfdf84d2a67e75d
re PR c++/91987 (-fstrict-eval-order issues)

PR c++/91987
cp/
* decl2.c (grok_array_decl): For -fstrong-eval-order, when array ref
operands have been swapped and at least one operand has side-effects,
revert the swapping before calling build_array_ref.
* typeck.c (cp_build_array_ref): For non-ARRAY_TYPE array ref with
side-effects on the index operand, if -fstrong-eval-order use
save_expr around the array operand.
(cp_build_binary_op): For shifts with side-effects in the second
operand, wrap first operand into SAVE_EXPR and evaluate it before
the shift.
* semantics.c (handle_omp_array_sections_1): Temporarily disable
flag_strong_eval_order during OMP_CLAUSE_REDUCTION array section
processing.
* cp-gimplify.c (gimplify_to_rvalue): New function.
(cp_gimplify_expr): Use it.
testsuite/
* g++.dg/cpp1z/eval-order6.C: New test.
* g++.dg/cpp1z/eval-order7.C: New test.
* g++.dg/cpp1z/eval-order8.C: New test.
* c-c++-common/gomp/pr91987.c: New test.

From-SVN: r276860
gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/cp/decl2.c
gcc/cp/semantics.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/gomp/pr91987.c [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/eval-order6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/eval-order7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/eval-order8.C [new file with mode: 0644]