|| GFC_DECL_CRAY_POINTEE (decl)
|| GFC_DESCRIPTOR_TYPE_P
(TREE_TYPE (TREE_TYPE (decl)))
- || n->sym->ts.type == BT_DERIVED))
+ || (n->sym->ts.type == BT_DERIVED
+ && (n->sym->ts.u.derived->ts.f90_type
+ != BT_VOID))))
{
tree orig_decl = decl;
}
tree present;
present = ((do_optional_check
- && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_HAS_DEVICE_ADDR)
+ && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_HAS_DEVICE_ADDR
+ && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_IS_DEVICE_PTR)
? omp_check_optional_argument (OMP_CLAUSE_DECL (c), true)
: NULL_TREE);
if (present)
--- /dev/null
+module m
+ use iso_c_binding
+ implicit none
+contains
+ subroutine s(x,y,z)
+ type(c_ptr), optional :: x
+ integer, pointer, optional :: y
+ integer, allocatable, optional :: z
+ logical is_present, is_null
+ is_present = present(x)
+ if (is_present) &
+ is_null = .not. c_associated(x)
+
+ !$omp target is_device_ptr(x) has_device_addr(y) has_device_addr(z)
+ if (is_present) then
+ if (is_null) then
+ if (c_associated(x)) stop 1
+ if (associated(y)) stop 2
+ if (allocated(z)) stop 3
+ else
+ if (.not. c_associated(x, c_loc(y))) stop 4
+ if (y /= 7) stop 5
+ if (z /= 9) stop 6
+ end if
+ end if
+ !$omp end target
+ end
+end
+
+use m
+implicit none
+integer, pointer :: p
+integer, allocatable :: a
+p => null()
+call s()
+!$omp target data map(p,a) use_device_addr(p,a)
+ call s(c_null_ptr, p, a)
+!$omp end target data
+allocate(p,a)
+p = 7
+a = 9
+!$omp target data map(p,a) use_device_addr(p,a)
+ call s(c_loc(p), p, a)
+!$omp end target data
+deallocate(p,a)
+end
--- /dev/null
+! PR middle-end/108546
+!
+module m
+ use iso_c_binding
+ implicit none
+ type(c_ptr) :: p2, p3
+contains
+ subroutine s(x,y,z)
+ type(c_ptr), optional :: x
+ integer, pointer, optional :: y
+ integer, allocatable, optional, target :: z
+ logical is_present, is_null
+ is_present = present(x)
+ if (is_present) &
+ is_null = .not. c_associated(x)
+
+ !$omp target data use_device_ptr(x) use_device_addr(y) use_device_addr(z)
+ if (is_present) then
+ if (is_null) then
+ if (c_associated(x)) stop 1
+ if (associated(y)) stop 2
+ if (allocated(z)) stop 3
+ else
+ if (.not. c_associated(x, p2)) stop 4
+ if (.not. c_associated(c_loc(y), p2)) stop 5
+ if (.not. c_associated(c_loc(z), p3)) stop 6
+ end if
+ end if
+ !$omp end target data
+ end
+end
+
+use m
+implicit none
+type(c_ptr) :: cp
+integer, pointer :: p
+integer, allocatable, target :: a
+call s()
+p => null()
+call s(c_null_ptr, p, a)
+allocate(p,a)
+p = 7
+a = 9
+cp = c_loc(p)
+!$omp target enter data map(to: cp, p, a)
+!$omp target map(from: p2, p3)
+ p2 = c_loc(p)
+ p3 = c_loc(a)
+!$omp end target
+call s(cp, p, a)
+!$omp target exit data map(delete: cp, p, a)
+deallocate(p,a)
+end