Consider the following code
module m
type Base
integer i
end type
type, extends(Base) :: Child
integer j
end type
interface printMe
subroutine printBase(b)
import Base
type(Base), pointer :: b
end subroutine
subroutine printChild(c)
import Child
type(Child), allocatable :: c
end subroutine
end interface printMe
end module
program generic002
use m
type(Base), pointer :: b1
type(Child), allocatable :: c1
allocate(b1, SOURCE=Base(10))
allocate(c1, SOURCE=Child(8, 9))
call printMe(null(b1))
call printMe(null(c1))
end
Flang currently issues an error as:
error: Semantic errors in t.f
./t.f:32:5: error: No specific subroutine of generic 'printme' matches the actual arguments
call printMe(null(c1))
^^^^^^^^^^^^^^^^^^^^^^
The code seems valid as null(c1) should have a allocatable result of the same type as c1.