[flang-commits] [flang] [flang] Fix lowering of unused dummy procedure pointers (PR #155649)
Daniel Chen via flang-commits
flang-commits at lists.llvm.org
Wed Aug 27 11:57:52 PDT 2025
DanielCChen wrote:
```
MODULE M0
TYPE :: Base
CHARACTER(3) :: C
END TYPE
END MODULE
MODULE M
USE M0
TYPE, EXTENDS(Base) :: DT
PROCEDURE(IFun), NOPASS, POINTER :: ProcPtr
CONTAINS
PROCEDURE, NOPASS :: Proc=>ModFun
END TYPE
CONTAINS
FUNCTION ModFun(Arg)
TYPE(DT), INTENT(IN) :: Arg
TYPE(DT) :: ModFun
ModFun = Arg
END FUNCTION
FUNCTION IFun(Arg)
TYPE(DT), INTENT(IN) :: Arg
TYPE(DT) :: IFun
IFun = Arg
END FUNCTION
END MODULE
FUNCTION ExtFun(Arg)
USE M
TYPE(DT), INTENT(IN) :: Arg
TYPE(DT) :: ExtFun
ExtFun = Arg
END FUNCTION
PROGRAM Arg5
USE M
IMPLICIT NONE
PROCEDURE(IFun) :: ExtFun
PROCEDURE(IFun), POINTER :: ProcPtr
INTERFACE
FUNCTION IFun1(Arg)
IMPORT DT
TYPE(DT), INTENT(IN) :: Arg
TYPE(DT) :: IFun1
END FUNCTION
END INTERFACE
ProcPtr => ExtFun
CALL IntSub( ProcPtr, ProcPtr)
CONTAINS
SUBROUTINE IntSub(ProcPtr0, ProcPtr1)
IMPLICIT TYPE(DT)(P)
PROCEDURE(IFun1), POINTER :: ProcPtr0
PROCEDURE(TYPE(DT)), POINTER :: ProcPtr1
TYPE(DT) :: V
V = ProcPtr0(DT("321", ProcPtr0))
IF (V%C .NE. "321") STOP 21
IF ( .NOT. ASSOCIATED(V%ProcPtr, ProcPtr) ) STOP 22
V = ProcPtr1(DT("121", ExtFun))
IF (V%C .NE. "121") STOP 31
IF ( .NOT. ASSOCIATED(V%ProcPtr, ExtFun) ) STOP 32
END SUBROUTINE
END
```
https://github.com/llvm/llvm-project/pull/155649
More information about the flang-commits
mailing list