1! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=52 2! Check OpenMP 'if' clause validity for all directives that can have it 3 4program main 5 integer :: i 6 7 ! ---------------------------------------------------------------------------- 8 ! DISTRIBUTE PARALLEL DO 9 ! ---------------------------------------------------------------------------- 10 !$omp teams 11 !$omp distribute parallel do if(.true.) 12 do i = 1, 10 13 end do 14 !$omp end distribute parallel do 15 16 !$omp distribute parallel do if(parallel: .true.) 17 do i = 1, 10 18 end do 19 !$omp end distribute parallel do 20 21 !ERROR: TARGET is not a constituent of the DISTRIBUTE PARALLEL DO directive 22 !$omp distribute parallel do if(target: .true.) 23 do i = 1, 10 24 end do 25 !$omp end distribute parallel do 26 27 !ERROR: At most one IF clause can appear on the DISTRIBUTE PARALLEL DO directive 28 !$omp distribute parallel do if(.true.) if(parallel: .false.) 29 do i = 1, 10 30 end do 31 !$omp end distribute parallel do 32 !$omp end teams 33 34 ! ---------------------------------------------------------------------------- 35 ! DISTRIBUTE PARALLEL DO SIMD 36 ! ---------------------------------------------------------------------------- 37 !$omp teams 38 !$omp distribute parallel do simd if(.true.) 39 do i = 1, 10 40 end do 41 !$omp end distribute parallel do simd 42 43 !$omp distribute parallel do simd if(parallel: .true.) if(simd: .false.) 44 do i = 1, 10 45 end do 46 !$omp end distribute parallel do simd 47 48 !ERROR: TARGET is not a constituent of the DISTRIBUTE PARALLEL DO SIMD directive 49 !$omp distribute parallel do simd if(target: .true.) 50 do i = 1, 10 51 end do 52 !$omp end distribute parallel do simd 53 !$omp end teams 54 55 ! ---------------------------------------------------------------------------- 56 ! DISTRIBUTE SIMD 57 ! ---------------------------------------------------------------------------- 58 !$omp teams 59 !$omp distribute simd if(.true.) 60 do i = 1, 10 61 end do 62 !$omp end distribute simd 63 64 !$omp distribute simd if(simd: .true.) 65 do i = 1, 10 66 end do 67 !$omp end distribute simd 68 69 !ERROR: TARGET is not a constituent of the DISTRIBUTE SIMD directive 70 !$omp distribute simd if(target: .true.) 71 do i = 1, 10 72 end do 73 !$omp end distribute simd 74 75 !ERROR: At most one IF clause can appear on the DISTRIBUTE SIMD directive 76 !$omp distribute simd if(.true.) if(simd: .false.) 77 do i = 1, 10 78 end do 79 !$omp end distribute simd 80 !$omp end teams 81 82 ! ---------------------------------------------------------------------------- 83 ! DO SIMD 84 ! ---------------------------------------------------------------------------- 85 !$omp do simd if(.true.) 86 do i = 1, 10 87 end do 88 !$omp end do simd 89 90 !$omp do simd if(simd: .true.) 91 do i = 1, 10 92 end do 93 !$omp end do simd 94 95 !ERROR: TARGET is not a constituent of the DO SIMD directive 96 !$omp do simd if(target: .true.) 97 do i = 1, 10 98 end do 99 !$omp end do simd 100 101 !ERROR: At most one IF clause can appear on the DO SIMD directive 102 !$omp do simd if(.true.) if(simd: .false.) 103 do i = 1, 10 104 end do 105 !$omp end do simd 106 107 ! ---------------------------------------------------------------------------- 108 ! PARALLEL 109 ! ---------------------------------------------------------------------------- 110 !$omp parallel if(.true.) 111 !$omp end parallel 112 113 !$omp parallel if(parallel: .true.) 114 !$omp end parallel 115 116 !ERROR: TARGET is not a constituent of the PARALLEL directive 117 !$omp parallel if(target: .true.) 118 !$omp end parallel 119 120 !ERROR: At most one IF clause can appear on the PARALLEL directive 121 !$omp parallel if(.true.) if(parallel: .false.) 122 !$omp end parallel 123 124 ! ---------------------------------------------------------------------------- 125 ! PARALLEL DO 126 ! ---------------------------------------------------------------------------- 127 !$omp parallel do if(.true.) 128 do i = 1, 10 129 end do 130 !$omp end parallel do 131 132 !$omp parallel do if(parallel: .true.) 133 do i = 1, 10 134 end do 135 !$omp end parallel do 136 137 !ERROR: TARGET is not a constituent of the PARALLEL DO directive 138 !$omp parallel do if(target: .true.) 139 do i = 1, 10 140 end do 141 !$omp end parallel do 142 143 !ERROR: At most one IF clause can appear on the PARALLEL DO directive 144 !$omp parallel do if(.true.) if(parallel: .false.) 145 do i = 1, 10 146 end do 147 !$omp end parallel do 148 149 ! ---------------------------------------------------------------------------- 150 ! PARALLEL DO SIMD 151 ! ---------------------------------------------------------------------------- 152 !$omp parallel do simd if(.true.) 153 do i = 1, 10 154 end do 155 !$omp end parallel do simd 156 157 !$omp parallel do simd if(parallel: .true.) if(simd: .false.) 158 do i = 1, 10 159 end do 160 !$omp end parallel do simd 161 162 !ERROR: TARGET is not a constituent of the PARALLEL DO SIMD directive 163 !$omp parallel do simd if(target: .true.) 164 do i = 1, 10 165 end do 166 !$omp end parallel do simd 167 168 ! ---------------------------------------------------------------------------- 169 ! PARALLEL SECTIONS 170 ! ---------------------------------------------------------------------------- 171 !$omp parallel sections if(.true.) 172 !$omp end parallel sections 173 174 !$omp parallel sections if(parallel: .true.) 175 !$omp end parallel sections 176 177 !ERROR: TARGET is not a constituent of the PARALLEL SECTIONS directive 178 !$omp parallel sections if(target: .true.) 179 !$omp end parallel sections 180 181 !ERROR: At most one IF clause can appear on the PARALLEL SECTIONS directive 182 !$omp parallel sections if(.true.) if(parallel: .false.) 183 !$omp end parallel sections 184 185 ! ---------------------------------------------------------------------------- 186 ! PARALLEL WORKSHARE 187 ! ---------------------------------------------------------------------------- 188 !$omp parallel workshare if(.true.) 189 !$omp end parallel workshare 190 191 !$omp parallel workshare if(parallel: .true.) 192 !$omp end parallel workshare 193 194 !ERROR: TARGET is not a constituent of the PARALLEL WORKSHARE directive 195 !$omp parallel workshare if(target: .true.) 196 !$omp end parallel workshare 197 198 !ERROR: At most one IF clause can appear on the PARALLEL WORKSHARE directive 199 !$omp parallel workshare if(.true.) if(parallel: .false.) 200 !$omp end parallel workshare 201 202 ! ---------------------------------------------------------------------------- 203 ! SIMD 204 ! ---------------------------------------------------------------------------- 205 !$omp simd if(.true.) 206 do i = 1, 10 207 end do 208 !$omp end simd 209 210 !$omp simd if(simd: .true.) 211 do i = 1, 10 212 end do 213 !$omp end simd 214 215 !ERROR: TARGET is not a constituent of the SIMD directive 216 !$omp simd if(target: .true.) 217 do i = 1, 10 218 end do 219 !$omp end simd 220 221 !ERROR: At most one IF clause can appear on the SIMD directive 222 !$omp simd if(.true.) if(simd: .false.) 223 do i = 1, 10 224 end do 225 !$omp end simd 226 227 ! ---------------------------------------------------------------------------- 228 ! TARGET 229 ! ---------------------------------------------------------------------------- 230 !$omp target if(.true.) 231 !$omp end target 232 233 !$omp target if(target: .true.) 234 !$omp end target 235 236 !ERROR: PARALLEL is not a constituent of the TARGET directive 237 !$omp target if(parallel: .true.) 238 !$omp end target 239 240 !ERROR: At most one IF clause can appear on the TARGET directive 241 !$omp target if(.true.) if(target: .false.) 242 !$omp end target 243 244 ! ---------------------------------------------------------------------------- 245 ! TARGET DATA 246 ! ---------------------------------------------------------------------------- 247 !$omp target data map(tofrom: i) if(.true.) 248 !$omp end target data 249 250 !$omp target data map(tofrom: i) if(target data: .true.) 251 !$omp end target data 252 253 !ERROR: TARGET is not a constituent of the TARGET DATA directive 254 !$omp target data map(tofrom: i) if(target: .true.) 255 !$omp end target data 256 257 !ERROR: At most one IF clause can appear on the TARGET DATA directive 258 !$omp target data map(tofrom: i) if(.true.) if(target data: .false.) 259 !$omp end target data 260 261 ! ---------------------------------------------------------------------------- 262 ! TARGET ENTER DATA 263 ! ---------------------------------------------------------------------------- 264 !$omp target enter data map(to: i) if(.true.) 265 266 !$omp target enter data map(to: i) if(target enter data: .true.) 267 268 !ERROR: TARGET is not a constituent of the TARGET ENTER DATA directive 269 !$omp target enter data map(to: i) if(target: .true.) 270 271 !ERROR: At most one IF clause can appear on the TARGET ENTER DATA directive 272 !$omp target enter data map(to: i) if(.true.) if(target enter data: .false.) 273 274 ! ---------------------------------------------------------------------------- 275 ! TARGET EXIT DATA 276 ! ---------------------------------------------------------------------------- 277 !$omp target exit data map(from: i) if(.true.) 278 279 !$omp target exit data map(from: i) if(target exit data: .true.) 280 281 !ERROR: TARGET is not a constituent of the TARGET EXIT DATA directive 282 !$omp target exit data map(from: i) if(target: .true.) 283 284 !ERROR: At most one IF clause can appear on the TARGET EXIT DATA directive 285 !$omp target exit data map(from: i) if(.true.) if(target exit data: .false.) 286 287 ! ---------------------------------------------------------------------------- 288 ! TARGET PARALLEL 289 ! ---------------------------------------------------------------------------- 290 !$omp target parallel if(.true.) 291 !$omp end target parallel 292 293 !$omp target parallel if(target: .true.) if(parallel: .false.) 294 !$omp end target parallel 295 296 !ERROR: SIMD is not a constituent of the TARGET PARALLEL directive 297 !$omp target parallel if(simd: .true.) 298 !$omp end target parallel 299 300 ! ---------------------------------------------------------------------------- 301 ! TARGET PARALLEL DO 302 ! ---------------------------------------------------------------------------- 303 !$omp target parallel do if(.true.) 304 do i = 1, 10 305 end do 306 !$omp end target parallel do 307 308 !$omp target parallel do if(target: .true.) if(parallel: .false.) 309 do i = 1, 10 310 end do 311 !$omp end target parallel do 312 313 !ERROR: SIMD is not a constituent of the TARGET PARALLEL DO directive 314 !$omp target parallel do if(simd: .true.) 315 do i = 1, 10 316 end do 317 !$omp end target parallel do 318 319 ! ---------------------------------------------------------------------------- 320 ! TARGET PARALLEL DO SIMD 321 ! ---------------------------------------------------------------------------- 322 !$omp target parallel do simd if(.true.) 323 do i = 1, 10 324 end do 325 !$omp end target parallel do simd 326 327 !$omp target parallel do simd if(target: .true.) if(parallel: .false.) & 328 !$omp& if(simd: .true.) 329 do i = 1, 10 330 end do 331 !$omp end target parallel do simd 332 333 !ERROR: TEAMS is not a constituent of the TARGET PARALLEL DO SIMD directive 334 !$omp target parallel do simd if(teams: .true.) 335 do i = 1, 10 336 end do 337 !$omp end target parallel do simd 338 339 ! ---------------------------------------------------------------------------- 340 ! TARGET SIMD 341 ! ---------------------------------------------------------------------------- 342 !$omp target simd if(.true.) 343 do i = 1, 10 344 end do 345 !$omp end target simd 346 347 !$omp target simd if(target: .true.) if(simd: .false.) 348 do i = 1, 10 349 end do 350 !$omp end target simd 351 352 !ERROR: PARALLEL is not a constituent of the TARGET SIMD directive 353 !$omp target simd if(parallel: .true.) 354 do i = 1, 10 355 end do 356 !$omp end target simd 357 358 ! ---------------------------------------------------------------------------- 359 ! TARGET TEAMS 360 ! ---------------------------------------------------------------------------- 361 !$omp target teams if(.true.) 362 !$omp end target teams 363 364 !$omp target teams if(target: .true.) if(teams: .false.) 365 !$omp end target teams 366 367 !ERROR: PARALLEL is not a constituent of the TARGET TEAMS directive 368 !$omp target teams if(parallel: .true.) 369 !$omp end target teams 370 371 ! ---------------------------------------------------------------------------- 372 ! TARGET TEAMS DISTRIBUTE 373 ! ---------------------------------------------------------------------------- 374 !$omp target teams distribute if(.true.) 375 do i = 1, 10 376 end do 377 !$omp end target teams distribute 378 379 !$omp target teams distribute if(target: .true.) if(teams: .false.) 380 do i = 1, 10 381 end do 382 !$omp end target teams distribute 383 384 !ERROR: PARALLEL is not a constituent of the TARGET TEAMS DISTRIBUTE directive 385 !$omp target teams distribute if(parallel: .true.) 386 do i = 1, 10 387 end do 388 !$omp end target teams distribute 389 390 ! ---------------------------------------------------------------------------- 391 ! TARGET TEAMS DISTRIBUTE PARALLEL DO 392 ! ---------------------------------------------------------------------------- 393 !$omp target teams distribute parallel do if(.true.) 394 do i = 1, 10 395 end do 396 !$omp end target teams distribute parallel do 397 398 !$omp target teams distribute parallel do & 399 !$omp& if(target: .true.) if(teams: .false.) if(parallel: .true.) 400 do i = 1, 10 401 end do 402 !$omp end target teams distribute parallel do 403 404 !ERROR: SIMD is not a constituent of the TARGET TEAMS DISTRIBUTE PARALLEL DO directive 405 !$omp target teams distribute parallel do if(simd: .true.) 406 do i = 1, 10 407 end do 408 !$omp end target teams distribute parallel do 409 410 ! ---------------------------------------------------------------------------- 411 ! TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD 412 ! ---------------------------------------------------------------------------- 413 !$omp target teams distribute parallel do simd if(.true.) 414 do i = 1, 10 415 end do 416 !$omp end target teams distribute parallel do simd 417 418 !$omp target teams distribute parallel do simd & 419 !$omp& if(target: .true.) if(teams: .false.) if(parallel: .true.) & 420 !$omp& if(simd: .false.) 421 do i = 1, 10 422 end do 423 !$omp end target teams distribute parallel do simd 424 425 !ERROR: TASK is not a constituent of the TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD directive 426 !$omp target teams distribute parallel do simd if(task: .true.) 427 do i = 1, 10 428 end do 429 !$omp end target teams distribute parallel do simd 430 431 ! ---------------------------------------------------------------------------- 432 ! TARGET TEAMS DISTRIBUTE SIMD 433 ! ---------------------------------------------------------------------------- 434 !$omp target teams distribute simd if(.true.) 435 do i = 1, 10 436 end do 437 !$omp end target teams distribute simd 438 439 !$omp target teams distribute simd & 440 !$omp& if(target: .true.) if(teams: .false.) if(simd: .true.) 441 do i = 1, 10 442 end do 443 !$omp end target teams distribute simd 444 445 !ERROR: PARALLEL is not a constituent of the TARGET TEAMS DISTRIBUTE SIMD directive 446 !$omp target teams distribute simd if(parallel: .true.) 447 do i = 1, 10 448 end do 449 !$omp end target teams distribute simd 450 451 ! ---------------------------------------------------------------------------- 452 ! TARGET UPDATE 453 ! ---------------------------------------------------------------------------- 454 !$omp target update to(i) if(.true.) 455 456 !$omp target update to(i) if(target update: .true.) 457 458 !ERROR: TARGET is not a constituent of the TARGET UPDATE directive 459 !$omp target update to(i) if(target: .true.) 460 461 !ERROR: At most one IF clause can appear on the TARGET UPDATE directive 462 !$omp target update to(i) if(.true.) if(target update: .false.) 463 464 ! ---------------------------------------------------------------------------- 465 ! TASK 466 ! ---------------------------------------------------------------------------- 467 !$omp task if(.true.) 468 !$omp end task 469 470 !$omp task if(task: .true.) 471 !$omp end task 472 473 !ERROR: TARGET is not a constituent of the TASK directive 474 !$omp task if(target: .true.) 475 !$omp end task 476 477 !ERROR: At most one IF clause can appear on the TASK directive 478 !$omp task if(.true.) if(task: .false.) 479 !$omp end task 480 481 ! ---------------------------------------------------------------------------- 482 ! TASKLOOP 483 ! ---------------------------------------------------------------------------- 484 !$omp taskloop if(.true.) 485 do i = 1, 10 486 end do 487 !$omp end taskloop 488 489 !$omp taskloop if(taskloop: .true.) 490 do i = 1, 10 491 end do 492 !$omp end taskloop 493 494 !ERROR: TARGET is not a constituent of the TASKLOOP directive 495 !$omp taskloop if(target: .true.) 496 do i = 1, 10 497 end do 498 !$omp end taskloop 499 500 !ERROR: At most one IF clause can appear on the TASKLOOP directive 501 !$omp taskloop if(.true.) if(taskloop: .false.) 502 do i = 1, 10 503 end do 504 !$omp end taskloop 505 506 ! ---------------------------------------------------------------------------- 507 ! TASKLOOP SIMD 508 ! ---------------------------------------------------------------------------- 509 !$omp taskloop simd if(.true.) 510 do i = 1, 10 511 end do 512 !$omp end taskloop simd 513 514 !$omp taskloop simd if(taskloop: .true.) if(simd: .false.) 515 do i = 1, 10 516 end do 517 !$omp end taskloop simd 518 519 !ERROR: TARGET is not a constituent of the TASKLOOP SIMD directive 520 !$omp taskloop simd if(target: .true.) 521 do i = 1, 10 522 end do 523 !$omp end taskloop simd 524 525 ! ---------------------------------------------------------------------------- 526 ! TEAMS 527 ! ---------------------------------------------------------------------------- 528 !$omp teams if(.true.) 529 !$omp end teams 530 531 !$omp teams if(teams: .true.) 532 !$omp end teams 533 534 !ERROR: TARGET is not a constituent of the TEAMS directive 535 !$omp teams if(target: .true.) 536 !$omp end teams 537 538 !ERROR: At most one IF clause can appear on the TEAMS directive 539 !$omp teams if(.true.) if(teams: .false.) 540 !$omp end teams 541 542 ! ---------------------------------------------------------------------------- 543 ! TEAMS DISTRIBUTE 544 ! ---------------------------------------------------------------------------- 545 !$omp teams distribute if(.true.) 546 do i = 1, 10 547 end do 548 !$omp end teams distribute 549 550 !$omp teams distribute if(teams: .true.) 551 do i = 1, 10 552 end do 553 !$omp end teams distribute 554 555 !ERROR: TARGET is not a constituent of the TEAMS DISTRIBUTE directive 556 !$omp teams distribute if(target: .true.) 557 do i = 1, 10 558 end do 559 !$omp end teams distribute 560 561 !ERROR: At most one IF clause can appear on the TEAMS DISTRIBUTE directive 562 !$omp teams distribute if(.true.) if(teams: .true.) 563 do i = 1, 10 564 end do 565 !$omp end teams distribute 566 567 ! ---------------------------------------------------------------------------- 568 ! TEAMS DISTRIBUTE PARALLEL DO 569 ! ---------------------------------------------------------------------------- 570 !$omp teams distribute parallel do if(.true.) 571 do i = 1, 10 572 end do 573 !$omp end teams distribute parallel do 574 575 !$omp teams distribute parallel do if(teams: .true.) if(parallel: .false.) 576 do i = 1, 10 577 end do 578 !$omp end teams distribute parallel do 579 580 !ERROR: TARGET is not a constituent of the TEAMS DISTRIBUTE PARALLEL DO directive 581 !$omp teams distribute parallel do if(target: .true.) 582 do i = 1, 10 583 end do 584 !$omp end teams distribute parallel do 585 586 ! ---------------------------------------------------------------------------- 587 ! TEAMS DISTRIBUTE PARALLEL DO SIMD 588 ! ---------------------------------------------------------------------------- 589 !$omp teams distribute parallel do simd if(.true.) 590 do i = 1, 10 591 end do 592 !$omp end teams distribute parallel do simd 593 594 !$omp teams distribute parallel do simd & 595 !$omp& if(teams: .true.) if(parallel: .true.) if(simd: .true.) 596 do i = 1, 10 597 end do 598 !$omp end teams distribute parallel do simd 599 600 !ERROR: TARGET is not a constituent of the TEAMS DISTRIBUTE PARALLEL DO SIMD directive 601 !$omp teams distribute parallel do simd if(target: .true.) 602 do i = 1, 10 603 end do 604 !$omp end teams distribute parallel do simd 605 606 ! ---------------------------------------------------------------------------- 607 ! TEAMS DISTRIBUTE SIMD 608 ! ---------------------------------------------------------------------------- 609 !$omp teams distribute simd if(.true.) 610 do i = 1, 10 611 end do 612 !$omp end teams distribute simd 613 614 !$omp teams distribute simd if(teams: .true.) if(simd: .true.) 615 do i = 1, 10 616 end do 617 !$omp end teams distribute simd 618 619 !ERROR: TARGET is not a constituent of the TEAMS DISTRIBUTE SIMD directive 620 !$omp teams distribute simd if(target: .true.) 621 do i = 1, 10 622 end do 623 !$omp end teams distribute simd 624end program main 625