155 lines · plain
1! REQUIRES: openmp_runtime2 3! RUN: %python %S/../test_errors.py %s %flang_fc1 %openmp_flags -fopenmp-version=504! Semantic checks for various assignments related to atomic constructs5 6program sample7 use omp_lib8 integer :: x, v9 integer :: y(10)10 integer, allocatable :: k11 integer a(10)12 type sample_type13 integer :: y14 integer :: m15 endtype16 type(sample_type) :: z17 character :: l, r18 !$omp atomic read19 v = x20 21 !$omp atomic read22 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches scalar INTEGER(4) and rank 1 array of INTEGER(4)23 !ERROR: Atomic variable y(1_8:3_8:1_8) should be a scalar24 v = y(1:3)25 26 !$omp atomic read27 !ERROR: Atomic expression x*(10_4+x) should be a variable28 v = x * (10 + x)29 30 !$omp atomic read31 !ERROR: Atomic expression 4_4 should be a variable32 v = 433 34 !$omp atomic read35 !ERROR: Atomic variable k cannot be ALLOCATABLE36 v = k37 38 !$omp atomic write39 !ERROR: Atomic variable k cannot be ALLOCATABLE40 k = x41 42 !$omp atomic update43 !ERROR: Atomic variable k cannot be ALLOCATABLE44 k = k + x * (v * x)45 46 !$omp atomic47 !ERROR: Atomic variable k cannot be ALLOCATABLE48 k = v * k 49 50 !$omp atomic write51 !ERROR: Within atomic operation z%y and x+z%y access the same storage52 z%y = x + z%y53 54 !$omp atomic write55 !ERROR: Within atomic operation x and x access the same storage56 x = x57 58 !$omp atomic write59 !ERROR: Within atomic operation m and min(m,x,z%m)+k access the same storage60 m = min(m, x, z%m) + k61 62 !$omp atomic read63 !ERROR: Within atomic operation x and x access the same storage64 x = x65 66 !$omp atomic read67 !ERROR: Atomic expression min(m,x,z%m)+k should be a variable68 m = min(m, x, z%m) + k69 70 !$omp atomic read71 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches scalar INTEGER(4) and rank 1 array of INTEGER(4)72 !ERROR: Atomic variable a should be a scalar73 x = a74 75 !$omp atomic write76 !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches scalar INTEGER(4) and rank 1 array of INTEGER(4)77 x = a78 79 !$omp atomic write80 !ERROR: Atomic variable a should be a scalar81 a = x82 83 !$omp atomic capture84 v = x85 x = x + 186 !$omp end atomic87 88 !$omp atomic release capture89 v = x90 ! This ends up being "x = b + x".91 x = b + (x*1)92 !$omp end atomic93 94 !$omp atomic capture hint(0)95 v = x96 x = 197 !$omp end atomic98 99 !$omp atomic capture100 !ERROR: In ATOMIC UPDATE operation with CAPTURE the right-hand side of the capture assignment should read b101 v = x102 b = b + 1103 !$omp end atomic104 105 !$omp atomic capture106 !ERROR: In ATOMIC UPDATE operation with CAPTURE the right-hand side of the capture assignment should read b107 v = x108 b = 10109 !$omp end atomic110 111 !$omp atomic capture112 x = x + 10113 !ERROR: In ATOMIC UPDATE operation with CAPTURE the right-hand side of the capture assignment should read x114 v = b115 !$omp end atomic116 117 !ERROR: In ATOMIC UPDATE operation with CAPTURE neither statement could be the update or the capture118 !$omp atomic capture119 v = 1120 x = 4121 !$omp end atomic122 123 !$omp atomic capture124 !ERROR: In ATOMIC UPDATE operation with CAPTURE the right-hand side of the capture assignment should read z%m125 x = z%y126 z%m = z%m + 1.0127 !$omp end atomic128 129 !$omp atomic capture130 z%m = z%m + 1.0131 !ERROR: In ATOMIC UPDATE operation with CAPTURE the right-hand side of the capture assignment should read z%m132 x = z%y133 !$omp end atomic134 135 !$omp atomic capture136 !ERROR: In ATOMIC UPDATE operation with CAPTURE the right-hand side of the capture assignment should read y(1_8)137 x = y(2)138 y(1) = y(1) + 1139 !$omp end atomic140 141 !$omp atomic capture142 y(1) = y(1) + 1143 !ERROR: In ATOMIC UPDATE operation with CAPTURE the right-hand side of the capture assignment should read y(1_8)144 x = y(2)145 !$omp end atomic146 147 !$omp atomic read148 !ERROR: Atomic variable r cannot have CHARACTER type149 l = r150 151 !$omp atomic write152 !ERROR: Atomic variable l cannot have CHARACTER type153 l = r154end program155