summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c++/pr34513.C
blob: e5ad3bcb44d43aa9c9e857d507bd441135a6e02f (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
// PR c++/34513
// { dg-do run }

#include <omp.h>

extern "C" void abort ();

static int errors = 0;
static int thrs = 4;

int
main ()
{
  omp_set_dynamic (0);

  #pragma omp parallel num_threads (thrs)
  {
    static int shrd = 0;

    #pragma omp atomic
      shrd += 1;

    #pragma omp barrier

    if (shrd != thrs)
      #pragma omp atomic
	errors += 1;
  }

  if (errors)
    abort ();
}