1 // RUN: %clang_cc1 -verify -fopenmp %s 2 3 void foo() { 4 } 5 6 bool foobool(int argc) { 7 return argc; 8 } 9 10 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} 11 extern S1 a; 12 class S2 { 13 mutable int a; 14 15 public: 16 S2() : a(0) {} 17 S2(const S2 &s2) : a(s2.a) {} 18 static float S2s; 19 static const float S2sc; 20 }; 21 const float S2::S2sc = 0; 22 const S2 b; 23 const S2 ba[5]; 24 class S3 { 25 int a; 26 S3 &operator=(const S3 &s3); 27 28 public: 29 S3() : a(0) {} 30 S3(const S3 &s3) : a(s3.a) {} 31 }; 32 const S3 c; 33 const S3 ca[5]; 34 extern const int f; 35 class S4 { 36 int a; 37 S4(); 38 S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}} 39 40 public: 41 S4(int v) : a(v) {} 42 }; 43 class S5 { 44 int a; 45 S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}} 46 47 public: 48 S5() : a(0) {} 49 S5(int v) : a(v) {} 50 }; 51 class S6 { 52 int a; 53 S6() : a(0) {} 54 55 public: 56 S6(const S6 &s6) : a(s6.a) {} 57 S6(int v) : a(v) {} 58 }; 59 60 S3 h; 61 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} 62 63 template <class I, class C> 64 int foomain(int argc, char **argv) { 65 I e(4); 66 C g(5); 67 int i; 68 int &j = i; 69 #pragma omp parallel 70 #pragma omp for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}} 71 for (int k = 0; k < argc; ++k) 72 ++k; 73 #pragma omp parallel 74 #pragma omp for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 75 for (int k = 0; k < argc; ++k) 76 ++k; 77 #pragma omp parallel 78 #pragma omp for simd firstprivate() // expected-error {{expected expression}} 79 for (int k = 0; k < argc; ++k) 80 ++k; 81 #pragma omp parallel 82 #pragma omp for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 83 for (int k = 0; k < argc; ++k) 84 ++k; 85 #pragma omp parallel 86 #pragma omp for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 87 for (int k = 0; k < argc; ++k) 88 ++k; 89 #pragma omp parallel 90 #pragma omp for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 91 for (int k = 0; k < argc; ++k) 92 ++k; 93 #pragma omp parallel 94 #pragma omp for simd firstprivate(argc) 95 for (int k = 0; k < argc; ++k) 96 ++k; 97 #pragma omp parallel 98 #pragma omp for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}} 99 for (int k = 0; k < argc; ++k) 100 ++k; 101 #pragma omp parallel 102 #pragma omp for simd firstprivate(a, b) // expected-error {{a firstprivate variable with incomplete type 'S1'}} 103 for (int k = 0; k < argc; ++k) 104 ++k; 105 #pragma omp parallel 106 #pragma omp for simd firstprivate(argv[1]) // expected-error {{expected variable name}} 107 for (int k = 0; k < argc; ++k) 108 ++k; 109 #pragma omp parallel 110 #pragma omp for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} 111 for (int k = 0; k < argc; ++k) 112 ++k; 113 #pragma omp parallel 114 #pragma omp for simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} 115 for (int k = 0; k < argc; ++k) 116 ++k; 117 #pragma omp parallel 118 #pragma omp for simd linear(i) 119 for (int k = 0; k < argc; ++k) 120 ++k; 121 #pragma omp parallel 122 { 123 int v = 0; 124 int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for simd' directive into a parallel or another task region?}} 125 #pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable must be shared}} 126 for (int k = 0; k < argc; ++k) { 127 i = k; 128 v += i; 129 } 130 } 131 #pragma omp parallel shared(i) 132 #pragma omp parallel private(i) 133 #pragma omp for simd firstprivate(j) 134 for (int k = 0; k < argc; ++k) 135 ++k; 136 #pragma omp parallel 137 #pragma omp for simd firstprivate(i) 138 for (int k = 0; k < argc; ++k) 139 ++k; 140 #pragma omp parallel 141 #pragma omp for simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}} 142 for (i = 0; i < argc; ++i) 143 foo(); 144 #pragma omp parallel private(i) // expected-note {{defined as private}} 145 #pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable must be shared}} 146 for (i = 0; i < argc; ++i) 147 foo(); 148 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}} 149 #pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable must be shared}} 150 for (int k = 0; k < argc; ++k) 151 foo(); 152 return 0; 153 } 154 155 namespace A { 156 double x; 157 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} 158 } 159 namespace B { 160 using A::x; 161 } 162 163 int main(int argc, char **argv) { 164 const int d = 5; 165 const int da[5] = {0}; 166 S4 e(4); 167 S5 g(5); 168 S3 m; 169 S6 n(2); 170 int i; 171 int &j = i; 172 #pragma omp parallel 173 #pragma omp for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}} 174 for (i = 0; i < argc; ++i) 175 foo(); 176 #pragma omp parallel 177 #pragma omp for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 178 for (i = 0; i < argc; ++i) 179 foo(); 180 #pragma omp parallel 181 #pragma omp for simd firstprivate() // expected-error {{expected expression}} 182 for (i = 0; i < argc; ++i) 183 foo(); 184 #pragma omp parallel 185 #pragma omp for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 186 for (i = 0; i < argc; ++i) 187 foo(); 188 #pragma omp parallel 189 #pragma omp for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 190 for (i = 0; i < argc; ++i) 191 foo(); 192 #pragma omp parallel 193 #pragma omp for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 194 for (i = 0; i < argc; ++i) 195 foo(); 196 #pragma omp parallel 197 #pragma omp for simd firstprivate(argc) 198 for (i = 0; i < argc; ++i) 199 foo(); 200 #pragma omp parallel 201 #pragma omp for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}} 202 for (i = 0; i < argc; ++i) 203 foo(); 204 #pragma omp parallel 205 #pragma omp for simd firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} 206 for (i = 0; i < argc; ++i) 207 foo(); 208 #pragma omp parallel 209 #pragma omp for simd firstprivate(argv[1]) // expected-error {{expected variable name}} 210 for (i = 0; i < argc; ++i) 211 foo(); 212 #pragma omp parallel 213 #pragma omp for simd firstprivate(2 * 2) // expected-error {{expected variable name}} 214 for (i = 0; i < argc; ++i) 215 foo(); 216 #pragma omp parallel 217 #pragma omp for simd firstprivate(ba) // OK 218 for (i = 0; i < argc; ++i) 219 foo(); 220 #pragma omp parallel 221 #pragma omp for simd firstprivate(ca) // OK 222 for (i = 0; i < argc; ++i) 223 foo(); 224 #pragma omp parallel 225 #pragma omp for simd firstprivate(da) // OK 226 for (i = 0; i < argc; ++i) 227 foo(); 228 int xa; 229 #pragma omp parallel 230 #pragma omp for simd firstprivate(xa) // OK 231 for (i = 0; i < argc; ++i) 232 foo(); 233 #pragma omp parallel 234 #pragma omp for simd firstprivate(S2::S2s) // OK 235 for (i = 0; i < argc; ++i) 236 foo(); 237 #pragma omp parallel 238 #pragma omp for simd firstprivate(S2::S2sc) // OK 239 for (i = 0; i < argc; ++i) 240 foo(); 241 #pragma omp parallel 242 #pragma omp for simd safelen(5) 243 for (i = 0; i < argc; ++i) 244 foo(); 245 #pragma omp parallel 246 #pragma omp for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} 247 for (i = 0; i < argc; ++i) 248 foo(); 249 #pragma omp parallel 250 #pragma omp for simd firstprivate(m) // OK 251 for (i = 0; i < argc; ++i) 252 foo(); 253 #pragma omp parallel 254 #pragma omp for simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} 255 for (i = 0; i < argc; ++i) 256 foo(); 257 #pragma omp parallel 258 #pragma omp for simd firstprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} 259 for (i = 0; i < argc; ++i) 260 foo(); 261 #pragma omp parallel 262 #pragma omp for simd private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}} 263 for (i = 0; i < argc; ++i) 264 foo(); 265 #pragma omp parallel 266 #pragma omp for simd firstprivate(i) // expected-note {{defined as firstprivate}} 267 for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp for simd' directive may not be firstprivate, predetermined as linear}} 268 foo(); 269 #pragma omp parallel shared(xa) 270 #pragma omp for simd firstprivate(xa) // OK: may be firstprivate 271 for (i = 0; i < argc; ++i) 272 foo(); 273 #pragma omp parallel 274 #pragma omp for simd firstprivate(j) 275 for (i = 0; i < argc; ++i) 276 foo(); 277 #pragma omp parallel 278 #pragma omp for simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}} 279 for (i = 0; i < argc; ++i) 280 foo(); 281 #pragma omp parallel 282 #pragma omp for simd lastprivate(n) firstprivate(n) // OK 283 for (i = 0; i < argc; ++i) 284 foo(); 285 #pragma omp parallel 286 { 287 int v = 0; 288 int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for simd' directive into a parallel or another task region?}} 289 #pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable must be shared}} 290 for (int k = 0; k < argc; ++k) { 291 i = k; 292 v += i; 293 } 294 } 295 #pragma omp parallel private(i) // expected-note {{defined as private}} 296 #pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable must be shared}} 297 for (i = 0; i < argc; ++i) 298 foo(); 299 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}} 300 #pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable must be shared}} 301 for (i = 0; i < argc; ++i) 302 foo(); 303 static int si; 304 #pragma omp for simd firstprivate(si) 305 for (i = 0; i < argc; ++i) 306 si = i + 1; 307 308 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}} 309 } 310