Index: flang/lib/Semantics/check-omp-structure.cpp =================================================================== --- flang/lib/Semantics/check-omp-structure.cpp +++ flang/lib/Semantics/check-omp-structure.cpp @@ -343,7 +343,8 @@ void OmpStructureChecker::CheckIfDoOrderedClause( const parser::OmpBlockDirective &blkDirective) { if (blkDirective.v == llvm::omp::OMPD_ordered) { - if (!FindClauseParent(llvm::omp::Clause::OMPC_ordered)) { + if (llvm::omp::doSet.test(GetContextParent().directive) && + !FindClauseParent(llvm::omp::Clause::OMPC_ordered)) { context_.Say(blkDirective.source, "The ORDERED clause must be present on the loop" " construct if any ORDERED region ever binds" Index: flang/test/Semantics/omp-ordered-simd.f90 =================================================================== --- /dev/null +++ flang/test/Semantics/omp-ordered-simd.f90 @@ -0,0 +1,20 @@ +! RUN: %S/test_errors.sh %s %t %flang -fopenmp +! OpenMP Version 4.5 +! orderd SIMD should be allowed within a non-worksharing SIMD loop. + +SUBROUTINE WORK(I) + INTEGER I +END SUBROUTINE WORK + +SUBROUTINE ORDERED_GOOD(N) + INTEGER N + !$OMP SIMD + DO I = 1,N + IF (I <= 10) THEN + !$OMP ORDERED SIMD + CALL WORK(I) + !$OMP END ORDERED + ENDIF + END DO + !$OMP END SIMD +END SUBROUTINE ORDERED_GOOD