summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c++/shared-2.C
blob: 01855fbd496e48233928617021a186f491d9b475 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
extern "C" void abort (void);

void
parallel (int a, int b)
{
  int bad, LASTPRIV, LASTPRIV_SEC;
  int i;

  a = b = 3;

  bad = 0;

  #pragma omp parallel firstprivate (a,b) shared (bad) num_threads (5)
    {
      if (a != 3 || b != 3)
	bad = 1;

      #pragma omp for lastprivate (LASTPRIV)
      for (i = 0; i < 10; i++)
	LASTPRIV = i;

      #pragma omp sections lastprivate (LASTPRIV_SEC)
	{
	  #pragma omp section
	    { LASTPRIV_SEC = 3; }

	  #pragma omp section
	    { LASTPRIV_SEC = 42; }
	}

    }

  if (LASTPRIV != 9)
    abort ();

  if (LASTPRIV_SEC != 42)
    abort ();

  if (bad)
    abort ();
}

int main()
{
  parallel (1, 2);
  return 0;
}