<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/83622>83622</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Incorrect diagnose when referencing an implicitly typed procedure pointer within a module
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
flang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DanielCChen
</td>
</tr>
</table>
<pre>
Consider the following code:
```
MODULE M
IMPLICIT INTEGER(P)
PROCEDURE(), POINTER :: ProcPtr
CONTAINS
FUNCTION F()
INTEGER F
END FUNCTION
SUBROUTINE S()
ProcPtr => F
IF ( ProcPtr() .NE. 1 ) ERROR STOP 11
END SUBROUTINE
END
```
Flang currently issues an error:
```
./t.f:14:10: error: Cannot call subroutine 'procptr' like a function
IF ( ProcPtr() .NE. 1 ) ERROR STOP 11
^^^^^^^
./t.f:14:10: Declaration of 'procptr'
IF ( ProcPtr() .NE. 1 ) ERROR STOP 11
^^^^^^^
```
The code seems confirming to me. `ProcPtr` is implicitly typed to integer and pointer assignment to an integer function and referenced as a function.
If I put these code in a program unit instead of a module. It seems compiles pass the error.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVNuOozgU_BrzcjQIDHSSBx4yXFZI0yRKJx_gwAG8a2xkm231369MEnrSe3nYiRDBUD6uU-UyM4b3EjElyXeS5B6b7aB0mjPJUWTZgNK7qvYjzZQ0vEUNdkDolBDqncseGtUiifYkyEmwJy_B_VqGAK-H_PKjgNfHuHo9_qiy6gxVfS5-K06Ebo-E7u6zb6Dj6ZAV-eVUELp132gGx4PDn8AtFO3hqFVztPppFmSH-ryv6rfnt-Wlzs7VoYbyXu32_r48lA9cUecr9rnC2-X76XA5V3UBb081AB5EgEQ5iYq1WlUCoduV5jIJ_LrwIQT3WJxOhxO8nQ9HCMOfGXyu9cyhqPP7498UXhsVzLkxa43Sig_gxsxogElArZVeLYKvJXxCS-t3JNqHsbsFTuHHHMiYlMpCw4QAM1-1mi2XCIRuJq2ayXW3AcH_QGDQzbKxXMlPfeD_SbH-SFL8w_XvtHNsBNPMkQDVPbP8VVb_weWLorf7ecAlHGAQRwONkh3Xo4uMVTCi73x4EHgJgBvg4yR4w5179mPC1gG5tNijBiZbmJQbabgldkRpHYLJFfQwYEFr7FCjbLAFZn5yx7_RqzqoYJqti7O5M-USGExa9ZqNMEtugUtjkbVOTAajameBPlR27WmcuEADEzNmOReWfeN7bRq1u2jHPEzDTbCL6CbZUW9Im_CFNmyTJEG43V5ZHLXXOAgx2WKUhHEcezylAY2DKAhpGEYh9bsoaF9i3NDdJtnhdkfiAEfGhS_En6OvdO8tGz3dRi-UeoJdUZjlJKP0OveEUkIzQmnn0kGifaeVtChb9yHJPZ26Mt-uc29IHAhurPksbLkVy6m4RIskOVSyUVpjY6HlrJfKILwPKFepnbnOjq8-uk2I7axxtfCd22FR-6apN2uRDtZOxuWUloSWPbfDfPUbNRJaOk73v2-TVr9jYwktbxEntFya_ysAAP__dWysEg">