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

    <tr>
        <th>Summary</th>
        <td>
            [Flang] The variable outputted in the compilation error message is invalid
        </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 : 21.0.0(7500cead4e000d82d62f99f2896ffa94ee08ff7e)/AArch64
```

In the attached program, the second and third compilation messages are outputted with `%s` instead of `variable (i)`.

The following are the test program and Flang compilation result.

snfm_import_err02_2.f90:
```fortran
program main
  call test01()
  print *,"pass"
end program main

module mod1
  integer :: i
end module mod1

module mod2
  real    :: i
end module mod2

subroutine test01()
  use mod2
  use mod1
  interface
 subroutine subb()
       use mod1
       import i
     end subroutine subb
  end interface
end subroutine test01
```

```
$ flang snfm_import_err02_2.f90
error: Semantic errors in snfm_import_err02_2.f90
./snfm_import_err02_2.f90:20:15: error: A distinct 'i' is already present in this scope
         import i
 ^
./snfm_import_err02_2.f90:7:14: Previous declaration of '%s'
    integer :: i
               ^
./snfm_import_err02_2.f90:11:14: Declaration of '%s' in host scope
    real    :: i
               ^
$
```

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVF2P6yYQ_TX4BW2EJ_588IN7t5H6VqlVX1cYBpsrDBbgXN1_X8F6d5P9aC-KEg1hzjkzDIeHoGeLOJD6N1I_FnyPi_ODW6x7UN-LycmfA2nY8WHjP-iDdpY6RZXhdqbkPFIoT-zECHRtzZhALitkjMkOZAOq7xV0faMU7ytE1inVIoGewGUcvViairDxloGw8Q9L44KUx8jFgpJu3s2erwS-5f2AwllJuZU0LtpLKty6acNjErZiCHzGQLlH6va47TGipD90XGgigDqQhlFtQ0QuUx2kYVfuNZ8MUgKdTuIadnqW8veCVDlj3A9t54yZFEQM8UVV1nHJvbjV4THsJh4owar1Sa-b8_EJvWfwBCfVM3Ieb4tXzkfPLWHjC_TKdQopFdyYzMpKAl1SmHY3r22kBEYC3wjAxkMgAISNaF-b9oJB2Lg6uRukq5NlTtc24ow-XWG6RX0k3h-7y4Oc55EbSunXeXBUvU_e7VFb_Ch9DzeAR_CmyisuMEU3EGGfphuAvO4S83puctaU4yTsPUj6K-3fMr07d-j9MJl3IVTHG_jqetmI3jufmvQXrtxGLWjeCVTb_8g6Ebh8PTKQvso6ob7Cj1TqELUVaRxaTaClOlBuPHL5k24eA9qYSOOiAw3CbfjWs_uukfr3_5XQJgVVIv7T41W7PVCJwnD_PPvpUUGbnxq0B88nw0bv168Ql-Ur8-NXhKnMxYV4V-YnM_spPYH3flTI4Sz7c88LHMq2apuybMu-WIapA845ltBwNZWCNT2qSfYCz1U5lVIWegAGNavLDs5VWfcnLjoxKclbUau-a0tSMVy5NidjruvJ-bnQIew4lBWrurowfEITsjMD5Ekj51F5ZyNamR56_Vj4IeU-TPscSMWMDjG8oUUdTXb2bE-kfqTJzl7N7s0d9bPh3vpXHq0XN03DpO2VGy2L3ZthiXELqZVwIXCZdVz26STcSuCSyI-fh8277ygigUuuKxC4HKVdB_g3AAD__5pB-ug">