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

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Compilation error of FORALL statement
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:frontend
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang-new : 18.0.0(c07062a2e9bf9aa1211b958f6bb4c5746139c180)
```

Program using `FORALL` statement such as the following results in a compile-time error.
If the `-flang-experimental-hlfir` option is specified, Flang-new can compile successfully.

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

snggm306_5.f90:
```fortran
program main
 character(10):: text
  integer      :: i
  do kk=1,10
 text(kk:kk)='x'
  end do
  text(10:10)=achar(9)
  forall (i=1:10, text(i:i) == achar(9)) text(i:i)=' '
  print *,'pass'
end program main
```

```
$ flang-new snggm306_5.f90
error: loc("/home/ohno/tp/reproducerJ/Metro/F200X01/snggm306_5.f90":8:3): 'fir.result' op must be the last operation in the parent block
error: verification of lowering to FIR failed
$
```

```
$ flang-new snggm306_5.f90 -flang-experimental-hlfir
$
```

```
$ gfortran snggm306_5.f90
$
```

```
$ ifort snggm306_5.f90
$
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVd2O4zYPfRrmhkgg0_8XufA3gT9ssUWLRVH0rpBt2tFGtgxJ3pl9-0K2MzuTboG2aBAksCSec0geytI5NUzMZ0j_B-nlIBd_NfZsrpM59p8Pjem-niET-1dcQFS_snXKTGh67LWchuPEzwhxhVFxEicBVLQiFxlJ4rLpSykjiqKmTIs-a5qkTfMki-KyjQoBVG6QDwzb78_WDFaOuDg1DQiZqH_6VH38CJlA56XnkSePbmmvKB36K2NvtDbP4bBlt2jvUE0osTXjrDQfvRoZ2VpjTxvBh34Ng0wct0T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