================
@@ -19504,19 +19516,27 @@ static bool captureInCapturedRegion(
   if (IsTopScope && Kind != TryCaptureKind::Implicit) {
     ByRef = (Kind == TryCaptureKind::ExplicitByRef);
   } else if (S.getLangOpts().OpenMP && RSI->CapRegionKind == CR_OpenMP) {
+    bool IsBindingDecl = isa<BindingDecl>(Var);
+    ValueDecl *DSAVar = Var;
     // Using an LValue reference type is consistent with Lambdas (see below).
-    if (S.OpenMP().isOpenMPCapturedDecl(Var)) {
+    if (VarDecl *VD = S.OpenMP().isOpenMPCapturedDecl(Var)) {
+      Var = VD; // Capture the DecompositionDecl.
       bool HasConst = DeclRefType.isConstQualified();
+      // Note: DeclRefType should remain the BindingDecl's type (e.g., int),
+      // not the DecompositionDecl's type (e.g., Point). The variable being
+      // captured is the DecompositionDecl, but expressions still reference
+      // the individual binding's type.
       DeclRefType = DeclRefType.getUnqualifiedType();
       // Don't lose diagnostics about assignments to const.
       if (HasConst)
         DeclRefType.addConst();
     }
     // Do not capture firstprivates in tasks.
-    if (S.OpenMP().isOpenMPPrivateDecl(Var, RSI->OpenMPLevel,
+    if (!IsBindingDecl &&
----------------
alexey-bataev wrote:

isOpenMPCapturedByRef(DSAVar, ...) is called with the original BindingDecl, but 
Var has already been rewritten to the DecompositionDecl. For target regions 
where mapping determines by-ref vs by-copy, different bindings from the same 
DecompositionDecl could yield different capture-by-ref results, but the 
DecompositionDecl is only captured once (dedup in 
buildCapturedStmtCaptureList). The capture kind of whichever binding is 
processed first wins. Add a test with #pragma omp target map(tofrom:a) 
map(to:b) where a and b are from the same decomposition, and verify the 
DecompositionDecl capture kind is consistent.

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