Index: flang/test/Semantics/omp-do01.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-do01.f90 @@ -0,0 +1,18 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.7.1 Loop Construct +! collapse(n) where n > num of loops + +program omp_do + integer i, j, k + + !ERROR: Not enough do loops for collapsed !$OMP DO + !$omp do collapse(2) + do i = 1, 10 + print *, "hello" + end do + !$omp end do + +end program omp_do Index: flang/test/Semantics/omp-do02.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-do02.f90 @@ -0,0 +1,21 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.7.1 Loop Construct +! Exit statement terminating !$OMP DO loop + +program omp_do + integer i, j, k + + !$omp do + do i = 1, 10 + do j = 1, 10 + print *, "Hello" + end do + !ERROR: EXIT statement terminating !$OMP DO loop + exit + end do + !$omp end do + +end program omp_do Index: flang/test/Semantics/omp-do03.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-do03.f90 @@ -0,0 +1,26 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.7.1 Loop Construct +! Semantic error for correct test case + +program omp_do + integer i, j, k + integer :: a(10), b(10) + a = 10 + j = 0 + + !$omp parallel + !$omp do linear(j:1) + do i = 1, 10 + j = j + 1 + b(i) = a(i) * 2.0 + end do + !$omp end do + !$omp end parallel + + print *, j + print *, b + +end program omp_do Index: flang/test/Semantics/omp-do04.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-do04.f90 @@ -0,0 +1,20 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.7.1 Loop Construct +! The loop iteration variable may not appear in a threadprivate directive. + +program omp_do + integer i, j, k + + !$omp do firstprivate(i) + !ERROR: !$OMP DO iteration variable i is not allowed in threadprivate + do i = 1, 10 + do j = 1, 10 + print *, "Hello" + end do + end do + !$omp end do + +end program omp_do Index: flang/test/Semantics/omp-do05.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-do05.f90 @@ -0,0 +1,26 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.7.1 Loop Construct +! chunk_size must be a loop invariant integer expression +! with a positive value. + +program omp_do + integer i, j, k + integer :: a(10), b(10) + a = 10 + j = 0 + + !ERROR: INTEGER expression of SCHEDULE clause chunk_size must be positive + !$omp do schedule(static, -1) + do i = 1, 10 + j = j + 1 + b(i) = a(i) * 2.0 + end do + !$omp end do + + print *, j + print *, b + +end program omp_do Index: flang/test/Semantics/omp-do06.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-do06.f90 @@ -0,0 +1,21 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL:* + +! OpenMP Version 4.5 +! 2.7.1 Loop Construct +! The ordered clause must be present on the loop construct if any ordered +! region ever binds to a loop region arising from the loop construct. + +program omp_do + integer i, j, k + + !$omp do + do i = 1, 10 + !ERROR: ‘ordered’ region inside a loop region without an ordered clause. + !$omp ordered + call my_func() + !$omp end ordered + end do + !$omp end do + +end program omp_do Index: flang/test/Semantics/omp-do07.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-do07.f90 @@ -0,0 +1,24 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL:* + +! OpenMP Version 4.5 +! 2.7.1 Loop Construct +! No statement in the associated loops other than the DO statements +! can cause a branch out of the loops + +program omp_do + integer i, j, k + + !$omp do + do i = 1, 10 + do j = 1, 10 + print *, "Hello" + !ERROR: invalid branch to/from OpenMP structured block + goto 10 + end do + end do + !$omp end do + + 10 stop + +end program omp_do Index: flang/test/Semantics/omp-do08.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-do08.f90 @@ -0,0 +1,19 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.7.1 Loop Construct + +program omp_do + integer i, j, k + !$omp do collapse(2) + do i = 1, 10 + !ERROR: CYCLE statement to non-innermost collapsed !$OMP DO loop + if (i .lt. 5) cycle + do j = 1, 10 + print *, "Hello" + end do + end do + !$omp end do + +end program omp_do Index: flang/test/Semantics/omp-do09.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-do09.f90 @@ -0,0 +1,22 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.7.1 Loop Construct +! The do-loop cannot be a DO WHILE or a DO loop without loop control. + +program omp_do + integer i, j, k + i = 0 + + !$omp do + !ERROR: !$OMP DO cannot be a DO WHILE or DO without loop control + do while (i .lt. 10) + do j = 1, 10 + print *, "Hello" + end do + i = i + 1 + end do + !$omp end do + +end program omp_do Index: flang/test/Semantics/omp-do10.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-do10.f90 @@ -0,0 +1,20 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.7.1 Loop Construct +! The do-loop iteration variable must be of type integer. + +program omp_do + real i, j, k + + !$omp do + !ERROR: The do-loop iteration variable must be of type integer. + do i = 1, 10 + do j = 1, 10 + print *, "Hello" + end do + end do + !$omp end do + +end program omp_do Index: flang/test/Semantics/omp-loop-simd01.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-loop-simd01.f90 @@ -0,0 +1,24 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.8.3 Loop simd Construct +! Semantic error for correct test case. + +program omp_loop_simd + integer i, j, k, l + k = 0; + l = 0 + + !$omp parallel do simd linear(l) + do i = 1, 10 + do j = 1, 10 + print *, "omp loop simd" + k = k + 1 + l = l + 1 + end do + end do + + print *, k, l + +end program omp_loop_simd Index: flang/test/Semantics/omp-parallell01.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-parallell01.f90 @@ -0,0 +1,24 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.5 parallel construct. +! A program that branches into or out of a parallel region +! is non-conforming. + +program omp_parallel + integer i, j, k + + !$omp parallel + do i = 1, 10 + do j = 1, 10 + print *, "Hello" + !ERROR: invalid branch to/from OpenMP structured block + goto 10 + end do + end do + !$omp end parallel + + 10 stop + +end program omp_parallel Index: flang/test/Semantics/omp-parallell02.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-parallell02.f90 @@ -0,0 +1,24 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.5 parallel construct. +! A program that branches into or out of a parallel region +! is non-conforming. + +program omp_parallel + integer i, j, k + + !ERROR: invalid entry to OpenMP structured block + goto 10 + + !$omp parallel + do i = 1, 10 + do j = 1, 10 + print *, "Hello" + 10 stop + end do + end do + !$omp end parallel + +end program omp_parallel Index: flang/test/Semantics/omp-sections01.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-sections01.f90 @@ -0,0 +1,16 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.7.2 sections Construct +! Only a single nowait clause can appear on a sections directive. + +program omp_sections + + !$omp sections + !$omp section + print *, "omp section" + !ERROR: Only a single nowait clause can appear on a sections directive. + !$omp end sections nowait nowait + +end program omp_sections Index: flang/test/Semantics/omp-simd01.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-simd01.f90 @@ -0,0 +1,23 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.8.1 simd Construct +! A program that branches into or out of a simd region is non-conforming. + +program omp_simd + integer i, j + + !$omp simd + do i = 1, 10 + do j = 1, 10 + print *, "omp simd" + !ERROR: invalid branch to/from OpenMP structured block + goto 10 + end do + end do + !$omp end simd + + 10 stop + +end program omp_simd Index: flang/test/Semantics/omp-simd02.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-simd02.f90 @@ -0,0 +1,22 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.8.1 simd Construct +! Semantic error for correct test case + +program omp_simd + integer i, j, k + integer, allocatable :: a(:) + + allocate(a(10)) + + !$omp simd aligned(a) + do i = 1, 10 + a(i) = i + end do + !$omp end simd + + print *, a + +end program omp_simd Index: flang/test/Semantics/omp-simd03.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-simd03.f90 @@ -0,0 +1,26 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.8.1 simd Construct +! An ordered construct with the simd clause is the only OpenMP construct +! that can be encountered during execution of a simd region. + +program omp_simd + integer i, j, k + integer, allocatable :: a(:) + + allocate(a(10)) + + !$omp simd + do i = 1, 10 + !ERROR: Invalid OpenMP construct inside simd region + !$omp single + a(i) = i + !$omp end single + end do + !$omp end simd + + print *, a + +end program omp_simd Index: flang/test/Semantics/omp-single01.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-single01.f90 @@ -0,0 +1,17 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.7.3 single Construct +! Symbol present on multiple clauses + +program omp_single + integer i + i = 10 + + !$omp single private(i) + print *, "omp single", i + !ERROR: Symbol ‘i’ present on multiple clauses + !$omp end single copyprivate(i) + +end program omp_single Index: flang/test/Semantics/omp-single02.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-single02.f90 @@ -0,0 +1,19 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.7.3 single Construct +! Copyprivate variable is not thread private or private in outer context + +program omp_single + integer i + i = 10 + + !$omp parallel + !$omp single + print *, "omp single", i + !ERROR: copyprivate variable ‘i’ is not threadprivate or private + !$omp end single copyprivate(i) + !$omp end parallel + +end program omp_single Index: flang/test/Semantics/omp-task01.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-task01.f90 @@ -0,0 +1,32 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.9.1 task Construct +! Invalid entry to OpenMP structured block. + +recursive subroutine traverse ( P ) + type Node + type(Node), pointer :: left, right + end type Node + + type(Node) :: P + + !ERROR: invalid entry to OpenMP structured block + goto 10 + + if (associated(P%left)) then + !$omp task + call traverse(P%left) + 10 stop + !$omp end task + endif + + if (associated(P%right)) then + !$omp task + call traverse(P%right) + !$omp end task + endif + call process ( P ) + + end subroutine traverse Index: flang/test/Semantics/omp-taskloop-simd01.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-taskloop-simd01.f90 @@ -0,0 +1,21 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.9.3 taskloop simd Construct +! No reduction clause may be specified for !$omp taskloop simd. + +program omp_taskloop_simd + integer i , j , k + + !ERROR: Unexpected clause specified for !$OMP taskloop simd + !$omp taskloop simd reduction(+:k) + do i=1,10000 + do j=1,i + call loop_body(i, j) + k = k + 1 + end do + end do + !$omp end taskloop simd + +end program omp_taskloop_simd Index: flang/test/Semantics/omp-taskloop01.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-taskloop01.f90 @@ -0,0 +1,26 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.9.2 taskloop Construct +! Assert fail for correct test case. + +subroutine parallel_work + integer i + integer j + + !$omp taskgroup + !$omp task + call long_running_task() + !$omp end task + + !$omp taskloop private(j) grainsize(500) nogroup + do i=1,10000 + do j=1,i + call loop_body(i, j) + end do + end do + !$omp end taskloop + !$omp end taskgroup + +end subroutine parallel_work Index: flang/test/Semantics/omp-taskloop02.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-taskloop02.f90 @@ -0,0 +1,22 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.9.2 taskloop Construct +! Invalid entry to OpenMP structured block. + +program omp_taskloop + integer i , j + + !ERROR: invalid entry to OpenMP structured block + goto 10 + + !$omp taskloop private(j) grainsize(500) nogroup + do i=1,10000 + do j=1,i + 10 call loop_body(i, j) + end do + end do + !$omp end taskloop + +end program omp_taskloop Index: flang/test/Semantics/omp-taskloop03.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-taskloop03.f90 @@ -0,0 +1,25 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.9.2 taskloop Construct +! All loops associated with the taskloop construct must be perfectly nested, +! there must be no intervening code or any OpenMP directive between +! any two loops + +program omp_taskloop + integer i, j + + !$omp taskloop private(j) grainsize(500) nogroup + do i=1, 10000 + do j=1, i + call loop_body(i, j) + end do + !ERROR: Loops associated with !$omp taskloop is not perfectly nested + !$omp single + print *, "omp single" + !$omp end single + end do + !$omp end taskloop + +end program omp_taskloop Index: flang/test/Semantics/omp-workshare01.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-workshare01.f90 @@ -0,0 +1,23 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.7.4 workshare Construct +! Invalid do construct inside !$omp workshare + +subroutine workshare(aa, bb, cc, dd, ee, ff, n) + integer n, i + real aa(n,n), bb(n,n), cc(n,n), dd(n,n), ee(n,n), ff(n,n) + + !$omp workshare + !ERROR: Unexpected do stmt inside !$omp workshare + do i = 1, n + print *, "omp workshare" + end do + + aa = bb + cc = dd + ee = ff + !$omp end workshare + +end subroutine workshare Index: flang/test/Semantics/omp-workshare02.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-workshare02.f90 @@ -0,0 +1,29 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! XFAIL: * + +! OpenMP Version 4.5 +! 2.7.4 workshare Construct +! The !omp workshare construct must not contain any user defined +! function calls unless the function is ELEMENTAL. + +module my_mod + contains + function my_func(n) + integer :: my_func(n, n) + my_func = 10 + end function my_func +end module my_mod + +subroutine workshare(aa, bb, cc, dd, ee, ff, n) + use my_mod + integer n, i + real aa(n,n), bb(n,n), cc(n,n), dd(n,n), ee(n,n), ff(n,n) + + !$omp workshare + !ERROR: Non-ELEMENTAL function is not allowed in !$omp workshare construct + aa = my_func(n) + cc = dd + ee = ff + !$omp end workshare + +end subroutine workshare