[flang] Don't emit spurious error for polymorphic actual argument in PURE
authorPeter Klausler <pklausler@nvidia.com>
Wed, 2 Nov 2022 18:11:23 +0000 (11:11 -0700)
committerPeter Klausler <pklausler@nvidia.com>
Fri, 2 Dec 2022 21:17:06 +0000 (13:17 -0800)
commit7efec1a40a9a0b7dd43cb4dbbd3b1285741d240b
treeeffd2f0a8aaacef947b84b8070e58f0de1aa65f0
parent745f6fcd2ba0dc624d9033679f5454a0a41ecd5b
[flang] Don't emit spurious error for polymorphic actual argument in PURE

Definability checking is unconditionally flagging the use of a polymorphic
variable as an actual argument for a procedure reference in a PURE subprogram
unless the corresponding dummy is INTENT(IN).  This isn't necessary, since
an INTENT(OUT) polymorphic dummy is already caught as an error in the definition
of the callee, which must also be PURE; and an INTENT(IN OUT) or intent-free
dummy is allowed to be passed a polymorphic actual in a PURE context, with
any attempt to deallocate it being caught in the callee.

So add a flag to the definability checker to disable the "polymorphic
definition in PURE context" check when using it to check actual arguments.

Differential Revision: https://reviews.llvm.org/D139044
flang/lib/Semantics/check-call.cpp
flang/lib/Semantics/definable.cpp
flang/lib/Semantics/definable.h
flang/test/Semantics/call28.f90 [new file with mode: 0644]