[Flang] Incorrect diagnose on procedure pointer dummy with corresponding actual being a function that returns a procedure pointer
Consider the following code.
PROGRAM main
INTERFACE
integer FUNCTION IntF(Arg)
integer, INTENT(IN) :: Arg
END FUNCTION
END INTERFACE
PROCEDURE(IntF) :: ExtFun
CALL IntSub(IntFun1(ExtFun))
CONTAINS
FUNCTION IntFun1(Proc)
PROCEDURE(IntF) :: Proc
PROCEDURE(IntF), POINTER :: IntFun1
IntFun1 => Proc
END FUNCTION
SUBROUTINE IntSub(ProcPtr0)
PROCEDURE(IntF), POINTER :: ProcPtr0
END SUBROUTINE
END
Flang currently issues an error as:
error: Actual argument associated with procedure pointer dummy argument 'procptr0=' must be a pointer unless INTENT(IN)
CALL IntSub( IntFun1(ExtFun))
^^^^^^^^^^^^^^^
It seems the diagnose here is incorrect. The code is conforming and should be compiled successfully.
@llvm/issue-subscribers-flang-frontend
Author: Daniel Chen (DanielCChen)
CALL IntSub(IntFun1(ExtFun))
CONTAINS
FUNCTION IntFun1(Proc) PROCEDURE(IntF) :: Proc PROCEDURE(IntF), POINTER :: IntFun1 IntFun1 => Proc END FUNCTION
SUBROUTINE IntSub(ProcPtr0) PROCEDURE(IntF), POINTER :: ProcPtr0 END SUBROUTINE
END
Flang currently issues an error as:
error: Actual argument associated with procedure pointer dummy argument 'procptr0=' must be a pointer unless INTENT(IN) CALL IntSub( IntFun1(ExtFun)) ^^^^^^^^^^^^^^^
It seems the diagnose here is incorrect. The code is conforming and should be compiled successfully.
</details>
@llvm/issue-subscribers-bug
Author: Daniel Chen (DanielCChen)
CALL IntSub(IntFun1(ExtFun))
CONTAINS
FUNCTION IntFun1(Proc) PROCEDURE(IntF) :: Proc PROCEDURE(IntF), POINTER :: IntFun1 IntFun1 => Proc END FUNCTION
SUBROUTINE IntSub(ProcPtr0) PROCEDURE(IntF), POINTER :: ProcPtr0 END SUBROUTINE
END
Flang currently issues an error as:
error: Actual argument associated with procedure pointer dummy argument 'procptr0=' must be a pointer unless INTENT(IN) CALL IntSub( IntFun1(ExtFun)) ^^^^^^^^^^^^^^^
It seems the diagnose here is incorrect. The code is conforming and should be compiled successfully.
</details>
Discussed with @klausler and I agreed that Flang's current behavior is correct.