aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-openmp.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-04-20 19:06:17 +0200
committerThomas Schwinge <thomas@codesourcery.com>2022-04-25 23:14:02 +0200
commitb2202431910e30d8505c94d1cb9341cac7080d10 (patch)
tree0d32c5d40834f0b7a5d297398070378dd40e471d /gcc/fortran/trans-openmp.cc
parent68fd1c9f22ad42536bcb63a4c776004268702b0b (diff)
downloadgcc-b2202431910e30d8505c94d1cb9341cac7080d10.zip
gcc-b2202431910e30d8505c94d1cb9341cac7080d10.tar.gz
gcc-b2202431910e30d8505c94d1cb9341cac7080d10.tar.bz2
fortran: Fix up gfc_trans_oacc_construct [PR104717]
So that move_sese_region_to_fn works properly, OpenMP/OpenACC constructs for which that function is invoked need an extra artificial BIND_EXPR around their body so that we move all variables of the bodies. The C/C++ FEs do that both for OpenMP constructs like OMP_PARALLEL, OMP_TASK or OMP_TARGET and for OpenACC constructs that behave similarly to OMP_TARGET, but the Fortran FE only does that for OpenMP constructs. The following patch does that for OpenACC constructs too. PR fortran/104717 gcc/fortran/ * trans-openmp.cc (gfc_trans_oacc_construct): Wrap construct body in an extra BIND_EXPR. gcc/testsuite/ * gfortran.dg/goacc/pr104717.f90: New test. * gfortran.dg/goacc/privatization-1-compute-loop.f90: Adjust. libgomp/ * testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: Adjust. Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
Diffstat (limited to 'gcc/fortran/trans-openmp.cc')
-rw-r--r--gcc/fortran/trans-openmp.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index 25dde82..43d59ab 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -4444,7 +4444,9 @@ gfc_trans_oacc_construct (gfc_code *code)
gfc_start_block (&block);
oacc_clauses = gfc_trans_omp_clauses (&block, code->ext.omp_clauses,
code->loc, false, true);
+ pushlevel ();
stmt = gfc_trans_omp_code (code->block->next, true);
+ stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
stmt = build2_loc (gfc_get_location (&code->loc), construct_code,
void_type_node, stmt, oacc_clauses);
gfc_add_expr_to_block (&block, stmt);