[Bug fortran/122910] [OpenMP] 'firstprivate' on 'target' mishandled – should privatize pointer not (also) the pointee
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jun 10 14:32:18 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122910
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Chung-Lin Tang <cltang@gcc.gnu.org>:
https://gcc.gnu.org/g:800227516cf3d407ef17e7206b8bebe2d29f4dc1
commit r17-1467-g800227516cf3d407ef17e7206b8bebe2d29f4dc1
Author: Chung-Lin Tang <cltang@baylibre.com>
Date: Wed Jun 10 14:29:06 2026 +0000
Fortran/OpenMP: Fix POINTER array mis-privatization [PR122910]
This patch fixes a case where POINTER attribute arrays are deep copied
when not supposed to. Namely, OpenMP states for the "firstprivate Clause":
"If an original list item has the POINTER attribute, the new list
items receive the same association status as the original list
item, as if by pointer assignment."
This creates a new langhook 'omp_array_data_privatize' to differentiate
cases in certain places during omp-low.
PR fortran/122910
gcc/fortran/ChangeLog:
* f95-lang.cc (LANG_HOOKS_OMP_ARRAY_DATA_PRIVATIZE): Define as
gfc_omp_array_data_privatize.
* trans-openmp.cc (gfc_omp_array_data_privatize): New function.
* trans.h (gfc_omp_array_data_privatize): New declaration.
gcc/ChangeLog:
* langhooks-def.h (LANG_HOOKS_OMP_ARRAY_DATA_PRIVATIZE): Define.
* langhooks.h (struct lang_hooks_for_decls): Define
omp_array_data_privatize hook.
* omp-low.cc (scan_sharing_clauses): Add new calls to
lang_hooks.decls.omp_array_data_privatize,
(lower_omp_target): Likewise.
libgomp/ChangeLog:
* testsuite/libgomp.fortran/pr122910.f90: New test.
Reviewed-by: Tobias Burnus <tburnus@baylibre.com>
More information about the Gcc-bugs
mailing list