PR rtl-optimization/77919
[official-gcc.git] / libgomp / testsuite / libgomp.c / pr36802-2.c
blob7bda65931979a988f11280073c207587a24a87d1
1 /* PR middle-end/36802 */
3 extern void abort (void);
4 extern int omp_set_dynamic (int);
5 extern void omp_set_nested (int);
6 extern int omp_get_num_threads (void);
8 int q;
10 int
11 foo (int k)
13 int i = 6, n = 0;
14 omp_set_dynamic (0);
15 omp_set_nested (1);
16 #pragma omp parallel shared (i) num_threads (3)
18 int l;
20 if (omp_get_num_threads () != 3)
21 #pragma omp atomic
22 n += 1;
23 else
24 #pragma omp for
25 for (l = 0; l < 3; l++)
26 if (k)
27 #pragma omp atomic
28 q += i;
29 else
30 #pragma omp parallel shared (i) num_threads (4)
32 if (omp_get_num_threads () != 4)
33 #pragma omp atomic
34 n += 1;
35 #pragma omp critical
36 i += 1;
39 if (n == 0 && i != 6 + 3 * 4)
40 abort ();
41 return 0;
44 int
45 main (void)
47 foo (0);
48 return 0;