[flang-commits] [flang] [llvm] [Flang] Adding lowering for the allocation and deallocation of coarrays (PR #182110)
Jean-Didier PAILLEUX via flang-commits
flang-commits at lists.llvm.org
Mon Mar 16 05:19:05 PDT 2026
================
@@ -701,6 +730,14 @@ static void instantiateGlobal(Fortran::lower::AbstractConverter &converter,
mlir::Value cast = builder.createConvert(loc, varAddrType, addrOf);
Fortran::lower::StatementContext stmtCtx;
mapSymbolAttributes(converter, var, symMap, stmtCtx, cast);
+ // Local coarray must have the SAVE or ALLOCATABLE attribute and are
+ // never explicitly deallaocated or finalized (see 7.5.6.4).
+ // Otherwize, a coarray is global we will add an implicit deallocation
+ // for nonallocatable and nonpointer at the end of the scope.
+ if (Fortran::evaluate::IsCoarray(sym) &&
+ !Fortran::semantics::IsAllocatable(sym) &&
+ !Fortran::semantics::IsPointer(sym))
+ genCleanupDeallocateCoarray(converter, var, symMap);
----------------
JDPailleux wrote:
Agreed, and sorry about the handling of the SAVE attribute.
About allocated ALLOCATABLE coarrays, I need to add more things (and check) to ensure that we don't call mif.dealloc_coarray twice (if I explicitly use DEALLOCATE).
https://github.com/llvm/llvm-project/pull/182110
More information about the flang-commits
mailing list