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 @@ -915,12 +915,17 @@ return emitError(loc) << "no binding tables found"; // Get derived type information. - auto declaredType = llvm::TypeSwitch( - dispatch.getObject().getType().getEleTy()) - .Case( - [](auto p) { return p.getEleTy(); }) - .Default([](mlir::Type t) { return t; }); - + auto declaredType = + llvm::TypeSwitch( + dispatch.getObject().getType().getEleTy()) + .Case( + [](auto p) { + if (auto seq = + p.getEleTy().template dyn_cast()) + return seq.getEleTy(); + return p.getEleTy(); + }) + .Default([](mlir::Type t) { return t; }); assert(declaredType.isa() && "expecting fir.type"); auto recordType = declaredType.dyn_cast(); std::string typeDescName = diff --git a/flang/test/Fir/dispatch.f90 b/flang/test/Fir/dispatch.f90 --- a/flang/test/Fir/dispatch.f90 +++ b/flang/test/Fir/dispatch.f90 @@ -120,6 +120,21 @@ call p%proc_pass(1) end subroutine + subroutine no_pass_array(a) + class(p1) :: a(:) + call a(1)%proc_nopass() + end subroutine + + subroutine no_pass_array_allocatable(a) + class(p1), allocatable :: a(:) + call a(1)%proc_nopass() + end subroutine + + subroutine no_pass_array_pointer(a) + class(p1), allocatable :: a(:) + call a(1)%proc_nopass() + end subroutine + end module program test_type_to_class @@ -232,6 +247,9 @@ ! CHECK: %[[FUNC_PTR:.*]] = inttoptr i64 %[[FUNC_ADDR]] to ptr ! CHECK: call void %[[FUNC_PTR]](ptr %[[INT32]], ptr %[[CLASS]]) +! CHECK-LABEL: _QMdispatch1Pno_pass_array +! CHECK-LABEL: _QMdispatch1Pno_pass_array_allocatable +! CHECK-LABEL: _QMdispatch1Pno_pass_array_pointer ! Check the layout of the binding table. This is easier to do in FIR than in ! LLVM IR.