1extern "C" void abort (void);
2
3void
4parallel (int a, int b)
5{
6  int bad, LASTPRIV, LASTPRIV_SEC;
7  int i;
8
9  a = b = 3;
10
11  bad = 0;
12
13  #pragma omp parallel firstprivate (a,b) shared (bad) num_threads (5)
14    {
15      if (a != 3 || b != 3)
16	bad = 1;
17
18      #pragma omp for lastprivate (LASTPRIV)
19      for (i = 0; i < 10; i++)
20	LASTPRIV = i;
21
22      #pragma omp sections lastprivate (LASTPRIV_SEC)
23	{
24	  #pragma omp section
25	    { LASTPRIV_SEC = 3; }
26
27	  #pragma omp section
28	    { LASTPRIV_SEC = 42; }
29	}
30
31    }
32
33  if (LASTPRIV != 9)
34    abort ();
35
36  if (LASTPRIV_SEC != 42)
37    abort ();
38
39  if (bad)
40    abort ();
41}
42
43int main()
44{
45  parallel (1, 2);
46  return 0;
47}
48