xref: /llvm-project/offload/test/offloading/extern.c (revision 330d8983d25d08580fc1642fea48b2473f47a9da)
1 // RUN: %libomptarget-compile-generic -DVAR -c -o %t.o
2 // RUN: %libomptarget-compile-generic %t.o && %libomptarget-run-generic | %fcheck-generic
3 
4 #ifdef VAR
5 int x = 1;
6 #else
7 #include <stdio.h>
8 #include <assert.h>
9 extern int x;
10 
main()11 int main() {
12   int value = 0;
13 #pragma omp target map(from : value)
14   value = x;
15   assert(value == 1);
16 
17   x = 999;
18 #pragma omp target update to(x)
19 
20 #pragma omp target map(from : value)
21   value = x;
22   assert(value == 999);
23 
24   // CHECK: PASS
25   printf ("PASS\n");
26 }
27 #endif
28