124f836e8SJoachim Protze // RUN: %libomptarget-compile-generic -fopenmp-version=51
224f836e8SJoachim Protze // RUN: %libomptarget-run-fail-generic 2>&1 \
324f836e8SJoachim Protze // RUN: | %fcheck-generic
4708752b2SJoel E. Denny 
5708752b2SJoel E. Denny 
6708752b2SJoel E. Denny #include <stdio.h>
7708752b2SJoel E. Denny 
main()8708752b2SJoel E. Denny int main() {
9708752b2SJoel E. Denny   int arr[5];
10708752b2SJoel E. Denny 
11708752b2SJoel E. Denny   // CHECK: addr=0x[[#%x,HOST_ADDR:]]
12708752b2SJoel E. Denny   fprintf(stderr, "addr=%p\n", arr);
13708752b2SJoel E. Denny 
14708752b2SJoel E. Denny   // CHECK-NOT: Libomptarget
15708752b2SJoel E. Denny #pragma omp target data map(alloc: arr[0:5])
16708752b2SJoel E. Denny #pragma omp target map(present, alloc: arr[0:0])
17708752b2SJoel E. Denny   ;
18708752b2SJoel E. Denny 
19708752b2SJoel E. Denny   // CHECK: arr is present
20708752b2SJoel E. Denny   fprintf(stderr, "arr is present\n");
21708752b2SJoel E. Denny 
22708752b2SJoel E. Denny   // arr[0:0] doesn't create an actual mapping in the first directive.
23708752b2SJoel E. Denny   //
24708752b2SJoel E. Denny   // CHECK: Libomptarget message: device mapping required by 'present' map type modifier does not exist for host address 0x{{0*}}[[#HOST_ADDR]] (0 bytes)
25*a2bd4408SGeorge Rokos   // CHECK: Libomptarget error: Call to getTargetPointer returned null pointer ('present' map type modifier).
267a5a74eaSJoseph Huber   // CHECK: Libomptarget error: Call to targetDataBegin failed, abort target.
277a5a74eaSJoseph Huber   // CHECK: Libomptarget error: Failed to process data before launching the kernel.
28708752b2SJoel E. Denny   // CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory
29708752b2SJoel E. Denny #pragma omp target data map(alloc: arr[0:0])
30708752b2SJoel E. Denny #pragma omp target map(present, alloc: arr[0:0])
31708752b2SJoel E. Denny   ;
32708752b2SJoel E. Denny 
33708752b2SJoel E. Denny   // CHECK-NOT: arr is present
34708752b2SJoel E. Denny   fprintf(stderr, "arr is present\n");
35708752b2SJoel E. Denny 
36708752b2SJoel E. Denny   return 0;
37708752b2SJoel E. Denny }
38