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 
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 enter data map(alloc: arr[0:5])
16 #pragma omp target exit data map(present, release: arr[0:0])
17 
18   // CHECK: arr is present
19   fprintf(stderr, "arr is present\n");
20 
21   // arr[0:0] doesn't create an actual mapping in the first directive.
22   //
23   // CHECK: Libomptarget message: device mapping required by 'present' map type modifier does not exist for host address 0x{{0*}}[[#HOST_ADDR]] (0 bytes)
24   // CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory
25 #pragma omp target enter data map(alloc: arr[0:0])
26 #pragma omp target exit data map(present, release: arr[0:0])
27 
28   // CHECK-NOT: arr is present
29   fprintf(stderr, "arr is present\n");
30 
31   return 0;
32 }
33