1 /* PR libgomp/42942 */ 2 /* { dg-do run } */ 3 /* { dg-additional-options "-Wno-deprecated-declarations" } */ 4 5 #include <omp.h> 6 #include <stdlib.h> 7 8 int main(void)9main (void) 10 { 11 int e = 0; 12 omp_set_dynamic (0); 13 omp_set_nested (1); 14 omp_set_max_active_levels (1); 15 if (omp_get_max_active_levels () != 1) 16 abort (); 17 #pragma omp parallel num_threads(2) reduction(|:e) 18 if (!omp_in_parallel () 19 || omp_get_num_threads () != 2) 20 e = 1; 21 else 22 #pragma omp parallel num_threads(2) reduction(|:e) 23 if (!omp_in_parallel () 24 || omp_get_num_threads () != 1) 25 e = 1; 26 if (e) 27 abort (); 28 omp_set_max_active_levels (0); 29 if (omp_get_max_active_levels () != 0) 30 abort (); 31 #pragma omp parallel num_threads(2) reduction(|:e) 32 if (omp_in_parallel () 33 || omp_get_num_threads () != 1) 34 e = 1; 35 else 36 #pragma omp parallel num_threads(2) reduction(|:e) 37 if (omp_in_parallel () 38 || omp_get_num_threads () != 1) 39 e = 1; 40 if (e) 41 abort (); 42 omp_set_max_active_levels (2); 43 if (omp_get_max_active_levels () != 2) 44 abort (); 45 #pragma omp parallel num_threads(2) reduction(|:e) 46 if (!omp_in_parallel () 47 || omp_get_num_threads () != 2) 48 e = 1; 49 else 50 #pragma omp parallel num_threads(2) reduction(|:e) 51 if (!omp_in_parallel () 52 || omp_get_num_threads () != 2) 53 e = 1; 54 else 55 #pragma omp parallel num_threads(2) reduction(|:e) 56 if (!omp_in_parallel () 57 || omp_get_num_threads () != 1) 58 e = 1; 59 if (e) 60 abort (); 61 return 0; 62 } 63