<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97241>97241</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang][OpenMP] Compilation error when initializer-clause is specified as declare reduction directive
</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(1f98ac095e35f12a85d71101269df00279faa55c)/AArch64
```
When `initializer-clause` is specified as `declare reduction` directive, a compilation error occurs.
The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.
simd9_UDR_0005_22.f90:
```fortran
subroutine initn(x,n)
integer x,n
x=n
end subroutine initn
function foo0(x, n, init)
integer foo0
integer x(n)
integer tmp
tmp=init
do i=1,n
tmp=tmp+x(i)
enddo
foo0=tmp
end function foo0
function foo(x, n, init)
integer foo
integer x(n)
integer tmp
interface
subroutine initn(x,n)
integer x,n
end subroutine initn
end interface
!$omp declare reduction(udr_add:integer(4):omp_out=omp_out+omp_in) initializer(initn(omp_priv,0))
tmp=init
!$omp simd reduction(udr_add:tmp)
do i=1,n
tmp=tmp+x(i)
enddo
foo=tmp
end function foo
program main
integer,parameter::N=10
integer x(N)/1,2,3,4,5,6,7,8,9,10/
integer ret0,ret
interface
function foo0(x,n,init)
integer foo0,x(n),init
end function foo0
function foo(x,n,init)
integer foo,x(n),init
end function foo
end interface
ret0 = foo0(x,N,10)
ret = foo(x,N,10);
if (ret0.ne.ret) then
print*,"NG:",ret0,ret
endif
print*,ret0,ret
print*,"OK"
end program main
```
```
$ flang-new -fopenmp simd9_UDR_0005_2.f90
error: Could not parse simd9_UDR_0005_22.f90
./simd9_UDR_0005_22.f90:26:68: error: expected end of line
!$omp declare reduction(udr_add:integer(4):omp_out=omp_out+omp_in) initializer(initn(omp_priv,0))
^
./simd9_UDR_0005_22.f90:26:1: in the context: specification construct
!$omp declare reduction(udr_add:integer(4):omp_out=omp_out+omp_in) initializer(initn(omp_priv,0))
^
./simd9_UDR_0005_22.f90:26:1: in the context: declaration construct
!$omp declare reduction(udr_add:integer(4):omp_out=omp_out+omp_in) initializer(initn(omp_priv,0))
^
./simd9_UDR_0005_22.f90:18:3: in the context: specification part
integer foo
^
./simd9_UDR_0005_22.f90:17:1: in the context: FUNCTION subprogram
function foo(x, n, init)
^
$
```
```
$ gfortran -fopenmp simd9_UDR_0005_22.f90; ./a.out
65 65
OK
$
```
```
$ ifort -qopenmp -diag-disable=10448 simd9_UDR_0005_22.f90; ./a.out
65 65
OK
$
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcV01v4zYT_jXjC2GDGkmWdPDBkV8vXiyaFMVuewxocWRzIZMqRWXT_vqCkuwolp1m26JYNAhkkRrOPM98cEjRNGqviVYQ30G8mYnWHYxdmYM28_LLbGfkbytY8uGfb4CvfybbKKOZKVlZCb2fa_rKIFyzIFvwBQdMgzJLRcGzmMK4DFCksUyCgAe4zGTJOSZZKUQcF4AZ4Ha9tsVhGfXKL2z1z18OpBksudLKKVGp38nOi0q0DcGSM9WwpqZClYokE40XlFRUwhKzJNvCKaO9nFSWCqeeCDBnghXmWKtK-K-MrDWWmaJobbMYW_50IFaaqjJfld4zr9IdiDlqHKut2Vtx9Mq2Jzf4wYfSWGeFZkJLpvxgbApwS89UtJ1ZS01buVcGG3WU2ePnzU-PnPP4EXFRZhzC9YV3BhvDmnZnTeuUJuY9pAHTZ8Bce_d2Aowp7WhPlvXzw-QzhJthQFqyiZoRrLLVnR9ZaQwf9DPtH170iqFObmo8vQbKHethyr-Fm07lICMNUxBugjFuxgZB_8Q7r1aN1JKW0pwGHY5e8kz0NZkbLN9J8ts5dlO2FAWN-Px5CK9GkHVsb0Su_3ZhDTAAjMyxZtMawbSV9lFICeF6MAeYRh5DuDbH-tG0DsLN6Q3v_JvyGNmoMn00Bgr-e23VE2DO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