[flang-commits] [flang] [flang][cuda] Propagate CUDA attrs from parent variable to component allocations (PR #206614)

Vijay Kandiah via flang-commits flang-commits at lists.llvm.org
Mon Jun 29 16:52:54 PDT 2026


================
@@ -623,11 +654,15 @@ class AllocateStmtHelper {
 
   void genSourceMoldAllocation(const Allocation &alloc,
                                const fir::MutableBoxValue &box, bool isSource) {
-    unsigned allocatorIdx = Fortran::lower::getAllocatorIdx(alloc.getSymbol());
+    bool isCudaAllocate = Fortran::semantics::HasCUDAAttr(alloc.getSymbol());
+    const Fortran::semantics::Symbol *cudaSymForAlloc = &alloc.getSymbol();
+    if (!isCudaAllocate)
+      isCudaAllocate = propagateCUDAAttrsFromParent(alloc, cudaSymForAlloc);
+    unsigned allocatorIdx = Fortran::lower::getAllocatorIdx(*cudaSymForAlloc);
     fir::ExtendedValue exv = isSource ? sourceExv : moldExv;
 
     bool sourceIsDevice = false;
-    if (const Fortran::semantics::Symbol *sym{GetLastSymbol(sourceExpr)})
+    if (const Fortran::semantics::Symbol * sym{GetLastSymbol(sourceExpr)})
----------------
VijayKandiah wrote:

Fixed

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


More information about the flang-commits mailing list