PR target/82855
[official-gcc.git] / libgomp / testsuite / libgomp.c / target-26.c
blobfa6b52598da9b4ba07b5bc992c8c12dc7eed1933
1 extern void abort (void);
2 #pragma omp declare target
3 int a[4] = { 2, 3, 4, 5 }, *b;
4 #pragma omp end declare target
6 int
7 main ()
9 int err;
10 int c[3] = { 6, 7, 8 };
11 b = c;
12 #pragma omp target map(to: a[0:2], b[0:2]) map(from: err)
13 err = a[0] != 2 || a[1] != 3 || a[2] != 4 || a[3] != 5 || b[0] != 6 || b[1] != 7;
14 if (err)
15 abort ();
16 a[1] = 9;
17 a[2] = 10;
18 #pragma omp target map(always,to:a[1:2]) map(from: err)
19 err = a[0] != 2 || a[1] != 9 || a[2] != 10 || a[3] != 5;
20 if (err)
21 abort ();
22 #pragma omp parallel firstprivate(a, b, c, err) num_threads (2)
23 #pragma omp single
25 b = c + 1;
26 a[0] = 11;
27 a[2] = 13;
28 c[1] = 14;
29 int d = 0;
30 #pragma omp target map(to: a[0:3], b[d:2]) map (from: err)
31 err = a[0] != 11 || a[1] != 9 || a[2] != 13 || b[0] != 14 || b[1] != 8;
32 if (err)
33 abort ();
35 return 0;