Skip to content

[Flang] Incorrect diagnostic on NULL(allocatable) as actual argument for generic resolution #125928

@DanielCChen

Description

@DanielCChen

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.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions