llvm-project/flang/test/Semantics/OpenMP/omp-atomic-write-pointer-derived.f90
Krish Gupta 59ab4d4bbc
[flang][OpenMP] Add diagnostic for ATOMIC WRITE with pointer to non-intrinsic type (#162364)
Fixes https://github.com/llvm/llvm-project/issues/161932

Added a check for non-intrinsic types in non-pointer assignments.

Added bool checkTypeOnPointer = true to both CheckAtomicVariable and
CheckAtomicType. All atomic assignment functions now pass
!IsPointerAssignment(...) to control the check. The pointer-to-non-intrinsic
check lives in CheckAtomicType, guarded by the checkTypeOnPointer flag.
The check now applies uniformly to all atomic operations while properly
excluding pointer assignments (=>).

---------

Co-authored-by: Krish Gupta <krishgupta@Krishs-MacBook-Air.local>
2025-10-15 13:42:33 -05:00

9 lines
266 B
Fortran

! RUN: not %flang_fc1 -fopenmp -fsyntax-only %s 2>&1 | FileCheck %s
type t
end type
type(t), pointer :: a1, a2
!$omp atomic write
a1 = a2
! CHECK: error: ATOMIC operation requires an intrinsic scalar variable; 'a1' has the POINTER attribute and derived type 't'
end