2011-09-27 Tom de Vries <tom@codesourcery.com>
[official-gcc.git] / libgomp / testsuite / libgomp.c / nestedfn-3.c
blob8f8847f97e9917d1a9fc6bc024e7603c9d88c57d
1 /* { dg-do run } */
3 #include <omp.h>
5 extern void abort (void);
7 int
8 main (void)
10 int i = 5, l = 0;
11 int foo (void) { return i == 6; }
12 int bar (void) { return i - 3; }
14 omp_set_dynamic (0);
16 #pragma omp parallel if (foo ()) num_threads (bar ()) reduction (|:l)
17 if (omp_get_num_threads () != 1)
18 l = 1;
20 i++;
22 #pragma omp parallel if (foo ()) num_threads (bar ()) reduction (|:l)
23 if (omp_get_num_threads () != 3)
24 l = 1;
26 i++;
28 #pragma omp master
29 if (bar () != 4)
30 abort ();
32 #pragma omp single
34 if (foo ())
35 abort ();
36 i--;
37 if (! foo ())
38 abort ();
41 if (l)
42 abort ();
44 i = 8;
45 #pragma omp atomic
46 l += bar ();
48 if (l != 5)
49 abort ();
51 return 0;