Debian Codegraph @

libgomp/testsuite/libgomp.c-c++-common/ind-base-4.c

raw
1 // { dg-do run }
2 // { dg-options "-fopenmp" }
3
4 #include <assert.h>
5 #include <stdlib.h>
6
7 typedef struct
8 {
9 int x[10];
10 } S;
11
12 typedef struct
13 {
14 S ***s;
15 } T;
16
17 typedef struct
18 {
19 T **t;
20 } U;
21
22 void
23 foo (void)
24 {
25 U *u = (U *) malloc (sizeof (U));
26 T *real_t = (T *) malloc (sizeof (T));
27 S *real_s = (S *) malloc (sizeof (S));
28 T **t_pp = &real_t;
29 S **s_pp = &real_s;
30 S ***s_ppp = &s_pp;
31 u->t = t_pp;
32 (*u->t)->s = s_ppp;
33 for (int i = 0; i < 10; i++)
34 (**((*u->t)->s))->x[i] = 0;
35 #pragma omp target map(u->t, *u->t, (*u->t)->s, *(*u->t)->s, **(*u->t)->s, \
36 (**(*u->t)->s)->x[0:10])
37 for (int i = 0; i < 10; i++)
38 (**((*u->t)->s))->x[i] = i * 3;
39 for (int i = 0; i < 10; i++)
40 assert ((**((*u->t)->s))->x[i] == i * 3);
41 free (real_s);
42 free (real_t);
43 free (u);
44 }
45
46 int main (int argc, char *argv[])
47 {
48 foo ();
49 return 0;
50 }