summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c/nestedfn-5.c
blob: 6072b1fe369022e3467087a5ddb1d44ebc7b9694 (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
/* { dg-do run } */
/* { dg-options "-O2" } */

extern void abort (void);

void
foo (int *j)
{
  int i = 5;
  int bar (void) { return i + 1; }
#pragma omp sections
  {
    #pragma omp section
      {
	if (bar () != 6)
	#pragma omp atomic
	  ++*j;
      }
    #pragma omp section
      {
	if (bar () != 6)
	#pragma omp atomic
	  ++*j;
      }
  }
}

int
main (void)
{
  int j = 0;
#pragma omp parallel num_threads (2)
  foo (&j);
  if (j)
    abort ();
  return 0;
}