[flang-commits] [flang] Get the BoxType from the RHS instead of LHS for polymorphic pointer assignment inside FORALL. (PR #164279)
Daniel Chen via flang-commits
flang-commits at lists.llvm.org
Tue Oct 21 13:14:04 PDT 2025
================
@@ -4730,13 +4730,14 @@ class FirConverter : public Fortran::lower::AbstractConverter {
if (Fortran::evaluate::UnwrapExpr<Fortran::evaluate::NullPointer>(
assign.rhs))
return fir::factory::createUnallocatedBox(*builder, loc, lhsBoxType, {});
- hlfir::Entity rhs = Fortran::lower::convertExprToHLFIR(
- loc, *this, assign.rhs, localSymbols, rhsContext);
+ hlfir::Entity rhs{fir::getBase(genExprBox(loc, assign.rhs, rhsContext))};
+ auto rhsBoxType =
+ llvm::cast<fir::BaseBoxType>(fir::unwrapRefType(rhs.getType()));
----------------
DanielCChen wrote:
Sorr that I mis-spoke the error.
I indeed have the correct BoxType for `rhsBoxType` as `!fir.box<!fir.char<1>>`. I also got `rhsBox` as
```
%189 = "fir.embox"(%188) <{operandSegmentSizes = array<i32: 1, 0, 0, 0, 0>}> : (!fir.ref<!fir.char<1>>) -> !fir.box<!fir.ptr<!fir.char<1>>>
```
However, `fir.convert` now complains
```
error: 'fir.convert' op invalid type conversion'!fir.box<!fir.ptr<!fir.char<1>>>' / '!fir.class<!fir.ptr<none>>'
error: Lowering to LLVM IR failed
```
https://github.com/llvm/llvm-project/pull/164279
More information about the flang-commits
mailing list