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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenACC] Assertion `mlir::isa<mlir::acc::PointerLikeType>(baseAddr.getType()) && "expected pointer-like"' failed.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir,
            flang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          k-arrows
      </td>
    </tr>
</table>

<pre>
    Crash itself is reproducible on godbolt. The reproducer here is reduced from https://github.com/gcc-mirror/gcc/blob/master/libgomp/testsuite/libgomp.oacc-fortran/privatized-ref-2.f90.
See https://godbolt.org/z/cxzK8Y3vs
```f90
program main
  implicit none (type, external)
  character(len=:), allocatable :: my_str

  my_str = "1234567890"
  call foo_str(my_str)
  deallocate (my_str)
contains
 subroutine foo_str(str)
    integer :: i
    character(len=*) :: str

 !$acc parallel copyout(str)
    str = "abcdefghij"
    !$acc end parallel
  end
end
```

With assertion-enabled flang, the reproducer hits the following assertion:
```txt
/path_to_project/llvm-project/flang/lib/Lower/OpenACC.cpp:164: Op createDataEntryOp(fir::FirOpBuilder &, mlir::Location, mlir::Value, std::stringstream &, mlir::SmallVector<mlir::Value>, bool, bool, mlir::acc::DataClause, mlir::Type, llvm::ArrayRef<mlir::Value>, llvm::ArrayRef<mlir::Attribute>, llvm::ArrayRef<mlir::Attribute>, bool, mlir::Value) [Op = mlir::acc::CreateOp]: Assertion `mlir::isa<mlir::acc::PointerLikeType>(baseAddr.getType()) && "expected pointer-like"' failed.
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVc1u4zYQfhr6QtigKVmxDj4o9urSAC66iy16CkbUSOKGEgVylMR5-oKUEzvJtgV6WsCwPcP5-76ZIcF73Q6IO7a5ZZvDAibqrNs9LME5--QXla1Pu70D33FNHk3Dt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