<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/107400>107400</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang][Semantics] Flang reports misleading errors if it is unable to open a `use`d module
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
inaki-amatria
</td>
</tr>
</table>
<pre>
- `flang-new` version is: `flang-new version 20.0.0git (https://github.com/llvm/llvm-project.git 1254259e325428c5912843aa94f6fc663a40ea1b)`
- Reduced test case is:
```fortran
! foo.f90
module bar
contains
subroutine doBar(x)
logical, intent(in) :: x
end subroutine doBar
end module bar
module foo
use bar
use baz, only : bazVar
contains
subroutine doFoo()
call doBar(bazVar)
end subroutine doFoo
end module foo
```
- `flang-new` invocation is: `flang-new foo.f90`
- Expected behavior is: Flang should only report the following error: `error: Cannot read module file for module 'baz': Source file 'baz.mod' was not found`.
- Actual behavior: Flang does not stop Semantics after failing to open module `baz.mod` and therefore reports misleading errors. Although this is a reduced test case, in the original example, hundreds of error lines were generated, misleading us into believing Flang was encountering semantic errors. The real issue was simply an incorrectly set module directory.
```txt
error: Semantic errors in foo.f90
/app/example.f90:10:7: error: Cannot read module file for module 'baz': Source file 'baz.mod' was not found
use baz, only : bazVar
^^^
/app/example.f90:13:16: error: Actual argument type 'REAL(4)' is not compatible with dummy argument type 'LOGICAL(4)'
call doBar(bazVar)
^^^^^^
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VcuO47YS_Rp6U2iBoh6WF154ptsXFxggwHSQfUksSUwoUiApdztfH1CW7LYbk0kWMQTJZL3OqQeJ3qvOEO1Z8YUVzxucQm_dXhn8Qz3hgMEp3NRWnvdPwEreajTdk6E3VnI4kfPKGlCeZYc76VUkeMIT3qkATFR9CGNUZeLIxLFToZ_qpLEDE0etT-vnaXT2d2pCEq1SUeSi2FEWv1V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