| 1 | // RUN: %clang_cc1 -fsyntax-only -fopenmp -triple x86_64-unknown-unknown -verify %s |
| 2 | |
| 3 | // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -triple x86_64-unknown-unknown -verify %s |
| 4 | |
| 5 | // expected-error@+1 {{unexpected OpenMP directive '#pragma omp taskloop simd'}} |
| 6 | #pragma omp taskloop simd |
| 7 | |
| 8 | // expected-error@+1 {{unexpected OpenMP directive '#pragma omp taskloop simd'}} |
| 9 | #pragma omp taskloop simd foo |
| 10 | |
| 11 | void test_no_clause() { |
| 12 | int i; |
| 13 | #pragma omp taskloop simd |
| 14 | for (i = 0; i < 16; ++i) |
| 15 | ; |
| 16 | |
| 17 | // expected-error@+2 {{statement after '#pragma omp taskloop simd' must be a for loop}} |
| 18 | #pragma omp taskloop simd |
| 19 | ++i; |
| 20 | } |
| 21 | |
| 22 | void test_branch_protected_scope() { |
| 23 | int i = 0; |
| 24 | L1: |
| 25 | ++i; |
| 26 | |
| 27 | int x[24]; |
| 28 | |
| 29 | #pragma omp parallel |
| 30 | #pragma omp taskloop simd |
| 31 | for (i = 0; i < 16; ++i) { |
| 32 | if (i == 5) |
| 33 | goto L1; // expected-error {{use of undeclared label 'L1'}} |
| 34 | else if (i == 6) |
| 35 | return; // expected-error {{cannot return from OpenMP region}} |
| 36 | else if (i == 7) |
| 37 | goto L2; |
| 38 | else if (i == 8) { |
| 39 | L2: |
| 40 | x[i]++; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | if (x[0] == 0) |
| 45 | goto L2; // expected-error {{use of undeclared label 'L2'}} |
| 46 | else if (x[1] == 1) |
| 47 | goto L1; |
| 48 | } |
| 49 | |
| 50 | void test_invalid_clause() { |
| 51 | int i; |
| 52 | #pragma omp parallel |
| 53 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}} |
| 54 | #pragma omp taskloop simd foo bar |
| 55 | for (i = 0; i < 16; ++i) |
| 56 | ; |
| 57 | // expected-error@+1 {{directive '#pragma omp taskloop simd' cannot contain more than one 'nogroup' clause}} |
| 58 | #pragma omp taskloop simd nogroup nogroup |
| 59 | for (i = 0; i < 16; ++i) |
| 60 | ; |
| 61 | } |
| 62 | |
| 63 | void test_non_identifiers() { |
| 64 | int i, x; |
| 65 | |
| 66 | #pragma omp parallel |
| 67 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}} |
| 68 | #pragma omp taskloop simd; |
| 69 | for (i = 0; i < 16; ++i) |
| 70 | ; |
| 71 | // expected-warning@+2 {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}} |
| 72 | #pragma omp parallel |
| 73 | #pragma omp taskloop simd linear(x); |
| 74 | for (i = 0; i < 16; ++i) |
| 75 | ; |
| 76 | |
| 77 | #pragma omp parallel |
| 78 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}} |
| 79 | #pragma omp taskloop simd private(x); |
| 80 | for (i = 0; i < 16; ++i) |
| 81 | ; |
| 82 | |
| 83 | #pragma omp parallel |
| 84 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}} |
| 85 | #pragma omp taskloop simd, private(x); |
| 86 | for (i = 0; i < 16; ++i) |
| 87 | ; |
| 88 | } |
| 89 | |
| 90 | extern int foo(); |
| 91 | |
| 92 | void test_collapse() { |
| 93 | int i; |
| 94 | #pragma omp parallel |
| 95 | // expected-error@+1 {{expected '('}} |
| 96 | #pragma omp taskloop simd collapse |
| 97 | for (i = 0; i < 16; ++i) |
| 98 | ; |
| 99 | #pragma omp parallel |
| 100 | // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} |
| 101 | #pragma omp taskloop simd collapse( |
| 102 | for (i = 0; i < 16; ++i) |
| 103 | ; |
| 104 | #pragma omp parallel |
| 105 | // expected-error@+1 {{expected expression}} |
| 106 | #pragma omp taskloop simd collapse() |
| 107 | for (i = 0; i < 16; ++i) |
| 108 | ; |
| 109 | #pragma omp parallel |
| 110 | // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} |
| 111 | #pragma omp taskloop simd collapse(, |
| 112 | for (i = 0; i < 16; ++i) |
| 113 | ; |
| 114 | #pragma omp parallel |
| 115 | // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} |
| 116 | #pragma omp taskloop simd collapse(, ) |
| 117 | for (i = 0; i < 16; ++i) |
| 118 | ; |
| 119 | #pragma omp parallel |
| 120 | // expected-warning@+2 {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}} |
| 121 | // expected-error@+1 {{expected '('}} |
| 122 | #pragma omp taskloop simd collapse 4) |
| 123 | for (i = 0; i < 16; ++i) |
| 124 | ; |
| 125 | #pragma omp parallel |
| 126 | // expected-error@+2 {{expected ')'}} |
| 127 | // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} |
| 128 | #pragma omp taskloop simd collapse(4 |
| 129 | for (i = 0; i < 16; ++i) |
| 130 | ; // expected-error {{expected 4 for loops after '#pragma omp taskloop simd', but found only 1}} |
| 131 | #pragma omp parallel |
| 132 | // expected-error@+2 {{expected ')'}} |
| 133 | // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} |
| 134 | #pragma omp taskloop simd collapse(4, |
| 135 | for (i = 0; i < 16; ++i) |
| 136 | ; // expected-error {{expected 4 for loops after '#pragma omp taskloop simd', but found only 1}} |
| 137 | #pragma omp parallel |
| 138 | // expected-error@+2 {{expected ')'}} |
| 139 | // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} |
| 140 | #pragma omp taskloop simd collapse(4, ) |
| 141 | for (i = 0; i < 16; ++i) |
| 142 | ; // expected-error {{expected 4 for loops after '#pragma omp taskloop simd', but found only 1}} |
| 143 | #pragma omp parallel |
| 144 | // expected-note@+1 {{as specified in 'collapse' clause}} |
| 145 | #pragma omp taskloop simd collapse(4) |
| 146 | for (i = 0; i < 16; ++i) |
| 147 | ; // expected-error {{expected 4 for loops after '#pragma omp taskloop simd', but found only 1}} |
| 148 | #pragma omp parallel |
| 149 | // expected-error@+2 {{expected ')'}} |
| 150 | // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} |
| 151 | #pragma omp taskloop simd collapse(4 4) |
| 152 | for (i = 0; i < 16; ++i) |
| 153 | ; // expected-error {{expected 4 for loops after '#pragma omp taskloop simd', but found only 1}} |
| 154 | #pragma omp parallel |
| 155 | // expected-error@+2 {{expected ')'}} |
| 156 | // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} |
| 157 | #pragma omp taskloop simd collapse(4, , 4) |
| 158 | for (i = 0; i < 16; ++i) |
| 159 | ; // expected-error {{expected 4 for loops after '#pragma omp taskloop simd', but found only 1}} |
| 160 | #pragma omp parallel |
| 161 | #pragma omp taskloop simd collapse(4) |
| 162 | for (int i1 = 0; i1 < 16; ++i1) |
| 163 | for (int i2 = 0; i2 < 16; ++i2) |
| 164 | for (int i3 = 0; i3 < 16; ++i3) |
| 165 | for (int i4 = 0; i4 < 16; ++i4) |
| 166 | foo(); |
| 167 | #pragma omp parallel |
| 168 | // expected-error@+2 {{expected ')'}} |
| 169 | // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} |
| 170 | #pragma omp taskloop simd collapse(4, 8) |
| 171 | for (i = 0; i < 16; ++i) |
| 172 | ; // expected-error {{expected 4 for loops after '#pragma omp taskloop simd', but found only 1}} |
| 173 | #pragma omp parallel |
| 174 | // expected-error@+1 {{expression is not an integer constant expression}} |
| 175 | #pragma omp taskloop simd collapse(2.5) |
| 176 | for (i = 0; i < 16; ++i) |
| 177 | ; |
| 178 | #pragma omp parallel |
| 179 | // expected-error@+1 {{expression is not an integer constant expression}} |
| 180 | #pragma omp taskloop simd collapse(foo()) |
| 181 | for (i = 0; i < 16; ++i) |
| 182 | ; |
| 183 | #pragma omp parallel |
| 184 | // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} |
| 185 | #pragma omp taskloop simd collapse(-5) |
| 186 | for (i = 0; i < 16; ++i) |
| 187 | ; |
| 188 | #pragma omp parallel |
| 189 | // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} |
| 190 | #pragma omp taskloop simd collapse(0) |
| 191 | for (i = 0; i < 16; ++i) |
| 192 | ; |
| 193 | #pragma omp parallel |
| 194 | // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} |
| 195 | #pragma omp taskloop simd collapse(5 - 5) |
| 196 | for (i = 0; i < 16; ++i) |
| 197 | ; |
| 198 | } |
| 199 | |
| 200 | void test_private() { |
| 201 | int i; |
| 202 | #pragma omp parallel |
| 203 | // expected-error@+2 {{expected expression}} |
| 204 | // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} |
| 205 | #pragma omp taskloop simd private( |
| 206 | for (i = 0; i < 16; ++i) |
| 207 | ; |
| 208 | #pragma omp parallel |
| 209 | // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} |
| 210 | // expected-error@+1 2 {{expected expression}} |
| 211 | #pragma omp taskloop simd private(, |
| 212 | for (i = 0; i < 16; ++i) |
| 213 | ; |
| 214 | #pragma omp parallel |
| 215 | // expected-error@+1 2 {{expected expression}} |
| 216 | #pragma omp taskloop simd private(, ) |
| 217 | for (i = 0; i < 16; ++i) |
| 218 | ; |
| 219 | #pragma omp parallel |
| 220 | // expected-error@+1 {{expected expression}} |
| 221 | #pragma omp taskloop simd private() |
| 222 | for (i = 0; i < 16; ++i) |
| 223 | ; |
| 224 | #pragma omp parallel |
| 225 | // expected-error@+1 {{expected expression}} |
| 226 | #pragma omp taskloop simd private(int) |
| 227 | for (i = 0; i < 16; ++i) |
| 228 | ; |
| 229 | #pragma omp parallel |
| 230 | // expected-error@+1 {{expected variable name}} |
| 231 | #pragma omp taskloop simd private(0) |
| 232 | for (i = 0; i < 16; ++i) |
| 233 | ; |
| 234 | |
| 235 | int x, y, z; |
| 236 | #pragma omp parallel |
| 237 | #pragma omp taskloop simd private(x) |
| 238 | for (i = 0; i < 16; ++i) |
| 239 | ; |
| 240 | #pragma omp parallel |
| 241 | #pragma omp taskloop simd private(x, y) |
| 242 | for (i = 0; i < 16; ++i) |
| 243 | ; |
| 244 | #pragma omp parallel |
| 245 | #pragma omp taskloop simd private(x, y, z) |
| 246 | for (i = 0; i < 16; ++i) { |
| 247 | x = y * i + z; |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | void test_lastprivate() { |
| 252 | int i; |
| 253 | #pragma omp parallel |
| 254 | // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} |
| 255 | // expected-error@+1 {{expected expression}} |
| 256 | #pragma omp taskloop simd lastprivate( |
| 257 | for (i = 0; i < 16; ++i) |
| 258 | ; |
| 259 | |
| 260 | #pragma omp parallel |
| 261 | // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} |
| 262 | // expected-error@+1 2 {{expected expression}} |
| 263 | #pragma omp taskloop simd lastprivate(, |
| 264 | for (i = 0; i < 16; ++i) |
| 265 | ; |
| 266 | #pragma omp parallel |
| 267 | // expected-error@+1 2 {{expected expression}} |
| 268 | #pragma omp taskloop simd lastprivate(, ) |
| 269 | for (i = 0; i < 16; ++i) |
| 270 | ; |
| 271 | #pragma omp parallel |
| 272 | // expected-error@+1 {{expected expression}} |
| 273 | #pragma omp taskloop simd lastprivate() |
| 274 | for (i = 0; i < 16; ++i) |
| 275 | ; |
| 276 | #pragma omp parallel |
| 277 | // expected-error@+1 {{expected expression}} |
| 278 | #pragma omp taskloop simd lastprivate(int) |
| 279 | for (i = 0; i < 16; ++i) |
| 280 | ; |
| 281 | #pragma omp parallel |
| 282 | // expected-error@+1 {{expected variable name}} |
| 283 | #pragma omp taskloop simd lastprivate(0) |
| 284 | for (i = 0; i < 16; ++i) |
| 285 | ; |
| 286 | |
| 287 | int x, y, z; |
| 288 | #pragma omp parallel |
| 289 | #pragma omp taskloop simd lastprivate(x) |
| 290 | for (i = 0; i < 16; ++i) |
| 291 | ; |
| 292 | #pragma omp parallel |
| 293 | #pragma omp taskloop simd lastprivate(x, y) |
| 294 | for (i = 0; i < 16; ++i) |
| 295 | ; |
| 296 | #pragma omp parallel |
| 297 | #pragma omp taskloop simd lastprivate(x, y, z) |
| 298 | for (i = 0; i < 16; ++i) |
| 299 | ; |
| 300 | } |
| 301 | |
| 302 | void test_firstprivate() { |
| 303 | int i; |
| 304 | #pragma omp parallel |
| 305 | // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} |
| 306 | // expected-error@+1 {{expected expression}} |
| 307 | #pragma omp taskloop simd firstprivate( |
| 308 | for (i = 0; i < 16; ++i) |
| 309 | ; |
| 310 | |
| 311 | #pragma omp parallel |
| 312 | // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} |
| 313 | // expected-error@+1 2 {{expected expression}} |
| 314 | #pragma omp taskloop simd firstprivate(, |
| 315 | for (i = 0; i < 16; ++i) |
| 316 | ; |
| 317 | #pragma omp parallel |
| 318 | // expected-error@+1 2 {{expected expression}} |
| 319 | #pragma omp taskloop simd firstprivate(, ) |
| 320 | for (i = 0; i < 16; ++i) |
| 321 | ; |
| 322 | #pragma omp parallel |
| 323 | // expected-error@+1 {{expected expression}} |
| 324 | #pragma omp taskloop simd firstprivate() |
| 325 | for (i = 0; i < 16; ++i) |
| 326 | ; |
| 327 | #pragma omp parallel |
| 328 | // expected-error@+1 {{expected expression}} |
| 329 | #pragma omp taskloop simd firstprivate(int) |
| 330 | for (i = 0; i < 16; ++i) |
| 331 | ; |
| 332 | #pragma omp parallel |
| 333 | // expected-error@+1 {{expected variable name}} |
| 334 | #pragma omp taskloop simd firstprivate(0) |
| 335 | for (i = 0; i < 16; ++i) |
| 336 | ; |
| 337 | |
| 338 | int x, y, z; |
| 339 | #pragma omp parallel |
| 340 | #pragma omp taskloop simd lastprivate(x) firstprivate(x) |
| 341 | for (i = 0; i < 16; ++i) |
| 342 | ; |
| 343 | #pragma omp parallel |
| 344 | #pragma omp taskloop simd lastprivate(x, y) firstprivate(x, y) |
| 345 | for (i = 0; i < 16; ++i) |
| 346 | ; |
| 347 | #pragma omp parallel |
| 348 | #pragma omp taskloop simd lastprivate(x, y, z) firstprivate(x, y, z) |
| 349 | for (i = 0; i < 16; ++i) |
| 350 | ; |
| 351 | // expected-error@+1 {{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}} |
| 352 | #pragma omp taskloop simd simdlen(64) safelen(8) |
| 353 | for (i = 0; i < 16; ++i) |
| 354 | ; |
| 355 | } |
| 356 | |
| 357 | void test_loop_messages() { |
| 358 | float a[100], b[100], c[100]; |
| 359 | #pragma omp parallel |
| 360 | // expected-error@+2 {{variable must be of integer or pointer type}} |
| 361 | #pragma omp taskloop simd |
| 362 | for (float fi = 0; fi < 10.0; fi++) { |
| 363 | c[(int)fi] = a[(int)fi] + b[(int)fi]; |
| 364 | } |
| 365 | #pragma omp parallel |
| 366 | // expected-error@+2 {{variable must be of integer or pointer type}} |
| 367 | #pragma omp taskloop simd |
| 368 | for (double fi = 0; fi < 10.0; fi++) { |
| 369 | c[(int)fi] = a[(int)fi] + b[(int)fi]; |
| 370 | } |
| 371 | |
| 372 | // expected-warning@+2 {{OpenMP loop iteration variable cannot have more than 64 bits size and will be narrowed}} |
| 373 | #pragma omp taskloop simd |
| 374 | for (__int128 ii = 0; ii < 10; ii++) { |
| 375 | c[ii] = a[ii] + b[ii]; |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | |