Skip to content

Conversation

@NimishMishra
Copy link
Contributor

Atomic update expression does not allow overloaded user-defined operators. This PR adds a test case for the same; the semantic check is already existent.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:openmp flang:semantics labels Apr 12, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 12, 2024

@llvm/pr-subscribers-flang-semantics

@llvm/pr-subscribers-flang-openmp

Author: None (NimishMishra)

Changes

Atomic update expression does not allow overloaded user-defined operators. This PR adds a test case for the same; the semantic check is already existent.


Full diff: https://github.com/llvm/llvm-project/pull/88471.diff

1 Files Affected:

  • (added) flang/test/Semantics/OpenMP/atomic-update-overloaded-ops.f90 (+38)
diff --git a/flang/test/Semantics/OpenMP/atomic-update-overloaded-ops.f90 b/flang/test/Semantics/OpenMP/atomic-update-overloaded-ops.f90
new file mode 100644
index 00000000000000..feac4b20f726aa
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/atomic-update-overloaded-ops.f90
@@ -0,0 +1,38 @@
+! REQUIRES: openmp_runtime
+
+! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp 
+!
+
+module new_operator
+    implicit none
+    private
+    public operator(.MYOPERATOR.)
+
+    interface operator(.MYOPERATOR.)
+       module procedure myprocedure
+    end interface
+contains
+    pure integer function myprocedure(param1, param2)
+        integer, intent(in) :: param1, param2
+        myprocedure = param1 + param2
+    end function
+end module
+
+program sample
+    use omp_lib
+    use new_operator
+    implicit none
+    integer :: x, y 
+
+    
+    !$omp atomic update
+        x = x / y
+     
+    !$omp atomic update
+    !ERROR: Invalid or missing operator in atomic update statement
+        x = x .MYOPERATOR. y
+
+    !$omp atomic
+    !ERROR: Invalid or missing operator in atomic update statement
+        x = x .MYOPERATOR. y
+end program

Copy link
Contributor

@kiranchandramohan kiranchandramohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG.

Comment on lines 8 to 9
private
public operator(.MYOPERATOR.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: you can probably remove these two.

@NimishMishra NimishMishra force-pushed the atomic-update-overloaded-op branch from 00f321e to 0151f72 Compare April 24, 2024 11:40
@NimishMishra NimishMishra merged commit d94582e into llvm:main May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:openmp flang:semantics flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants