[flang-commits] [flang] [Flang] Fix handling of unlimited	polymorphic arrays (PR #159624)
    via flang-commits 
    flang-commits at lists.llvm.org
       
    Fri Sep 19 08:22:14 PDT 2025
    
    
  
================
@@ -127,7 +127,8 @@ class AssignOpConversion : public mlir::OpRewritePattern<hlfir::AssignOp> {
                // types of the LHS and the RHS must match already. We use the
                // runtime in this case so that the polymorphic (including
                // unlimited) content is copied properly.
-               (lhs.isPolymorphic() && assignOp.isTemporaryLHS())) {
+               (lhs.isPolymorphic() && assignOp.isTemporaryLHS()) ||
----------------
jeanPerier wrote:
`lhs.isPolymorphic()` is enough of a condition. We should not fall here because the rhs is polymorphic but the LHS is not (in that case, the LHS declared type is driving the assignment and we do not need the runtime).
So removing `&& assignOp.isTemporaryLHS()` should be enough.
Please update the comment above after `generated for creating polymorphic expressions.` to tell that is also needed for polymorphic allocatable LHS in WHERE statement. The comment currently tells the logic is only needed for compiler generated temps.
https://github.com/llvm/llvm-project/pull/159624
    
    
More information about the flang-commits
mailing list