diff --git a/flang/lib/Lower/CallInterface.cpp b/flang/lib/Lower/CallInterface.cpp --- a/flang/lib/Lower/CallInterface.cpp +++ b/flang/lib/Lower/CallInterface.cpp @@ -965,7 +965,14 @@ mlir::Type boxType = fir::wrapInClassOrBoxType( type, obj.type.type().IsPolymorphic(), obj.type.type().IsAssumedType()); - if (obj.attrs.test(Attrs::Allocatable) || obj.attrs.test(Attrs::Pointer)) { + if (obj.type.type().IsAssumedType() && isBindC) { + mlir::Type voidPtrType = fir::ReferenceType::get( + mlir::NoneType::get(&interface.converter.getMLIRContext())); + addFirOperand(voidPtrType, nextPassedArgPosition(), Property::BaseAddress, + attrs); + addPassedArg(PassEntityBy::BaseAddress, entity, characteristics); + } else if (obj.attrs.test(Attrs::Allocatable) || + obj.attrs.test(Attrs::Pointer)) { // Pass as fir.ref or fir.ref mlir::Type boxRefType = fir::ReferenceType::get(boxType); addFirOperand(boxRefType, nextPassedArgPosition(), Property::MutableBox, diff --git a/flang/test/Lower/polymorphic-types.f90 b/flang/test/Lower/polymorphic-types.f90 --- a/flang/test/Lower/polymorphic-types.f90 +++ b/flang/test/Lower/polymorphic-types.f90 @@ -172,13 +172,13 @@ end subroutine assumed_type_dummy ! CHECK-LABEL: func.func @assumed_type_dummy( - ! CHECK-SAME: %{{.*}}: !fir.box + ! CHECK-SAME: %{{.*}}: !fir.ref subroutine assumed_type_dummy_array(a) bind(c) type(*) :: a(:) end subroutine assumed_type_dummy_array ! CHECK-LABEL: func.func @assumed_type_dummy_array( - ! CHECK-SAME: %{{.*}}: !fir.box> + ! CHECK-SAME: %{{.*}}: !fir.ref end module