Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang][OpenMP] Add test for checking overloaded operator in atomic update #88471

Merged
merged 1 commit into from
May 16, 2024

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
Collaborator

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 merged commit d94582e into llvm:main May 16, 2024
3 of 4 checks passed
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.

None yet

3 participants