Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions flang/lib/Optimizer/HLFIR/Transforms/ConvertToFIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ class AssignOpConversion : public mlir::OpRewritePattern<hlfir::AssignOp> {
fir::runtime::genAssignTemporary(builder, loc, toMutableBox, from);
else
fir::runtime::genAssign(builder, loc, toMutableBox, from);
} else if (lhs.isPolymorphic() && rhs.isPolymorphic()) {
if (fir::isNoneOrSeqNone(fir::getElementTypeOf(lhsExv)) &&
fir::isNoneOrSeqNone(fir::getElementTypeOf(rhsExv))) {
mlir::Value to = fir::getBase(builder.createBox(loc, lhsExv));
mlir::Value from = fir::getBase(builder.createBox(loc, rhsExv));
fir::runtime::genAssignPolymorphic(builder, loc, to, from);
}
} else {
// TODO: use the type specification to see if IsFinalizable is set,
// or propagate IsFinalizable attribute from lowering.
Expand Down
27 changes: 27 additions & 0 deletions flang/test/Lower/polymorphic-array.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
! RUN: bbc -emit-fir %s -o - | FileCheck %s

! Checks that no fir store is present with fir.class<none> as the first operand.
! Regression test for bug: FIR lowering failure on polymorphic assignment.

! CHECK-NOT: fir.store{{.*}}!fir.class<none>
module m1
type x
end type x
logical,parameter::t=.true.,f=.false.
logical::mask(3)=[t,f,t]
end module m1

subroutine s1
use m1
class(*),allocatable::v(:),u(:)
allocate(x::v(3))
allocate(x::u(3))
where(mask)
u=v
end where
end subroutine s1

program main
call s1
print *,'pass'
end program main
Loading