1 int bar (int);
2 int baz (int *);
3 
4 void
f1(int x)5 f1 (int x)
6 {
7   int i = 0, j = 0;
8   #pragma omp for
9   for (i = 0; i < 16; i++)
10     ;
11   #pragma omp for
12   for (i = 0; 16 > i; i++)
13     ;
14   #pragma omp for
15   for (i = 0; i < 16; i = i + 2)
16     ;
17   #pragma omp for
18   for (i = 0; i < 16; i = 2 + i)
19     ;
20   #pragma omp for
21   for (i = i; i < 16; i++) /* { dg-error "initializer expression refers to iteration variable" } */
22     ;
23   #pragma omp for
24   for (i = 2 * (i & x); i < 16; i++) /* { dg-error "initializer expression refers to iteration variable" } */
25     ;
26   #pragma omp for
27   for (i = bar (i); i < 16; i++) /* { dg-error "initializer expression refers to iteration variable" } */
28     ;
29   #pragma omp for
30   for (i = baz (&i); i < 16; i++) /* { dg-error "initializer expression refers to iteration variable" } */
31     ;
32   #pragma omp for
33   for (i = 5; i < 2 * i + 17; i++) /* { dg-error "condition expression refers to iteration variable" } */
34     ;
35   #pragma omp for
36   for (i = 5; 2 * i + 17 > i; i++) /* { dg-error "condition expression refers to iteration variable" } */
37     ;
38   #pragma omp for
39   for (i = 5; bar (i) > i; i++) /* { dg-error "condition expression refers to iteration variable" } */
40     ;
41   #pragma omp for
42   for (i = 5; i <= baz (&i); i++) /* { dg-error "condition expression refers to iteration variable" } */
43     ;
44   #pragma omp for
45   for (i = 5; i <= i; i++) /* { dg-error "invalid controlling predicate|condition expression refers to iteration variable" } */
46     ;
47   #pragma omp for
48   for (i = 5; i < 16; i += i) /* { dg-error "increment expression refers to iteration variable" } */
49     ;
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" } */
52     ;
53   #pragma omp for
54   for (i = 5; i < 16; i = i + i) /* { dg-error "increment expression refers to iteration variable" } */
55     ;
56   #pragma omp for
57   for (i = 5; i < 16; i = i + bar (i)) /* { dg-error "increment expression refers to iteration variable" } */
58     ;
59   #pragma omp for
60   for (i = 5; i < 16; i = baz (&i) + i) /* { dg-error "increment expression refers to iteration variable" } */
61     ;
62   #pragma omp for
63   for (i = 5; i < 16; i += bar (i)) /* { dg-error "increment expression refers to iteration variable" } */
64     ;
65   #pragma omp for
66   for (i = 5; i < 16; i += baz (&i)) /* { dg-error "increment expression refers to iteration variable" } */
67     ;
68   #pragma omp for collapse(2)
69   for (i = 0; i < 16; i = i + 2)
70     for (j = 0; j < 16; j += 2)
71       ;
72   #pragma omp for collapse(2)
73   for (i = j; i < 16; i = i + 2) /* { dg-error "initializer expression refers to iteration variable" } */
74     for (j = 0; j < 16; j++)
75       ;
76   #pragma omp for collapse(2)
77   for (i = 0; i < 16; i = i + 2) /* { dg-error "initializer expression refers to iteration variable" } */
78     for (j = i; j < 16; j += 2)
79       ;
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" } */
83       ;
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" } */
87       ;
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" } */
91       ;
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" } */
95       ;
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" } */
99       ;
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++)
103       ;
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++)
107       ;
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++)
111       ;
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" } */
115       ;
116   #pragma omp for collapse(2)
117   for (i = 0; i < 16; i += j) /* { dg-error "increment expression refers to iteration variable" } */
118     for (j = 0; j < 16; j++)
119       ;
120   #pragma omp for collapse(2)
121   for (i = 0; i < 16; i++) /* { dg-error "increment expression refers to iteration variable" } */
122     for (j = 0; j < 16; j += i)
123       ;
124   #pragma omp for collapse(2)
125   for (i = 0; i < 16; i = j + i) /* { dg-error "increment expression refers to iteration variable" } */
126     for (j = 0; j < 16; j++)
127       ;
128   #pragma omp for collapse(2)
129   for (i = 0; i < 16; i++) /* { dg-error "increment expression refers to iteration variable" } */
130     for (j = 0; j < 16; j = j + i)
131       ;
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++)
135       ;
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" } */
139       ;
140 }
141 
142 void
f2(int x)143 f2 (int x)
144 {
145   #pragma omp for
146   for (int i = 0; i < 16; i++)
147     ;
148   #pragma omp for
149   for (int i = 0; 16 > i; i++)
150     ;
151   #pragma omp for
152   for (int i = 0; i < 16; i = i + 2)
153     ;
154   #pragma omp for
155   for (int i = 0; i < 16; i = 2 + i)
156     ;
157   #pragma omp for
158   for (int i = i; i < 16; i++) /* { dg-error "initializer expression refers to iteration variable" } */
159     ;
160   #pragma omp for
161   for (int i = 2 * (i & x); i < 16; i++) /* { dg-error "initializer expression refers to iteration variable" } */
162     ;
163   #pragma omp for
164   for (int i = bar (i); i < 16; i++) /* { dg-error "initializer expression refers to iteration variable" } */
165     ;
166   #pragma omp for
167   for (int i = baz (&i); i < 16; i++) /* { dg-error "initializer expression refers to iteration variable" } */
168     ;
169   #pragma omp for
170   for (int i = 5; i < 2 * i + 17; i++) /* { dg-error "condition expression refers to iteration variable" } */
171     ;
172   #pragma omp for
173   for (int i = 5; 2 * i + 17 > i; i++) /* { dg-error "condition expression refers to iteration variable" } */
174     ;
175   #pragma omp for
176   for (int i = 5; bar (i) > i; i++) /* { dg-error "condition expression refers to iteration variable" } */
177     ;
178   #pragma omp for
179   for (int i = 5; i <= baz (&i); i++) /* { dg-error "condition expression refers to iteration variable" } */
180     ;
181   #pragma omp for
182   for (int i = 5; i <= i; i++) /* { dg-error "invalid controlling predicate|condition expression refers to iteration variable" } */
183     ;
184   #pragma omp for
185   for (int i = 5; i < 16; i += i) /* { dg-error "increment expression refers to iteration variable" } */
186     ;
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" } */
189     ;
190   #pragma omp for
191   for (int i = 5; i < 16; i = i + i) /* { dg-error "increment expression refers to iteration variable" } */
192     ;
193   #pragma omp for
194   for (int i = 5; i < 16; i = i + bar (i)) /* { dg-error "increment expression refers to iteration variable" } */
195     ;
196   #pragma omp for
197   for (int i = 5; i < 16; i = baz (&i) + i) /* { dg-error "increment expression refers to iteration variable" } */
198     ;
199   #pragma omp for
200   for (int i = 5; i < 16; i += bar (i)) /* { dg-error "increment expression refers to iteration variable" } */
201     ;
202   #pragma omp for
203   for (int i = 5; i < 16; i += baz (&i)) /* { dg-error "increment expression refers to iteration variable" } */
204     ;
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)
208       ;
209   #pragma omp for collapse(2)
210   for (int i = 0; i < 16; i = i + 2) /* { dg-error "initializer expression refers to iteration variable" } */
211     for (int j = i; j < 16; j += 2)
212       ;
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" } */
216       ;
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" } */
220       ;
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" } */
224       ;
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" } */
228       ;
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" } */
232       ;
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" } */
236       ;
237   #pragma omp for collapse(2)
238   for (int i = 0; i < 16; i++) /* { dg-error "increment expression refers to iteration variable" } */
239     for (int j = 0; j < 16; j += i)
240       ;
241   #pragma omp for collapse(2)
242   for (int i = 0; i < 16; i++) /* { dg-error "increment expression refers to iteration variable" } */
243     for (int j = 0; j < 16; j = j + i)
244       ;
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" } */
248       ;
249 }
250 
251 void
f3(void)252 f3 (void)
253 {
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++)
258       ;
259   #pragma omp for collapse(2)
260   for (int i = 0; i < j + 4; i++)
261     for (int j = 0; j < 16; j++)
262       ;
263   #pragma omp for collapse(2)
264   for (int i = 0; i < j; i++)
265     for (int j = 0; j < 16; j++)
266       ;
267   #pragma omp for collapse(2)
268   for (int i = 0; i < bar (j); i++)
269     for (int j = 0; j < 16; j++)
270       ;
271   #pragma omp for collapse(2)
272   for (int i = 0; i < 16; i += j)
273     for (int j = 0; j < 16; j++)
274       ;
275   #pragma omp for collapse(2)
276   for (int i = 0; i < 16; i = j + i)
277     for (int j = 0; j < 16; j++)
278       ;
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++)
282       ;
283 }
284