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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] flang-new doesn't report a wrong usage of `atomic capture`
        </td>
    </tr>

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

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

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

<pre>
    This is an issue from Fujitsu testsuite.

Flang-new doesn't emit a correct error message for a wrong usage of `atomic capture`.

The following are the test program and the compilation results of Flang-new and gfortran.

```fortran
! test.f90
integer :: vv,yy,yy1
vv=1
yy=1
yy1=1

!$omp atomic capture
vv=yy
yy=yy+yy
!$omp end atomic

!$omp atomic capture
vv=yy
yy=(yy1+yy)+yy1
!$omp end atomic
end
```
```console
$ flang-new -v test.f90 -fopenmp
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git 61ff9f8db8d18002767ea27f83a4bfb8ed47f255)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/install/bin
Found candidate GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12
Selected GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/path/to/install/bin/flang-new" -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/test-af2dc0.o -x f95-cpp-input test.f90
error: loc("/path/to/test.f90":4:1): no atomic update operation with region argument as operand found inside atomic.update region
error: LLVM Translation failed for operation: omp.atomic.capture
error: failed to create the LLVM module
```
```console
$ gfortran -v test.f90 -fopenmp
Driving: gfortran -v test.f90 -fopenmp -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/8/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-18) (GCC) 
 :
test.f90:9:3:

 yy=yy+yy
   1
Error: expr in !$OMP ATOMIC assignment var = var op expr must be scalar and cannot reference var at (1)
test.f90:14:3:

 yy=(yy1+yy)+yy1
   1
Error: !$OMP ATOMIC assignment must be var = var op expr or var = expr op var at (1)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8V91u67gRfhr6ZkBDovx74QvHXm8XyEEOTtP2MqCokcwcimRJyrH36QtSspxkk-wWBQoYljQznD8Ovxly72WjETdkfkfm-wnvwtG4zaXzxTLPaP08KU112TwepQfpgWuQ3ncItTMtHLpnGXwHAX3wnQw4JdmeZNv-_6C4bqjGF6gMek3YMgC2MgAHYZxDEQCdMw5a9J43CLVxwOHFGd1AlyimBrLIeDCtFCC4DZ1DssjemHk8xpVKmRepG-AOIRwxuQTWmcbxFriuElGY1krFgzQaHPpOBR9N3ByNgk1tXHBcvzFCFln_G5gDleXJ0LReZz1F6oANOiDFlhRbOJ0I210u6S_vJU4nUuyH98vl9Xt--xjVEzYzrYV3GbgpulxeaYqG7q6U22LU1aDgf1FO2Cq6mAywdXrmf2YJdfUufe8-hdHeKLzq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