[flang-commits] [flang] 7aa0968 - [flang] Add atomic_fetch_xor to list of intrinsics
Katherine Rasmussen via flang-commits
flang-commits at lists.llvm.org
Thu Oct 27 17:30:25 PDT 2022
Author: Katherine Rasmussen
Date: 2022-10-27T17:07:25-07:00
New Revision: 7aa0968842c5c36595042257009d1dc1a244ff6a
URL: https://github.com/llvm/llvm-project/commit/7aa0968842c5c36595042257009d1dc1a244ff6a
DIFF: https://github.com/llvm/llvm-project/commit/7aa0968842c5c36595042257009d1dc1a244ff6a.diff
LOG: [flang] Add atomic_fetch_xor to list of intrinsics
Add the atomic subroutine, atomic_fetch_xor, to the list of
intrinsic subroutines, add its last dummy argument to a check
for coindexed-object, and update test.
Reviewed By: PeteSteinfeld
Differential Revision: https://reviews.llvm.org/D136804
Added:
Modified:
flang/lib/Evaluate/intrinsics.cpp
flang/test/Semantics/atomic08.f90
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index a31609ed79c18..e4400d6b18792 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -1154,6 +1154,16 @@ static const IntrinsicInterface intrinsicSubroutine[]{
{"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 @@ static bool ApplySpecificChecks(SpecificCall &call, FoldingContext &context) {
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(
diff --git a/flang/test/Semantics/atomic08.f90 b/flang/test/Semantics/atomic08.f90
index 0af0a4465f371..8d4110c9acfd5 100644
--- a/flang/test/Semantics/atomic08.f90
+++ b/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 @@ program test_atomic_fetch_xor
!___ 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 @@ program test_atomic_fetch_xor
!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
More information about the flang-commits
mailing list