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

    <tr>
        <th>Summary</th>
        <td>
            [flang][OpenMP] OMP ATOMIC restriction too strong?
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          eugeneepshteyn
      </td>
    </tr>
</table>

<pre>
    Consider the following code:
```
subroutine test(a,b,c)
  logical :: a,b,c
  !$OMP ATOMIC
  ! This fails:
  a = a .and. b .and. c
  ! This succeeds:
  a = a .and. (b .and. c)
end subroutine
```
Compiling with flang:
```
$ flang -c -fopenmp atomic-err.f90 
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
error: Semantic errors in atomic-err.f90
./atomic-err.f90:5:7: error: The atomic variable a cannot be a proper subexpression of an argument (here: a.and.b) in the update operation
    a = a .and. b .and. c
 ^^^^^^^^^^^^^^^^^
./atomic-err.f90:5:7: error: The atomic variable a should appear as an argument of the top-level AND operator
    a = a .and. b .and. c
        ^^^^^^^^^^^^^^^^^
```
It seems to be a bit arbitrary that `a = a .and. b .and. c` fails, but `a = a .and. (b .and. c)` succeeds. Perhaps it would be possible to process `a = a .and. b .and. c` as if it had parenthesis in the right places?

FWIW, gfortran and ifx accept this code.

Compiler version:
```
$ flang --version
flang version 21.0.0git (https://github.com/llvm/llvm-project 3de01d07c33c10dfefc753c87c0a926fd512425b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
...
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVU1v4zgP_jXKhbAhy1Y-Dj64yRugh74tsAV6XMgSbWtXkQRJbtN_v5CTTj92ZwazGxhwIJE0n4cPSRGjHi1iS_gN4YeVmNPkQovziBbRxynhq131Tr22e2ejVhggTQiDM8a9aDuCdApJ3RHakTW9PrSLcx_cnLRFS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