Remove xfail for hppa*-*-hpux* from stdatomic-flag.c and stdatomic-flag-2.c
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c++ / deep-copy-12.C
bloba512008685d20f9f17534cf074124214b3437ba1
1 #include <stdlib.h>
3 /* Test attach/detach with dereferences of reference to pointer to struct.  */
5 typedef struct {
6   int *a;
7   int *b;
8   int *c;
9 } mystruct;
11 int main(int argc, char* argv[])
13   const int N = 1024;
14   mystruct *m = (mystruct *) malloc (sizeof (*m));
15   mystruct *&mref = m;
16   int i;
18   mref->a = (int *) malloc (N * sizeof (int));
19   m->b = (int *) malloc (N * sizeof (int));
20   m->c = (int *) malloc (N * sizeof (int));
22   for (i = 0; i < N; i++)
23     {
24       mref->a[i] = 0;
25       m->b[i] = 0;
26       m->c[i] = 0;
27     }
29 #pragma acc enter data copyin(m[0:1])
31   for (int i = 0; i < 99; i++)
32     {
33       int j;
34 #pragma acc parallel loop copy(mref->a[0:N])
35       for (j = 0; j < N; j++)
36         mref->a[j]++;
37 #pragma acc parallel loop copy(mref->b[0:N], m->c[5:N-10])
38       for (j = 0; j < N; j++)
39         {
40           mref->b[j]++;
41           if (j > 5 && j < N - 5)
42             m->c[j]++;
43         }
44     }
46 #pragma acc exit data copyout(m[0:1])
48   for (i = 0; i < N; i++)
49     {
50       if (m->a[i] != 99)
51         abort ();
52       if (m->b[i] != 99)
53         abort ();
54       if (i > 5 && i < N-5)
55         {
56           if (m->c[i] != 99)
57             abort ();
58         }
59       else
60         {
61           if (m->c[i] != 0)
62             abort ();
63         }
64     }
66   free (m->a);
67   free (m->b);
68   free (m->c);
69   free (m);
71   return 0;