[flang-commits] [flang] adb2ba5 - [flang] Write semantics test for atomic_xor

Katherine Rasmussen via flang-commits flang-commits at lists.llvm.org
Wed Sep 21 15:55:00 PDT 2022


Author: Katherine Rasmussen
Date: 2022-09-21T15:50:14-07:00
New Revision: adb2ba5ca3b601bc665eedee53a72abe531ad311

URL: https://github.com/llvm/llvm-project/commit/adb2ba5ca3b601bc665eedee53a72abe531ad311
DIFF: https://github.com/llvm/llvm-project/commit/adb2ba5ca3b601bc665eedee53a72abe531ad311.diff

LOG: [flang] Write semantics test for atomic_xor

Write a semantics test for the atomic intrinsic subroutine,
atomic_xor.

Reviewed By: rouson

Differential Revision: https://reviews.llvm.org/D134298

Added: 
    flang/test/Semantics/atomic11.f90

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/flang/test/Semantics/atomic11.f90 b/flang/test/Semantics/atomic11.f90
new file mode 100644
index 0000000000000..d46c7af1b03b5
--- /dev/null
+++ b/flang/test/Semantics/atomic11.f90
@@ -0,0 +1,107 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+! XFAIL: *
+! This test checks for semantic errors in atomic_xor subroutine calls based on
+! the interface defined in section 16.9.30 of the Fortran 2018 standard.
+
+program test_atomic_xor
+  use iso_fortran_env, only: atomic_int_kind
+  implicit none
+
+  integer(kind=atomic_int_kind) :: scalar_coarray[*], non_scalar_coarray(10)[*], val, non_coarray
+  integer(kind=atomic_int_kind) :: repeated_atom[*], repeated_val, array(10)
+  integer :: status, default_kind_coarray[*], coindexed_status[*], extra_arg, repeated_status, status_array(10)
+  integer(kind=1) :: kind1_coarray[*]
+  real :: non_integer_coarray[*]
+  logical :: non_integer
+
+  !___ standard-conforming calls ___
+  call atomic_xor(scalar_coarray, val)
+  call atomic_xor(scalar_coarray[1], val)
+  call atomic_xor(scalar_coarray, val, status)
+  call atomic_xor(scalar_coarray[1], val, status)
+  call atomic_xor(scalar_coarray, val, stat=status)
+  call atomic_xor(scalar_coarray, value=val, stat=status)
+  call atomic_xor(atom=scalar_coarray, value=val)
+  call atomic_xor(atom=scalar_coarray, value=val, stat=status)
+  call atomic_xor(stat=status, value=val, atom=scalar_coarray)
+
+  !___ non-standard-conforming calls ___
+
+  !ERROR: 'atom=' argument must be a scalar coarray for intrinsic 'atomic_xor'
+  call atomic_xor(non_scalar_coarray, val)
+
+  !ERROR: 'atom=' argument must be a coarray or a coindexed object for intrinsic 'atomic_xor'
+  call atomic_xor(non_coarray, val)
+
+  !ERROR: 'atom=' argument must be a coarray or a coindexed object for intrinsic 'atomic_xor'
+  call atomic_xor(array, val)
+
+  !ERROR: Actual argument for 'atom=' must have kind=atomic_int_kind, but is 'INTEGER(4)'
+  call atomic_xor(default_kind_coarray, val)
+
+  !ERROR: Actual argument for 'atom=' must have kind=atomic_int_kind, but is 'INTEGER(1)'
+  call atomic_xor(kind1_coarray, val)
+
+  !ERROR: Actual argument for 'atom=' has bad type 'REAL(4)'
+  call atomic_xor(non_integer_coarray, val)
+
+  !ERROR: 'value=' argument has unacceptable rank 1
+  call atomic_xor(scalar_coarray, array)
+
+  !ERROR: Actual argument for 'value=' has bad type 'LOGICAL(4)'
+  call atomic_xor(scalar_coarray, non_integer)
+
+  !ERROR: Actual argument for 'stat=' has bad type 'LOGICAL(4)'
+  call atomic_xor(scalar_coarray, val, non_integer)
+
+  !ERROR: 'stat=' argument has unacceptable rank 1
+  call atomic_xor(scalar_coarray, val, status_array)
+
+  call atomic_xor(scalar_coarray, val, coindexed_status[1])
+
+  !ERROR: Actual argument associated with INTENT(OUT) dummy argument 'stat=' must be definable
+  call atomic_xor(scalar_coarray, val, 1)
+
+  !ERROR: missing mandatory 'atom=' argument
+  call atomic_xor()
+
+  !ERROR: missing mandatory 'atom=' argument
+  call atomic_xor(value=val, stat=status)
+
+  !ERROR: missing mandatory 'value=' argument
+  call atomic_xor(scalar_coarray)
+
+  !ERROR: missing mandatory 'value=' argument
+  call atomic_xor(atom=scalar_coarray, stat=status)
+
+  !ERROR: too many actual arguments for intrinsic 'atomic_xor'
+  call atomic_xor(scalar_coarray, val, status, extra_arg)
+
+  !ERROR: repeated keyword argument to intrinsic 'atomic_xor'
+  call atomic_xor(atom=scalar_coarray, atom=repeated_atom, value=val, stat=status)
+
+  !ERROR: repeated keyword argument to intrinsic 'atomic_xor'
+  call atomic_xor(atom=scalar_coarray, value=val, value=repeated_val, stat=status)
+
+  !ERROR: repeated keyword argument to intrinsic 'atomic_xor'
+  call atomic_xor(atom=scalar_coarray, value=val, stat=status, stat=repeated_status)
+
+  !ERROR: unknown keyword argument to intrinsic 'atomic_xor'
+  call atomic_xor(atomic=scalar_coarray, value=val, stat=status)
+
+  !ERROR: unknown keyword argument to intrinsic 'atomic_xor'
+  call atomic_xor(atom=scalar_coarray, values=val, stat=status)
+
+  !ERROR: unknown keyword argument to intrinsic 'atomic_xor'
+  call atomic_xor(atom=scalar_coarray, value=val, status=status)
+
+  !ERROR: keyword argument to intrinsic 'atomic_xor' was supplied positionally by an earlier actual argument
+  call atomic_xor(scalar_coarray, val, atom=repeated_atom)
+
+  !ERROR: keyword argument to intrinsic 'atomic_xor' was supplied positionally by an earlier actual argument
+  call atomic_xor(scalar_coarray, val, value=repeated_val)
+
+  !ERROR: keyword argument to intrinsic 'atomic_xor' was supplied positionally by an earlier actual argument
+  call atomic_xor(scalar_coarray, val, status, stat=repeated_status)
+
+end program test_atomic_xor


        


More information about the flang-commits mailing list