1! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp -fopenmp-version=52 2! OpenMP Version 5.1 3! Check OpenMP construct validity for the following directives: 4! 2.14.7 Declare Target Directive 5 6program declare_target02 7 integer :: arr1(10), arr1_to(10), arr1_link(10) 8 common /blk1/ a1, a1_to, a1_link 9 real, save :: eq_a, eq_b, eq_c, eq_d 10 11 12 !$omp declare target (arr1) 13 14 !$omp declare target (blk1) 15 16 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 17 !$omp declare target (a1) 18 19 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 20 !$omp declare target to (arr1_to) 21 22 !$omp declare target enter (arr1_to) 23 24 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 25 !$omp declare target to (blk1_to) 26 27 !$omp declare target enter (blk1_to) 28 29 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 30 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 31 !$omp declare target to (a1_to) 32 33 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 34 !$omp declare target enter (a1_to) 35 36 !$omp declare target link (arr1_link) 37 38 !$omp declare target link (blk1_link) 39 40 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 41 !$omp declare target link (a1_link) 42 43 equivalence(eq_a, eq_b) 44 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement 45 !$omp declare target (eq_a) 46 47 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 48 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement 49 !$omp declare target to (eq_a) 50 51 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement 52 !$omp declare target enter (eq_a) 53 54 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement 55 !$omp declare target link (eq_b) 56 57 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement 58 !$omp declare target (eq_c) 59 60 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 61 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement 62 !$omp declare target to (eq_c) 63 64 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement 65 !$omp declare target enter (eq_c) 66 67 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement 68 !$omp declare target link (eq_d) 69 equivalence(eq_c, eq_d) 70 71contains 72 subroutine func() 73 integer :: arr2(10), arr2_to(10), arr2_link(10) 74 integer, save :: arr3(10), arr3_to(10), arr3_link(10) 75 common /blk2/ a2, a2_to, a2_link 76 common /blk3/ a3, a3_to, a3_link 77 save /blk3/ 78 79 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly 80 !$omp declare target (arr2) 81 82 !$omp declare target (arr3) 83 84 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 85 !$omp declare target (a2) 86 87 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 88 !$omp declare target (a3) 89 90 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 91 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly 92 !$omp declare target to (arr2_to) 93 94 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly 95 !$omp declare target enter (arr2_to) 96 97 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 98 !$omp declare target to (arr3_to) 99 100 !$omp declare target enter (arr3_to) 101 102 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 103 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 104 !$omp declare target to (a2_to) 105 106 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 107 !$omp declare target enter (a2_to) 108 109 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 110 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 111 !$omp declare target to (a3_to) 112 113 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 114 !$omp declare target enter (a3_to) 115 116 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly 117 !$omp declare target link (arr2_link) 118 119 !$omp declare target link (arr3_link) 120 121 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 122 !$omp declare target link (a2_link) 123 124 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 125 !$omp declare target link (a3_link) 126 end 127end 128 129module mod4 130 integer :: arr4(10), arr4_to(10), arr4_link(10) 131 common /blk4/ a4, a4_to, a4_link 132 133 !$omp declare target (arr4) 134 135 !$omp declare target (blk4) 136 137 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 138 !$omp declare target (a4) 139 140 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 141 !$omp declare target to (arr4_to) 142 143 !$omp declare target enter (arr4_to) 144 145 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 146 !$omp declare target to (blk4_to) 147 !$omp declare target enter (blk4_to) 148 149 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 150 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 151 !$omp declare target to (a4_to) 152 153 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 154 !$omp declare target enter (a4_to) 155 156 !$omp declare target link (arr4_link) 157 158 !$omp declare target link (blk4_link) 159 160 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 161 !$omp declare target link (a4_link) 162end 163 164subroutine func5() 165 integer :: arr5(10), arr5_to(10), arr5_link(10) 166 common /blk5/ a5, a5_to, a5_link 167 168 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly 169 !$omp declare target (arr5) 170 171 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly 172 !$omp declare target (blk5) 173 174 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 175 !$omp declare target (a5) 176 177 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 178 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly 179 !$omp declare target to (arr5_to) 180 181 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly 182 !$omp declare target enter (arr5_to) 183 184 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 185 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly 186 !$omp declare target to (blk5_to) 187 188 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly 189 !$omp declare target enter (blk5_to) 190 191 !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead. 192 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 193 !$omp declare target to (a5_to) 194 195 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 196 !$omp declare target enter (a5_to) 197 198 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly 199 !$omp declare target link (arr5_link) 200 201 !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly 202 !$omp declare target link (blk5_link) 203 204 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 205 !$omp declare target link (a5_link) 206end 207