[clang] [OpenMP] Fix crash with extern reference and diagnose loop variable reuse in collapsed loops. (PR #203252)

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 13 12:45:42 PDT 2026


================
@@ -9740,7 +9782,12 @@ static bool checkOpenMPIterationSpace(
         DoacrossC->setLoopData(CurrentNestedLoopCount, CntValue);
     }
   }
-
+  // Record the loop induction variable for nested loop reuse checking.
+  if (CurrentNestedLoopCount < NestedLoopCount && !HasErrors) {
+    if (const ValueDecl *LCDecl = ISC.getLoopDecl()) {
+      CollapsedLoopInductionVars.insert(LCDecl->getCanonicalDecl());
+    }
----------------
alexey-bataev wrote:

```suggestion
    if (const ValueDecl *LCDecl = ISC.getLoopDecl())
      CollapsedLoopInductionVars.insert(LCDecl->getCanonicalDecl());
```

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


More information about the cfe-commits mailing list