diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -603,6 +603,18 @@ parser::ToUpperCaseLetters( parser::OmpScheduleClause::EnumToString(kind))); } + // OpenMP 4.5 : 2.7.1 Schedule clause + if (const auto &chunkExpr{ + std::get>(x.t)}) { + if (const auto chunkValue{GetIntValue(chunkExpr)}) { + if (*chunkValue <= 0) { + context_.Say(GetContext().clauseSource, + "The chunk size of the schedule clause must be a" + " positive integer."_err_en_US, + ContextDirectiveAsFortran()); + } + } + } } if (ScheduleModifierHasType( diff --git a/flang/test/Semantics/omp-do-schedule.f90 b/flang/test/Semantics/omp-do-schedule.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Semantics/omp-do-schedule.f90 @@ -0,0 +1,13 @@ +! RUN: %S/test_errors.sh %s %t %f18 -fopenmp +! OpenMP Version 4.5 +! 2.7.1 Schedule Clause +program omp_doSchedule + integer :: i,n + real :: a(100), y(100), z(100) +!ERROR: The chunk size of the schedule clause must be a positive integer. + !$omp do schedule(STATIC, -1) + do i=2,n+1 + y(i) = z(i-1) + a(i) + end do + !$omp end do +end program omp_doSchedule