Merge from mainline
[official-gcc.git] / libgomp / testsuite / libgomp.c / shared-2.c
blob56c88ecc734a51ce85c77e7a37c4eeac7cc48d30
1 #include <stdio.h>
2 #include <omp.h>
4 extern void abort (void);
6 void
7 parallel (int a, int b)
9 int bad, LASTPRIV, LASTPRIV_SEC;
10 int i;
12 a = b = 3;
14 bad = 0;
16 #pragma omp parallel firstprivate (a,b) shared (bad) num_threads (5)
18 if (a != 3 || b != 3)
19 bad = 1;
21 #pragma omp for lastprivate (LASTPRIV)
22 for (i = 0; i < 10; i++)
23 LASTPRIV = i;
25 #pragma omp sections lastprivate (LASTPRIV_SEC)
27 #pragma omp section
28 { LASTPRIV_SEC = 3; }
30 #pragma omp section
31 { LASTPRIV_SEC = 42; }
36 if (LASTPRIV != 9)
37 abort ();
39 if (LASTPRIV_SEC != 42)
40 abort ();
42 if (bad)
43 abort ();
46 int main()
48 parallel (1, 2);
49 return 0;