OpenMP: Fix nested use_device_ptr
authorChung-Lin Tang <cltang@codesourcery.com>
Tue, 5 Apr 2022 15:31:34 +0000 (08:31 -0700)
committerChung-Lin Tang <cltang@codesourcery.com>
Tue, 5 Apr 2022 15:31:34 +0000 (08:31 -0700)
commitb0af8e3a502a64a0e0a04cc54ef055e5d942240f
tree6489081f39f9876d2d6b7edd33576289426d66a7
parente68f5c90bae44e886bd1b13a135dbfd00bceea0a
OpenMP: Fix nested use_device_ptr

This patch fixes a bug in lower_omp_target, where for Fortran arrays,
the expanded sender assignment is wrongly using the variable in the
current ctx, instead of the one looked-up outside, which is causing
use_device_ptr/addr to fail to work when used inside an omp-parallel
(where the omp child_fn is split away from the original).

The fix is inside omp-low.cc, though because the omp_array_data langhook
is used only by Fortran, this is essentially Fortran-specific.

2022-04-05  Chung-Lin Tang  <cltang@codesourcery.com>

gcc/ChangeLog:

* omp-low.cc (lower_omp_target): Use outer context looked-up 'var' as
argument to lang_hooks.decls.omp_array_data, instead of 'ovar' from
current clause.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/use_device_ptr-4.f90: New testcase.
gcc/omp-low.cc
libgomp/testsuite/libgomp.fortran/use_device_ptr-4.f90 [new file with mode: 0644]