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

    <tr>
        <th>Summary</th>
        <td>
            [flang][OpenMP] Threadprivate variable in host-association
        </td>
    </tr>

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

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

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

<pre>
    https://github.com/flang-compiler/f18-llvm-project/issues/1136 has the detailed info about the support status of Threadprivate directive.
## Test case
```
$ cat hostassoc1.f90 
program main
  use omp_lib
  integer, save :: a
  !$omp threadprivate(a)
 call sub()
contains
  subroutine sub()
    a = 2
    !$omp parallel num_threads(4)
      a = omp_get_thread_num()
      print *, a, omp_get_thread_num()
    !$omp end parallel
    !$omp parallel num_threads(4)
      print *, a, omp_get_thread_num()
    !$omp end parallel
  end
end
$ cat hostassoc2.f90 
program main
  use omp_lib
  integer :: a
  !$omp threadprivate(a)
  call sub()
contains
  subroutine sub()
    a = 2
    !$omp parallel num_threads(4)
      a = omp_get_thread_num()
      print *, a, omp_get_thread_num()
    !$omp end parallel
    !$omp parallel num_threads(4)
      print *, a, omp_get_thread_num()
    !$omp end parallel
  end
end
```
## Expected results:
```
 0           0
           2           2
           3           3
 1           1
           2           2
           3 3
           1           1
           0           0
```
gfortran 12 and ifort 2021 support `hostassoc1.f90`, but do not support `hostassoc2.f90`. For `hostassoc2.f90`, gfortran 12 gives wrong running results, while ifort reports the semantic error.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVU2P4zYM_TXyhZhApmPHOfgwO2luRbfA3ge0TdsqZMnQR2b77ws7niSbCbbotoce1kgi5ZEiH2WCj7xXvWGuRP5J5IeEYhisqz6z-qrM74psUtv2z2oIYfIiexZ4FHjsVRhivWnsKPDYaTL9U2PHSWl2M5CWT1qfxqfJ2T-4CQKPyvvIXuAxTbMCBvIQBoaWAynNLSjTWaDaxrDgPk6TdQF8oBA92A6-DI6pnZw6UWBoleMmqBNvhDwI-SwwE5jBF_YBGvK8ooVcP6vTFhoKMFgfyHvbpJtuL-FsnJztHY0wkjJnBCB6BjtOr1rV75Aygfu5xhfwdGKYLyR7Bnq3C0wFbu04QbglLLAkgfvVqyGtwcdaYHkBG2sCKePfA_lYOxuDMnzvCQBAILID4BW45p3IkdaswcTx9UzCCyy335x_jzBX13NY_V5NHO8zAUxOmQACn-eiaf75-1NXOmzaC6V_Qfe_J8GmPW8vmw_9gT_cHz_WFz8b43_aGPdzZBk2v3yduAncgmMfdVhm4yN3kHB95C335cHb_QdrdrtfrekNlv7jeNkH7PvxHrC_K7DvrAuODKQIZFpQ839AielljotCfjt158P4AnUM0FowNjx0xdV1A0frHlrmILf5e3ViD2_Omh5cNEbN6_p-8AXeBqV5Jeh4znfWIc8jmaAaYOes2yRtlbX7bE8JV2mxK7ZFVmZlMlQkuyIvy11KtNs2xb6Zv6lM8yJPcUeUqAolZhLTPEXM8nKDsisx7drtrpU7yZ3YSh5J6c2sjxvr-mRRxqqQuyJLNNWs_aLEiIbfYDEKxFmYXbVoah17L7ZSKx_8NUpQQS8SvoixyA8i__TbxObXzyI_3KnniZyier4Iswy7p-VKFQVlTRKd_p7WzwnX5ZG6L2X8FQAA__-3FGV7">