blob: 0569d1c6deb435a949e94c3423b4c3a13de74cc5 (
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
66
67
68
|
// { dg-do run }
extern "C" void abort ();
int cnt;
int
foo ()
{
return cnt++;
}
template <typename T>
void
bar ()
{
extern T x;
T 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 ();
}
int x = 6;
int
main ()
{
bar <int> ();
return 0;
}
|