summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c++/ctor-12.C
blob: 8bd53de3f23d14dc14af91ed87d5583d2154bcf6 (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
63
64
65
// PR c++/36308
// { dg-do run }

extern "C" void abort ();

static int n;

struct A
{
  A ()
  {
    l = 0;
    #pragma omp atomic
      ctors++;
  }
  A (const A &x)
  {
    l = x.l;
    #pragma omp atomic
      copyctors++;
  }
  virtual A& operator= (const A &x)
  {
    l = x.l;
    #pragma omp atomic
      assignops++;
    return *this;
  }
  virtual ~A ()
  {
    #pragma omp atomic
      dtors++;
  }
  int l;
  static int ctors, dtors, copyctors, assignops;
};

int A::ctors;
int A::dtors;
int A::copyctors;
int A::assignops;

int
main ()
{
  A a;
#pragma omp parallel private (a)
  {
    a.l = 6;
    #pragma omp single copyprivate (a)
    {
      a.l = 3;
    }
    if (a.l != 3)
      abort ();
    #pragma omp atomic
      n++;
  }
  if (A::ctors != n + 1
      || A::copyctors != 0
      || A::dtors != n
      || A::assignops != n - 1)
    abort ();
  return 0;
}