https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126255
Bug ID: 126255
Summary: [OpenMP] declare target not handled for host-assocated
variables
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: openmp, rejects-valid
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
Target Milestone: ---
The following program fails with offloading with:
foo.c:3:12: error: variable 'val' has been referenced in offloaded code but
hasn't been marked to be included in the offloaded code
-------------------
program main
implicit none
!$omp requires self_maps
integer :: var, res
var = 5
call test
!$omp target
res = f()
!$omp end target
contains
subroutine test
!$omp declare target enter(var)
end
integer function f()
f = var
end
end
-------------------
However, OpenMP states (here: TR15):
------ Fortran ------
If a variable that is host associated appears in an enter clause then a
corresponding list item to the original list item is created in the device data
environment of all devices to which the directive of the clause applies.