<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/109727>109727</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang][OpenMP] Compilation error when derived type with procedure pointer appears within private attribute
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang:ir,
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-new : 20.0.0(675c748bb606d75a959481e6014299849cf3094c)/AArch64
```
When building [GAMESS](https://www.msg.chem.iastate.edu/gamess/index.html), the following error is detected.
When `derived type` with `procedure pointer` appears within `private` attribute, a compilation-time error (`Lowering to LLVM IR failed`) occurs.
A similar error occurs with `firstprivate` attribute.
Compilation succeeds in the following case:
- Do not specify `-fopenmp` option.
The following are a self-made reproducer, Flang-new compilation result.
foo.F90:
```fortran
module m1
type :: typ1
procedure(), pointer, nopass :: p1 => null()
end type typ1
contains
subroutine sub2()
type(typ1) :: t1
!$omp parallel private(t1)
!$omp end parallel
end subroutine sub2
end module m1
program main
use m1
print *,'pass'
end program main
```
```
$ flang-new -c -fopenmp foo.F90
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/Metro/GAMESS/foo.F90":7:19): Invalid yielded value. Expected type: '!fir.ref<!fir.type<_QMm1Ttyp1{p1:!fir.boxproc<() -> ()>}>>', got: '!fir.ref<!fir.type<_QMm1Ttyp1UnboxProc{p1:() -> ()}>>'
error: Lowering to LLVM IR failed
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/Metro/GAMESS/foo.F90":1:1): LLVM Translation failed for operation: fir.global
error: failed to create the LLVM module
$
```
```
$ flang-new -c foo.F90
$ ls -al *.o
-rw-rw-r--. 1 ohno ohno 7784 Sep 20 15:27 foo.o
$
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVk9v47YT_TT0ZSBBGsn6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