Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / target_teams_distribute_misc_messages.c
blob27b924d0bbf50fd0528f94ae7aa182062484770a
1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s -Wuninitialized
3 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify %s -Wuninitialized
5 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp target teams distribute'}}
6 #pragma omp target teams distribute
8 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp target teams distribute'}}
9 #pragma omp target teams distribute foo
11 void test_no_clause(void) {
12 int i;
13 #pragma omp target teams distribute
14 for (i = 0; i < 16; ++i)
17 // expected-error@+2 {{statement after '#pragma omp target teams distribute' must be a for loop}}
18 #pragma omp target teams distribute
19 ++i;
22 void test_branch_protected_scope(void) {
23 int i = 0;
24 L1:
25 ++i;
27 int x[24];
29 #pragma omp target teams distribute
30 for (i = 0; i < 16; ++i) {
31 if (i == 5)
32 goto L1; // expected-error {{use of undeclared label 'L1'}}
33 else if (i == 6)
34 return; // expected-error {{cannot return from OpenMP region}}
35 else if (i == 7)
36 goto L2;
37 else if (i == 8) {
38 L2:
39 x[i]++;
43 if (x[0] == 0)
44 goto L2; // expected-error {{use of undeclared label 'L2'}}
45 else if (x[1] == 1)
46 goto L1;
49 void test_invalid_clause(void) {
50 int i;
51 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}}
52 #pragma omp target teams distribute foo bar
53 for (i = 0; i < 16; ++i)
57 void test_non_identifiers(void) {
58 int i, x;
60 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}}
61 #pragma omp target teams distribute;
62 for (i = 0; i < 16; ++i)
65 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}}
66 #pragma omp target teams distribute private(x);
67 for (i = 0; i < 16; ++i)
70 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}}
71 #pragma omp target teams distribute, private(x);
72 for (i = 0; i < 16; ++i)
76 extern int foo(void);
78 void test_collapse(void) {
79 int i;
80 // expected-error@+1 {{expected '('}}
81 #pragma omp target teams distribute collapse
82 for (i = 0; i < 16; ++i)
84 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
85 #pragma omp target teams distribute collapse(
86 for (i = 0; i < 16; ++i)
88 // expected-error@+1 {{expected expression}}
89 #pragma omp target teams distribute collapse()
90 for (i = 0; i < 16; ++i)
92 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
93 #pragma omp target teams distribute collapse(,
94 for (i = 0; i < 16; ++i)
96 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
97 #pragma omp target teams distribute collapse(, )
98 for (i = 0; i < 16; ++i)
100 // expected-warning@+2 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}}
101 // expected-error@+1 {{expected '('}}
102 #pragma omp target teams distribute collapse 4)
103 for (i = 0; i < 16; ++i)
105 // expected-error@+2 {{expected ')'}}
106 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
107 #pragma omp target teams distribute collapse(4
108 for (i = 0; i < 16; ++i)
109 ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}}
110 // expected-error@+2 {{expected ')'}}
111 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
112 #pragma omp target teams distribute collapse(4,
113 for (i = 0; i < 16; ++i)
114 ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}}
115 // expected-error@+2 {{expected ')'}}
116 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
117 #pragma omp target teams distribute collapse(4, )
118 for (i = 0; i < 16; ++i)
119 ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}}
120 // expected-note@+1 {{as specified in 'collapse' clause}}
121 #pragma omp target teams distribute collapse(4)
122 for (i = 0; i < 16; ++i)
123 ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}}
124 // expected-error@+2 {{expected ')'}}
125 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
126 #pragma omp target teams distribute collapse(4 4)
127 for (i = 0; i < 16; ++i)
128 ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}}
129 // expected-error@+2 {{expected ')'}}
130 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
131 #pragma omp target teams distribute collapse(4, , 4)
132 for (i = 0; i < 16; ++i)
133 ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}}
134 #pragma omp target teams distribute collapse(4)
135 for (int i1 = 0; i1 < 16; ++i1)
136 for (int i2 = 0; i2 < 16; ++i2)
137 for (int i3 = 0; i3 < 16; ++i3)
138 for (int i4 = 0; i4 < 16; ++i4)
139 foo();
140 // expected-error@+2 {{expected ')'}}
141 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
142 #pragma omp target teams distribute collapse(4, 8)
143 for (i = 0; i < 16; ++i)
144 ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute', but found only 1}}
145 // expected-error@+1 {{integer constant expression}}
146 #pragma omp target teams distribute collapse(2.5)
147 for (i = 0; i < 16; ++i)
149 // expected-error@+1 {{integer constant expression}}
150 #pragma omp target teams distribute collapse(foo())
151 for (i = 0; i < 16; ++i)
153 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
154 #pragma omp target teams distribute collapse(-5)
155 for (i = 0; i < 16; ++i)
157 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
158 #pragma omp target teams distribute collapse(0)
159 for (i = 0; i < 16; ++i)
161 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
162 #pragma omp target teams distribute collapse(5 - 5)
163 for (i = 0; i < 16; ++i)
165 // expected-error@+3 {{loop iteration variable in the associated loop of 'omp target teams distribute' directive may not be firstprivate, predetermined as private}}
166 // expected-note@+1 {{defined as firstprivate}}
167 #pragma omp target teams distribute collapse(2) firstprivate(i)
168 for (i = 0; i < 16; ++i)
169 for (int j = 0; j < 16; ++j)
170 #pragma omp parallel for reduction(+ : i, j)
171 for (int k = 0; k < 16; ++k)
172 i += j;
175 void test_private(void) {
176 int i;
177 // expected-error@+2 {{expected expression}}
178 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
179 #pragma omp target teams distribute private(
180 for (i = 0; i < 16; ++i)
182 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
183 // expected-error@+1 2 {{expected expression}}
184 #pragma omp target teams distribute private(,
185 for (i = 0; i < 16; ++i)
187 // expected-error@+1 2 {{expected expression}}
188 #pragma omp target teams distribute private(, )
189 for (i = 0; i < 16; ++i)
191 // expected-error@+1 {{expected expression}}
192 #pragma omp target teams distribute private()
193 for (i = 0; i < 16; ++i)
195 // expected-error@+1 {{expected expression}}
196 #pragma omp target teams distribute private(int)
197 for (i = 0; i < 16; ++i)
199 // expected-error@+1 {{expected variable name}}
200 #pragma omp target teams distribute private(0)
201 for (i = 0; i < 16; ++i)
204 int x, y, z;
205 #pragma omp target teams distribute private(x)
206 for (i = 0; i < 16; ++i)
208 #pragma omp target teams distribute private(x, y)
209 for (i = 0; i < 16; ++i)
211 #pragma omp target teams distribute private(x, y, z)
212 for (i = 0; i < 16; ++i) {
213 x = y * i + z;
217 void test_lastprivate(void) {
218 int i;
219 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
220 // expected-error@+1 {{expected expression}}
221 #pragma omp target teams distribute lastprivate(
222 for (i = 0; i < 16; ++i)
225 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
226 // expected-error@+1 2 {{expected expression}}
227 #pragma omp target teams distribute lastprivate(,
228 for (i = 0; i < 16; ++i)
230 // expected-error@+1 2 {{expected expression}}
231 #pragma omp target teams distribute lastprivate(, )
232 for (i = 0; i < 16; ++i)
234 // expected-error@+1 {{expected expression}}
235 #pragma omp target teams distribute lastprivate()
236 for (i = 0; i < 16; ++i)
238 // expected-error@+1 {{expected expression}}
239 #pragma omp target teams distribute lastprivate(int)
240 for (i = 0; i < 16; ++i)
242 // expected-error@+1 {{expected variable name}}
243 #pragma omp target teams distribute lastprivate(0)
244 for (i = 0; i < 16; ++i)
247 int x, y, z;
248 #pragma omp target teams distribute lastprivate(x)
249 for (i = 0; i < 16; ++i)
251 #pragma omp target teams distribute lastprivate(x, y)
252 for (i = 0; i < 16; ++i)
254 #pragma omp target teams distribute lastprivate(x, y, z)
255 for (i = 0; i < 16; ++i)
259 void test_firstprivate(void) {
260 int i;
261 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
262 // expected-error@+1 {{expected expression}}
263 #pragma omp target teams distribute firstprivate(
264 for (i = 0; i < 16; ++i)
267 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
268 // expected-error@+1 2 {{expected expression}}
269 #pragma omp target teams distribute firstprivate(,
270 for (i = 0; i < 16; ++i)
272 // expected-error@+1 2 {{expected expression}}
273 #pragma omp target teams distribute firstprivate(, )
274 for (i = 0; i < 16; ++i)
276 // expected-error@+1 {{expected expression}}
277 #pragma omp target teams distribute firstprivate()
278 for (i = 0; i < 16; ++i)
280 // expected-error@+1 {{expected expression}}
281 #pragma omp target teams distribute firstprivate(int)
282 for (i = 0; i < 16; ++i)
284 // expected-error@+1 {{expected variable name}}
285 #pragma omp target teams distribute firstprivate(0)
286 for (i = 0; i < 16; ++i)
289 int x, y, z;
290 // expected-error@+1 {{lastprivate variable cannot be firstprivate}} expected-note@+1 {{defined as lastprivate}}
291 #pragma omp target teams distribute lastprivate(x) firstprivate(x)
292 for (i = 0; i < 16; ++i)
294 // expected-error@+1 2 {{lastprivate variable cannot be firstprivate}} expected-note@+1 2 {{defined as lastprivate}}
295 #pragma omp target teams distribute lastprivate(x, y) firstprivate(x, y)
296 for (i = 0; i < 16; ++i)
298 // expected-error@+1 3 {{lastprivate variable cannot be firstprivate}} expected-note@+1 3 {{defined as lastprivate}}
299 #pragma omp target teams distribute lastprivate(x, y, z) firstprivate(x, y, z)
300 for (i = 0; i < 16; ++i)
304 void test_loop_messages(void) {
305 float a[100], b[100], c[100];
306 // expected-error@+2 {{variable must be of integer or pointer type}}
307 #pragma omp target teams distribute
308 for (float fi = 0; fi < 10.0; fi++) {
309 c[(int)fi] = a[(int)fi] + b[(int)fi];
311 // expected-error@+2 {{variable must be of integer or pointer type}}
312 #pragma omp target teams distribute
313 for (double fi = 0; fi < 10.0; fi++) {
314 c[(int)fi] = a[(int)fi] + b[(int)fi];