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

    <tr>
        <th>Summary</th>
        <td>
            [flang][OpenMP] Compilation error of variable specified in the FIRSTPRIVATE and REDUCTION clauses in TASK construct
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang-new : 17.0.0(3e0866bf616bf7b293cec93d06d030dd11d7911f)
```

Variable specified in the `FIRSTPRIVATE` and `REDUCTION` clauses in `TASK` construct result in a compile-time error.

The following are the test program, flang-new, gfortran and ifort compilation result.


omp3_task_nested_007_3.f90:
```fortran
subroutine SUB00()
  integer(4)::i,j,a
  a=100
!$omp task firstprivate(a)
!$omp parallel do reduction(+:a)
  do i=1,10
     do j=1,100
        a=a+j
     end do
  end do
!$omp end parallel do
  write(6,*) "inside  : a = ", a  ! a = 50600
!$omp end task
 write(6,*) "outside : a = ", a  ! a = 100
end subroutine SUB00

program MAIN
!$omp parallel
  call SUB00()
!$omp end parallel
end program MAIN
```

```
$ flang-new -flang-experimental-exec -fopenmp omp3_task_nested_007_3.f90
error: Semantic errors in omp3_task_nested_007_3.f90
./omp3_task_nested_007_3.f90:5:19: error: REDUCTION variable 'a' is FIRSTPRIVATE in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
  !$omp parallel do reduction(+:a)
 ^^^^^^^^^^^^^^
$
```

```
$ gfortran -fopenmp omp3_task_nested_007_3.f90
$
```

```
$ ifort -qopenmp omp3_task_nested_007_3.f90
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVVlv2zgQ_jXjl4ENirqsBz8odg0Eix5I0r4GlDiymUqklqSS9N8vKF9qkmbbXUBIzI_HN-c3wjm100QrS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