[flang-commits] [flang] [llvm] [flang][OpenMP] Check conflicts between predetermined/explicit DSA (PR #194961)

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Thu Apr 30 10:47:02 PDT 2026


================
@@ -443,30 +442,89 @@ const parser::Name OmpStructureChecker::GetLoopIndex(
   return std::get<Bounds>(x->GetLoopControl()->u).Name().thing;
 }
 
-void OmpStructureChecker::SetLoopInfo(const parser::OpenMPLoopConstruct &x) {
-  if (const auto *loop{x.GetNestedLoop()}) {
-    if (loop->IsDoNormal()) {
-      const parser::Name &itrVal{GetLoopIndex(loop)};
-      SetLoopIv(itrVal.symbol);
+void OmpStructureChecker::CheckIterationVariables(
+    const parser::OpenMPLoopConstruct &x) {
+  unsigned version{context_.langOptions().OpenMPVersion};
+  auto doLoops{CollectAffectedDoLoops(x, version, &context_)};
+  if (!doLoops) {
+    return;
+  }
+  const parser::OmpDirectiveSpecification &spec{x.BeginDir()};
+  llvm::omp::Directive dirId{spec.DirId()};
+
+  // Collect symbols from DSA clauses on the construct. These symbols
+  // are the "host" versions of symbols inside the construct. The flags
+  // of interest are on the associated symbols.
+  std::map<const Symbol *, std::pair<parser::CharBlock, llvm::omp::Clause>> dsa;
----------------
luporl wrote:

Will symbols with 2 DSA clauses (although invalid in a loop construct) be handled correctly?

For instance, a symbol that appears first in lastprivate and then in firstprivate. Can't it end up passing the check below?

https://github.com/llvm/llvm-project/pull/194961


More information about the flang-commits mailing list