blob: 12962d80705e4a3fe905bc4a5c453128ae198a26 (
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/* PR middle-end/35130 */
extern void abort (void);
void
f1 (void)
{
int a[4], k;
void nested (int x)
{
a[x] = 42;
}
for (k = 0; k < 4; k++)
a[k] = 0;
#pragma omp parallel for
for (k = 0; k < 4; k++)
nested (k);
if (a[0] != 42 || a[1] != 42 || a[2] != 42 || a[3] != 42)
abort ();
}
void
f2 (void)
{
int a[4], k;
void nested (void)
{
int l;
void nested2 (int x)
{
a[x] = 42;
}
#pragma omp parallel for
for (l = 0; l < 4; l++)
nested2 (l);
}
for (k = 0; k < 4; k++)
a[k] = 0;
nested ();
if (a[0] != 42 || a[1] != 42 || a[2] != 42 || a[3] != 42)
abort ();
}
void
f3 (void)
{
int a[4], b[4], c[4], k;
void nested (int x)
{
a[x] = b[x] = c[x] = 42;
}
for (k = 0; k < 4; k++)
a[k] = b[k] = c[k] = 0;
nested (0);
#pragma omp parallel
{
#pragma omp single
{
a[1] = 43;
b[1] = 43;
}
#pragma omp parallel
{
#pragma omp single
{
b[2] = 44;
c[2] = 44;
}
}
}
if (a[0] != 42 || a[1] != 43 || a[2] != 0 || a[3] != 0)
abort ();
if (b[0] != 42 || b[1] != 43 || b[2] != 44 || b[3] != 0)
abort ();
if (c[0] != 42 || c[1] != 0 || c[2] != 44 || c[3] != 0)
abort ();
}
void
f4 (void)
{
int a[4], b[4], c[4], k;
void nested ()
{
#pragma omp parallel
{
#pragma omp single
{
a[1] = 43;
b[1] = 43;
}
#pragma omp parallel
{
#pragma omp single
{
b[2] = 44;
c[2] = 44;
}
}
}
}
for (k = 0; k < 4; k++)
a[k] = b[k] = c[k] = k == 0 ? 42 : 0;
nested ();
if (a[0] != 42 || a[1] != 43 || a[2] != 0 || a[3] != 0)
abort ();
if (b[0] != 42 || b[1] != 43 || b[2] != 44 || b[3] != 0)
abort ();
if (c[0] != 42 || c[1] != 0 || c[2] != 44 || c[3] != 0)
abort ();
}
int
main (void)
{
f1 ();
f2 ();
f3 ();
f4 ();
return 0;
}
|