[clangd] Re-land "support outgoing calls in call hierarchy" (#117673)
[llvm-project.git] / flang / test / Semantics / OpenMP / omp-atomic-assignment-stmt.f90
blob505cbc48fef90119265d84c1417c2e764b19ea25
1 ! REQUIRES: openmp_runtime
3 ! RUN: %python %S/../test_errors.py %s %flang_fc1 %openmp_flags -fopenmp-version=50
4 ! Semantic checks for various assignments related to atomic constructs
6 program sample
7 use omp_lib
8 integer :: x, v
9 integer :: y(10)
10 integer, allocatable :: k
11 integer a(10)
12 type sample_type
13 integer :: y
14 integer :: m
15 endtype
16 type(sample_type) :: z
17 character :: l, r
18 !$omp atomic read
19 v = x
21 !$omp atomic read
22 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches scalar INTEGER(4) and rank 1 array of INTEGER(4)
23 !ERROR: Expected scalar expression on the RHS of atomic assignment statement
24 v = y(1:3)
26 !$omp atomic read
27 !ERROR: Expected scalar variable of intrinsic type on RHS of atomic assignment statement
28 v = x * (10 + x)
30 !$omp atomic read
31 !ERROR: Expected scalar variable of intrinsic type on RHS of atomic assignment statement
32 v = 4
34 !$omp atomic read
35 !ERROR: k must not have ALLOCATABLE attribute
36 v = k
38 !$omp atomic write
39 !ERROR: k must not have ALLOCATABLE attribute
40 k = x
42 !$omp atomic update
43 !ERROR: k must not have ALLOCATABLE attribute
44 k = k + x * (v * x)
46 !$omp atomic
47 !ERROR: k must not have ALLOCATABLE attribute
48 k = v * k
50 !$omp atomic write
51 !ERROR: RHS expression on atomic assignment statement cannot access 'z%y'
52 z%y = x + z%y
54 !$omp atomic write
55 !ERROR: RHS expression on atomic assignment statement cannot access 'x'
56 x = x
58 !$omp atomic write
59 !ERROR: RHS expression on atomic assignment statement cannot access 'm'
60 m = min(m, x, z%m) + k
62 !$omp atomic read
63 !ERROR: RHS expression on atomic assignment statement cannot access 'x'
64 x = x
66 !$omp atomic read
67 !ERROR: Expected scalar variable of intrinsic type on RHS of atomic assignment statement
68 !ERROR: RHS expression on atomic assignment statement cannot access 'm'
69 m = min(m, x, z%m) + k
71 !$omp atomic read
72 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches scalar INTEGER(4) and rank 1 array of INTEGER(4)
73 !ERROR: Expected scalar expression on the RHS of atomic assignment statement
74 x = a
76 !$omp atomic read
77 !ERROR: Expected scalar variable on the LHS of atomic assignment statement
78 a = x
80 !$omp atomic write
81 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches scalar INTEGER(4) and rank 1 array of INTEGER(4)
82 !ERROR: Expected scalar expression on the RHS of atomic assignment statement
83 x = a
85 !$omp atomic write
86 !ERROR: Expected scalar variable on the LHS of atomic assignment statement
87 a = x
89 !$omp atomic capture
90 v = x
91 x = x + 1
92 !$omp end atomic
94 !$omp atomic release capture
95 v = x
96 !ERROR: Atomic update statement should be of form `x = x operator expr` OR `x = expr operator x`
97 x = b + (x*1)
98 !$omp end atomic
100 !$omp atomic capture hint(0)
101 v = x
102 x = 1
103 !$omp end atomic
105 !$omp atomic capture
106 !ERROR: Captured variable/array element/derived-type component x expected to be assigned in the second statement of ATOMIC CAPTURE construct
107 v = x
108 b = b + 1
109 !$omp end atomic
111 !$omp atomic capture
112 !ERROR: Captured variable/array element/derived-type component x expected to be assigned in the second statement of ATOMIC CAPTURE construct
113 v = x
114 b = 10
115 !$omp end atomic
117 !$omp atomic capture
118 !ERROR: Updated variable/array element/derived-type component x expected to be captured in the second statement of ATOMIC CAPTURE construct
119 x = x + 10
120 v = b
121 !$omp end atomic
123 !$omp atomic capture
124 !ERROR: Invalid ATOMIC CAPTURE construct statements. Expected one of [update-stmt, capture-stmt], [capture-stmt, update-stmt], or [capture-stmt, write-stmt]
125 v = 1
126 x = 4
127 !$omp end atomic
129 !$omp atomic capture
130 !ERROR: Captured variable/array element/derived-type component z%y expected to be assigned in the second statement of ATOMIC CAPTURE construct
131 x = z%y
132 z%m = z%m + 1.0
133 !$omp end atomic
135 !$omp atomic capture
136 !ERROR: Updated variable/array element/derived-type component z%m expected to be captured in the second statement of ATOMIC CAPTURE construct
137 z%m = z%m + 1.0
138 x = z%y
139 !$omp end atomic
141 !$omp atomic capture
142 !ERROR: Captured variable/array element/derived-type component y(2) expected to be assigned in the second statement of ATOMIC CAPTURE construct
143 x = y(2)
144 y(1) = y(1) + 1
145 !$omp end atomic
147 !$omp atomic capture
148 !ERROR: Updated variable/array element/derived-type component y(1) expected to be captured in the second statement of ATOMIC CAPTURE construct
149 y(1) = y(1) + 1
150 x = y(2)
151 !$omp end atomic
153 !$omp atomic read
154 !ERROR: Expected scalar variable on the LHS of atomic assignment statement
155 !ERROR: Expected scalar expression on the RHS of atomic assignment statement
156 l = r
158 !$omp atomic write
159 !ERROR: Expected scalar variable on the LHS of atomic assignment statement
160 !ERROR: Expected scalar expression on the RHS of atomic assignment statement
161 l = r
162 end program