<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/87214>87214</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang][OpenMP] Compilation error when end single construct has a copyprivate clause
</td>
</tr>
<tr>
<th>Labels</th>
<td>
openmp,
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ohno-fj
</td>
</tr>
</table>
<pre>
```
Version of flang-new : 19.0.0(cbcdf126ccc774c063b5d5140c1393ff5305dded)/AArch64
```
Compilation error occurs when `end single` construct has a `copyprivate` clause.
Compilation terminates normally in the following cases:
- Delete the `COPYPRIVATE` clause, or (omp30_example_a_37_01_222.f90)
- Add the following before the assignments A and B, or (omp30_example_a_37_01_223.f90)
```
!$OMP THREADPRIVATE(A,B)
```
- Add `PARALLEL` construct (omp30_example_a_37_01_224.f90)
The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.
omp30_example_a_37_01_22.f90:
```fortran
program main
REAL A, B
A=1.0
B=2.0
!$OMP SINGLE
!READ (11) A,B
!$OMP END SINGLE COPYPRIVATE (A,B)
print *,'pass'
end program main
```
```
$ flang-new -fopenmp omp30_example_a_37_01_22.f90
error: Semantic errors in omp30_example_a_37_01_22.f90
./omp30_example_a_37_01_22.f90:7:31: error: COPYPRIVATE variable 'a' is not PRIVATE or THREADPRIVATE in outer context
!$OMP END SINGLE COPYPRIVATE (A,B)
^
./omp30_example_a_37_01_22.f90:7:33: error: COPYPRIVATE variable 'b' is not PRIVATE or THREADPRIVATE in outer context
!$OMP END SINGLE COPYPRIVATE (A,B)
^
$
```
```
$ export OMP_NUM_THREADS=1; gfortran -fopenmp omp30_example_a_37_01_22.f90; ./a.out
pass
$
```
```
$ export OMP_NUM_THREADS=1; ifort -qopenmp -diag-disable=10448 omp30_example_a_37_01_22.f90; ./a.out
pass
$
```
omp30_example_a_37_01_222.f90:
```fortran
program main
REAL A, B
A=1.0
B=2.0
!$OMP SINGLE
!READ (11) A,B
!$OMP END SINGLE ! COPYPRIVATE(A,B)
print *,'pass'
end program main
```
omp30_example_a_37_01_223.f90:
```fortran
program main
REAL A, B
!$OMP THREADPRIVATE(A,B)
A=1.0
B=2.0
!$OMP SINGLE
!READ (11) A,B
!$OMP END SINGLE COPYPRIVATE(A,B)
print *,'pass'
end program main
```
omp30_example_a_37_01_224.f90:
```fortran
program main
REAL A, B
!$OMP PARALLEL
A=1.0
B=2.0
!$OMP SINGLE
!READ (11) A,B
!$OMP END SINGLE COPYPRIVATE(A,B)
!$OMP END PARALLEL
print *,'pass'
end program main
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUV1tvozgU_jXOixVkjrmEhzyQJpkdqZeo7Y60T5EBk3gENmubXv79ykCaS6eZ7nY60kpVKhsfzvd95-IDM0ZsJOdTFM5QOB-x1m6VnqqtVOPy-yhTxfMURWT4I3NE0m9cG6EkViUuKyY3Y8kfMaIp9hOPeATBJM_yovQhyvM8joOcRDQLi9APSO7ThJZlSElYFLxAkCBYpqnOt1HQv_zEV_97oepGVMw6r1xrpbHK81Yb_LjlEqOIcFlgI-Sm4igiOFfSWN3mFm-ZwcwdyFXz3GjxwGx_omKt4d5bPizXtZDMcoOl0jWrqmcsJLZbjktVVepRyA3OmeEG0cF8jOe84pZ3h1BELm5Wf61uv35L7xd7hwgusNIYwUTVDSVr_sTqpuJrtqbxmvhrAPDKhDhZhpemRXHiNuOl0r2bPnY1l9bgFDNZ4NngAZ_zQY98nAjuLH0Ewc3VCt__cbtI5zsWMEkRXMzeMuyxoois0tv08nJxeRyJM3iCYzwHv_dHzNlA23JjcaPVRrPa8V3uktAtvpRKW81kJ4dwC5zvI4tgyZ943nZR1ty0lT1Kgrcgdgh3oX4hPrjqdwdAuGZC7qS8XaSX2KmGZ7utFNG5772IPUN0DrvlXvm7r9dfLhcvuy4MTkHfR5DgPgwnFovr-WCFD1IPv4oaxo0W0sXD7SOIG2YMgr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