xref: /llvm-project/offload/test/offloading/weak.c (revision 330d8983d25d08580fc1642fea48b2473f47a9da)
1 // RUN: %libomptarget-compile-generic -DA -c -o %t-a.o
2 // RUN: %libomptarget-compile-generic -DB -c -o %t-b.o
3 // RUN: %libomptarget-compile-generic %t-a.o %t-b.o && \
4 // RUN:   %libomptarget-run-generic | %fcheck-generic
5 
6 #if defined(A)
7 __attribute__((weak)) int x = 999;
8 #pragma omp declare target to(x)
9 #elif defined(B)
10 int x = 42;
11 #pragma omp declare target to(x)
12 __attribute__((weak)) int y = 42;
13 #pragma omp declare target to(y)
14 #else
15 
16 #include <stdio.h>
17 
18 extern int x;
19 #pragma omp declare target to(x)
20 extern int y;
21 #pragma omp declare target to(y)
22 
main()23 int main() {
24   x = 0;
25 
26 #pragma omp target update from(x)
27 #pragma omp target update from(y)
28 
29   // CHECK: PASS
30   if (x == 42 && y == 42)
31     printf("PASS\n");
32 }
33 #endif
34