<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/119151>119151</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Compilation error when a subroutine described in generic procedure interface is referred to by generic name
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
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:
```fortran
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)
$
```


</pre>
<img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