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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] Compilation error when lastprivate clause specified in do construct has a derived type with an allocatable variable
        </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(1a498103ee5c4d101e70dc49db11938d8b87b518)/AArch64
```

When `lastprivate` clause specified in `do` construct has a `derived type` with an allocatable variable, a compilation terminates abnormally.  
When `lastprivate` clause in `do` construct is removed, a compilation terminates normally.

The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.

lp10_32.f90:
```fortran
subroutine s4
  type y3
 integer,allocatable::x
  end type y3
  type(y3)::v
 allocate(v%x)
  v%x=0
!$omp parallel
  if (.not. allocated(v%x)) print *,'101'
!$omp do lastprivate(v)
  do i=1,10
     v%x=i
 end do
!$omp end do
!$omp end parallel
end subroutine s4

program main
  call s4
  print *,'pass'
end program main
```

```
$ export OMP_NUM_THREADS=2; flang-new -fopenmp lp10_32.f90; ./a.out

fatal Fortran runtime error(/work/home/ohno/CT/test/fort/tp/reproducerJ/fomp_omp40/lp10_32.f90:12): Assign: mismatching types (to code 64 != from code 9)
fatal Fortran runtime error(/work/home/ohno/CT/test/fort/tp/reproducerJ/fomp_omp40/lp10_32.f90:12): Assign: mismatching types (to code 64 != from code 9)

Aborted (core dumped)
$
```

```
$ export OMP_NUM_THREADS=2; gfortran -fopenmp lp10_32.f90; ./a.out
 pass
$
```

```
$ export OMP_NUM_THREADS=2; ifort -qopenmp -diag-disable=10448 lp10_32.f90; ./a.out
 pass
$
```

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