Merge from mainline (157519:158021).
[official-gcc/graphite-test-results.git] / libgomp / testsuite / libgomp.c / pr42942.c
blob5d57852450ad329fc2e38b6ce9c3778129f24858
1 /* PR libgomp/42942 */
2 /* { dg-do run } */
4 #include <omp.h>
5 #include <stdlib.h>
7 int
8 main (void)
10 int e = 0;
11 omp_set_dynamic (0);
12 omp_set_nested (1);
13 omp_set_max_active_levels (1);
14 if (omp_get_max_active_levels () != 1)
15 abort ();
16 #pragma omp parallel num_threads(2) reduction(|:e)
17 if (!omp_in_parallel ()
18 || omp_get_num_threads () != 2)
19 e = 1;
20 else
21 #pragma omp parallel num_threads(2) reduction(|:e)
22 if (!omp_in_parallel ()
23 || omp_get_num_threads () != 1)
24 e = 1;
25 if (e)
26 abort ();
27 omp_set_max_active_levels (0);
28 if (omp_get_max_active_levels () != 0)
29 abort ();
30 #pragma omp parallel num_threads(2) reduction(|:e)
31 if (omp_in_parallel ()
32 || omp_get_num_threads () != 1)
33 e = 1;
34 else
35 #pragma omp parallel num_threads(2) reduction(|:e)
36 if (omp_in_parallel ()
37 || omp_get_num_threads () != 1)
38 e = 1;
39 if (e)
40 abort ();
41 omp_set_max_active_levels (2);
42 if (omp_get_max_active_levels () != 2)
43 abort ();
44 #pragma omp parallel num_threads(2) reduction(|:e)
45 if (!omp_in_parallel ()
46 || omp_get_num_threads () != 2)
47 e = 1;
48 else
49 #pragma omp parallel num_threads(2) reduction(|:e)
50 if (!omp_in_parallel ()
51 || omp_get_num_threads () != 2)
52 e = 1;
53 else
54 #pragma omp parallel num_threads(2) reduction(|:e)
55 if (!omp_in_parallel ()
56 || omp_get_num_threads () != 1)
57 e = 1;
58 if (e)
59 abort ();
60 return 0;