<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63828>63828</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang][OpenMP] Unexpected warning emitted for a FORALL construct
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
rofirrim
</td>
</tr>
</table>
<pre>
When compiling the following testcase with OpenMP enabled
```fortran
! t.f90
subroutine p(n, k)
implicit none
integer :: i
integer :: j
integer :: n
integer :: k(10, 10)
!$omp task private(i, j)
forall(i=1:10, j=1:10) k(i, j) = 0
!$omp end task
end subroutine p
```
the following diagnostics are emitted
```
$ flang-new -c t.f90 -fopenmp
./t.f90:10:25: warning: FORALL index variable 'i' not used on left-hand side of assignment
forall(i=1:10, j=1:10) k(i, j) = 0
^^^^^^^^^^^
./t.f90:10:25: warning: FORALL index variable 'j' not used on left-hand side of assignment
forall(i=1:10, j=1:10) k(i, j) = 0
^^^^^^^^^^^
```
but the variables are indeed used.
The diagnostic is not emitted if OpenMP is not enabled.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVEGPmzoQ_jXmMgrCBhI4cMi-PE77tE9Vq54NDDBZYyPbbLb_vgKS3aTKqpX2UGQZZmzzzTfzeaRz1GnEgqUPLD0EcvK9sYU1LVlLQ1CZ5kfxvUcNtRlGUqQ78D1Ca5Qyp8VC52vpEE7ke3gaUf_3P6CWlcKGRQcW7c_zNlpHa6y3Up-9goMP2zxaTTdV1kyeNMLIRKaZ-AeemcjXVaBhVFSTB200XnzaY4cWWLxn8R7ovvt4363vu5-ZyHg0g89zfkNDcCYSM4zgpXuG0dKL9MhERvP243usrbFSqWUhPnAW79cfHq-sfAF6OwgsPkD0KwzqZoFa_bN1k6Tb3F5HelumhmSnjfNUO5AWAQfy_oMKXUJIoFVSdxuNJ9jUa50ANq0ZUQ9n6JCJci3gwinei3TO4ElaTbqbP8unL_vHRyDd4Cu8SEuzNICJHTGxA208TA4bMBoUtn7Ty5kiNQimhVWeA2p_zip8Mq_w4cPSf38zPsv3-Df4_iGtuwqqJr9c9guJVTkzMWwWEuH17q89XqkMyC1czzoDai-94bKwtogwaIq4yeNcBljwbZbzHU9SHvRFmiWy5WmbZVLwXZ0lQlZbbJpmx1OJogqoEJGIox0XPOG7mIdVmkYZb6uorpKW5zVLIhwkqVCplyE0tgvIuQmLbZyJLFCyQuUujc8W86ZNNXWOJZEi5937MU9eLS2ynO8DSw8sfVjZsPQA3zS-jljPLM8yeGPdGgvyoojaaOftVPtgsqrovR_d3G9EyUTZke-nKqzNwEQ5455fm9GaI9aeiXKJ3TFRLuH_DAAA___cpqS9">