1 /* Test OpenACC's support for manual deep copy, including the attach
2    and detach clauses.  */
3 
4 void
t1()5 t1 ()
6 {
7   struct foo {
8     int *a, *b, c, d, *e;
9   } s;
10 
11   int *a, *z, scalar, **y;
12 
13 #pragma acc enter data copyin(s) detach(z) /* { dg-error ".detach. is not valid for" } */
14   {
15 #pragma acc data copy(s.a[0:10]) copy(z[0:10])
16     {
17       s.e = z;
18 #pragma acc parallel loop attach(s.e) detach(s.b) /* { dg-error ".detach. is not valid for" } */
19       for (int i = 0; i < 10; i++)
20         s.a[i] = s.e[i];
21 
22       a = s.e;
23 #pragma acc enter data attach(a) detach(s.c) /* { dg-error ".detach. is not valid for" } */
24 #pragma acc exit data detach(a)
25     }
26 
27 #pragma acc enter data attach(z[:5]) /* { dg-error "expected single pointer in .attach. clause" } */
28 /* { dg-error "has no data movement clause" "" { target *-*-* } .-1 } */
29 #pragma acc exit data detach(z[:5]) /* { dg-error "expected single pointer in .detach. clause" } */
30 /* { dg-error "has no data movement clause" "" { target *-*-* } .-1 } */
31 #pragma acc enter data attach(z[1:]) /* { dg-error "expected single pointer in .attach. clause" } */
32 /* { dg-error "has no data movement clause" "" { target *-*-* } .-1 } */
33 #pragma acc exit data detach(z[1:]) /* { dg-error "expected single pointer in .detach. clause" } */
34 /* { dg-error "has no data movement clause" "" { target *-*-* } .-1 } */
35 #pragma acc enter data attach(z[:]) /* { dg-error "expected single pointer in .attach. clause" } */
36 /* { dg-error "has no data movement clause" "" { target *-*-* } .-1 } */
37 #pragma acc exit data detach(z[:]) /* { dg-error "expected single pointer in .detach. clause" } */
38 /* { dg-error "has no data movement clause" "" { target *-*-* } .-1 } */
39 #pragma acc enter data attach(z[3]) /* { dg-error "expected pointer in .attach. clause" } */
40 #pragma acc exit data detach(z[3]) /* { dg-error "expected pointer in .detach. clause" } */
41 
42 #pragma acc acc enter data attach(s.e)
43 #pragma acc exit data detach(s.e) attach(z) /* { dg-error ".attach. is not valid for" } */
44 
45 #pragma acc data attach(s.e)
46     {
47     }
48 #pragma acc exit data delete(a) attach(s.a) /* { dg-error ".attach. is not valid for" } */
49 
50 #pragma acc enter data attach(scalar) /* { dg-error "expected pointer in .attach. clause" } */
51 /* { dg-error "has no data movement clause" "" { target *-*-* } .-1 } */
52 #pragma acc exit data detach(scalar) /* { dg-error "expected pointer in .detach. clause" } */
53 /* { dg-error "has no data movement clause" "" { target *-*-* } .-1 } */
54 #pragma acc enter data attach(s) /* { dg-error "expected pointer in .attach. clause" } */
55 /* { dg-error "has no data movement clause" "" { target *-*-* } .-1 } */
56 #pragma acc exit data detach(s) /* { dg-error "expected pointer in .detach. clause" } */
57 /* { dg-error "has no data movement clause" "" { target *-*-* } .-1 } */
58   }
59 
60 #pragma acc enter data attach(y[10])
61 #pragma acc exit data detach(y[10])
62 }
63