================
@@ -9924,11 +9941,24 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr 
*CollapseLoopCountExpr,
             Stmt *DependentPreInits = Transform->getPreInits();
             if (!DependentPreInits)
               return;
-            for (Decl *C : cast<DeclStmt>(DependentPreInits)->getDeclGroup()) {
-              auto *D = cast<VarDecl>(C);
-              DeclRefExpr *Ref = buildDeclRefExpr(SemaRef, D, D->getType(),
-                                                  Transform->getBeginLoc());
-              Captures[Ref] = Ref;
+
+            // Search for pre-init declared variables that need to be captured
+            // to be referenceable inside the directive.
+            SmallVector<Stmt *> Constituents;
+            if (auto *CS = dyn_cast<CompoundStmt>(DependentPreInits))
+              llvm::append_range(Constituents, CS->body());
+            else
+              Constituents.push_back(DependentPreInits);
+            for (Stmt *S : Constituents) {
+              if (DeclStmt *DC = dyn_cast<DeclStmt>(S)) {
----------------
alexey-bataev wrote:

```suggestion
              if (auto *DC = dyn_cast<DeclStmt>(S)) {
```

https://github.com/llvm/llvm-project/pull/91459
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to