Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / mapping / lambda_by_value.cpp
blob5516dedd72a98e0a11a51f90282605a760be8c27
1 // RUN: %libomptarget-compilexx-run-and-check-generic
3 #include <stdint.h>
4 #include <stdio.h>
6 // CHECK: before: [[V1:111]] [[V2:222]] [[PX:0x[^ ]+]] [[PY:0x[^ ]+]]
7 // CHECK: lambda: [[V1]] [[V2]] [[PX_TGT:0x[^ ]+]] 0x{{.*}}
8 // CHECK: tgt : [[V2]] [[PX_TGT]] 1
9 // CHECK: out : [[V2]] [[V2]] [[PX]] [[PY]]
11 #pragma omp begin declare target
12 int a = -1, *c;
13 long b = -1;
14 const long *d;
15 int e = -1, *f, g = -1;
16 #pragma omp end declare target
18 int main() {
19 int x[10];
20 long y[8];
21 x[1] = 111;
22 y[1] = 222;
24 auto lambda = [&x, y]() {
25 a = x[1];
26 b = y[1];
27 c = &x[0];
28 d = &y[0];
29 printf("lambda: %d %ld %p %p\n", x[1], y[1], &x[0], &y[0]);
30 x[1] = y[1];
32 printf("before: %d %ld %p %p\n", x[1], y[1], &x[0], &y[0]);
34 intptr_t xp = (intptr_t)&x[0];
35 #pragma omp target firstprivate(xp)
37 lambda();
38 e = x[1];
39 f = &x[0];
40 g = (&x[0] != (int *)xp);
41 printf("tgt : %d %p %d\n", x[1], &x[0], (&x[0] != (int *)xp));
43 #pragma omp target update from(a, b, c, d, e, f, g)
44 printf("lambda: %d %ld %p %p\n", a, b, c, d);
45 printf("tgt : %d %p %d\n", e, f, g);
46 printf("out : %d %ld %p %p\n", x[1], y[1], &x[0], &y[0]);
48 return 0;