1 // RUN: %libomptarget-compilexx-run-and-check-generic
2 
3 #include <cstdio>
4 #include <cstdlib>
5 
6 typedef struct {
7   int a;
8   double *b;
9 } C1;
10 #pragma omp declare mapper(C1 s) map(to : s.a) map(from : s.b [0:2])
11 
12 typedef struct {
13   int a;
14   double *b;
15   C1 c;
16 } C;
17 #pragma omp declare mapper(C s) map(to : s.a, s.c) map(from : s.b [0:2])
18 
19 typedef struct {
20   int e;
21   C f;
22   int h;
23 } D;
24 
25 int main() {
26   constexpr int N = 10;
27   D s;
28   s.e = 111;
29   s.f.a = 222;
30   s.f.c.a = 777;
31   double x[2];
32   double x1[2];
33   x[1] = 20;
34   s.f.b = &x[0];
35   s.f.c.b = &x1[0];
36   s.h = N;
37 
38   D *sp = &s;
39   D **spp = &sp;
40 
41   printf("%d %d %d %4.5f %d\n", spp[0][0].e, spp[0][0].f.a, spp[0][0].f.c.a,
42          spp[0][0].f.b[1], spp[0][0].f.b == &x[0] ? 1 : 0);
43   // CHECK: 111 222 777 20.00000 1
44 
45   __intptr_t p = reinterpret_cast<__intptr_t>(&x[0]);
46 #pragma omp target map(tofrom : spp[0][0]) firstprivate(p)
47   {
48     printf("%d %d %d\n", spp[0][0].f.a, spp[0][0].f.c.a,
49            spp[0][0].f.b == reinterpret_cast<void *>(p) ? 1 : 0);
50     // CHECK: 222 777 0
51     spp[0][0].e = 333;
52     spp[0][0].f.a = 444;
53     spp[0][0].f.c.a = 555;
54     spp[0][0].f.b[1] = 40;
55   }
56   printf("%d %d %d %4.5f %d\n", spp[0][0].e, spp[0][0].f.a, spp[0][0].f.c.a,
57          spp[0][0].f.b[1], spp[0][0].f.b == &x[0] ? 1 : 0);
58   // CHECK: 333 222 777 40.00000 1
59 }
60