Retro68/gcc/libgomp/testsuite/libgomp.c++/atomic-12.C
2014-09-21 19:33:12 +02:00

59 lines
1.1 KiB
C

// { dg-do run }
extern "C" void abort ();
int x = 6, cnt;
int
foo ()
{
return cnt++;
}
int
main ()
{
int v, *p;
p = &x;
#pragma omp atomic update
p[foo (), 0] = 16 + 6 - p[foo (), 0];
#pragma omp atomic read
v = x;
if (cnt != 2 || v != 16)
abort ();
#pragma omp atomic capture
v = p[foo () + foo (), 0] = p[foo () + foo (), 0] + 3;
if (cnt != 6 || v != 19)
abort ();
#pragma omp atomic capture
v = p[foo (), 0] = 12 * 1 / 2 + (foo (), 0) + p[foo (), 0];
if (cnt != 9 || v != 25)
abort ();
#pragma omp atomic capture
{
v = p[foo () & 0]; p[foo () & 0] = (foo (), 1) * 9 - p[foo () & 0];
}
if (cnt != 13 || v != 25)
abort ();
#pragma omp atomic read
v = x;
if (v != -16)
abort ();
#pragma omp atomic capture
{
p[0 & foo ()] = 16 - 2 + 3 + p[0 & foo ()]; v = p[0 & foo ()];
}
if (cnt != 16 || v != 1)
abort ();
#pragma omp atomic capture
{
v = p[foo (), 0]; p[foo (), 0] = (foo (), 7) ? 13 : foo () + 6;
}
if (cnt != 19 || v != 1)
abort ();
#pragma omp atomic read
v = x;
if (v != 13)
abort ();
return 0;
}