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