<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/130533>130533</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang][OpenMP] Compile error of end single copyprivate statement written within parallel private construct within task construct
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang:openmp
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ohno-fj
</td>
</tr>
</table>
<pre>
```
Version of flang : 21.0.0(8c7c791284877e36f73c41ffa56b52c13e613993)/AArch64
```
`end single statement` with `copyprivate clause` written in `parallel construct` with `private clause` in `task construct` results in compilation errors.
The above program is `sngtomp028_21.f90`.
When `task construct` is removed, the compilation succeeds.
The above program is `sngtomp028_22.f90`.
The following are the test program, Flang, Gfortran and ifx compilation/execution result.
sngtomp028_21.f90:
```fortran
program main
real, dimension(:), allocatable :: a
real, dimension(:), pointer :: b
!$omp task
!$omp parallel private (a, b)
allocate (a(5))
allocate (b(10))
!$omp single
a = 22
b = 33
!$omp end single copyprivate (a, b)
if(any(a/=(/(22,j=1,5)/))) print *,'err1'
if(any(b/=(/(33,k=1,10)/))) print *,'err2'
!$omp end parallel
!$omp end task
print *,'pass'
end program main
```
```
$ flang -fopenmp sngtomp028_21.f90
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
error: Semantic errors in sngtomp028_21.f90
./sngtomp028_21.f90:11:31: error: COPYPRIVATE variable 'a' is not PRIVATE or THREADPRIVATE in outer context
!$omp end single copyprivate (a, b)
^
./sngtomp028_21.f90:11:34: error: COPYPRIVATE variable 'b' is not PRIVATE or THREADPRIVATE in outer context
!$omp end single copyprivate (a, b)
^
$
```
```
$ export OMP_NUM_THREADS=2; gfortran -fopenmp sngtomp028_21.f90; ./a.out
pass
$
```
```
$ export OMP_NUM_THREADS=2; ifx -qopenmp sngtomp028_21.f90; ./a.out
pass
$
```
sngtomp028_22.f90:
```fortran
program main
real, dimension(:), allocatable :: a
real, dimension(:), pointer :: b
! !$omp task
!$omp parallel private (a, b)
allocate (a(5))
allocate (b(10))
!$omp single
a = 22
b = 33
!$omp end single copyprivate (a, b)
if(any(a/=(/(22,j=1,5)/))) print *,'err1'
if(any(b/=(/(33,k=1,10)/))) print *,'err2'
!$omp end parallel
! !$omp end task
print *,'pass'
end program main
```
```
$ export OMP_NUM_THREADS=2; flang -fopenmp sngtomp028_21.f90; ./a.out
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
pass
$
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsV02P2zYQ_TX0hbBBDa0PH3zQ2lHbQ5pFkiboKaCkkc2EIlWScnb_fUFJ9trrzSYB0iCHAou1qeG8eRy-GY-Ec3KnEdckviHxdiZ6vzd2bfbazJuPs9LU92uSsOmP5e_QOmk0NQ1tlNA7SnhOIVqwBSOQZVVapasIsmWWpsiTJuXVMmoaESdlDFXEMYn4asUJrAgUeW6rfbIkLD-PMC5R19RJvVNInRceW9SeJIx-ln5PScIq0913Vh6ER1op0TscrFZ6j5pKHfZ0wgqlUNHKaOdtX10gXHuPXl64T5ceFl2vvAv2yrSdVMKHFKC1xroFpYTlb_dIRWkOSDtrdla0VLoA5vTOm7ZjkH2AaNGswhlHj_d7_EI46ajF1hywJrChfo8XUV1fVYj1d8SFY9wxucGlMUqZz1LvqLA4hPDo_BEjhC3C5YYvvzXGeis0Fbqmsrk7J0OgwDus-oHYmKUpyPW5eX5-zxMoYfmRdytkWFJqUagQuJYtajdEyYJ3kMyGCqVMJbwoFQbpBfWJb3DrjNQe7dGlDFwgIrA0bUfDFVw8OAnnqBECmQgwZYAL0SYaR0sWD3GubSWBLGIn40OIUdvjfkr4lgIMi3JYcH6x-awYznV_xUo24ZG-Hw0F4duQBCgIZAAENh8J30YENiPbYqIFq3BO7SmBnMCGQIrWRgTSgHkGWT6C5JzA5tMEOR3yWUwYMS_Pdcz1lWG6FfoYqBPOjUCD-6V8rhvJwxKW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