Fixes #169484 The compiler crashed with an assertion failure when processing OpenMP ATOMIC constructs containing invalid variable expressions like function references or undeclared variables. ## Root Cause: `CheckAtomicVariable()` assumed `GetAllDesignators()` always returns exactly one designator, but it returns an empty vector for function references. ## Fix: Replaced the assertion with proper validation that emits diagnostic errors instead of crashing. ## Testing: Added regression test [atomic-invalid-variable.f90]
33 lines
1.0 KiB
Fortran
33 lines
1.0 KiB
Fortran
! 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
|