[flang-commits] [flang] [flang][OpenMP] Add diagnostic for ATOMIC WRITE with pointer to non-intrinsic type (PR #162364)

Krish Gupta via flang-commits flang-commits at lists.llvm.org
Tue Oct 14 13:38:47 PDT 2025


KrxGu wrote:

> This looks good! I have a suggestion:
> 
> Remove the CheckAtomicVariable overload, instead add a parameter e.g. "bool CheckTypeOnPointer = true". Pass "!IsPointerAssignment(...)" at the call sites where needed. Add the same parameter to CheckAtomicType and pass it from CheckAtomicVariable. Then put the actual check into CheckAtomicType.
> 
> This way the checks are done where they logically belong.

Thank you for the feedback! I've implemented your suggestions:

1. **Removed the overload** - Deleted the `CheckAtomicVariable(atom, source, assign)` overload
2. **Added bool parameter** - Added `bool checkTypeOnPointer = true` to both `CheckAtomicVariable` and `CheckAtomicType`
3. **Updated call sites** - All atomic assignment functions now pass `!IsPointerAssignment(...)` to control the check:
   - `CheckAtomicWriteAssignment`
   - `CheckAtomicReadAssignment`
   - `CheckAtomicCaptureAssignment`
   - `CheckAtomicUpdateAssignment`
   - `CheckAtomicConditionalUpdateAssignment`
4. **Moved logic to CheckAtomicType** - The pointer-to-non-intrinsic check now lives in `CheckAtomicType`, guarded by the `checkTypeOnPointer` flag

The check now applies uniformly to all atomic operations while properly excluding pointer assignments (`=>`). Tests pass locally with the updated implementation.

@kparzysz CI is all green, good to merge!!

https://github.com/llvm/llvm-project/pull/162364


More information about the flang-commits mailing list