[flang] [llvm] [flang][OpenMP] Overhaul implementation of ATOMIC construct (PR #137852)
Tom Eccles via llvm-commits
llvm-commits at lists.llvm.org
Wed May 28 10:19:06 PDT 2025
================
@@ -0,0 +1,83 @@
+!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=60
+
+subroutine f00
+ integer :: x, y
+
+ ! The x is a direct argument of the + operator. Expect no diagnostics.
+ !$omp atomic update
+ x = x + (y - 1)
+end
+
+subroutine f01
+ integer :: x
+
+ ! x + 0 is unusual, but legal. Expect no diagnostics.
+ !$omp atomic update
+ x = x + 0
+end
+
+subroutine f02
+ integer :: x
+
+ ! This is formally not allowed by the syntax restrictions of the spec,
+ ! but it's equivalent to either x+0 or x*1, both of which are legal.
+ ! Allow this case. Expect no diagnostics.
+ !$omp atomic update
+ x = x
+end
+
+subroutine f03
+ integer :: x, y
+
+ !$omp atomic update
+ !ERROR: The atomic variable x should occur exactly once among the arguments of the top-level + operator
+ x = (x + y) + 1
+end
+
+subroutine f04
+ integer :: x
+ real :: y
+
+ !$omp atomic update
+ !ERROR: This intrinsic function is not a valid ATOMIC UPDATE operation
+ x = floor(x + y)
+end
+
+subroutine f05
+ integer :: x
+ real :: y
+
+ ! An explicit conversion is accepted as an extension.
+ !$omp atomic update
+ x = int(x + y)
----------------
tblah wrote:
Please could you document this extension (maybe flang/docs/Extensions.md or at least explain in the commit message about these consequences of using evaluate::Expr).
https://github.com/llvm/llvm-project/pull/137852
More information about the llvm-commits
mailing list