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

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Compilation error when proc-decl is defined using sub for proc-pointer-init in recursive subroutine
        </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-new : 20.0.0(7111d031f19ce7d523796b4812d6afcb2958b025)/AArch64
```

When `proc-decl` is defined using `sub` for `proc-pointer-init` in `recursive subroutine (sub)`, a compilation error occurs.

The following are the test program, Flang-new, Gfortran and ifx compilation/execution result.

snf_pointer_ivl_007_2.f90:
```fortran
recursive subroutine sub()
  procedure(sub),pointer :: p=>sub
  p=>sub
end subroutine sub

program main
  print *,'pass'
end program main
```

```
$ flang-new snf_pointer_ivl_007_2.f90
error: Semantic errors in snf_pointer_ivl_007_2.f90
./snf_pointer_ivl_007_2.f90:2:29: error: Procedure pointer 'p' initializer 'sub' is neither an external nor a module procedure
    procedure(sub),pointer :: p=>sub
 ^
$
```

```
$ gfortran snf_pointer_ivl_007_2.f90; ./a.out
 pass
$
```

```
$ ifx snf_pointer_ivl_007_2.f90; ./a.out
 pass
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVE1v7CYU_TV4g8aCa_y18GJe8txtpVbtMsL4eswTAxbgJO2vr_A4k-kkfVWfKs2HjLn3cM65HBmCPlnEjpRfSPmYyTXOzndutu4wfcsGN_7RkYrtH_ZI2PE39EE7S91EJyPt6WDxhZLiSIHlLGcEmppzPrKCT7xVWI8lFHVbDaLhMFZyUgO0ZTMwKAm0BPrj0au5Epfmd1iX399ntJRUbPFOHUZUhlSM6kBHnLTFka5B21PaENYhvZqcv25fnLYR_UFbHbeyrZNHtfqgn5GGdfBujdoiJdCkBtAmeHigkip3XrSRMdFF752nTqXC_PZ0v85IJ2eMe0mnkB5pnJFGDJEu3p28PKdm_ZtU6eGnyfnopaXSjlRPr7dABHp8RbVuoB7DauLf4IKdnnZST_rZPDFWP0E-tYwUxzsNd5TL6qeUN75NorztoenECsfV47sY8LDDJZOTzwspHknxNb1-q7pbQTveo9ww2FWhZ6ntO662kRI4EnggUC8yBAL1e7ePNZ9Oyv0iiJsZ_WflLjDJ4MTvFzxLG7W6WB7SyPxLaU6g_54vkL5t6n0F-flNaHpVF-qFQE3TpGpp9J-Xtc2FOo27RR1n9FRaiq8RvZWGWueppGc3rgZvzNtV_UE_Sfn1qt9_E_v0NtjfUeMLTXLJ3K1xx9vc_jHAdHn-Z6xs7IqxLVqZYcfrgjdtIRqRzV0jygL5iGXDsFasVA20gxS8UgMXRYWZ7oCB4Jw3jBccRK6gaCYhJgF8EpUYiGB4ltrkxjyfc-dPmQ5hxY7zqqyqzMgBTdiiGGCbW1IcJ-9sRDsSgBTQvku1h2E9BSKY0SGG925RR7NF-ZY2pHykDx8S7CWF6TVJP8ZoWIctQD-kZ7oHn4VItnrTzTEuIc0T9AT6k47zOuTKnQn06XT732Hx7huqSKDfiAcC_c79uYO_AgAA__-LLvkg">