[flang-commits] [flang] [flang][hlfir] address char_convert issues as mentioned in #64315 (PR #67570)

Anthony Cabrera via flang-commits flang-commits at lists.llvm.org
Wed Oct 4 09:08:59 PDT 2023


================
@@ -1435,8 +1434,12 @@ struct UnaryOp<
       // allocate space on the stack for toBuffer
       auto dest = builder.create<fir::AllocaOp>(loc, toTy,
                                                 mlir::ValueRange{bufferSize});
-      builder.create<fir::CharConvertOp>(loc, lhs.getFirBase(), origBufferSize,
-                                         dest);
+      auto src = hlfir::convertToAddress(loc, builder, lhs,
+                                         lhs.getFortranElementType());
+      builder.create<fir::CharConvertOp>(loc, src.first.getCharBox()->getAddr(),
+                                         origBufferSize, dest);
+      if (src.second.has_value())
+        src.second.value();
----------------
cabreraam wrote:

Yep, you are correct. I didn't actually call the `hlfir::cleanupFunction`.  I added another set of parens so now it's 
```cpp
src.second.value()()
```

I added your concat test and verified that `hlfir.end_associate` is called

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


More information about the flang-commits mailing list