xref: /llvm-project/offload/test/offloading/ctor_dtor.cpp (revision 330d8983d25d08580fc1642fea48b2473f47a9da)
1 // RUN: %libomptarget-compilexx-run-and-check-generic
2 // RUN: %libomptarget-compileoptxx-run-and-check-generic
3 
4 #include <cstdio>
5 struct S {
SS6   S() : i(7) {}
~SS7   ~S() { foo(); }
fooS8   int foo() { return i; }
9 
10 private:
11   int i;
12 };
13 
14 S s;
15 #pragma omp declare target(s)
16 
main()17 int main() {
18   int r;
19 #pragma omp target map(from : r)
20   r = s.foo();
21 
22   // CHECK: 7
23   printf("%i\n", r);
24 }
25