xref: /llvm-project/offload/test/offloading/global_constructor.cpp (revision 330d8983d25d08580fc1642fea48b2473f47a9da)
1 // RUN: %libomptarget-compilexx-generic && %libomptarget-run-generic | %fcheck-generic
2 
3 #include <cstdio>
4 
foo()5 int foo() { return 1; }
6 
7 class C {
8 public:
C()9   C() : x(foo()) {}
10 
11   int x;
12 };
13 
14 C c;
15 #pragma omp declare target(c)
16 
main()17 int main() {
18   int x = 0;
19 #pragma omp target map(from : x)
20   { x = c.x; }
21 
22   // CHECK: PASS
23   if (x == 1)
24     printf("PASS\n");
25 }
26