1 // RUN: %libomptarget-compile-generic -fopenmp-version=51
2 // RUN: %libomptarget-run-fail-generic 2>&1 \
3 // RUN: | %fcheck-generic
4 
5 
6 #include <stdio.h>
7 
main()8 int main() {
9   int arr[5];
10 
11   // CHECK: addr=0x[[#%x,HOST_ADDR:]]
12   fprintf(stderr, "addr=%p\n", arr);
13 
14   // CHECK-NOT: Libomptarget
15 #pragma omp target data map(alloc: arr[0:5])
16 #pragma omp target map(present, alloc: arr[0:0])
17   ;
18 
19   // CHECK: arr is present
20   fprintf(stderr, "arr is present\n");
21 
22   // arr[0:0] doesn't create an actual mapping in the first directive.
23   //
24   // CHECK: Libomptarget message: device mapping required by 'present' map type modifier does not exist for host address 0x{{0*}}[[#HOST_ADDR]] (0 bytes)
25   // CHECK: Libomptarget error: Call to getTargetPointer returned null pointer ('present' map type modifier).
26   // CHECK: Libomptarget error: Call to targetDataBegin failed, abort target.
27   // CHECK: Libomptarget error: Failed to process data before launching the kernel.
28   // CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory
29 #pragma omp target data map(alloc: arr[0:0])
30 #pragma omp target map(present, alloc: arr[0:0])
31   ;
32 
33   // CHECK-NOT: arr is present
34   fprintf(stderr, "arr is present\n");
35 
36   return 0;
37 }
38