Fix broken MinGW build of gcc.c
[official-gcc.git] / gcc / testsuite / gcc.dg / gomp / loop-1.c
blob527d31929231c63990ca09f4d03543d8b48525e8
1 int bar (int);
2 int baz (int *);
4 void
5 f1 (int x)
7 int i = 0, j = 0;
8 #pragma omp for
9 for (i = 0; i < 16; i++)
11 #pragma omp for
12 for (i = 0; 16 > i; i++)
14 #pragma omp for
15 for (i = 0; i < 16; i = i + 2)
17 #pragma omp for
18 for (i = 0; i < 16; i = 2 + i)
20 #pragma omp for /* { dg-error "initializer expression refers to iteration variable" } */
21 for (i = i; i < 16; i++)
23 #pragma omp for
24 for (i = 2 * (i & x); i < 16; i++) /* { dg-error "initializer expression refers to iteration variable" } */
26 #pragma omp for
27 for (i = bar (i); i < 16; i++) /* { dg-error "initializer expression refers to iteration variable" } */
29 #pragma omp for
30 for (i = baz (&i); i < 16; i++) /* { dg-error "initializer expression refers to iteration variable" } */
32 #pragma omp for
33 for (i = 5; i < 2 * i + 17; i++) /* { dg-error "condition expression refers to iteration variable" } */
35 #pragma omp for
36 for (i = 5; 2 * i + 17 > i; i++) /* { dg-error "condition expression refers to iteration variable" } */
38 #pragma omp for
39 for (i = 5; bar (i) > i; i++) /* { dg-error "condition expression refers to iteration variable" } */
41 #pragma omp for
42 for (i = 5; i <= baz (&i); i++) /* { dg-error "condition expression refers to iteration variable" } */
44 #pragma omp for
45 for (i = 5; i <= i; i++) /* { dg-error "invalid controlling predicate|condition expression refers to iteration variable" } */
47 #pragma omp for /* { dg-error "increment expression refers to iteration variable" "" { xfail *-*-* } } */
48 for (i = 5; i < 16; i += i) /* { dg-bogus "invalid increment expression" "" { xfail *-*-* } } */
50 #pragma omp for
51 for (i = 5; i < 16; i = i + 2 * i) /* { dg-error "invalid increment expression|increment expression refers to iteration variable" } */
53 #pragma omp for /* { dg-error "increment expression refers to iteration variable" "" { xfail *-*-* } } */
54 for (i = 5; i < 16; i = i + i) /* { dg-bogus "invalid increment expression" "" { xfail *-*-* } } */
56 #pragma omp for
57 for (i = 5; i < 16; i = i + bar (i)) /* { dg-error "increment expression refers to iteration variable" } */
59 #pragma omp for
60 for (i = 5; i < 16; i = baz (&i) + i) /* { dg-error "increment expression refers to iteration variable" } */
62 #pragma omp for
63 for (i = 5; i < 16; i += bar (i)) /* { dg-error "increment expression refers to iteration variable" } */
65 #pragma omp for
66 for (i = 5; i < 16; i += baz (&i)) /* { dg-error "increment expression refers to iteration variable" } */
68 #pragma omp for collapse(2)
69 for (i = 0; i < 16; i = i + 2)
70 for (j = 0; j < 16; j += 2)
72 #pragma omp for collapse(2) /* { dg-error "initializer expression refers to iteration variable" } */
73 for (i = j; i < 16; i = i + 2)
74 for (j = 0; j < 16; j++)
76 #pragma omp for collapse(2) /* { dg-error "initializer expression refers to iteration variable" } */
77 for (i = 0; i < 16; i = i + 2)
78 for (j = i; j < 16; j += 2)
80 #pragma omp for collapse(2)
81 for (i = 0; i < 16; i = i + 2)
82 for (j = i + 3; j < 16; j += 2) /* { dg-error "initializer expression refers to iteration variable" } */
84 #pragma omp for collapse(2)
85 for (i = 0; i < 16; i++)
86 for (j = baz (&i); j < 16; j += 2) /* { dg-error "initializer expression refers to iteration variable" } */
88 #pragma omp for collapse(2)
89 for (i = 0; i < 16; i++)
90 for (j = 16; j > (i & x); j--) /* { dg-error "condition expression refers to iteration variable" } */
92 #pragma omp for collapse(2)
93 for (i = 0; i < 16; i++)
94 for (j = 0; j < i; j++) /* { dg-error "condition expression refers to iteration variable" } */
96 #pragma omp for collapse(2)
97 for (i = 0; i < 16; i++)
98 for (j = 0; j < i + 4; j++) /* { dg-error "condition expression refers to iteration variable" } */
100 #pragma omp for collapse(2)
101 for (i = 0; i < j + 4; i++) /* { dg-error "condition expression refers to iteration variable" } */
102 for (j = 0; j < 16; j++)
104 #pragma omp for collapse(2)
105 for (i = 0; i < j; i++) /* { dg-error "condition expression refers to iteration variable" } */
106 for (j = 0; j < 16; j++)
108 #pragma omp for collapse(2)
109 for (i = 0; i < bar (j); i++) /* { dg-error "condition expression refers to iteration variable" } */
110 for (j = 0; j < 16; j++)
112 #pragma omp for collapse(2)
113 for (i = 0; i < 16; i++)
114 for (j = 0; j < baz (&i); j++) /* { dg-error "condition expression refers to iteration variable" } */
116 #pragma omp for collapse(2) /* { dg-error "increment expression refers to iteration variable" } */
117 for (i = 0; i < 16; i += j)
118 for (j = 0; j < 16; j++)
120 #pragma omp for collapse(2) /* { dg-error "increment expression refers to iteration variable" } */
121 for (i = 0; i < 16; i++)
122 for (j = 0; j < 16; j += i)
124 #pragma omp for collapse(2) /* { dg-error "increment expression refers to iteration variable" } */
125 for (i = 0; i < 16; i = j + i)
126 for (j = 0; j < 16; j++)
128 #pragma omp for collapse(2) /* { dg-error "increment expression refers to iteration variable" } */
129 for (i = 0; i < 16; i++)
130 for (j = 0; j < 16; j = j + i)
132 #pragma omp for collapse(2)
133 for (i = 0; i < 16; i = bar (j) + i) /* { dg-error "increment expression refers to iteration variable" } */
134 for (j = 0; j < 16; j++)
136 #pragma omp for collapse(2)
137 for (i = 0; i < 16; i++)
138 for (j = 0; j < 16; j = j + baz (&i)) /* { dg-error "increment expression refers to iteration variable" } */
142 void
143 f2 (int x)
145 #pragma omp for
146 for (int i = 0; i < 16; i++)
148 #pragma omp for
149 for (int i = 0; 16 > i; i++)
151 #pragma omp for
152 for (int i = 0; i < 16; i = i + 2)
154 #pragma omp for
155 for (int i = 0; i < 16; i = 2 + i)
157 #pragma omp for /* { dg-error "initializer expression refers to iteration variable" } */
158 for (int i = i; i < 16; i++)
160 #pragma omp for
161 for (int i = 2 * (i & x); i < 16; i++) /* { dg-error "initializer expression refers to iteration variable" } */
163 #pragma omp for
164 for (int i = bar (i); i < 16; i++) /* { dg-error "initializer expression refers to iteration variable" } */
166 #pragma omp for
167 for (int i = baz (&i); i < 16; i++) /* { dg-error "initializer expression refers to iteration variable" } */
169 #pragma omp for
170 for (int i = 5; i < 2 * i + 17; i++) /* { dg-error "condition expression refers to iteration variable" } */
172 #pragma omp for
173 for (int i = 5; 2 * i + 17 > i; i++) /* { dg-error "condition expression refers to iteration variable" } */
175 #pragma omp for
176 for (int i = 5; bar (i) > i; i++) /* { dg-error "condition expression refers to iteration variable" } */
178 #pragma omp for
179 for (int i = 5; i <= baz (&i); i++) /* { dg-error "condition expression refers to iteration variable" } */
181 #pragma omp for
182 for (int i = 5; i <= i; i++) /* { dg-error "invalid controlling predicate|condition expression refers to iteration variable" } */
184 #pragma omp for /* { dg-error "increment expression refers to iteration variable" "" { xfail *-*-* } } */
185 for (int i = 5; i < 16; i += i) /* { dg-bogus "invalid increment expression" "" { xfail *-*-* } } */
187 #pragma omp for
188 for (int i = 5; i < 16; i = i + 2 * i) /* { dg-error "invalid increment expression|increment expression refers to iteration variable" } */
190 #pragma omp for /* { dg-error "increment expression refers to iteration variable" "" { xfail *-*-* } } */
191 for (int i = 5; i < 16; i = i + i) /* { dg-bogus "invalid increment expression" "" { xfail *-*-* } } */
193 #pragma omp for
194 for (int i = 5; i < 16; i = i + bar (i)) /* { dg-error "increment expression refers to iteration variable" } */
196 #pragma omp for
197 for (int i = 5; i < 16; i = baz (&i) + i) /* { dg-error "increment expression refers to iteration variable" } */
199 #pragma omp for
200 for (int i = 5; i < 16; i += bar (i)) /* { dg-error "increment expression refers to iteration variable" } */
202 #pragma omp for
203 for (int i = 5; i < 16; i += baz (&i)) /* { dg-error "increment expression refers to iteration variable" } */
205 #pragma omp for collapse(2)
206 for (int i = 0; i < 16; i = i + 2)
207 for (int j = 0; j < 16; j += 2)
209 #pragma omp for collapse(2) /* { dg-error "initializer expression refers to iteration variable" } */
210 for (int i = 0; i < 16; i = i + 2)
211 for (int j = i; j < 16; j += 2)
213 #pragma omp for collapse(2)
214 for (int i = 0; i < 16; i = i + 2)
215 for (int j = i + 3; j < 16; j += 2) /* { dg-error "initializer expression refers to iteration variable" } */
217 #pragma omp for collapse(2)
218 for (int i = 0; i < 16; i++)
219 for (int j = baz (&i); j < 16; j += 2) /* { dg-error "initializer expression refers to iteration variable" } */
221 #pragma omp for collapse(2)
222 for (int i = 0; i < 16; i++)
223 for (int j = 16; j > (i & x); j--) /* { dg-error "condition expression refers to iteration variable" } */
225 #pragma omp for collapse(2)
226 for (int i = 0; i < 16; i++)
227 for (int j = 0; j < i; j++) /* { dg-error "condition expression refers to iteration variable" } */
229 #pragma omp for collapse(2)
230 for (int i = 0; i < 16; i++)
231 for (int j = 0; j < i + 4; j++) /* { dg-error "condition expression refers to iteration variable" } */
233 #pragma omp for collapse(2)
234 for (int i = 0; i < 16; i++)
235 for (int j = 0; j < baz (&i); j++) /* { dg-error "condition expression refers to iteration variable" } */
237 #pragma omp for collapse(2) /* { dg-error "increment expression refers to iteration variable" } */
238 for (int i = 0; i < 16; i++)
239 for (int j = 0; j < 16; j += i)
241 #pragma omp for collapse(2) /* { dg-error "increment expression refers to iteration variable" } */
242 for (int i = 0; i < 16; i++)
243 for (int j = 0; j < 16; j = j + i)
245 #pragma omp for collapse(2)
246 for (int i = 0; i < 16; i++)
247 for (int j = 0; j < 16; j = j + baz (&i)) /* { dg-error "increment expression refers to iteration variable" } */
251 void
252 f3 (void)
254 int j = 0;
255 #pragma omp for collapse(2)
256 for (int i = j; i < 16; i = i + 2)
257 for (int j = 0; j < 16; j++)
259 #pragma omp for collapse(2)
260 for (int i = 0; i < j + 4; i++)
261 for (int j = 0; j < 16; j++)
263 #pragma omp for collapse(2)
264 for (int i = 0; i < j; i++)
265 for (int j = 0; j < 16; j++)
267 #pragma omp for collapse(2)
268 for (int i = 0; i < bar (j); i++)
269 for (int j = 0; j < 16; j++)
271 #pragma omp for collapse(2)
272 for (int i = 0; i < 16; i += j)
273 for (int j = 0; j < 16; j++)
275 #pragma omp for collapse(2)
276 for (int i = 0; i < 16; i = j + i)
277 for (int j = 0; j < 16; j++)
279 #pragma omp for collapse(2)
280 for (int i = 0; i < 16; i = bar (j) + i)
281 for (int j = 0; j < 16; j++)