[flang-commits] [flang] [flang] Use the namelist item descriptor if it is local polymorphic entity. (PR #162701)

via flang-commits flang-commits at lists.llvm.org
Thu Oct 9 10:55:56 PDT 2025


https://github.com/jeanPerier requested changes to this pull request.

Thanks for working on this!

```
! CHECK: %[[V_14:[0-9]+]] = fir.convert %[[V_13]] : (!fir.class<!fir.heap<!fir.type<_QMmTbase{r1:f32}>>>) -> !fir.ref<!fir.box<none>>
```

That is a very suspicious cast that only happens to work because of the current fir.box codegen. I'll need to check why this is allowed.

I would rather not rely on this. The fix I think is to update the: `fir::BoxType boxType = fir::BoxType::get(fir::PointerType::get(type));` to something like `fir::BaseBoxType boxType = mlir::isa<fir::ClassType>(type) ?  fir::ClassType::get(fir::PointerType::get(type)) : fir::BoxType::get(fir::PointerType::get(type));` (this is not correct C++, just to illustrate).

The point is that the created temporary pointer should be a polymorphic pointer so that is correctly associated.

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


More information about the flang-commits mailing list