A disassociated procedure pointer is allowed to be passed as an absent
actual argument that corresponds to an optional dummy procedure,
but not NULL(); accept that case as well.
Differential Revision: https://reviews.llvm.org/D125127
dummyName);
}
} else if (IsNullPointer(*expr)) {
- if (!dummyIsPointer) {
+ if (!dummyIsPointer &&
+ !dummy.attrs.test(
+ characteristics::DummyProcedure::Attr::Optional)) {
messages.Say(
"Actual argument associated with procedure %s is a null pointer"_err_en_US,
dummyName);
!ERROR: A dummy procedure may not be ELEMENTAL
procedure(elem) :: dummy
end subroutine
+ subroutine optionalsubr(dummy)
+ procedure(sin), optional :: dummy
+ end subroutine
+ subroutine ptrsubr(dummy)
+ procedure(sin), pointer, intent(in) :: dummy
+ end subroutine
end interface
intrinsic :: cos
call subr(cos) ! not an error
call subr(elem) ! C1533
!ERROR: Actual argument associated with procedure dummy argument 'dummy=' is a null pointer
call subr(null())
+ call optionalsubr(null()) ! ok
+ call ptrsubr(null()) ! ok
!ERROR: Actual argument associated with procedure dummy argument 'dummy=' is typeless
call subr(B"1010")
end subroutine