/// value.
bool isUnlimitedPolymorphicType(mlir::Type ty);
+/// Return true iff `ty` is the type of an assumed type.
+bool isAssumedType(mlir::Type ty);
+
/// Return true iff `boxTy` wraps a record type or an unlimited polymorphic
/// entity. Polymorphic entities with intrinsic type spec do not have addendum
inline bool boxHasAddendum(fir::BaseBoxType boxTy) {
box = Fortran::evaluate::IsVariable(*expr)
? builder.createBox(loc, genBoxArg(*expr),
fir::isPolymorphicType(argTy),
- fir::isBoxNone(argTy))
+ fir::isAssumedType(argTy))
: builder.createBox(getLoc(), genTempExtAddr(*expr),
fir::isPolymorphicType(argTy),
- fir::isBoxNone(argTy));
+ fir::isAssumedType(argTy));
if (box.getType().isa<fir::BoxType>() &&
- fir::isPolymorphicType(argTy) && !fir::isBoxNone(argTy)) {
+ fir::isPolymorphicType(argTy) && !fir::isAssumedType(argTy)) {
mlir::Type actualTy = argTy;
if (Fortran::lower::isParentComponent(*expr))
actualTy = fir::BoxType::get(converter.genType(*expr));
return create<fir::EmboxProcOp>(loc, toTy, proc);
}
- if ((fir::isPolymorphicType(fromTy) &&
- (fir::isAllocatableType(fromTy) || fir::isPointerType(fromTy)) &&
- fir::isPolymorphicType(toTy)) ||
- (fir::isPolymorphicType(fromTy) && toTy.isa<fir::BoxType>()))
+ if (((fir::isPolymorphicType(fromTy) &&
+ (fir::isAllocatableType(fromTy) || fir::isPointerType(fromTy)) &&
+ fir::isPolymorphicType(toTy)) ||
+ (fir::isPolymorphicType(fromTy) && toTy.isa<fir::BoxType>())) &&
+ !(fir::isUnlimitedPolymorphicType(fromTy) && fir::isAssumedType(toTy)))
return create<fir::ReboxOp>(loc, toTy, val, mlir::Value{},
/*slice=*/mlir::Value{});
return false;
}
-static bool isAssumedType(mlir::Type ty) {
+bool isAssumedType(mlir::Type ty) {
if (auto boxTy = ty.dyn_cast<fir::BoxType>()) {
if (boxTy.getEleTy().isa<mlir::NoneType>())
return true;
end subroutine
end interface
+ interface
+ subroutine assumed_r(a)
+ type(*), intent(in), target :: a(*)
+ end subroutine
+ end interface
+
contains
subroutine call_assmued()
! CHECK: %[[BOX_NONE:.*]] = fir.embox %[[I]] : (!fir.ref<i32>) -> !fir.box<none>
! CHECK: fir.call @_QPassumed(%[[BOX_NONE]]) fastmath<contract> : (!fir.box<none>) -> ()
+ subroutine call_assumed_r()
+ integer, target :: i(10)
+ call assumed_r(i)
+ end subroutine
+
+! CHECK-LABEL: func.func @_QMassumed_type_testPcall_assumed_r() {
+! CHECK: %[[C10:.*]] = arith.constant 10 : index
+! CHECK: %[[I:.*]] = fir.alloca !fir.array<10xi32> {bindc_name = "i", fir.target, uniq_name = "_QMassumed_type_testFcall_assumed_rEi"}
+! CHECK: %[[SHAPE:.*]] = fir.shape %[[C10]] : (index) -> !fir.shape<1>
+! CHECK: %[[BOX_NONE:.*]] = fir.embox %[[I]](%[[SHAPE]]) : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<10xnone>>
+! CHECK: %[[CONV:.*]] = fir.convert %[[BOX_NONE]] : (!fir.box<!fir.array<10xnone>>) -> !fir.box<!fir.array<?xnone>>
+! CHECK: fir.call @_QPassumed_r(%[[CONV]]) {{.*}} : (!fir.box<!fir.array<?xnone>>) -> ()
+
end module