1 /* PR middle-end/36802 */ 2 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); 7 8 int q; 9 10 int foo(int k)11foo (int k) 12 { 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) 17 { 18 int l; 19 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) 31 { 32 if (omp_get_num_threads () != 4) 33 #pragma omp atomic 34 n += 1; 35 #pragma omp critical 36 i += 1; 37 } 38 } 39 if (n == 0 && i != 6 + 3 * 4) 40 abort (); 41 return 0; 42 } 43 44 int main(void)45main (void) 46 { 47 foo (0); 48 return 0; 49 } 50