2011-09-27 Tom de Vries <tom@codesourcery.com>
[official-gcc.git] / libgomp / testsuite / libgomp.c / nestedfn-1.c
blob26c0d237cd2e5c25ce430de92c8496a76faf1ba4
1 /* { dg-do run } */
3 #include <omp.h>
4 #include <stdlib.h>
6 int
7 main (void)
9 int a = 1, b = 2, c = 3;
10 void
11 foo (void)
13 int l = 0;
14 #pragma omp parallel shared (a) private (b) firstprivate (c) \
15 num_threads (2) reduction (||:l)
17 if (a != 1 || c != 3) l = 1;
18 #pragma omp barrier
19 if (omp_get_thread_num () == 0)
21 a = 4;
22 b = 5;
23 c = 6;
25 #pragma omp barrier
26 if (omp_get_thread_num () == 1)
28 if (a != 4 || c != 3) l = 1;
29 a = 7;
30 b = 8;
31 c = 9;
33 else if (omp_get_num_threads () == 1)
34 a = 7;
35 #pragma omp barrier
36 if (omp_get_thread_num () == 0)
37 if (a != 7 || b != 5 || c != 6) l = 1;
38 #pragma omp barrier
39 if (omp_get_thread_num () == 1)
40 if (a != 7 || b != 8 || c != 9) l = 1;
42 if (l)
43 abort ();
45 foo ();
46 if (a != 7)
47 abort ();
48 return 0;