[clangd] Re-land "support outgoing calls in call hierarchy" (#117673)
[llvm-project.git] / flang / test / Semantics / OpenMP / use_device_ptr1.f90
blob41dbadc59ce7ca7044d476f5f670017ff0c54249
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.
11 subroutine 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
20 type(my_type) :: my_var
21 a = 1
23 !ERROR: A variable that is part of another variable (structure element) cannot appear on the TARGET DATA 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
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
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
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
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
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
63 end subroutine omp_target_data