[flang] Add TODO for creation of polymorphic temporary
authorJean Perier <jperier@nvidia.com>
Mon, 3 Apr 2023 07:21:01 +0000 (09:21 +0200)
committerJean Perier <jperier@nvidia.com>
Mon, 3 Apr 2023 07:21:45 +0000 (09:21 +0200)
commit15da136f091939357f0178f360da74547aa6145a
treeabd97da82aec61d860ec35fe6ebb536fd653a328
parent04a920b76acf0a52a3eb957c6331ba81a1173e2a
[flang] Add TODO for creation of polymorphic temporary

The current code is wrong: it is doing an alloca with the declared
type instead of the dynamic type, leading to undefined behavior
when the dynamic type and declared type differ and the temporary
is later used.
This also introduces some `fir.alloca none` for unlimited polymorphic that
are not allocating the right thing at all.

Add TODOs for now, the correct thing to do will probably be to use the
runtime (like AssignTemporary), but since this happens in code doing
"mold" temp allocation, I first need to check if there is a need for "mold"
temporary creation not followed by an assign, or if this can be combined
with the assign instead (for HLFIR, it is pretty easy combine this from as_expr
codegen, not sure for the current lowering).

Differential Revision: https://reviews.llvm.org/D147333
flang/lib/Lower/ConvertExpr.cpp
flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp
flang/test/HLFIR/as_expr-codegen.fir
flang/test/Lower/polymorphic.f90