1d0bc04d6SGeorge Rokos // RUN: %libomptarget-compilexx-run-and-check-generic
2d0bc04d6SGeorge Rokos 
327177b82SJon Chesterfield // Wrong results on amdgpu
4b0d68c71SPushpinder Singh // XFAIL: amdgcn-amd-amdhsa
5ae23be84SJoseph Huber // XFAIL: amdgcn-amd-amdhsa-oldDriver
6*d5d83663SJoseph Huber // XFAIL: amdgcn-amd-amdhsa-LTO
7b0d68c71SPushpinder Singh 
8d0bc04d6SGeorge Rokos #include <stdio.h>
9d0bc04d6SGeorge Rokos #include <stdint.h>
10d0bc04d6SGeorge Rokos 
11d0bc04d6SGeorge Rokos // CHECK: before: [[V1:111]] [[V2:222]] [[PX:0x[^ ]+]] [[PY:0x[^ ]+]]
12d0bc04d6SGeorge Rokos // CHECK: lambda: [[V1]] [[V2]] [[PX_TGT:0x[^ ]+]] 0x{{.*}}
13d0bc04d6SGeorge Rokos // CHECK: tgt   : [[V2]] [[PX_TGT]] 1
14d0bc04d6SGeorge Rokos // CHECK: out   : [[V2]] [[V2]] [[PX]] [[PY]]
15d0bc04d6SGeorge Rokos 
main()16d0bc04d6SGeorge Rokos int main() {
17d0bc04d6SGeorge Rokos   int x[10];
18d0bc04d6SGeorge Rokos   long y[8];
19d0bc04d6SGeorge Rokos   x[1] = 111;
20d0bc04d6SGeorge Rokos   y[1] = 222;
21d0bc04d6SGeorge Rokos 
22d0bc04d6SGeorge Rokos   auto lambda = [&x, y]() {
23d0bc04d6SGeorge Rokos     printf("lambda: %d %ld %p %p\n", x[1], y[1], &x[0], &y[0]);
24d0bc04d6SGeorge Rokos     x[1] = y[1];
25d0bc04d6SGeorge Rokos   };
26d0bc04d6SGeorge Rokos 
27d0bc04d6SGeorge Rokos   printf("before: %d %ld %p %p\n", x[1], y[1], &x[0], &y[0]);
28d0bc04d6SGeorge Rokos 
29d0bc04d6SGeorge Rokos   intptr_t xp = (intptr_t) &x[0];
30d0bc04d6SGeorge Rokos #pragma omp target firstprivate(xp)
31d0bc04d6SGeorge Rokos   {
32d0bc04d6SGeorge Rokos     lambda();
33d0bc04d6SGeorge Rokos     printf("tgt   : %d %p %d\n", x[1], &x[0], (&x[0] != (int*) xp));
34d0bc04d6SGeorge Rokos   }
35d0bc04d6SGeorge Rokos   printf("out   : %d %ld %p %p\n", x[1], y[1], &x[0], &y[0]);
36d0bc04d6SGeorge Rokos 
37d0bc04d6SGeorge Rokos   return 0;
38d0bc04d6SGeorge Rokos }
39d0bc04d6SGeorge Rokos 
40