Skip various cmp-mem-const tests on lp64 hppa*-*-*
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / array-of-struct-2.c
blobd5d74b8c07d60d5cc72e3b7c63d13299f7a1896c
1 /* { dg-do run } */
3 #include <stdlib.h>
4 #include <string.h>
5 #include <assert.h>
7 #define N 16
9 /* NOTE: This test is the same as array-of-struct-1.c, except the fields of
10 this struct are in a different order. */
12 struct Z {
13 int *ptr;
14 int arr[N];
15 int c;
18 void
19 foo (struct Z *zarr, int len)
21 #pragma omp target map(to:zarr, zarr[5].ptr) map(tofrom:zarr[5].ptr[0:len])
23 for (int i = 0; i < len; i++)
24 zarr[5].ptr[i]++;
27 #pragma omp target map(to:zarr) map(tofrom:zarr[4].arr[0:len])
29 for (int i = 0; i < len; i++)
30 zarr[4].arr[i]++;
33 #pragma omp target map (to:zarr[3].ptr) map(tofrom:zarr[3].ptr[0:len])
35 for (int i = 0; i < len; i++)
36 zarr[3].ptr[i]++;
39 #pragma omp target map(tofrom:zarr[2].arr[0:len])
41 for (int i = 0; i < len; i++)
42 zarr[2].arr[i]++;
46 int main (int argc, char *argv[])
48 struct Z zs[10];
49 memset (zs, 0, sizeof zs);
51 for (int i = 0; i < 10; i++)
52 zs[i].ptr = (int *) calloc (N, sizeof (int));
54 foo (zs, N);
56 for (int i = 0; i < N; i++)
58 assert (zs[2].arr[i] == 1);
59 assert (zs[4].arr[i] == 1);
60 assert (zs[3].ptr[i] == 1);
61 assert (zs[5].ptr[i] == 1);
64 return 0;