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

    <tr>
        <th>Summary</th>
        <td>
            [flang][openmp] Bad code for index variable used in "shared" clause
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          psteinfeld
      </td>
    </tr>
</table>

<pre>
    Here's a reproducer:
```
program bug
  implicit none
  integer :: i, j
  i = 0
  j = 0
  !$omp parallel shared(i)
    !$omp sections
      do i=1,10
        j = j + i
      end do
    !$omp end sections
  !$omp end parallel
  print *, "i: ", i
  if ( i==11 ) then
    print *,'ok'
  else
    print *,'fail, i: ', i
  end if
end program
```
When I compile this program with the `-fopenmp` option and execute it, I get the output:
```
 i:  0
 fail, i: 0
```
When similarly compiled with gfortran and executed, I get:
```
 ok
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0lNFuqzAMhp_G3FirgoFSLrhoV1VnT3CuAzGQLhCUhJ3t7Y-gpWunVapUOb-T_3PsIL3X7cBcQnaA7BjJKXTWlaMPrIeGjYoqq77KP-wYKPco0fHorJpqdpDsQRxB7GErrr8lHJ1tneyxmtrLAqLuR6NrHXCwA98Wh8AtO5zPSfaogV7xfBMRkiOKNTw_hkAxUGr7EUfppDFs0HfSsQLaaaBizbvP9FwHbQf_rSEqixqSYwz0Got7YXU8I9AB9b3Eg0Jlf3OYlZ8uj-pKu6qj00NAoP1cOxDp-SKAaA5vprpBoN0COrPGCFRg6Hj4Zrg_Byi370D5qrLx_DSzkdpczBbj_MF4JtbNJVroL439tel_Ox7wDWvbj9owhk77NR__6dDNwAhb8dLYkYd-hK1AO85XhXJQyJ9cT4FRh5ngDVsOyw47hXEKzybtgn0bi4dixHNMr3ttpDNfK666ILaNdcHJByJ143kKYd9_rEeqTFSRFDLiMs4pSQux3WVRVzZ5Jpo04d1WNsWW0yIvUpHzLi9kVe3SONIlCUrFLqa4oDTNNpwUBWVSJplKY8EFpIJ7qc3GmI9-Y10bae8nLmNBxTaOjKzY-OUxEzVGDu08TNkxcuW84aWaWg-pMNoH_31E0MEsX4DLjuwI2eHapeyIB6mwtoqxsQ71oPgTP6TTsjKMk2eFephHdn1_hLWRk-docqbsQhj9fHF0Ajq1OnRTtaltD3Sa3a9_L6OzZ64D0GmpxgOdrgV9lPQ_AAD__xW5T_I">