================ @@ -9924,11 +9954,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); ---------------- alexey-bataev wrote:
```suggestion appendFlattendedStmtList(Constituents, DependentPreInits); ``` 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