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

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Incorrect execution result when rename is specified for a variable in a module (rename and the variables in the module have the same name)
        </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 : 17.0.0(f6c8a8e9cb7d8b8abb382b52c88fb287a6f27a2b)
```

An variable defined in `MODULE` statement are declared with `rename`.
If one is the same name as a variable in the module and the other is an alias, the value of the variable with the same name is wrong.
When `USE` statements are written in different order, the result is correct.

- Before the change
```
  use mod,iii=>iii
  use mod,iiia=>iii
```

- After the change
```
  use mod,iiia=>iii
  use mod,iii=>iii
```

The following are the test program, results of Flang-new, Gfortran and ifort compilation and execution.


snfmod_37_3.f90:
```fortran
module mod
 integer :: iii=100
end module

program main
  use mod,iii=>iii
  use mod,iiia=>iii
  write(6,*) "iiia = ", iiia, " iii = ", iii
  if(100.ne.iiia) write(6,*) "NG2"
  if(100.ne.iii) write(6,*) "NG3"
  print *,"pass"
end program main
```

```
$ flang-new -flang-experimental-exec snfmod_37_3.f90; ./a.out
 iiia =  100  iii =  -2145384446
 NG3
 pass
$
```

```
$ gfortran snfmod_37_3.f90; ./a.out
 iiia = 100  iii =          100
 pass
$
```

```
$ ifort snfmod_37_3.f90; ./a.out
 iiia =          100  iii =          100
 pass
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVUuP4ygQ_jXkUoqFsWPjgw_pzmQ00j4Ou7N7HGFT2IxsiAB3Zv_9Cj_6kcmO1JpttRygnt9XBSW8151BrMnhgRxOOzGF3rra9sbu1dddY-U_NSno-k9PhB7_Que1NWAVqEGYbm_wCiQ7QlomNK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