1 extern "C" void abort ();
2 struct S { char a[64]; int (&r)[2]; char b[64]; };
4 __attribute__((noinline, noclone)) void
5 foo (S s, int (&t)[3], int z)
8 // Test that implicit mapping of reference to array does NOT
9 // behave like zero length array sections. s.r can't be used
10 // implicitly, as that means implicit mapping of the whole s
11 // and trying to dereference the references in there is unspecified.
12 #pragma omp target map(from: err) map(to: sep)
14 err = t[0] != 1 || t[1] != 2 || t[2] != 3;
18 // But explicit zero length array section mapping does.
19 #pragma omp target map(from: err) map(tofrom: s.r[:0], t[:0])
22 err = s.r != (int *) 0 || t != (int *) 0;
24 err = t[0] != 1 || t[1] != 2 || t[2] != 3 || s.r[0] != 6 || s.r[1] != 7;
27 // Similarly zero length array section, but unknown at compile time.
28 #pragma omp target map(from: err) map(tofrom: s.r[:z], t[:z])
31 err = s.r != (int *) 0 || t != (int *) 0;
33 err = t[0] != 1 || t[1] != 2 || t[2] != 3 || s.r[0] != 6 || s.r[1] != 7;
36 #pragma omp target enter data map (to: s.r, t)
37 // But when already mapped, it binds to existing mappings.
38 #pragma omp target map(from: err) map(tofrom: s.r[:0], t[:0])
40 err = t[0] != 1 || t[1] != 2 || t[2] != 3 || s.r[0] != 6 || s.r[1] != 7;
44 #pragma omp target map(from: err) map(tofrom: s.r[:z], t[:z])
46 err = t[0] != 1 || t[1] != 2 || t[2] != 3 || s.r[0] != 6 || s.r[1] != 7;
55 int t[3] = { 1, 2, 3 };