| 1 |
! PR middle-end/108546 |
| 2 |
! |
| 3 |
module m |
| 4 |
use iso_c_binding |
| 5 |
implicit none |
| 6 |
type(c_ptr) :: p2, p3 |
| 7 |
contains |
| 8 |
subroutine s(x,y,z) |
| 9 |
type(c_ptr), optional :: x |
| 10 |
integer, pointer, optional :: y |
| 11 |
integer, allocatable, optional, target :: z |
| 12 |
logical is_present, is_null |
| 13 |
is_present = present(x) |
| 14 |
if (is_present) & |
| 15 |
is_null = .not. c_associated(x) |
| 16 |
|
| 17 |
!$omp target data use_device_ptr(x) use_device_addr(y) use_device_addr(z) |
| 18 |
if (is_present) then |
| 19 |
if (is_null) then |
| 20 |
if (c_associated(x)) stop 1 |
| 21 |
if (associated(y)) stop 2 |
| 22 |
if (allocated(z)) stop 3 |
| 23 |
else |
| 24 |
if (.not. c_associated(x, p2)) stop 4 |
| 25 |
if (.not. c_associated(c_loc(y), p2)) stop 5 |
| 26 |
if (.not. c_associated(c_loc(z), p3)) stop 6 |
| 27 |
end if |
| 28 |
end if |
| 29 |
!$omp end target data |
| 30 |
end |
| 31 |
end |
| 32 |
|
| 33 |
use m |
| 34 |
implicit none |
| 35 |
type(c_ptr) :: cp |
| 36 |
integer, pointer :: p |
| 37 |
integer, allocatable, target :: a |
| 38 |
call s() |
| 39 |
p => null() |
| 40 |
call s(c_null_ptr, p, a) |
| 41 |
allocate(p,a) |
| 42 |
p = 7 |
| 43 |
a = 9 |
| 44 |
cp = c_loc(p) |
| 45 |
!$omp target enter data map(to: cp, p, a) |
| 46 |
!$omp target map(from: p2, p3) |
| 47 |
p2 = c_loc(p) |
| 48 |
p3 = c_loc(a) |
| 49 |
!$omp end target |
| 50 |
call s(cp, p, a) |
| 51 |
!$omp target exit data map(delete: cp, p, a) |
| 52 |
deallocate(p,a) |
| 53 |
end |