[flang-commits] [flang] [flang][OpenMP] Add test for checking overloaded operator in atomic update (PR #88471)

via flang-commits flang-commits at lists.llvm.org
Thu Apr 11 22:11:39 PDT 2024


https://github.com/NimishMishra created https://github.com/llvm/llvm-project/pull/88471

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.

>From 00f321e1597f93617f9bbdb4bf4bf36376dfe625 Mon Sep 17 00:00:00 2001
From: Nimish Mishra <neelam.nimish at gmail.com>
Date: Fri, 12 Apr 2024 10:32:31 +0530
Subject: [PATCH] [flang][OpenMP] Add test for checking overloaded operator in
 atomic update

---
 .../OpenMP/atomic-update-overloaded-ops.f90   | 38 +++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 flang/test/Semantics/OpenMP/atomic-update-overloaded-ops.f90

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



More information about the flang-commits mailing list