Update concepts branch to revision 131834
[official-gcc.git] / libgomp / testsuite / libgomp.c++ / pr26943.C
blob07b7b5dbf74cb14592491f0ed57347c8d6b3551c
1 // PR c++/26943
2 // { dg-do run }
4 #include <assert.h>
5 #include <unistd.h>
7 struct S
9   public:
10     int x;
11     S () : x(-1) { }
12     S (const S &);
13     S& operator= (const S &);
14     void test ();
17 static volatile int hold;
19 S::S (const S &s)
21   #pragma omp master
22     sleep (1);
24   assert (s.x == -1);
25   x = 0;
29 S::operator= (const S& s)
31   assert (s.x == 1);
32   x = 2;
33   return *this;
36 void
37 S::test ()
39   assert (x == 0);
40   x = 1;
43 static S x;
45 void
46 foo ()
48   #pragma omp sections firstprivate(x) lastprivate(x)
49   {
50     x.test();
51   }
54 int
55 main ()
57   #pragma omp parallel num_threads(2)
58     foo();
60   assert (x.x == 2);
61   return 0;