1 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized 2 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=40 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized 3 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized 4 // RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized 5 6 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized 7 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=40 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized 8 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized 9 // RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized 10 11 void foo() { 12 } 13 14 bool foobool(int argc) { 15 return argc; 16 } 17 18 struct S1; // expected-note 2 {{declared here}} 19 extern S1 a; 20 class S2 { 21 mutable int a; 22 public: 23 S2():a(0) { } 24 S2(S2 &s2):a(s2.a) { } 25 static float S2s; 26 static const float S2sc; 27 }; 28 const float S2::S2sc = 0; 29 const S2 b; 30 const S2 ba[5]; 31 class S3 { 32 int a; 33 public: 34 S3():a(0) { } 35 S3(S3 &s3):a(s3.a) { } 36 }; 37 const S3 c; 38 const S3 ca[5]; 39 extern const int f; 40 class S4 { 41 int a; 42 S4(); 43 S4(const S4 &s4); 44 public: 45 S4(int v):a(v) { } 46 }; 47 class S5 { 48 int a; 49 S5():a(0) {} 50 S5(const S5 &s5):a(s5.a) { } 51 public: 52 S5(int v):a(v) { } 53 }; 54 struct S6 { 55 int ii; 56 int aa[30]; 57 float xx; 58 double *pp; 59 }; 60 struct S7 { 61 int i; 62 int a[50]; 63 float x; 64 S6 s6[5]; 65 double *p; 66 unsigned bfa : 4; 67 }; 68 struct S8 { 69 int *ptr; 70 int a; 71 struct S7* S; 72 void foo() { 73 #pragma omp target update to(*this) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 74 {} 75 #pragma omp target update to(*(this->ptr)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 76 #pragma omp target update to(*(this->S->i+this->S->p)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 77 #pragma omp target update to(*(this->S->i+this->S->s6[0].pp)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 78 #pragma omp target update to(*(a+this->ptr)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 79 #pragma omp target update to(*(*(this->ptr)+a+this->ptr)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 80 #pragma omp target update to(*(this+this)) // expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} expected-error {{invalid operands to binary expression ('S8 *' and 'S8 *')}} 81 {} 82 } 83 }; 84 85 S3 h; 86 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} 87 88 typedef int from; 89 90 template <typename T, int I> // expected-note {{declared here}} 91 T tmain(T argc) { 92 const T d = 5; 93 const T da[5] = { 0 }; 94 S4 e(4); 95 S5 g(5); 96 T *m; 97 T i, t[20]; 98 T &j = i; 99 T *k = &j; 100 T x; 101 T y; 102 T to; 103 const T (&l)[5] = da; 104 S7 s7; 105 106 #pragma omp target update to // expected-error {{expected '(' after 'to'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 107 #pragma omp target update to( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 108 #pragma omp target update to() // expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 109 #pragma omp target update() // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 110 #pragma omp target update to(alloc) // expected-error {{use of undeclared identifier 'alloc'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 111 #pragma omp target update to(x) 112 #pragma omp target update to(t[:I]) 113 #pragma omp target update to(T) // expected-error {{'T' does not refer to a value}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 114 #pragma omp target update to(I) // le50-error 2 {{expected addressable lvalue in 'to' clause}} le45-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} 115 #pragma omp target update to(S2::S2s) 116 #pragma omp target update to(S2::S2sc) 117 #pragma omp target update to(to) 118 #pragma omp target update to(y x) // expected-error {{expected ',' or ')' in 'to' clause}} 119 #pragma omp target update to(argc > 0 ? x : y) // le50-error 2 {{expected addressable lvalue in 'to' clause}} le45-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} 120 #pragma omp target update to(S1) // expected-error {{'S1' does not refer to a value}}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 121 #pragma omp target update to(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} 122 #pragma omp target update to(ba) 123 #pragma omp target update to(h) // expected-error {{threadprivate variables are not allowed in 'to' clause}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 124 #pragma omp target update to(k), from(k) // expected-error 2 {{variable can appear only once in OpenMP 'target update' construct}} expected-note 2 {{used here}} 125 #pragma omp target update to(t), to(t[:5]) // expected-error 2 {{variable can appear only once in OpenMP 'target update' construct}} expected-note 2 {{used here}} 126 #pragma omp target update to(da) 127 #pragma omp target update to(da[:4]) 128 129 #pragma omp target update to(x, a[:2]) // expected-error {{subscripted value is not an array or pointer}} 130 #pragma omp target update to(x, c[:]) // expected-error {{subscripted value is not an array or pointer}} 131 #pragma omp target update to(x, (m+1)[2]) // le45-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} 132 #pragma omp target update to(s7.i, s7.a[:3]) 133 #pragma omp target update to(s7.s6[1].aa[0:5]) 134 #pragma omp target update to(x, s7.s6[:5].aa[6]) // expected-error {{OpenMP array section is not allowed here}} 135 #pragma omp target update to(x, s7.s6[:5].aa[:6]) // expected-error {{OpenMP array section is not allowed here}} 136 #pragma omp target update to(s7.p[:10]) 137 #pragma omp target update to(x, s7.bfa) // expected-error {{bit fields cannot be used to specify storage in a 'to' clause}} 138 #pragma omp target update to(x, s7.p[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} 139 #pragma omp target data map(to: s7.i) 140 { 141 #pragma omp target update to(s7.x) 142 } 143 return 0; 144 } 145 146 int main(int argc, char **argv) { 147 const int d = 5; 148 const int da[5] = { 0 }; 149 S4 e(4); 150 S5 g(5); 151 int i, t[20]; 152 int &j = i; 153 int *k = &j; 154 int x; 155 int y; 156 int to; 157 const int (&l)[5] = da; 158 S7 s7; 159 int *m; 160 int **BB, *offset; 161 int ***BBB; 162 163 #pragma omp target update to // expected-error {{expected '(' after 'to'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 164 #pragma omp target update to( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 165 #pragma omp target update to() // expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 166 #pragma omp target update() // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 167 #pragma omp target update to(alloc) // expected-error {{use of undeclared identifier 'alloc'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 168 #pragma omp target update to(x) 169 #pragma omp target update to(t[:i]) 170 #pragma omp target update to(S2::S2s) 171 #pragma omp target update to(S2::S2sc) 172 #pragma omp target update to(to) 173 #pragma omp target update to(y x) // expected-error {{expected ',' or ')' in 'to' clause}} 174 #pragma omp target update to(argc > 0 ? x : y) // le50-error {{expected addressable lvalue in 'to' clause}} le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 175 #pragma omp target update to(S1) // expected-error {{'S1' does not refer to a value}}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 176 #pragma omp target update to(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} 177 #pragma omp target update to(ba) 178 #pragma omp target update to(h) // expected-error {{threadprivate variables are not allowed in 'to' clause}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 179 #pragma omp target update to(k), from(k) // expected-error {{variable can appear only once in OpenMP 'target update' construct}} expected-note {{used here}} 180 #pragma omp target update to(t), to(t[:5]) // expected-error {{variable can appear only once in OpenMP 'target update' construct}} expected-note {{used here}} 181 #pragma omp target update to(da) 182 #pragma omp target update to(da[:4]) 183 184 #pragma omp target update to(x, a[:2]) // expected-error {{subscripted value is not an array or pointer}} 185 #pragma omp target update to(x, c[:]) // expected-error {{subscripted value is not an array or pointer}} 186 #pragma omp target update to(x, (m+1)[2]) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} 187 #pragma omp target update to(s7.i, s7.a[:3]) 188 #pragma omp target update to(s7.s6[1].aa[0:5]) 189 #pragma omp target update to(x, s7.s6[:5].aa[6]) // expected-error {{OpenMP array section is not allowed here}} 190 #pragma omp target update to(x, s7.s6[:5].aa[:6]) // expected-error {{OpenMP array section is not allowed here}} 191 #pragma omp target update to(s7.p[:10]) 192 #pragma omp target update to(x, s7.bfa) // expected-error {{bit fields cannot be used to specify storage in a 'to' clause}} 193 #pragma omp target update to(x, s7.p[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} 194 #pragma omp target data map(to: s7.i) 195 { 196 #pragma omp target update to(s7.x) 197 } 198 199 #pragma omp target update to(**(BB+*offset)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 200 #pragma omp target update to(**(BB+y)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 201 #pragma omp target update to(*(m+*offset)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 202 #pragma omp target update to(**(*offset+BB)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 203 #pragma omp target update to(**(y+BB)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 204 #pragma omp target update to(*(*offset+m)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 205 #pragma omp target update to(**(*offset+BB+*m)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 206 #pragma omp target update to(**(*(*(&offset))+BB+*m)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 207 #pragma omp target update to(*(x+*(y+*(**BB+BBB)+s7.i))) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le45-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 208 #pragma omp target update to(*(m+(m))) // expected-error {{invalid operands to binary expression ('int *' and 'int *')}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 209 #pragma omp target update to(*(1+y+y)) // expected-error {{indirection requires pointer operand ('int' invalid)}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} 210 {} 211 return tmain<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}} 212 } 213 214