xref: /llvm-project/flang/test/Semantics/OpenMP/use_device_ptr1.f90 (revision 02db35a1d644b559d3841f31e9167d12458f8efc)
1! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp -fopenmp-version=50
2! OpenMP Version 5.0
3! 2.10.1 use_device_ptr clause
4! List item in USE_DEVICE_PTR clause must not be structure element.
5! List item in USE_DEVICE_PTR clause must be of type C_PTR.
6! List items that appear in a use_device_ptr clause can not appear in
7! use_device_addr clause.
8! Same list item can not be present multiple times or in multipe
9! USE_DEVICE_PTR clauses.
10
11subroutine omp_target_data
12   use iso_c_binding
13   integer :: a(1024)
14   type(C_PTR) :: b
15   integer, pointer :: arrayB
16   type my_type
17    type(C_PTR) :: my_cptr
18   end type my_type
19
20   type(my_type) :: my_var
21   a = 1
22
23   !ERROR: A variable that is part of another variable cannot appear on the USE_DEVICE_PTR clause
24   !$omp target data map(tofrom: a, arrayB) use_device_ptr(my_var%my_cptr)
25      allocate(arrayB)
26      call c_f_pointer(my_var%my_cptr, arrayB)
27      a = arrayB
28   !$omp end target data
29
30   !WARNING: Use of non-C_PTR type 'a' in USE_DEVICE_PTR is deprecated, use USE_DEVICE_ADDR instead
31   !$omp target data map(tofrom: a) use_device_ptr(a)
32      a = 2
33   !$omp end target data
34
35   !ERROR: List item 'b' present at multiple USE_DEVICE_PTR clauses
36   !$omp target data map(tofrom: a, arrayB) use_device_ptr(b) use_device_ptr(b)
37      allocate(arrayB)
38      call c_f_pointer(b, arrayB)
39      a = arrayB
40   !$omp end target data
41
42   !ERROR: List item 'b' present at multiple USE_DEVICE_PTR clauses
43   !$omp target data map(tofrom: a, arrayB) use_device_ptr(b,b)
44      allocate(arrayB)
45      call c_f_pointer(b, arrayB)
46      a = arrayB
47   !$omp end target data
48
49   !ERROR: Variable 'b' may not appear on both USE_DEVICE_PTR and USE_DEVICE_ADDR clauses on a TARGET DATA construct
50   !$omp target data map(tofrom: a, arrayB) use_device_addr(b) use_device_ptr(b)
51      allocate(arrayB)
52      call c_f_pointer(b, arrayB)
53      a = arrayB
54   !$omp end target data
55
56   !ERROR: Variable 'b' may not appear on both USE_DEVICE_PTR and USE_DEVICE_ADDR clauses on a TARGET DATA construct
57   !$omp target data map(tofrom: a, arrayB) use_device_ptr(b) use_device_addr(b)
58      allocate(arrayB)
59      call c_f_pointer(b, arrayB)
60      a = arrayB
61   !$omp end target data
62
63end subroutine omp_target_data
64
65