1 // RUN: %libomptarget-compile-run-and-check-x86_64-pc-linux-gnu
2 // RUN: %libomptarget-compile-x86_64-pc-linux-gnu -DUNUSED -Wall -Werror
3 
4 #include <omp.h>
5 #include <stdio.h>
6 
7 int main() {
8   int errors = 0;
9 #ifdef UNUSED
10 // Test if it is OK to leave the variants unused in the header
11 #else // UNUSED
12   int host = omp_is_initial_device();
13   int device = 1;
14 #pragma omp target map(tofrom : device)
15   { device = omp_is_initial_device(); }
16   if (!host) {
17     printf("omp_is_initial_device() returned false on host\n");
18     errors++;
19   }
20   if (device) {
21     printf("omp_is_initial_device() returned true on device\n");
22     errors++;
23   }
24 #endif // UNUSED
25 
26   // CHECK: PASS
27   printf("%s\n", errors ? "FAIL" : "PASS");
28 
29   return errors;
30 }
31