]> git.ipfire.org Git - thirdparty/gcc.git/commit
OpenMP/Fortran: Fix present modifier in map clauses for allocatables
authorPaul-Antoine Arras <parras@baylibre.com>
Mon, 2 Feb 2026 10:19:06 +0000 (11:19 +0100)
committerPaul-Antoine Arras <parras@baylibre.com>
Wed, 4 Feb 2026 18:12:14 +0000 (19:12 +0100)
commit1e71ff87c97fcd37b8b98c76b684f23a17bae973
tree9bdc659697e768be3838dd2e5366f526e8a87acc
parenta82ca5803483043f758c6c153d5bbc80060b091c
OpenMP/Fortran: Fix present modifier in map clauses for allocatables

The OpenMP 6.0 spec reads (Section 7.9.6 "map Clause"):
"Unless otherwise specified, if a list item is a referencing variable then the
effect of the map clause is applied to its referring pointer and, if a
referenced pointee exists, its referenced pointee."

In other words, the map clause (and its modifiers) applies to the array
descriptor (unconditionally), and also to the array data if it is allocated.

Without this patch, the semantics enforced in libgomp is incorrect: an
allocatable is deemed present only if it is allocated. Correct semantics: an
allocatable is in the present table as long as its descriptor is mapped, even if
no data exists.

libgomp/ChangeLog:

* target.c (gomp_present_fatal): New function.
(gomp_map_vars_internal): For a Fortran allocatable array, present
causes runtime termination only if the descriptor is not mapped.
(gomp_update): Call gomp_present_fatal.
* testsuite/libgomp.fortran/map-alloc-present-1.f90: New test.
libgomp/target.c
libgomp/testsuite/libgomp.fortran/map-alloc-present-1.f90 [new file with mode: 0644]