summaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c++/atomic-1.C
blob: 73f6e7c40594100bf41887d2e4430ef7d0b4af7f (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
// PR c++/33894
// { dg-do run }
// { dg-options "-O2" }

extern "C" void abort ();

int check;

template<typename T> void
foo ()
{
  #pragma omp atomic
  check |= sizeof (T);
}

template<typename T> void
bar (T *x, T y)
{
  #pragma omp atomic
  *x += y;
}

template<typename T> void
baz ()
{
  #pragma omp atomic
  check++;
}

int
main ()
{
  int i = 0;
  long l = 0;

  check = 0;
  foo<char> ();
  if (check != sizeof (char))
    abort ();
  foo<short> ();
  if (check != (sizeof (char) | sizeof (short)))
    abort ();
  bar(&i, 4);
  bar(&l, 8L);
  if (i != 4 || l != 8L)
    abort ();
  baz<char> ();
  if (check != (sizeof (char) | sizeof (short)) + 1)
    abort ();
  baz<long double> ();
  if (check != (sizeof (char) | sizeof (short)) + 2)
    abort ();
}