Hi, everyone. There is a problem a I'm not quite understand about optional dummy argument. Here is the code:
MODULE Test IMPLICIT NONE TYPE :: MyType INTEGER :: a CONTAINS GENERIC, PUBLIC :: Set => SetBy2Arguments,& SetBy3Arguments PROCEDURE, PASS :: SetBy2Arguments PROCEDURE, PASS :: SetBy3Arguments END TYPE MyType CONTAINS FUNCTION SetBy2Arguments(this, arg1, arg2) IMPLICIT NONE INTEGER :: SetBy2Arguments CLASS(MyType), INTENT(IN) :: this INTEGER, INTENT(IN) :: arg1 INTEGER, INTENT(IN) :: arg2 SetBy2Arguments = this%a + arg1 + arg2 RETURN END FUNCTION SetBy2Arguments FUNCTION SetBy3Arguments(this, arg1, arg2, arg3) IMPLICIT NONE INTEGER :: SetBy3Arguments CLASS(MyType), INTENT(IN) :: this INTEGER, INTENT(IN) :: arg1 INTEGER, INTENT(IN) :: arg2 INTEGER, OPTIONAL, INTENT(IN) :: arg3 SetBy3Arguments = this%a + arg1 + arg2 + arg3 RETURN END FUNCTION SetBy3Arguments END MODULE Test
When compiling, The compiler generates a warning message saying that:
warning #8449: The type/rank/keyword signature for this specific procedure matches another specific procedure that shares the same generic binding name. [SETBY3ARGUMENTS]
So why are these 2 binding procedures matches each other ? And How is the compiler treat a dummy argument that has an OPTIONAL attribute ? Appriciate any replies, thanks.