xref: /llvm-project/flang/test/Semantics/atomic02.f90 (revision 512b44d5e1534ef60b5db7a99818e1021cf6064c)
1e13b273dSKatherine Rasmussen! RUN: %python %S/test_errors.py %s %flang_fc1
2e13b273dSKatherine Rasmussen! This test checks for semantic errors in atomic_and subroutine calls based on
3e13b273dSKatherine Rasmussen! the interface defined in section 16.9.21 of the Fortran 2018 standard.
4e13b273dSKatherine Rasmussen
5e13b273dSKatherine Rasmussenprogram test_atomic_and
6cc2e8e50SKatherine Rasmussen  use iso_fortran_env, only: atomic_int_kind, atomic_logical_kind
7*512b44d5SPeter Klausler  implicit none(external, type)
8e13b273dSKatherine Rasmussen
9e13b273dSKatherine Rasmussen  integer(kind=atomic_int_kind) :: scalar_coarray[*], non_scalar_coarray(10)[*], val, non_coarray
10e13b273dSKatherine Rasmussen  integer(kind=atomic_int_kind) :: repeated_atom[*], repeated_val, array(10)
11e13b273dSKatherine Rasmussen  integer :: status, default_kind_coarray[*], coindexed_status[*], extra_arg, repeated_status, status_array(10)
12e13b273dSKatherine Rasmussen  integer(kind=1) :: kind1_coarray[*]
13e13b273dSKatherine Rasmussen  real :: non_integer_coarray[*]
14e13b273dSKatherine Rasmussen  logical :: non_integer
15cc2e8e50SKatherine Rasmussen  logical(atomic_logical_kind) :: atomic_logical[*]
16e13b273dSKatherine Rasmussen
17e13b273dSKatherine Rasmussen  !___ standard-conforming calls ___
18e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray, val)
19e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray[1], val)
20e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray, val, status)
21e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray[1], val, status)
22e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray, val, stat=status)
23e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray, value=val, stat=status)
24e13b273dSKatherine Rasmussen  call atomic_and(atom=scalar_coarray, value=val)
25e13b273dSKatherine Rasmussen  call atomic_and(atom=scalar_coarray, value=val, stat=status)
26e13b273dSKatherine Rasmussen  call atomic_and(stat=status, value=val, atom=scalar_coarray)
27e13b273dSKatherine Rasmussen
28e13b273dSKatherine Rasmussen  !___ non-standard-conforming calls ___
29e13b273dSKatherine Rasmussen
30cc2e8e50SKatherine Rasmussen  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_and'
31e13b273dSKatherine Rasmussen  call atomic_and(non_scalar_coarray, val)
32e13b273dSKatherine Rasmussen
33cc2e8e50SKatherine Rasmussen  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_and'
34cc2e8e50SKatherine Rasmussen  call atomic_and(non_scalar_coarray[1], val)
35cc2e8e50SKatherine Rasmussen
36cc2e8e50SKatherine Rasmussen  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_and'
37e13b273dSKatherine Rasmussen  call atomic_and(non_coarray, val)
38e13b273dSKatherine Rasmussen
39cc2e8e50SKatherine Rasmussen  !ERROR: 'atom=' argument must be a scalar coarray or coindexed object for intrinsic 'atomic_and'
40e13b273dSKatherine Rasmussen  call atomic_and(array, val)
41e13b273dSKatherine Rasmussen
42e13b273dSKatherine Rasmussen  !ERROR: Actual argument for 'atom=' must have kind=atomic_int_kind, but is 'INTEGER(4)'
43e13b273dSKatherine Rasmussen  call atomic_and(default_kind_coarray, val)
44e13b273dSKatherine Rasmussen
45e13b273dSKatherine Rasmussen  !ERROR: Actual argument for 'atom=' must have kind=atomic_int_kind, but is 'INTEGER(1)'
46e13b273dSKatherine Rasmussen  call atomic_and(kind1_coarray, val)
47e13b273dSKatherine Rasmussen
48e13b273dSKatherine Rasmussen  !ERROR: Actual argument for 'atom=' has bad type 'REAL(4)'
49e13b273dSKatherine Rasmussen  call atomic_and(non_integer_coarray, val)
50e13b273dSKatherine Rasmussen
51cc2e8e50SKatherine Rasmussen  !ERROR: Actual argument for 'atom=' has bad type 'LOGICAL(8)'
52cc2e8e50SKatherine Rasmussen  call atomic_and(atomic_logical, val)
53cc2e8e50SKatherine Rasmussen
54e13b273dSKatherine Rasmussen  !ERROR: 'value=' argument has unacceptable rank 1
55e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray, array)
56e13b273dSKatherine Rasmussen
57e13b273dSKatherine Rasmussen  !ERROR: Actual argument for 'value=' has bad type 'LOGICAL(4)'
58e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray, non_integer)
59e13b273dSKatherine Rasmussen
60e13b273dSKatherine Rasmussen  !ERROR: Actual argument for 'stat=' has bad type 'LOGICAL(4)'
61e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray, val, non_integer)
62e13b273dSKatherine Rasmussen
63e13b273dSKatherine Rasmussen  !ERROR: 'stat=' argument has unacceptable rank 1
64e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray, val, status_array)
65e13b273dSKatherine Rasmussen
66cc2e8e50SKatherine Rasmussen  !ERROR: 'stat' argument to 'atomic_and' may not be a coindexed object
67e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray, val, coindexed_status[1])
68e13b273dSKatherine Rasmussen
69573fc618SPeter Klausler  !ERROR: Actual argument associated with INTENT(OUT) dummy argument 'stat=' is not definable
70573fc618SPeter Klausler  !BECAUSE: '1_4' is not a variable or pointer
71e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray, val, 1)
72e13b273dSKatherine Rasmussen
73e13b273dSKatherine Rasmussen  !ERROR: missing mandatory 'atom=' argument
74e13b273dSKatherine Rasmussen  call atomic_and()
75e13b273dSKatherine Rasmussen
76e13b273dSKatherine Rasmussen  !ERROR: missing mandatory 'atom=' argument
77e13b273dSKatherine Rasmussen  call atomic_and(value=val, stat=status)
78e13b273dSKatherine Rasmussen
79e13b273dSKatherine Rasmussen  !ERROR: missing mandatory 'value=' argument
80e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray)
81e13b273dSKatherine Rasmussen
82e13b273dSKatherine Rasmussen  !ERROR: missing mandatory 'value=' argument
83e13b273dSKatherine Rasmussen  call atomic_and(atom=scalar_coarray, stat=status)
84e13b273dSKatherine Rasmussen
85e13b273dSKatherine Rasmussen  !ERROR: too many actual arguments for intrinsic 'atomic_and'
86e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray, val, status, extra_arg)
87e13b273dSKatherine Rasmussen
88e13b273dSKatherine Rasmussen  !ERROR: repeated keyword argument to intrinsic 'atomic_and'
89e13b273dSKatherine Rasmussen  call atomic_and(atom=scalar_coarray, atom=repeated_atom, value=val, stat=status)
90e13b273dSKatherine Rasmussen
91e13b273dSKatherine Rasmussen  !ERROR: repeated keyword argument to intrinsic 'atomic_and'
92e13b273dSKatherine Rasmussen  call atomic_and(atom=scalar_coarray, value=val, value=repeated_val, stat=status)
93e13b273dSKatherine Rasmussen
94e13b273dSKatherine Rasmussen  !ERROR: repeated keyword argument to intrinsic 'atomic_and'
95e13b273dSKatherine Rasmussen  call atomic_and(atom=scalar_coarray, value=val, stat=status, stat=repeated_status)
96e13b273dSKatherine Rasmussen
97e13b273dSKatherine Rasmussen  !ERROR: unknown keyword argument to intrinsic 'atomic_and'
98e13b273dSKatherine Rasmussen  call atomic_and(atomic=scalar_coarray, value=val, stat=status)
99e13b273dSKatherine Rasmussen
100e13b273dSKatherine Rasmussen  !ERROR: unknown keyword argument to intrinsic 'atomic_and'
101e13b273dSKatherine Rasmussen  call atomic_and(atom=scalar_coarray, values=val, stat=status)
102e13b273dSKatherine Rasmussen
103e13b273dSKatherine Rasmussen  !ERROR: unknown keyword argument to intrinsic 'atomic_and'
104e13b273dSKatherine Rasmussen  call atomic_and(atom=scalar_coarray, value=val, status=status)
105e13b273dSKatherine Rasmussen
106e13b273dSKatherine Rasmussen  !ERROR: keyword argument to intrinsic 'atomic_and' was supplied positionally by an earlier actual argument
107e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray, val, atom=repeated_atom)
108e13b273dSKatherine Rasmussen
109e13b273dSKatherine Rasmussen  !ERROR: keyword argument to intrinsic 'atomic_and' was supplied positionally by an earlier actual argument
110e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray, val, value=repeated_val)
111e13b273dSKatherine Rasmussen
112e13b273dSKatherine Rasmussen  !ERROR: keyword argument to intrinsic 'atomic_and' was supplied positionally by an earlier actual argument
113e13b273dSKatherine Rasmussen  call atomic_and(scalar_coarray, val, status, stat=repeated_status)
114e13b273dSKatherine Rasmussen
115e13b273dSKatherine Rasmussenend program test_atomic_and
116