File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
flang/lib/Optimizer/HLFIR/Transforms Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -446,8 +446,17 @@ struct AssociateOpConversion
446446 ((mlir::isa<fir::BoxCharType>(sourceVar.getType ()) &&
447447 !mlir::isa<fir::BoxCharType>(assocType)))) {
448448 sourceVar = builder.create <fir::BoxAddrOp>(loc, assocType, sourceVar);
449- } else if (!mlir::isa<fir::ReferenceType>(sourceVar.getType ()) ||
450- !mlir::isa<fir::BoxCharType>(assocType)) {
449+ } else if (mlir::isa<fir::ReferenceType>(sourceVar.getType ()) &&
450+ mlir::isa<fir::BoxCharType>(assocType)) {
451+ auto refTy = mlir::cast<fir::ReferenceType>(sourceVar.getType ());
452+ auto charTy = mlir::dyn_cast<fir::CharacterType>(refTy.getEleTy ());
453+ mlir::Value lenVal = builder.createIntegerConstant (
454+ loc, builder.getCharacterLengthType (), charTy.getLen ());
455+ auto boxCharType =
456+ fir::BoxCharType::get (builder.getContext (), charTy.getFKind ());
457+ sourceVar = builder.create <fir::EmboxCharOp>(loc, boxCharType,
458+ sourceVar, lenVal);
459+ } else {
451460 sourceVar = builder.createConvert (loc, assocType, sourceVar);
452461 }
453462 return sourceVar;
You can’t perform that action at this time.
0 commit comments