@@ -164,30 +164,34 @@ class CanonicalizationOfOmp {
164164 std::get<parser::OmpBeginLoopDirective>(ompLoopCons->t );
165165 auto &beginLoopDirective =
166166 std::get<parser::OmpLoopDirective>(beginDirective.t );
167- // iterate through the remaining block items to find the end directive for the unroll/tile directive.
168- parser::Block::iterator endIt;
169- endIt = nextIt;
170- while (endIt != block.end ()) {
171- if (auto *endDir{
172- GetConstructIf<parser::OmpEndLoopDirective>(*endIt)}) {
173- auto &endLoopDirective = std::get<parser::OmpLoopDirective>(endDir->t );
174- if (endLoopDirective.v == dir.v ) {
175- std::get<std::optional<parser::OmpEndLoopDirective>>(x.t ) =
176- std::move (*endDir);
177- endIt = block.erase (endIt);
178- continue ;
167+ if ((beginLoopDirective.v == llvm::omp::Directive::OMPD_unroll ||
168+ beginLoopDirective.v == llvm::omp::Directive::OMPD_tile)) {
169+ // iterate through the remaining block items to find the end directive for the unroll/tile directive.
170+ parser::Block::iterator endIt;
171+ endIt = nextIt;
172+ while (endIt != block.end ()) {
173+ if (auto *endDir{
174+ GetConstructIf<parser::OmpEndLoopDirective>(*endIt)}) {
175+ auto &endLoopDirective = std::get<parser::OmpLoopDirective>(endDir->t );
176+ if (endLoopDirective.v == dir.v ) {
177+ std::get<std::optional<parser::OmpEndLoopDirective>>(x.t ) =
178+ std::move (*endDir);
179+ endIt = block.erase (endIt);
180+ continue ;
181+ }
179182 }
183+ ++endIt;
180184 }
181- ++endIt;
182- }
183- if ((beginLoopDirective.v == llvm::omp::Directive::OMPD_unroll ||
184- beginLoopDirective.v == llvm::omp::Directive::OMPD_tile)) {
185185 RewriteOpenMPLoopConstruct (*ompLoopCons, block, nextIt);
186186 auto &ompLoop = std::get<std::optional<std::variant<parser::DoConstruct, common::Indirection<parser::OpenMPLoopConstruct>>>>(x.t );
187187 ompLoop = std::optional<std::variant<parser::DoConstruct, common::Indirection<parser::OpenMPLoopConstruct>>>{
188188 std::variant<parser::DoConstruct, common::Indirection<parser::OpenMPLoopConstruct>>{
189189 common::Indirection{std::move (*ompLoopCons)}}};
190190 nextIt = block.erase (nextIt);
191+ } else {
192+ messages_.Say (dir.source ,
193+ " Only OpenMP Loop Transformation Constructs can be nested within OpenMPLoopConstruct's" _err_en_US,
194+ parser::ToUpperCaseLetters (dir.source .ToString ()));
191195 }
192196 } else {
193197 missingDoConstruct (dir);
0 commit comments