[flang-commits] [PATCH] D137097: [flang] Add atomic_or to list of intrinsics

Katherine Rasmussen via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Oct 31 11:13:37 PDT 2022


ktras created this revision.
ktras added reviewers: klausler, jeanPerier, PeteSteinfeld, rouson, hussainjk, pmccormick, sscalpone.
ktras added projects: Flang, LLVM.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
ktras requested review of this revision.

Add the atomic subroutine, `atomic_or`, to the list of
intrinsic subroutines, add its last dummy argument to a check
for a `coindexed-object`, and update test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137097

Files:
  flang/lib/Evaluate/intrinsics.cpp
  flang/test/Semantics/atomic09.f90


Index: flang/test/Semantics/atomic09.f90
===================================================================
--- flang/test/Semantics/atomic09.f90
+++ flang/test/Semantics/atomic09.f90
@@ -1,10 +1,9 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1
-! XFAIL: *
 ! This test checks for semantic errors in atomic_or subroutine calls based on
 ! the interface defined in section 16.9.28 of the Fortran 2018 standard.
 
 program test_atomic_or
-  use iso_fortran_env, only: atomic_int_kind
+  use iso_fortran_env, only: atomic_int_kind, atomic_logical_kind
   implicit none
 
   integer(kind=atomic_int_kind) :: scalar_coarray[*], non_scalar_coarray(10)[*], val, non_coarray
@@ -13,6 +12,7 @@
   integer(kind=1) :: kind1_coarray[*]
   real :: non_integer_coarray[*]
   logical :: non_integer
+  logical(atomic_logical_kind) :: atomic_logical[*]
 
   !___ standard-conforming calls ___
   call atomic_or(scalar_coarray, val)
@@ -27,13 +27,16 @@
 
   !___ non-standard-conforming calls ___
 
-  !ERROR: 'atom=' argument must be a scalar coarray for intrinsic 'atomic_or'
+  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_or'
   call atomic_or(non_scalar_coarray, val)
 
-  !ERROR: 'atom=' argument must be a coarray or a coindexed object for intrinsic 'atomic_or'
+  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_or'
+  call atomic_or(non_scalar_coarray[1], val)
+
+  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_or'
   call atomic_or(non_coarray, val)
 
-  !ERROR: 'atom=' argument must be a coarray or a coindexed object for intrinsic 'atomic_or'
+  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_or'
   call atomic_or(array, val)
 
   !ERROR: Actual argument for 'atom=' must have kind=atomic_int_kind, but is 'INTEGER(4)'
@@ -45,6 +48,9 @@
   !ERROR: Actual argument for 'atom=' has bad type 'REAL(4)'
   call atomic_or(non_integer_coarray, val)
 
+  !ERROR: Actual argument for 'atom=' has bad type 'LOGICAL(8)'
+  call atomic_or(atomic_logical, val)
+
   !ERROR: 'value=' argument has unacceptable rank 1
   call atomic_or(scalar_coarray, array)
 
@@ -57,6 +63,7 @@
   !ERROR: 'stat=' argument has unacceptable rank 1
   call atomic_or(scalar_coarray, val, status_array)
 
+  !ERROR: 'stat' argument to 'atomic_or' may not be a coindexed object
   call atomic_or(scalar_coarray, val, coindexed_status[1])
 
   !ERROR: Actual argument associated with INTENT(OUT) dummy argument 'stat=' must be definable
Index: flang/lib/Evaluate/intrinsics.cpp
===================================================================
--- flang/lib/Evaluate/intrinsics.cpp
+++ flang/lib/Evaluate/intrinsics.cpp
@@ -1211,6 +1211,14 @@
             {"stat", AnyInt, Rank::scalar, Optionality::optional,
                 common::Intent::Out}},
         {}, Rank::elemental, IntrinsicClass::atomicSubroutine},
+    {"atomic_or",
+        {{"atom", AtomicInt, Rank::atom, Optionality::required,
+             common::Intent::InOut},
+            {"value", AnyInt, Rank::scalar, Optionality::required,
+                common::Intent::In},
+            {"stat", AnyInt, Rank::scalar, Optionality::optional,
+                common::Intent::Out}},
+        {}, Rank::elemental, IntrinsicClass::atomicSubroutine},
     {"atomic_ref",
         {{"value", AnyIntOrLogical, Rank::scalar, Optionality::required,
              common::Intent::Out},
@@ -2742,7 +2750,7 @@
     }
   } else if (name == "associated") {
     return CheckAssociated(call, context);
-  } else if (name == "atomic_and") {
+  } else if (name == "atomic_and" || name == "atomic_or") {
     return CheckForCoindexedObject(context, call.arguments[2], name, "stat");
   } else if (name == "atomic_cas") {
     return CheckForCoindexedObject(context, call.arguments[4], name, "stat");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137097.472075.patch
Type: text/x-patch
Size: 3903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221031/ec7ae667/attachment.bin>


More information about the flang-commits mailing list