[flang] Deal with NULL() passed as actual arg to unlimited polymorphic dummy
authorValentin Clement <clementval@gmail.com>
Mon, 23 Jan 2023 08:44:12 +0000 (09:44 +0100)
committerValentin Clement <clementval@gmail.com>
Mon, 23 Jan 2023 08:49:59 +0000 (09:49 +0100)
commit262dad4a8133c2befd6dae4cef5cee5b602f85cb
tree27cd2ac204932572fcb0dcf4ac0dbc3481ca5b41
parent4dbf3f2e8e72472161223d084c5646b76cc41d63
[flang] Deal with NULL() passed as actual arg to unlimited polymorphic dummy

NULL() passed as actual argument to a procedure with an optional
dummy argument is represented with `fir.box<none>` type. When the dummy
argument is polymoprhic or unlimited polymorphic, the SelectOp will complain
if the types of the two arguments are not identical. Add a conversion from
`fir.box<none>` to `fir.class<none>` in that case.
Other situations with optional will require a fir.rebox and will be done in
a follow up patch.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D142203
flang/include/flang/Optimizer/Dialect/FIRType.h
flang/lib/Lower/ConvertExpr.cpp
flang/lib/Optimizer/Dialect/FIRType.cpp
flang/test/Lower/polymorphic.f90