1! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp 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 !$omp declare target to (arr1_to) 20 21 !$omp declare target to (blk1_to) 22 23 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 24 !$omp declare target to (a1_to) 25 26 !$omp declare target link (arr1_link) 27 28 !$omp declare target link (blk1_link) 29 30 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 31 !$omp declare target link (a1_link) 32 33 equivalence(eq_a, eq_b) 34 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement 35 !$omp declare target (eq_a) 36 37 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement 38 !$omp declare target to (eq_a) 39 40 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement 41 !$omp declare target link (eq_b) 42 43 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement 44 !$omp declare target (eq_c) 45 46 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement 47 !$omp declare target to (eq_c) 48 49 !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement 50 !$omp declare target link (eq_d) 51 equivalence(eq_c, eq_d) 52 53contains 54 subroutine func() 55 integer :: arr2(10), arr2_to(10), arr2_link(10) 56 integer, save :: arr3(10), arr3_to(10), arr3_link(10) 57 common /blk2/ a2, a2_to, a2_link 58 common /blk3/ a3, a3_to, a3_link 59 save /blk3/ 60 61 !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 62 !$omp declare target (arr2) 63 64 !$omp declare target (arr3) 65 66 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 67 !$omp declare target (a2) 68 69 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 70 !$omp declare target (a3) 71 72 !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 73 !$omp declare target to (arr2_to) 74 75 !$omp declare target to (arr3_to) 76 77 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 78 !$omp declare target to (a2_to) 79 80 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 81 !$omp declare target to (a3_to) 82 83 !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 84 !$omp declare target link (arr2_link) 85 86 !$omp declare target link (arr3_link) 87 88 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 89 !$omp declare target link (a2_link) 90 91 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 92 !$omp declare target link (a3_link) 93 end 94end 95 96module mod4 97 integer :: arr4(10), arr4_to(10), arr4_link(10) 98 common /blk4/ a4, a4_to, a4_link 99 100 !$omp declare target (arr4) 101 102 !$omp declare target (blk4) 103 104 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 105 !$omp declare target (a4) 106 107 !$omp declare target to (arr4_to) 108 109 !$omp declare target to (blk4_to) 110 111 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 112 !$omp declare target to (a4_to) 113 114 !$omp declare target link (arr4_link) 115 116 !$omp declare target link (blk4_link) 117 118 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 119 !$omp declare target link (a4_link) 120end 121 122subroutine func5() 123 integer :: arr5(10), arr5_to(10), arr5_link(10) 124 common /blk5/ a5, a5_to, a5_link 125 126 !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 127 !$omp declare target (arr5) 128 129 !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 130 !$omp declare target (blk5) 131 132 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 133 !$omp declare target (a5) 134 135 !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 136 !$omp declare target to (arr5_to) 137 138 !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 139 !$omp declare target to (blk5_to) 140 141 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 142 !$omp declare target to (a5_to) 143 144 !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 145 !$omp declare target link (arr5_link) 146 147 !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 148 !$omp declare target link (blk5_link) 149 150 !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block 151 !$omp declare target link (a5_link) 152end 153