Update concepts branch to revision 131834
[official-gcc.git] / libgomp / testsuite / libgomp.c / pr26943-4.c
blob0f1d4197a5f12a7dd6e57ed3cae794bd8365c717
1 /* PR c++/26943 */
2 /* { dg-do run } */
4 extern int omp_set_dynamic (int);
5 extern int omp_get_thread_num (void);
6 extern void abort (void);
8 int a = 8, b = 12, c = 16, d = 20, j = 0, l = 0;
9 char e[10] = "a", f[10] = "b", g[10] = "c", h[10] = "d";
10 volatile int k;
12 int
13 main (void)
15 int i;
16 omp_set_dynamic (0);
17 omp_set_nested (1);
18 #pragma omp parallel num_threads (2) reduction (+:l) \
19 firstprivate (a, b, c, d, e, f, g, h, j)
20 if (k == omp_get_thread_num ())
22 #pragma omp parallel for shared (a, e) firstprivate (b, f) \
23 lastprivate (c, g) private (d, h) \
24 schedule (static, 1) num_threads (4) \
25 reduction (+:j)
26 for (i = 0; i < 4; i++)
28 if (a != 8 || b != 12 || e[0] != 'a' || f[0] != 'b')
29 j++;
30 #pragma omp barrier /* { dg-warning "may not be closely nested" } */
31 #pragma omp atomic
32 a += i;
33 b += i;
34 c = i;
35 d = i;
36 #pragma omp atomic
37 e[0] += i;
38 f[0] += i;
39 g[0] = 'g' + i;
40 h[0] = 'h' + i;
41 #pragma omp barrier /* { dg-warning "may not be closely nested" } */
42 if (a != 8 + 6 || b != 12 + i || c != i || d != i)
43 j += 8;
44 if (e[0] != 'a' + 6 || f[0] != 'b' + i || g[0] != 'g' + i)
45 j += 64;
46 if (h[0] != 'h' + i)
47 j += 512;
49 if (j || a != 8 + 6 || b != 12 || c != 3 || d != 20)
50 ++l;
51 if (e[0] != 'a' + 6 || f[0] != 'b' || g[0] != 'g' + 3 || h[0] != 'd')
52 l += 8;
54 if (l)
55 abort ();
56 if (a != 8 || b != 12 || c != 16 || d != 20)
57 abort ();
58 if (e[0] != 'a' || f[0] != 'b' || g[0] != 'c' || h[0] != 'd')
59 abort ();
60 return 0;