xref: /llvm-project/offload/test/offloading/target_constexpr_mapping.cpp (revision 330d8983d25d08580fc1642fea48b2473f47a9da)
1 // RUN: %libomptarget-compileoptxx-run-and-check-generic
2 
3 #include <omp.h>
4 #include <stdio.h>
5 
6 #pragma omp declare target
7 class A {
8 public:
9   constexpr static double pi = 3.141592653589793116;
A()10   A() { ; }
~A()11   ~A() { ; }
12 };
13 #pragma omp end declare target
14 
15 #pragma omp declare target
16 constexpr static double anotherPi = 3.14;
17 #pragma omp end declare target
18 
main()19 int main() {
20   double a[2];
21 #pragma omp target map(tofrom : a[:2])
22   {
23     a[0] = A::pi;
24     a[1] = anotherPi;
25   }
26 
27   // CHECK: pi = 3.141592653589793116
28   printf("pi = %.18f\n", a[0]);
29 
30   // CHECK: anotherPi = 3.14
31   printf("anotherPi = %.2f\n", a[1]);
32 
33   return 0;
34 }
35