Merge C++ from gomp-20050608-branch.
[official-gcc.git] / libgomp / testsuite / libgomp.c++ / ctor-6.C
blobeab74e08922473be70c39a785cb755720fbbac8d
1 // { dg-do run }
3 #include <omp.h>
4 #include <assert.h>
6 struct B
8   static int count;
9   static B *expected;
11   B& operator=(const B &);
14 int B::count;
15 B * B::expected;
17 B& B::operator= (const B &b)
19   assert (&b == expected);
20   assert (this != expected);
21   #pragma omp atomic
22     count++;
23   return *this;
26 static int nthreads;
28 void foo()
30   #pragma omp parallel
31     {
32       B b;
33       #pragma omp single copyprivate(b)
34         {
35           nthreads = omp_get_num_threads ();
36           B::expected = &b;
37         }
38     }
41 int main()
43   omp_set_dynamic (0);
44   omp_set_num_threads (4);
45   foo();
47   assert (B::count == nthreads-1);
49   return 0;