2018-01-22 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / libgomp / testsuite / libgomp.c++ / shared-2.C
blob01855fbd496e48233928617021a186f491d9b475
1 extern "C" void abort (void);
3 void
4 parallel (int a, int b)
6   int bad, LASTPRIV, LASTPRIV_SEC;
7   int i;
9   a = b = 3;
11   bad = 0;
13   #pragma omp parallel firstprivate (a,b) shared (bad) num_threads (5)
14     {
15       if (a != 3 || b != 3)
16         bad = 1;
18       #pragma omp for lastprivate (LASTPRIV)
19       for (i = 0; i < 10; i++)
20         LASTPRIV = i;
22       #pragma omp sections lastprivate (LASTPRIV_SEC)
23         {
24           #pragma omp section
25             { LASTPRIV_SEC = 3; }
27           #pragma omp section
28             { LASTPRIV_SEC = 42; }
29         }
31     }
33   if (LASTPRIV != 9)
34     abort ();
36   if (LASTPRIV_SEC != 42)
37     abort ();
39   if (bad)
40     abort ();
43 int main()
45   parallel (1, 2);
46   return 0;