1 // RUN: %clang_cc1 -verify=expected,lt50,lt51 -fopenmp -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized 2 // RUN: %clang_cc1 -verify=expected,ge50,lt51 -fopenmp -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized 3 // RUN: %clang_cc1 -verify=expected,ge50,ge51 -fopenmp -fopenmp-version=51 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized 4 5 // RUN: %clang_cc1 -verify=expected,lt50,lt51 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized 6 // RUN: %clang_cc1 -verify=expected,ge50,lt51 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized 7 // RUN: %clang_cc1 -verify=expected,ge50,ge51 -fopenmp-simd -fopenmp-version=51 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized 8 9 void xxx(int argc) { 10 int x; // expected-note {{initialize the variable 'x' to silence this warning}} 11 #pragma omp target update to(x) 12 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}} 13 } 14 15 void foo() { 16 } 17 18 bool foobool(int argc) { 19 return argc; 20 } 21 22 struct S1; // Aexpected-note {{declared here}} 23 24 template <class T, class S> // Aexpected-note {{declared here}} 25 int tmain(T argc, S **argv) { 26 int n; 27 return 0; 28 } 29 30 struct S { 31 int i; 32 }; 33 34 int main(int argc, char **argv) { 35 int m; 36 #pragma omp target update // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 37 #pragma omp target update to(m) { // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} 38 #pragma omp target update to(m) ( // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} 39 #pragma omp target update to(m) [ // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} 40 #pragma omp target update to(m) ] // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} 41 #pragma omp target update to(m) ) // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} 42 43 #pragma omp declare mapper(id: S s) map(s.i) 44 S s; 45 46 // Check parsing with no modifiers. 47 // lt51-error@+2 {{expected expression}} 48 // lt51-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 49 #pragma omp target update to(: s) 50 // expected-error@+2 {{expected expression}} 51 // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 52 #pragma omp target update to(:) 53 // expected-error@+2 2 {{expected expression}} 54 // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 55 #pragma omp target update to(,:) 56 57 // Check parsing with one modifier. 58 // expected-error@+2 {{use of undeclared identifier 'foobar'}} 59 // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 60 #pragma omp target update to(foobar: s) 61 // expected-error@+3 {{expected ',' or ')' in 'to' clause}} 62 // expected-error@+2 {{expected ')'}} 63 // expected-note@+1 {{to match this '('}} 64 #pragma omp target update to(m: s) 65 #pragma omp target update to(mapper(id): s) 66 // lt51-error@+2 {{use of undeclared identifier 'present'}} 67 // lt51-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 68 #pragma omp target update to(present: s) 69 // ge51-warning@+4 {{missing ':' after motion modifier - ignoring}} 70 // lt51-warning@+3 {{missing ':' after ) - ignoring}} 71 // expected-error@+2 {{expected expression}} 72 // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 73 #pragma omp target update to(mapper(id) s) 74 // ge51-warning@+4 {{missing ':' after motion modifier - ignoring}} 75 // ge51-error@+3 {{expected expression}} 76 // lt51-error@+2 {{use of undeclared identifier 'present'}} 77 // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 78 #pragma omp target update to(present s) 79 // ge51-warning@+4 {{missing ':' after motion modifier - ignoring}} 80 // lt51-warning@+3 {{missing ':' after ) - ignoring}} 81 // expected-error@+2 {{expected expression}} 82 // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 83 #pragma omp target update to(mapper(id)) 84 // ge51-warning@+4 {{missing ':' after motion modifier - ignoring}} 85 // ge51-error@+3 {{expected expression}} 86 // lt51-error@+2 {{use of undeclared identifier 'present'}} 87 // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 88 #pragma omp target update to(present) 89 // expected-error@+2 {{expected expression}} 90 // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 91 #pragma omp target update to(mapper(id):) 92 // ge51-error@+3 {{expected expression}} 93 // lt51-error@+2 {{use of undeclared identifier 'present'}} 94 // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 95 #pragma omp target update to(present:) 96 97 // Check parsing with two modifiers. 98 // lt51-warning@+1 {{missing ':' after ) - ignoring}} 99 #pragma omp target update to(mapper(id), present: s) 100 // lt51-error@+3 {{use of undeclared identifier 'present'}} 101 // lt51-error@+2 {{use of undeclared identifier 'id'}} 102 // lt51-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 103 #pragma omp target update to(present, mapper(id): s) 104 // lt51-warning@+1 {{missing ':' after ) - ignoring}} 105 #pragma omp target update to(mapper(id) present: s) 106 // lt51-error@+2 {{use of undeclared identifier 'present'}} 107 // lt51-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 108 #pragma omp target update to(present mapper(id): s) 109 110 // Check parsing with unnecessary commas. 111 // lt51-warning@+1 {{missing ':' after ) - ignoring}} 112 #pragma omp target update to(mapper(id),: s) 113 // lt51-error@+3 {{use of undeclared identifier 'present'}} 114 // lt51-error@+2 {{expected expression}} 115 // lt51-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 116 #pragma omp target update to(present , : s) 117 // ge51-warning@+2 {{missing ':' after motion modifier - ignoring}} 118 // lt51-warning@+1 {{missing ':' after ) - ignoring}} 119 #pragma omp target update to(mapper(id),,: s) 120 // ge51-warning@+5 {{missing ':' after motion modifier - ignoring}} 121 // lt51-error@+4 {{use of undeclared identifier 'present'}} 122 // lt51-error@+3 {{expected expression}} 123 // lt51-error@+2 {{expected expression}} 124 // lt51-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 125 #pragma omp target update to(present,,: s) 126 // lt51-warning@+1 {{missing ':' after ) - ignoring}} 127 #pragma omp target update to(mapper(id), present,: s) 128 // lt51-error@+4 {{use of undeclared identifier 'present'}} 129 // lt51-error@+3 {{use of undeclared identifier 'id'}} 130 // lt51-error@+2 {{expected expression}} 131 // lt51-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 132 #pragma omp target update to(present, mapper(id),: s) 133 134 #pragma omp target update from(m) allocate(m) // expected-error {{unexpected OpenMP clause 'allocate' in directive '#pragma omp target update'}} 135 { 136 foo(); 137 } 138 139 double marr[10][5][10]; 140 #pragma omp target update to(marr[0:2][2:4][1:2]) // lt50-error {{array section does not specify contiguous storage}} lt50-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 141 {} 142 #pragma omp target update from(marr[0:2][2:4][1:2]) // lt50-error {{array section does not specify contiguous storage}} lt50-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 143 144 #pragma omp target update to(marr[0:][1:2:2][1:2]) // ge50-error {{array section does not specify length for outermost dimension}} lt50-error {{expected ']'}} lt50-note {{to match this '['}} lt50-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 145 {} 146 #pragma omp target update from(marr[0:][1:2:2][1:2]) // ge50-error {{array section does not specify length for outermost dimension}} lt50-error {{expected ']'}} lt50-note {{to match this '['}} lt50-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 147 148 int arr[4][3][2][1]; 149 #pragma omp target update to(arr[0:2][2:4][:2][1]) // lt50-error {{array section does not specify contiguous storage}} lt50-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 150 {} 151 #pragma omp target update from(arr[0:2][2:4][:2][1]) // lt50-error {{array section does not specify contiguous storage}} lt50-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 152 153 double ***dptr; 154 #pragma omp target update to(dptr[0:2][2:4][1:2]) // lt50-error {{array section does not specify contiguous storage}} ge50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} lt50-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 155 {} 156 #pragma omp target update from(dptr[0:2][2:4][1:2]) // lt50-error {{array section does not specify contiguous storage}} ge50-error 2 {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}} lt50-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 157 158 int iarr[5][5]; 159 // ge50-error@+4 {{section stride is evaluated to a non-positive value -1}} 160 // lt50-error@+3 {{expected ']'}} 161 // lt50-note@+2 {{to match this '['}} 162 // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 163 #pragma omp target update to(iarr[0:][1:2:-1]) 164 {} 165 // ge50-error@+4 {{section stride is evaluated to a non-positive value -1}} 166 // lt50-error@+3 {{expected ']'}} 167 // lt50-note@+2 {{to match this '['}} 168 // expected-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 169 #pragma omp target update from(iarr[0:][1:2:-1]) 170 {} 171 // lt50-error@+5 {{expected expression}} 172 // ge50-error@+4 {{array section does not specify length for outermost dimension}} 173 // lt50-error@+3 {{expected ']'}} 174 // lt50-note@+2 {{to match this '['}} 175 // lt50-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 176 #pragma omp target update to(iarr[0: :2][1:2]) 177 {} 178 // lt50-error@+5 {{expected expression}} 179 // ge50-error@+4 {{array section does not specify length for outermost dimension}} 180 // lt50-error@+3 {{expected ']'}} 181 // lt50-note@+2 {{to match this '['}} 182 // lt50-error@+1 {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 183 #pragma omp target update from(iarr[0: :2][1:2]) 184 {} 185 186 return tmain(argc, argv); 187 } 188 189 template<typename _Tp, int _Nm> struct array { 190 _Tp & operator[](int __n) noexcept; 191 }; 192 193 #pragma omp declare target 194 extern array<double, 4> arr; 195 #pragma omp end declare target 196 197 void copy_host_to_device() 198 { 199 #pragma omp target update from(arr) // expected-no-error 200 arr[0] = 0; 201 } 202 203 struct FOO; // expected-note {{forward declaration of 'FOO'}} 204 extern FOO a; 205 template <typename T, int I> 206 struct bar { 207 void func() { 208 #pragma omp target map(to: a) // expected-error {{incomplete type 'FOO' where a complete type is required}} 209 foo(); 210 } 211 }; 212