[flang-commits] [PATCH] D136804: [flang] Add atomic_fetch_xor to list of intrinsics

Katherine Rasmussen via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Oct 27 17:30:28 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG7aa0968842c5: [flang] Add atomic_fetch_xor to list of intrinsics (authored by ktras).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136804/new/

https://reviews.llvm.org/D136804

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


Index: flang/test/Semantics/atomic08.f90
===================================================================
--- flang/test/Semantics/atomic08.f90
+++ flang/test/Semantics/atomic08.f90
@@ -1,18 +1,19 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1
-! XFAIL: *
 ! This test checks for semantic errors in atomic_fetch_xor subroutine calls based on
 ! the interface defined in section 16.9.27 of the Fortran 2018 standard.
 
 program test_atomic_fetch_xor
-  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, old_val, non_coarray
   integer(kind=atomic_int_kind) :: repeated_atom[*], repeated_old, repeated_val, array(10)
-  integer :: status, default_kind_coarray[*], not_same_kind_as_atom, coindexed_status[*], extra_arg, repeated_status, status_array(10)
+  integer :: status, default_kind_coarray[*], not_same_kind_as_atom, coindexed_status[*]
+  integer :: extra_arg, repeated_status, status_array(10)
   integer(kind=1) :: kind1_coarray[*]
   real :: non_integer_coarray[*], not_same_type_as_atom
   logical :: non_integer
+  logical(kind=atomic_logical_kind) :: atomic_logical[*], old_logical
 
   !___ standard-conforming calls ___
   call atomic_fetch_xor(scalar_coarray, val, old_val)
@@ -24,15 +25,24 @@
 
   !___ non-standard-conforming calls ___
 
-  !ERROR: 'atom=' argument must be a scalar coarray for intrinsic 'atomic_fetch_xor'
+  !ERROR: Actual argument for 'atom=' has bad type 'LOGICAL(8)'
+  call atomic_fetch_xor(atomic_logical, val, old_logical)
+
+  !ERROR: Actual argument for 'old=' has bad type 'LOGICAL(8)'
+  call atomic_fetch_xor(scalar_coarray, val, old_logical)
+
+  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_fetch_xor'
   call atomic_fetch_xor(non_scalar_coarray, val, old_val)
 
-  !ERROR: 'atom=' argument must be a coarray or a coindexed object for intrinsic 'atomic_fetch_xor'
+  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_fetch_xor'
   call atomic_fetch_xor(non_coarray, val, old_val)
 
-  !ERROR: 'atom=' argument must be a coarray or a coindexed object for intrinsic 'atomic_fetch_xor'
+  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_fetch_xor'
   call atomic_fetch_xor(array, val, old_val)
 
+  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_fetch_xor'
+  call atomic_fetch_xor(non_scalar_coarray[1], val, old_val)
+
   !ERROR: Actual argument for 'atom=' must have kind=atomic_int_kind, but is 'INTEGER(4)'
   call atomic_fetch_xor(default_kind_coarray, val, old_val)
 
@@ -66,6 +76,7 @@
   !ERROR: 'stat=' argument has unacceptable rank 1
   call atomic_fetch_xor(scalar_coarray, val, old_val, status_array)
 
+  !ERROR: 'stat' argument to 'atomic_fetch_xor' may not be a coindexed object
   call atomic_fetch_xor(scalar_coarray, val, old_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
@@ -1154,6 +1154,16 @@
             {"stat", AnyInt, Rank::scalar, Optionality::optional,
                 common::Intent::Out}},
         {}, Rank::elemental, IntrinsicClass::atomicSubroutine},
+    {"atomic_fetch_xor",
+        {{"atom", AtomicInt, Rank::atom, Optionality::required,
+             common::Intent::InOut},
+            {"value", AnyInt, Rank::scalar, Optionality::required,
+                common::Intent::In},
+            {"old", AtomicInt, Rank::scalar, Optionality::required,
+                common::Intent::Out},
+            {"stat", AnyInt, Rank::scalar, Optionality::optional,
+                common::Intent::Out}},
+        {}, Rank::elemental, IntrinsicClass::atomicSubroutine},
     {"atomic_ref",
         {{"value", AnyIntOrLogical, Rank::scalar, Optionality::required,
              common::Intent::Out},
@@ -2681,7 +2691,7 @@
     return CheckAtomicDefineAndRef(
         context, call.arguments[0], call.arguments[1], call.arguments[2], name);
   } else if (name == "atomic_fetch_add" || name == "atomic_fetch_and" ||
-      name == "atomic_fetch_or") {
+      name == "atomic_fetch_or" || name == "atomic_fetch_xor") {
     return CheckForCoindexedObject(context, call.arguments[3], name, "stat");
   } else if (name == "atomic_ref") {
     return CheckAtomicDefineAndRef(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136804.471339.patch
Type: text/x-patch
Size: 4661 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221028/d0692018/attachment-0001.bin>


More information about the flang-commits mailing list