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

    <tr>
        <th>Summary</th>
        <td>
            [flang][OpenMP][omp2012] Privatization failed due to existing binding while building omp2012
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    **Note**: This issue can be reproduced from the monorepo once the upstream from [fir-dev](https://github.com/flang-compiler/f18-llvm-project/tree/fir-dev) has matured

The following source dumps core with `flang-new -ffree-form -fopenmp -c -o rtc01.o rtc01.f`:

```
! FAIL: flang-new -ffree-form -fopenmp -c -o rtc01.o rtc01.f

PROGRAM rtc01
  INTEGER k
  INTEGER, PARAMETER :: limit=100
 
!$OMP PARALLEL DO PRIVATE(k)
                do k=2,limit
                enddo
!$OMP END PARALLEL DO
END PROGRAM
```

Core dumps as

```
flang-new: /home/amd/F18/f18-llvm-project/flang/lib/Lower/OpenMP.cpp:58: void createPrivateVarSyms(Fortran::lower::AbstractConverter&, const T*) [with T = Fortran::parser::OmpClause::Private]: Assertion `success && "Privatization failed due to existing binding"' failed.
```
[rtc01.log](https://github.com/llvm/llvm-project/files/8314921/rtc01.log)

Complete log is attached below. 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVNtu2zAM_RrnhUjga-o8-MFtkqJA2gRd0HdZlmOtsmVIcrLu60dJSW8oNnSBowtJH5KHpCtZvxRBXOLzIA3zpyApYd9yDVzrkQElPVQMFBuUrEfKamiU7MC0DDrZS5RLkD1lTjIO2ihGOm8TZNcNV9OaHYNsGcR5a8ygET6I1_gcuGnHakZlh5dGkP4wxfPABVNWEOVTIY7dFN3-ZNSgCJGZ1Zwh4wW0RENHzKhYHYTLICz9usdIGimEPPH-AFqOCsOrx27QQDFgOKFnCOahd9qzE0ybBsGnjVQdnuXA-m6AKYWpBGVoGM0ue4Ov2QzeebMS__hrHMG6vNtYGv_LwTvo3eP29rG89yovArh72K9uV4_w_EkQxDewK9F8tUetDRIjELzjJkiWUXgOD16jDOJ0e79zr2w2qw0st7B7vHsq9yss1TPSe8H_-Kslek6WMbrz4F9asb6u5WdXq4fle3de7YQ-z6_5dOuNrZsvIdF_Yf-VcZs8NksrO9szpKtxXUf5153l3sJd8ArXjTy5Ftxile53MzoMCJblFvEoeQ0UO9ywneJH3J6I-vHSaaRsLZVRpPfEC4fhjmWFM0GouZH9kSljoee2VlT22sDeDd3Czopryz1WbgkfsAai9AVs2w03goya-es5CDteGF2p0c5w2dvm1iOlTGtw3ua4xd6Y_ybOpCE4aTVyipMrgf3i2thpqXhfc0sGFvjqbDT7ujDZtW9ZIQ__nG9L-Hl7zzuiI3XrPInShW2T9Rvipf8u9e8GwQwDVOGHCYgxhLYYf8WQ6hlM6iKpF8mCTAw3ghX20-OKioFl176S_oxAcRjFeIHvEAKnFtVQjVy46xlmMipRfDtv92W1iWdpepVM2iKh0TxP8jDMm3SRxikN52GUpCSkV1G2yOlEEExU27SwMvaD4iBslbLlhBdxGMdhEkf4C5P5bHGVhxWJWBRlyZyhURqyDtOb2ThmUh0mqnAhVeNBo1JgrvpNSbTmh545Fi0-GU0rVfGA467be_wrMnH-Cxf_H0I44vY">