diff --git a/flang/lib/Optimizer/CodeGen/TypeConverter.h b/flang/lib/Optimizer/CodeGen/TypeConverter.h --- a/flang/lib/Optimizer/CodeGen/TypeConverter.h +++ b/flang/lib/Optimizer/CodeGen/TypeConverter.h @@ -60,6 +60,9 @@ [&](fir::PointerType pointer) { return convertPointerLike(pointer); }); addConversion( [&](fir::RecordType derived) { return convertRecordType(derived); }); + addConversion([&](fir::LenType field) { + return mlir::IntegerType::get(field.getContext(), 32); + }); addConversion( [&](fir::ComplexType cmplx) { return convertComplexType(cmplx); }); addConversion( diff --git a/flang/test/Fir/types-to-llvm.fir b/flang/test/Fir/types-to-llvm.fir --- a/flang/test/Fir/types-to-llvm.fir +++ b/flang/test/Fir/types-to-llvm.fir @@ -203,3 +203,11 @@ func private @foo16(%arg0: !fir.vector<2:!fir.real<16>>) // CHECK-LABEL: foo16 // CHECK-SAME: vector<2xf128> + +// ----- + +// Test `!fir.len` conversion. + +func private @foo0(%arg0: !fir.len) +// CHECK-LABEL: foo0 +// CHECK-SAME: i32