@@ -164,30 +164,34 @@ class CanonicalizationOfOmp {
164
164
std::get<parser::OmpBeginLoopDirective>(ompLoopCons->t );
165
165
auto &beginLoopDirective =
166
166
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
+ }
179
182
}
183
+ ++endIt;
180
184
}
181
- ++endIt;
182
- }
183
- if ((beginLoopDirective.v == llvm::omp::Directive::OMPD_unroll ||
184
- beginLoopDirective.v == llvm::omp::Directive::OMPD_tile)) {
185
185
RewriteOpenMPLoopConstruct (*ompLoopCons, block, nextIt);
186
186
auto &ompLoop = std::get<std::optional<std::variant<parser::DoConstruct, common::Indirection<parser::OpenMPLoopConstruct>>>>(x.t );
187
187
ompLoop = std::optional<std::variant<parser::DoConstruct, common::Indirection<parser::OpenMPLoopConstruct>>>{
188
188
std::variant<parser::DoConstruct, common::Indirection<parser::OpenMPLoopConstruct>>{
189
189
common::Indirection{std::move (*ompLoopCons)}}};
190
190
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 ()));
191
195
}
192
196
} else {
193
197
missingDoConstruct (dir);
0 commit comments