Skip to content

[Flang] Compilation error when a subroutine described in generic procedure interface is referred to by generic name #119151

@ohno-fj

Description

@ohno-fj
Version of flang : 20.0.0(9becc4a3c966d46b95ddfcf856b3c433c030db1e)/AArch64

In generic procedure interface, interface block is defined by generic name (sub) and specific names (sub1 and sub2) are described in it.
The two subroutines (sub1 and sub2) can be referred to not only by their specific names (sub1 and sub2) but also by their generic names (sub).
However, specifying generic name (sub) in call statement to refer to specific name (sub2) results in a compilation error.

The following are the test program, Flang, Gfortran and ifx compilation result.

snfmm001_22.f90:

subroutine test02()
  interface sub
     subroutine sub1(ifun,ians)
       integer ians
       interface
          integer function ifun()
          end function ifun
       end interface
     end subroutine sub1
     subroutine sub2(rfun,ians)
       integer ians
       real rfun
       external rfun
     end subroutine sub2
  end interface sub
  integer ians
  real rfun
  external rfun
  call sub(rfun,ians)
end subroutine test02
$ flang snfmm001_22.f90 -c
error: Semantic errors in snfmm001_22.f90
./snfmm001_22.f90:19:3: error: The actual arguments to the generic procedure 'sub' matched multiple specific procedures, perhaps due to use of NULL() without MOLD= or an actual procedure with an implicit interface
    call sub(rfun,ians)
    ^^^^^^^^^^^^^^^^^^^
$
$ gfortran snfmm001_22.f90 -c
$
$ ifx snfmm001_22.f90 -c
snfmm001_22.f90(10): error #5286: Ambiguous generic interface SUB: previously declared specific procedure SUB1 is not distinguishable from this declaration. [SUB2]
     subroutine sub2(rfun,ians)
----------------^
compilation aborted for snfmm001_22.f90 (code 1)
$

Metadata

Metadata

Assignees

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions