[flang-commits] [flang] [flang][OpenMP] Lower DO and SIMD variants in metadirectives (PR #210810)
via flang-commits
flang-commits at lists.llvm.org
Mon Jul 27 22:07:26 PDT 2026
================
@@ -1336,6 +1336,16 @@ void OmpStructureChecker::Leave(const parser::OpenMPConstruct &x) {
}
void OmpStructureChecker::Enter(const parser::OpenMPDeclarativeConstruct &x) {
+ std::size_t firstVariant{metadirectiveVariantScopeStarts_.empty()
+ ? 0
+ : metadirectiveVariantScopeStarts_.back()};
+ if (firstVariant < metadirectiveLoopVariants_.size()) {
+ // An OpenMP declarative directive between a loop-associated
+ // metadirective and a DO construct in the same scope interrupts their
+ // association. Preserve pending variants from enclosing scopes.
+ CheckMetadirectiveVariantsWithoutLoop(firstVariant);
----------------
MattPD wrote:
`CheckMetadirectiveVariantsWithoutLoop` matches only `OpenMPDeclarativeConstruct` nodes, but `spliceAssociatedDoEval` skips only end statements and `CompilerDirective`, and the OpenACC declarative forms are PFT directives too.
With `-fopenacc -fopenmp`, an `!$acc declare create(x)` or `!$acc routine seq` between the metadirective and its DO passes `-fsyntax-only` with no diagnostic and then reaches `not yet implemented: loop-associated METADIRECTIVE without associated DO`. Removing just the `!$acc` line lowers cleanly.
Would it be worth deriving the `spliceAssociatedDoEval` skip list and this check from one shared predicate, so the two cannot drift?
https://github.com/llvm/llvm-project/pull/210810
More information about the flang-commits
mailing list