Files
clang-p2996/flang/test/Semantics/OpenMP/use_device_addr1.f90
Raghu Maddhipatla 71d763b88d [OpenMP] [Semantics] [Flang] Adding more semantic checks for USE_DEVICE_PTR and USE_DEVICE_ADDR clauses.
The following restrictions for USE_DEVICE_PTR and USE_DEVICE_ADDR clauses on OMP TARGET DATA directive are implemented in this patch.

  - A list item may not be specified more than once in use_device_ptr clauses that appear on the directive.
  - A list item may not be specified more than once in use_device_addr clauses that appear on the directive.
  - A list item may not be specified in both a use_device_addr clause and a use_device_ptr clause on the directive.
  - A list item that appears in a use_device_ptr or use_device_addr clause must not be a structure element.
  - A list item that appears in a use_device_ptr must be of type C_PTR.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D155133
2023-08-04 00:19:36 -05:00

34 lines
1.0 KiB
Fortran

! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! OpenMP Version 5.0
! 2.10.1 use_device_ptr clause
! List item in USE_DEVICE_ADDR clause must not be structure element.
! Same list item can not be present multiple times or in multipe
! USE_DEVICE_ADDR clauses.
subroutine omp_target_data
integer :: a(1024)
integer, target :: b(1024)
type my_type
integer :: my_b(1024)
end type my_type
type(my_type) :: my_var
a = 1
!ERROR: A variable that is part of another variable (structure element) cannot appear on the TARGET DATA USE_DEVICE_ADDR clause
!$omp target data map(tofrom: a) use_device_addr(my_var%my_b)
my_var%my_b = a
!$omp end target data
!ERROR: List item 'b' present at multiple USE_DEVICE_ADDR clauses
!$omp target data map(tofrom: a) use_device_addr(b,b)
b = a
!$omp end target data
!ERROR: List item 'b' present at multiple USE_DEVICE_ADDR clauses
!$omp target data map(tofrom: a) use_device_addr(b) use_device_addr(b)
b = a
!$omp end target data
end subroutine omp_target_data