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)
10int 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
18extern int x;
19#pragma omp declare target to(x)
20extern int y;
21#pragma omp declare target to(y)
22
23int 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(format: "PASS\n");
32}
33#endif
34

source code of offload/test/offloading/weak.c