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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] Assertion `success && "Privatization failed due to existing binding"' failed.
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          k-arrows
      </td>
    </tr>
</table>

<pre>
    Reproducer:
```f90
!$omp parallel sections
!$omp section
    do i = 1, 2
    end do
!$omp section
    do i = 1, 2
    end do
!$omp end parallel sections
end
```

With assertion-disabled flang, the following output is obtained:
https://godbolt.org/z/GbfW7vYKj
```txt
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
error: loc("/app/example.f90":6:5): operand #1 does not dominate this use
error: verification of lowering to FIR failed
Compiler returned: 1
```

With assertion-enabled flang, the reproducer hits the following assertion:
```txt
flang: /path_to_project/llvm-project/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp:152: void Fortran::lower::omp::DataSharingProcessor::cloneSymbol(const semantics::Symbol *): Assertion `success && "Privatization failed due to existing binding"' failed.
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0lE2P4zYPxz8NcyESKPRLkoMPng384EFbdLB7GPS0kC0m1laWBEmemd1PX8hOd9PpAL20QA40RYnk_8dQxqivlrmB6gGq80bOaXSh-X0rQ3AvcdM79bX5yD44NQ8coGhBtFCL9Xc5ifxJe6DSTR69DNIYNhh5SNrZ-JfTmxNEi4ioHGqE4ox7oA9INy9bhcr9G9ey67162Kr7FrIt2iedRpQxcshhW6Wj7A0rvBhprzlRGhkvzhj3ou0V3Zz8nFBHdH2S2rJahRlT8jGb1AF1V6d6Z9LOhStQ9w2o-19_eTo8__bTl_sK0msC0S6ZtrSHosUXGay212z-6tn-8ohx9t6FhNquJeXUMWljkF89Bz2xTdIgVA_bp3vP1vlFu-qcOw_BZYJo3AB0BCKgTnoP1PGrnLzhXQZKBEVbQ9FWQKcc7jwHaRUCFXtUjiNal1C5SVuZGNOoI86R7zM8c9AXPcicHN0FjXvhkJVLDrv_f8SL1IYzhw9u8tpwwMBpDquQuP9HQGzf4RO-jymOOsU3zL5ffjPDd_Ln3ECdl2n8nNxnH9wXHhJQZ8zztP3xecvaGd0DdT_n3oC6FRVQd5ZJfhpl7vcxuIFjdGE3eA9Fu69okcdphZ0LKcilnKJdBFpNN_nVeO-d9WQwzvKnr1PvDNBxcDYmjDxJm_QQ15D1FIHaG8X2z_4RahHnIb-HQDVQjUD0GPSzTPrbimzlg2rmTIxfdUxZw15blQczT87hFrS7F3OjmkKdipPccLM_lCWV9aGuN2Nz5OFwEgOropLHUpSni1BFVR2EOha9UKeNbkhQJcq9EKI6Ub1TRaGqozhx3auyqglKwZPUZpdh5P_URsc4c7Mvqr04bozs2cRljRHdAFHeaKFZ6PXzNUIpjI4p_ngi6WSW3dctN6ozVA83jtX5v5NsMwfTvFkWOo1zvxvcdJu3v4_d0m8E6m4tPzf0RwAAAP__UG7SRA">