<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55240>55240</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
flang bug in scopes of used modules
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zerothi
</td>
</tr>
</table>
<pre>
A bug in how the resolution of interfaced subroutines is present in 11, 12 and 13 (14 untested).
The code that shows this error is:
```fortran
module m1
interface a
module procedure k
end interface
contains
subroutine k(i)
integer, intent(in) :: i
write(*,*) i
end subroutine k
end module m1
module m2
interface a
module procedure z
end interface
contains
subroutine z(x)
real, intent(in) :: x
write(*,*) x
end subroutine z
end module m2
module m3
use m1
contains
subroutine s
use m2
integer :: j=1
call a(j)
end subroutine s
end module m3
```
Since module `m3` uses both `m1` and `m2` albeit in different scopes they should still resolve uniquely and hence be valid.
However, all the mentioned llvm versions reports this as an error:
```
~ % ml llvm/11.1.0
~ % flang -c m.f90
m.f90:29:5: error: No specific procedure of generic 'a' matches the actual arguments
call a(j)
^^^^^^^^^
/opt/generic/llvm/11.1.0/bin/f18: semantic errors in m.f90
~ % ml switch llvm/12.0.1
~ % flang -c m.f90
m.f90:29:5: error: No specific procedure of generic 'a' matches the actual arguments
call a(j)
^^^^^^^^^
/opt/generic/llvm/12.0.1/bin/f18: Semantic errors in m.f90
flang: in /home/nicpa, f18 failed with exit status 0: /opt/generic/llvm/12.0.1/bin/f18 -module-suffix .f18.mod -intrinsic-module-directory /opt/generic/llvm/12.0.1/include/flang -c m.f90
~ % ml switch llvm/13.0.0
~ % flang -c m.f90
./m.f90:29:5: error: No specific procedure of generic 'a' matches the actual arguments
call a(j)
^^^^^^^^^
error: Semantic errors in m.f90
flang: in /home/nicpa, flang-new failed with exit status 1: /opt/generic/llvm/13.0.0/bin/flang-new -fc1 -module-suffix .f18.mod -fdebug-unparse -fno-analyzed-objects-for-unparse -c m.f90
~ %
```
I believe this is a bug @jme52 FYI
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztV0uT2ygQ_jXypUsqCVl-HHRwMnFtLrlkL3tECFnMIvACGj9-fRpkW2PPOM_D7mxFpbIR3cD3QX_QVLo-lCuo-g0IBa3egWs5GG617J3QCnSDBsdNQxmvwfaV0WhQ3IKwsEVHrpxvmmUReQ8ZAapqyHKIyCKbQo9NreN1RJZJlD5E6Wr4_RMHYbrmOBp1YHFci0XskRujDXYd5SfPaJYOb6ONM1QNtZ2ue8mhy4ZPGDECPVcBnLy2RiP23nD4-2zjCPLSZKhkWjkqlD27jFSxGVkIpDD27NtuuPGUfVE576HQBTzwfAVi9N0Z4TjaI7JC__C7HO0eydVQod7X3nC8Jk5-jPjx54gfEfb-irjhVN5nvf8G6_0d1seXrMlrrPNz-96OE_MV_HbEE1qQFyt4Rv4Y5Q_ZaGVUSpxQsnh8xv4GtH0JOr-J2eccPguFi3TyRBs6z1IPy0KlXRuqMl_lBeQ_SPiQFRdBYLVoGm682izTW-71wg9eOr1EWE4g4CDbJ46qE__0XB5CVy3341YcnqgU9ZUK_9A7_jREsefrld_hACh7lLqUTx2g1eKnxa63qL-TSCm-apDqqNNXmc8_4EZQQCdDdxFZZ1mSJSm88eeaXSOp2kDMUHdJs3zr5E6K80xwcTH681XhFXJebvikwW45E41gz3YYPCc2XHGDlRGZo3Tm0FHH2iFQgTLXU5SU2fQ-xJ4J847YApTiw913WAGy1lvchdanobF0FWdYqPwGtW6yhYdueUcxvtlAxnpZDURvo9XuBGK_BC1J0iT795bkF5_f0fqfj9YQYLfR-vmr0RrWMaQaCjmsW93hcbtWgm2p39CxD2iokLiTYyy3wPd4jFhHXW_BTxX8CBqIh3Mrtn3TiD0kWJdgFcR4jBo8ewU7e9TCcOa0OXzPAHgkyr72uC9R-V16zLH9243c_78eE1ykt6HJC6ZfE5s3x4rv7kou-4bkQkSPkrv0Fzcsu6--puZ4c4t7taUG89u4U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