1! REQUIRES: openmp_runtime 2 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 5 6program 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 20 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) 25 26 !$omp atomic read 27 !ERROR: Expected scalar variable of intrinsic type on RHS of atomic assignment statement 28 v = x * (10 + x) 29 30 !$omp atomic read 31 !ERROR: Expected scalar variable of intrinsic type on RHS of atomic assignment statement 32 v = 4 33 34 !$omp atomic read 35 !ERROR: k must not have ALLOCATABLE attribute 36 v = k 37 38 !$omp atomic write 39 !ERROR: k must not have ALLOCATABLE attribute 40 k = x 41 42 !$omp atomic update 43 !ERROR: k must not have ALLOCATABLE attribute 44 k = k + x * (v * x) 45 46 !$omp atomic 47 !ERROR: k must not have ALLOCATABLE attribute 48 k = v * k 49 50 !$omp atomic write 51 !ERROR: RHS expression on atomic assignment statement cannot access 'z%y' 52 z%y = x + z%y 53 54 !$omp atomic write 55 !ERROR: RHS expression on atomic assignment statement cannot access 'x' 56 x = x 57 58 !$omp atomic write 59 !ERROR: RHS expression on atomic assignment statement cannot access 'm' 60 m = min(m, x, z%m) + k 61 62 !$omp atomic read 63 !ERROR: RHS expression on atomic assignment statement cannot access 'x' 64 x = x 65 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 70 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 75 76 !$omp atomic read 77 !ERROR: Expected scalar variable on the LHS of atomic assignment statement 78 a = x 79 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 84 85 !$omp atomic write 86 !ERROR: Expected scalar variable on the LHS of atomic assignment statement 87 a = x 88 89 !$omp atomic capture 90 v = x 91 x = x + 1 92 !$omp end atomic 93 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 99 100 !$omp atomic capture hint(0) 101 v = x 102 x = 1 103 !$omp end atomic 104 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 110 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 116 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 122 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 128 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 134 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 140 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 146 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 152 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 157 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 162end program 163