aboutsummaryrefslogtreecommitdiff
path: root/flang/test/Semantics/OpenMP/atomic-invalid-variable.f90
blob: 32527d3cfd51d0bd0d8b67ab89dfbd04ce722f2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
! Test for issue #169484: Flang should not crash on invalid atomic variables
! This test verifies that proper diagnostics are emitted for invalid atomic
! constructs instead of crashing the compiler.

subroutine test_atomic_invalid(a, b, i)
  integer :: i, a, b
  interface
    function baz(i) result(res)
      integer :: i, res
    end function
  end interface
  
  ! Valid atomic update - should work fine
  !$omp atomic
    b = b + a
  
  ! Invalid: z is undeclared, so z(1) is treated as a function reference
  ! This should emit an error, not crash
  !$omp atomic
    !ERROR: Left-hand side of assignment is not definable
    !ERROR: 'z(1_4)' is not a variable or pointer
    z(1) = z(1) + 1
  
  ! Invalid: baz(i) is a function reference, not a variable
  ! This should emit an error, not crash
  !$omp atomic
    !ERROR: Left-hand side of assignment is not definable
    !ERROR: 'baz(i)' is not a variable or pointer
    !ERROR: This is not a valid ATOMIC UPDATE operation
    baz(i) = 1
end subroutine