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