diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp --- a/flang/lib/Lower/ConvertExpr.cpp +++ b/flang/lib/Lower/ConvertExpr.cpp @@ -4307,7 +4307,7 @@ llvm::SmallVector getShape(ArrayOperand array) { if (array.slice) return computeSliceShape(array.slice); - if (array.memref.getType().isa()) + if (array.memref.getType().isa()) return fir::factory::readExtents(builder, getLoc(), fir::BoxValue{array.memref}); return fir::factory::getExtents(array.shape); diff --git a/flang/lib/Optimizer/CodeGen/CGOps.cpp b/flang/lib/Optimizer/CodeGen/CGOps.cpp --- a/flang/lib/Optimizer/CodeGen/CGOps.cpp +++ b/flang/lib/Optimizer/CodeGen/CGOps.cpp @@ -56,7 +56,7 @@ unsigned fir::cg::XArrayCoorOp::getRank() { auto memrefTy = getMemref().getType(); - if (memrefTy.isa()) + if (memrefTy.isa()) if (auto seqty = fir::dyn_cast_ptrOrBoxEleTy(memrefTy).dyn_cast()) return seqty.getDimension(); diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp --- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp +++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp @@ -2293,7 +2293,7 @@ mlir::Value offset = genConstantIndex(loc, idxTy, rewriter, 0); const bool isShifted = !coor.getShift().empty(); const bool isSliced = !coor.getSlice().empty(); - const bool baseIsBoxed = coor.getMemref().getType().isa(); + const bool baseIsBoxed = coor.getMemref().getType().isa(); // For each dimension of the array, generate the offset calculation. for (unsigned i = 0; i < rank; ++i, ++indexOffset, ++shapeOffset, diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp --- a/flang/lib/Optimizer/Dialect/FIROps.cpp +++ b/flang/lib/Optimizer/Dialect/FIROps.cpp @@ -380,7 +380,7 @@ } else { auto s = shapeTy.cast(); shapeTyRank = s.getRank(); - if (!getMemref().getType().isa()) + if (!getMemref().getType().isa()) return emitOpError("shift can only be provided with fir.box memref"); } if (arrDim && arrDim != shapeTyRank) @@ -449,7 +449,7 @@ } else { auto s = shapeTy.cast(); shapeTyRank = s.getRank(); - if (!getMemref().getType().isa()) + if (!getMemref().getType().isa()) return emitOpError("shift can only be provided with fir.box memref"); } if (arrDim && arrDim != shapeTyRank) diff --git a/flang/test/Lower/polymorphic.f90 b/flang/test/Lower/polymorphic.f90 --- a/flang/test/Lower/polymorphic.f90 +++ b/flang/test/Lower/polymorphic.f90 @@ -76,4 +76,18 @@ ! CHECK: %[[CALL_RES:.*]] = fir.call @_QMpolymorphic_testPtest_fct_ret_class() {{.*}}: () -> !fir.class>> ! CHECK: fir.save_result %[[CALL_RES]] to %[[RESULT]] : !fir.class>>, !fir.ref>>> + subroutine implicit_loop_with_polymorphic() + class(p1), allocatable :: p(:) + allocate(p(3)) + p%a = [ 1, 2, 3 ] + end subroutine + +! CHECK-LABEL: func.func @_QMpolymorphic_testPimplicit_loop_with_polymorphic() { +! CHECK: %{{.*}} = fir.array_load %{{.*}}(%{{.*}}) [%{{.*}}] : (!fir.class>>>, !fir.shift<1>, !fir.slice<1>) -> !fir.array +! CHECK: %{{.*}} = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} unordered iter_args(%{{.*}} = %{{.*}}) -> (!fir.array) { +! CHECK: %{{.*}} = fir.array_fetch %{{.*}}, %{{.*}} : (!fir.array<3xi32>, index) -> i32 +! CHECK: %{{.*}} = fir.array_update %{{.*}}, %{{.*}}, %{{.*}} : (!fir.array, i32, index) -> !fir.array +! CHECK: } +! CHECK: fir.array_merge_store %{{.*}}, %{{.*}} to %{{.*}}[%{{.*}}] : !fir.array, !fir.array, !fir.class>>>, !fir.slice<1> + end module