Skip to content

Commit 9cb61ce

Browse files
committed
Using associate to get length. Also modified the test to check for emboxchar.
1 parent 4f86344 commit 9cb61ce

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,9 @@ struct AssociateOpConversion
448448
sourceVar = builder.create<fir::BoxAddrOp>(loc, assocType, sourceVar);
449449
} else if (mlir::isa<fir::ReferenceType>(sourceVar.getType()) &&
450450
mlir::isa<fir::BoxCharType>(assocType)) {
451+
mlir::Value lenVal = associate.getTypeparams()[0];
451452
auto refTy = mlir::cast<fir::ReferenceType>(sourceVar.getType());
452453
auto charTy = mlir::dyn_cast<fir::CharacterType>(refTy.getEleTy());
453-
mlir::Value lenVal = builder.createIntegerConstant(
454-
loc, builder.getCharacterLengthType(), charTy.getLen());
455454
auto boxCharType =
456455
fir::BoxCharType::get(builder.getContext(), charTy.getFKind());
457456
sourceVar = builder.create<fir::EmboxCharOp>(loc, boxCharType,

flang/test/Lower/adjustr.f90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
! RUN: bbc -emit-fir -o - %s | FileCheck %s
1+
! RUN: %flang_fc1 -emit-fir -o - %s | FileCheck %s
22

33
! Checking no reference to boxchar conversion is in the emitted fir.
44
! CHECK-NOT: (!fir.ref<!fir.char<1,4>>) -> !fir.boxchar<1>
5+
! CHECK: %[[Const4:.*]] = arith.constant 4 : index
6+
! CHECK: fir.emboxchar
57

68
program main
79
logical ,dimension(1):: mask = .true.

0 commit comments

Comments
 (0)