1*24f836e8SJoachim Protze // RUN: %libomptarget-compile-generic -fopenmp-version=51
2*24f836e8SJoachim Protze // RUN: %libomptarget-run-fail-generic 2>&1 \
3*24f836e8SJoachim 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 enter data map(alloc: arr[0:5])
16708752b2SJoel E. Denny #pragma omp target exit data map(present, release: arr[0:0])
17708752b2SJoel E. Denny 
18708752b2SJoel E. Denny   // CHECK: arr is present
19708752b2SJoel E. Denny   fprintf(stderr, "arr is present\n");
20708752b2SJoel E. Denny 
21708752b2SJoel E. Denny   // arr[0:0] doesn't create an actual mapping in the first directive.
22708752b2SJoel E. Denny   //
23708752b2SJoel 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)
24708752b2SJoel E. Denny   // CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory
25708752b2SJoel E. Denny #pragma omp target enter data map(alloc: arr[0:0])
26708752b2SJoel E. Denny #pragma omp target exit data map(present, release: arr[0:0])
27708752b2SJoel E. Denny 
28708752b2SJoel E. Denny   // CHECK-NOT: arr is present
29708752b2SJoel E. Denny   fprintf(stderr, "arr is present\n");
30708752b2SJoel E. Denny 
31708752b2SJoel E. Denny   return 0;
32708752b2SJoel E. Denny }
33