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