aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.2.1-5666.3/libgomp/testsuite/libgomp.c++/pr26943.C
blob: 07b7b5dbf74cb14592491f0ed57347c8d6b3551c (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// PR c++/26943
// { dg-do run }

#include <assert.h>
#include <unistd.h>

struct S
{
  public:
    int x;
    S () : x(-1) { }
    S (const S &);
    S& operator= (const S &);
    void test ();
};

static volatile int hold;

S::S (const S &s)
{
  #pragma omp master
    sleep (1);

  assert (s.x == -1);
  x = 0;
}

S&
S::operator= (const S& s)
{
  assert (s.x == 1);
  x = 2;
  return *this;
}

void
S::test ()
{
  assert (x == 0);
  x = 1;
}

static S x;

void
foo ()
{
  #pragma omp sections firstprivate(x) lastprivate(x)
  {
    x.test();
  }
}

int
main ()
{
  #pragma omp parallel num_threads(2)
    foo();

  assert (x.x == 2);
  return 0;
}