@@ -305,6 +305,9 @@ void OmpStructureChecker::Enter(const parser::OpenMPLoopConstruct &x) {
305305 beginName.v == llvm::omp::Directive::OMPD_distribute_simd) {
306306 CheckDistLinear (x);
307307 }
308+ if (beginName.v == llvm::omp::Directive::OMPD_fuse) {
309+ CheckLooprangeBounds (x);
310+ }
308311}
309312
310313const parser::Name OmpStructureChecker::GetLoopIndex (
@@ -453,6 +456,32 @@ void OmpStructureChecker::CheckDistLinear(
453456 }
454457}
455458
459+ void OmpStructureChecker::CheckLooprangeBounds (
460+ const parser::OpenMPLoopConstruct &x) {
461+ const parser::OmpClauseList &clauseList = x.BeginDir ().Clauses ();
462+ if (!clauseList.v .empty ()) {
463+ for (auto &clause : clauseList.v ) {
464+ if (const auto *lrClause{
465+ std::get_if<parser::OmpClause::Looprange>(&clause.u )}) {
466+ if (const auto first{GetIntValue (std::get<0 >((lrClause->v ).t ))}) {
467+ if (const auto count{GetIntValue (std::get<1 >((lrClause->v ).t ))}) {
468+ auto &loopConsList =
469+ std::get<std::list<parser::NestedConstruct>>(x.t );
470+ if (loopConsList.size () < (unsigned )(*first + *count - 1 )) {
471+ context_.Say (clause.source ,
472+ " The loop range indicated in the %s clause"
473+ " must not be out of the bounds of the Loop Sequence"
474+ " following the construct." _err_en_US,
475+ parser::ToUpperCaseLetters (clause.source .ToString ()));
476+ }
477+ }
478+ }
479+ return ;
480+ }
481+ }
482+ }
483+ }
484+
456485void OmpStructureChecker::Leave (const parser::OpenMPLoopConstruct &x) {
457486 const parser::OmpClauseList &clauseList{x.BeginDir ().Clauses ()};
458487
0 commit comments