Remove xfail for hppa*-*-hpux* from stdatomic-flag.c and stdatomic-flag-2.c
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c++ / deep-copy-17.C
blobdacbb520f3d892e7e6c0cc94ae7d8693e856be42
1 #include <cassert>
3 /* Test attach/detach operation with pointers and references to structs.  */
5 typedef struct mystruct {
6   int *a;
7   int b;
8   int *c;
9   int d;
10   int *e;
11 } mystruct;
13 void str (void)
15   int a[10], c[10], e[10];
16   mystruct m = { .a = a, .c = c, .e = e };
17   a[0] = 5;
18   c[0] = 7;
19   e[0] = 9;
20   #pragma acc parallel copy(m.a[0:10], m.b, m.c[0:10], m.d, m.e[0:10])
21   {
22     m.a[0] = m.c[0] + m.e[0];
23   }
24   assert (m.a[0] == 7 + 9);
27 void strp (void)
29   int *a = new int[10];
30   int *c = new int[10];
31   int *e = new int[10];
32   mystruct *m = new mystruct;
33   m->a = a;
34   m->c = c;
35   m->e = e;
36   a[0] = 6;
37   c[0] = 8;
38   e[0] = 10;
39   #pragma acc parallel copy(m->a[0:10], m->b, m->c[0:10], m->d, m->e[0:10])
40   {
41     m->a[0] = m->c[0] + m->e[0];
42   }
43   assert (m->a[0] == 8 + 10);
44   delete m;
45   delete[] a;
46   delete[] c;
47   delete[] e;
50 void strr (void)
52   int *a = new int[10];
53   int *c = new int[10];
54   int *e = new int[10];
55   mystruct m;
56   mystruct &n = m;
57   n.a = a;
58   n.c = c;
59   n.e = e;
60   a[0] = 7;
61   c[0] = 9;
62   e[0] = 11;
63   #pragma acc parallel copy(n.a[0:10], n.b, n.c[0:10], n.d, n.e[0:10])
64   {
65     n.a[0] = n.c[0] + n.e[0];
66   }
67   assert (n.a[0] == 9 + 11);
68   delete[] a;
69   delete[] c;
70   delete[] e;
73 void strrp (void)
75   int a[10], c[10], e[10];
76   mystruct *m = new mystruct;
77   mystruct *&n = m;
78   n->a = a;
79   n->b = 3;
80   n->c = c;
81   n->d = 5;
82   n->e = e;
83   a[0] = 8;
84   c[0] = 10;
85   e[0] = 12;
86   #pragma acc parallel copy(n->a[0:10], n->c[0:10], n->e[0:10])
87   {
88     n->a[0] = n->c[0] + n->e[0];
89   }
90   assert (n->a[0] == 10 + 12);
91   delete m;
94 int main (int argc, char *argv[])
96   str ();
97   strp ();
98   strr ();
99   strrp ();
100   return 0;