================
@@ -1407,7 +1423,35 @@ bool CodeGenFunction::EmitOMPLastprivateClauseInit(
     for (const Expr *IInit : C->private_copies()) {
       // Keep the address of the original variable for future update at the end
       // of the loop.
-      const auto *OrigVD = cast<VarDecl>(cast<DeclRefExpr>(*IRef)->getDecl());
+      const auto *OrigDecl = cast<DeclRefExpr>(*IRef)->getDecl();
+      // Handle BindingDecls with the same level of support as VarDecls.
+      if (const auto *BD = dyn_cast<BindingDecl>(OrigDecl)) {
+        if (AlreadyEmittedVars.insert(cast<ValueDecl>(BD->getCanonicalDecl()))
+                .second) {
+          const auto *DestVD =
+              cast<VarDecl>(cast<DeclRefExpr>(*IDestRef)->getDecl());
+          // Get the original binding address.
+          DeclRefExpr DRE(getContext(), const_cast<BindingDecl *>(BD),
+                          /*RefersToEnclosingVariableOrCapture=*/true,
+                          BD->getType(), VK_LValue, (*IRef)->getExprLoc());
+          PrivateScope.addPrivate(DestVD, EmitLValue(&DRE).getAddress());
+
+          if (IInit) {
+            const auto *VD = 
cast<VarDecl>(cast<DeclRefExpr>(IInit)->getDecl());
+            // Emit private VarDecl with copy init.
+            EmitDecl(*VD);
----------------
alexey-bataev wrote:

It never calls emitLastprivateConditionalInit, while 
checkForLastprivateConditionalUpdate skips BindingDecls. So, 
`lastprivate(conditional: a)` on a binding behaves as ordinary lastprivate with 
no diagnostic. Either diagnose as unsupported or handle it. Add a test either 
way.

https://github.com/llvm/llvm-project/pull/190832
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to