1 // RUN: %libomptarget-compile-generic -DLIBRARY -c -o %t.o
2 // RUN: ar rcs %t.a %t.o
3 // RUN: %libomptarget-compile-generic %t.a && %libomptarget-run-generic 2>&1 | %fcheck-generic
4 
5 // UNSUPPORTED: nvptx64-nvidia-cuda-oldDriver
6 // UNSUPPORTED: amdgcn-amd-amdhsa-oldDriver
7 
8 #ifdef LIBRARY
9 int x = 42;
10 #pragma omp declare target(x)
11 
foo()12 int foo() {
13   int value;
14 #pragma omp target map(from : value)
15   value = x;
16   return value;
17 }
18 #else
19 #include <stdio.h>
20 int foo();
21 
main()22 int main() {
23   int x = foo();
24 
25   // CHECK: PASS
26   if (x == 42)
27     printf("PASS\n");
28 }
29 #endif
30