Open
Description
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
...