Files
clang-p2996/flang/test/Semantics/OpenACC/acc-atomic-validity.f90
Valentin Clement (バレンタイン クレメン) c46d732fd7 [flang][openacc] Check atomic update lhs/rhs are scalar (#66113)
Add semantic check for `!$acc atomic update`. RHS and LHS of the update
assignment must be scalar.

Without this check the code was going all the way to MLIR and trigger a
verifier error. This gives better user error message.
2023-09-12 11:00:01 -07:00

50 lines
836 B
Fortran

! RUN: %python %S/../test_errors.py %s %flang -fopenacc
! Check OpenACC clause validity for the following construct and directive:
! 2.12 Atomic
program openacc_atomic_validity
implicit none
integer :: i
integer, parameter :: N = 256
integer, dimension(N) :: c
!$acc parallel
!$acc atomic update
c(i) = c(i) + 1
!$acc atomic update
c(i) = c(i) + 1
!$acc end atomic
!$acc atomic write
c(i) = 10
!$acc atomic write
c(i) = 10
!$acc end atomic
!$acc atomic read
i = c(i)
!$acc atomic read
i = c(i)
!$acc end atomic
!$acc atomic capture
c(i) = i
i = i + 1
!$acc end atomic
!$acc atomic update
!ERROR: RHS of atomic update statement must be scalar
!ERROR: LHS of atomic update statement must be scalar
c = c + 1
!$acc end parallel
end program openacc_atomic_validity