2018-01-22 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / libgomp / testsuite / libgomp.c++ / ctor-7.C
blob3d669a707910a0dba6395806066f84a4351959e3
1 // { dg-do run }
3 #include <omp.h>
4 #include <assert.h>
6 #define N 10
8 struct B
10   static int icount;
11   static int dcount;
12   static int xcount;
14   B();
15   B(const B &);
16   ~B();
17   B& operator=(const B &);
18   void doit();
21 int B::icount;
22 int B::dcount;
23 int B::xcount;
25 B::B()
27   #pragma omp atomic 
28     icount++;
31 B::~B()
33   #pragma omp atomic
34     dcount++;
37 void B::doit()
39   #pragma omp atomic
40     xcount++;
43 static int nthreads;
45 void foo()
47   B b[N];
48   #pragma omp parallel private(b)
49     {
50       #pragma omp master
51         nthreads = omp_get_num_threads ();
52       b[0].doit();
53     }
56 int main()
58   omp_set_dynamic (0);
59   omp_set_num_threads (4);
60   foo();
62   assert (B::xcount == nthreads);
63   assert (B::icount == (nthreads+1)*N);
64   assert (B::dcount == (nthreads+1)*N);
66   return 0;