[flang-commits] [flang] [FLANG] Solving issue with adjustr intrinsic in where construct (PR #146851)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Fri Jul 11 08:18:40 PDT 2025


================
@@ -446,6 +446,16 @@ struct AssociateOpConversion
             ((mlir::isa<fir::BoxCharType>(sourceVar.getType()) &&
               !mlir::isa<fir::BoxCharType>(assocType)))) {
           sourceVar = builder.create<fir::BoxAddrOp>(loc, assocType, sourceVar);
+        } else if (mlir::isa<fir::ReferenceType>(sourceVar.getType()) &&
+                   mlir::isa<fir::BoxCharType>(assocType)) {
+          auto refTy = mlir::cast<fir::ReferenceType>(sourceVar.getType());
+          auto charTy = mlir::dyn_cast<fir::CharacterType>(refTy.getEleTy());
----------------
vzakhari wrote:

Thanks for the update!

This will only work for the types with constant length.  I do not know if we should be here for non-constant lengths, but I would just take the type parameters from the `associate` operation - this should work for all the cases.

https://github.com/llvm/llvm-project/pull/146851


More information about the flang-commits mailing list