[llvm-branch-commits] [flang] [flang][OpenM] Check if loop nest/sequence is well-formed (PR #188025)
Jack Styles via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Mar 23 08:49:49 PDT 2026
================
@@ -268,93 +258,83 @@ void OmpStructureChecker::CheckNestedConstruct(
// Check constructs contained in the body of the loop construct.
auto &body{std::get<parser::Block>(x.t)};
+
for (auto &stmt : BlockRange(body, BlockRange::Step::Over)) {
if (auto *d{parser::Unwrap<parser::CompilerDirective>(stmt)}) {
context_.Say(d->source,
"Compiler directives are not allowed inside OpenMP loop constructs"_warn_en_US);
- } else if (auto *omp{parser::Unwrap<parser::OpenMPLoopConstruct>(stmt)}) {
- if (!IsLoopTransforming(omp->BeginDir().DirId())) {
- context_.Say(omp->source,
- "Only loop-transforming OpenMP constructs are allowed inside OpenMP loop constructs"_err_en_US);
- }
- if (IsFullUnroll(*omp)) {
- context_.Say(x.source,
- "OpenMP loop construct cannot apply to a fully unrolled loop"_err_en_US);
- }
- } else if (!parser::Unwrap<parser::DoConstruct>(stmt)) {
- parser::CharBlock source{parser::GetSource(stmt).value_or(x.source)};
- context_.Say(source,
- "OpenMP loop construct can only contain DO loops or loop-nest-generating OpenMP constructs"_err_en_US);
}
}
LoopSequence sequence(body, version, true);
- // Check if a loop-nest-associated construct has only one top-level loop
- // in it.
+ auto assoc{llvm::omp::getDirectiveAssociation(dir)};
auto needRange{GetAffectedLoopRangeWithReason(beginSpec, version)};
+ auto haveLength{sequence.length()};
- if (auto haveLength{sequence.length()}) {
- if (*haveLength.value == 0) {
+ if (assoc == llvm::omp::Association::LoopNest) {
----------------
Stylie777 wrote:
Is there a risk here that things may be missed if we are now checking only for loop nest associated directives?
https://github.com/llvm/llvm-project/pull/188025
More information about the llvm-branch-commits
mailing list