llvm-project/flang/test/Semantics/OpenMP/loop-transformation-construct03.f90
Krzysztof Parzyszek 06fc87bcd3
[flang][OpenMP] Better diagnostics for invalid or misplaced directives (#168885)
Add two more AST nodes, one for a misplaced end-directive, and one for
an invalid string following the OpenMP sentinel (e.g. "!$OMP XYZ").

Emit error messages when either node is encountered in semantic
analysis.
2025-11-23 07:55:10 -06:00

40 lines
956 B
Fortran

! Testing the Semantic failure of forming loop sequences under regular OpenMP directives
!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=60
subroutine loop_transformation_construct1
implicit none
integer, parameter :: i = 5
integer :: x
integer :: v(i)
! Only 1 do loop is associated with the OMP DO directive so the END DO directive is unmatched
!$omp do
do x = 1, i
v(x) = v(x) * 2
end do
do x = 1, i
v(x) = v(x) * 2
end do
!ERROR: Misplaced OpenMP end-directive
!$omp end do
end subroutine
subroutine loop_transformation_construct2
implicit none
integer, parameter :: i = 5
integer :: x
integer :: v(i)
! Only 1 do loop is associated with the OMP TILE directive so the END TILE directive is unmatched
!$omp tile sizes(2)
do x = 1, i
v(x) = v(x) * 2
end do
do x = 1, i
v(x) = v(x) * 2
end do
!ERROR: Misplaced OpenMP end-directive
!$omp end tile
end subroutine