summaryrefslogtreecommitdiff
path: root/offload/test/offloading/global_constructor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'offload/test/offloading/global_constructor.cpp')
-rw-r--r--offload/test/offloading/global_constructor.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/offload/test/offloading/global_constructor.cpp b/offload/test/offloading/global_constructor.cpp
new file mode 100644
index 000000000000..eb68c5f78358
--- /dev/null
+++ b/offload/test/offloading/global_constructor.cpp
@@ -0,0 +1,25 @@
+// RUN: %libomptarget-compilexx-generic && %libomptarget-run-generic | %fcheck-generic
+
+#include <cstdio>
+
+int foo() { return 1; }
+
+class C {
+public:
+ C() : x(foo()) {}
+
+ int x;
+};
+
+C c;
+#pragma omp declare target(c)
+
+int main() {
+ int x = 0;
+#pragma omp target map(from : x)
+ { x = c.x; }
+
+ // CHECK: PASS
+ if (x == 1)
+ printf("PASS\n");
+}