Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fopenmp=libiomp5 %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) {} |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 17 | S2(const S2 &s2) : a(s2.a) {} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 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) {} |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 30 | S3(const S3 &s3) : a(s3.a) {} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 31 | }; |
| 32 | const S3 c; |
| 33 | const S3 ca[5]; |
| 34 | extern const int f; |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 35 | class S4 { |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 36 | int a; |
| 37 | S4(); |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 38 | S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 39 | |
| 40 | public: |
| 41 | S4(int v) : a(v) {} |
| 42 | }; |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 43 | class S5 { |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 44 | int a; |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 45 | S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 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) { |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 65 | I e(4); |
| 66 | C g(5); |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 67 | int i; |
| 68 | int &j = i; // expected-note {{'j' defined here}} |
| 69 | #pragma omp parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}} |
| 70 | for (int k = 0; k < argc; ++k) |
| 71 | ++k; |
| 72 | #pragma omp parallel for 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 firstprivate() // expected-error {{expected expression}} |
| 76 | for (int k = 0; k < argc; ++k) |
| 77 | ++k; |
| 78 | #pragma omp parallel for 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 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 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 firstprivate(argc) |
| 88 | for (int k = 0; k < argc; ++k) |
| 89 | ++k; |
| 90 | #pragma omp parallel for 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 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 firstprivate(argv[1]) // expected-error {{expected variable name}} |
| 97 | for (int k = 0; k < argc; ++k) |
| 98 | ++k; |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 99 | #pragma omp parallel for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 100 | for (int k = 0; k < argc; ++k) |
| 101 | ++k; |
| 102 | #pragma omp parallel for 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 linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel for'}} |
| 106 | for (int k = 0; k < argc; ++k) |
| 107 | ++k; |
| 108 | #pragma omp parallel |
| 109 | { |
| 110 | int v = 0; |
| 111 | int i; |
| 112 | #pragma omp parallel for firstprivate(i) |
| 113 | for (int k = 0; k < argc; ++k) { |
| 114 | i = k; |
| 115 | v += i; |
| 116 | } |
| 117 | } |
| 118 | #pragma omp parallel shared(i) |
| 119 | #pragma omp parallel private(i) |
| 120 | #pragma omp parallel for firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}} |
| 121 | for (int k = 0; k < argc; ++k) |
| 122 | ++k; |
| 123 | #pragma omp parallel for firstprivate(i) |
| 124 | for (int k = 0; k < argc; ++k) |
| 125 | ++k; |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 126 | #pragma omp parallel for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 127 | for (i = 0; i < argc; ++i) |
| 128 | foo(); |
| 129 | #pragma omp parallel private(i) |
| 130 | #pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}} |
| 131 | for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}} |
| 132 | foo(); |
| 133 | #pragma omp parallel reduction(+ : i) |
| 134 | #pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}} |
| 135 | for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}} |
| 136 | foo(); |
| 137 | return 0; |
| 138 | } |
| 139 | |
Pirama Arumuga Nainar | 33337ca | 2015-05-06 11:48:57 -0700 | [diff] [blame] | 140 | namespace A { |
| 141 | double x; |
| 142 | #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} |
| 143 | } |
| 144 | namespace B { |
| 145 | using A::x; |
| 146 | } |
| 147 | |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 148 | int main(int argc, char **argv) { |
| 149 | const int d = 5; |
| 150 | const int da[5] = {0}; |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 151 | S4 e(4); |
| 152 | S5 g(5); |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 153 | S3 m; |
| 154 | S6 n(2); |
| 155 | int i; |
| 156 | int &j = i; // expected-note {{'j' defined here}} |
| 157 | #pragma omp parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}} |
| 158 | for (i = 0; i < argc; ++i) |
| 159 | foo(); |
| 160 | #pragma omp parallel for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 161 | for (i = 0; i < argc; ++i) |
| 162 | foo(); |
| 163 | #pragma omp parallel for firstprivate() // expected-error {{expected expression}} |
| 164 | for (i = 0; i < argc; ++i) |
| 165 | foo(); |
| 166 | #pragma omp parallel for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 167 | for (i = 0; i < argc; ++i) |
| 168 | foo(); |
| 169 | #pragma omp parallel for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 170 | for (i = 0; i < argc; ++i) |
| 171 | foo(); |
| 172 | #pragma omp parallel for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 173 | for (i = 0; i < argc; ++i) |
| 174 | foo(); |
| 175 | #pragma omp parallel for firstprivate(argc) |
| 176 | for (i = 0; i < argc; ++i) |
| 177 | foo(); |
| 178 | #pragma omp parallel for firstprivate(S1) // expected-error {{'S1' does not refer to a value}} |
| 179 | for (i = 0; i < argc; ++i) |
| 180 | foo(); |
| 181 | #pragma omp parallel for firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} |
| 182 | for (i = 0; i < argc; ++i) |
| 183 | foo(); |
| 184 | #pragma omp parallel for firstprivate(argv[1]) // expected-error {{expected variable name}} |
| 185 | for (i = 0; i < argc; ++i) |
| 186 | foo(); |
| 187 | #pragma omp parallel for firstprivate(2 * 2) // expected-error {{expected variable name}} |
| 188 | for (i = 0; i < argc; ++i) |
| 189 | foo(); |
| 190 | #pragma omp parallel for firstprivate(ba) // OK |
| 191 | for (i = 0; i < argc; ++i) |
| 192 | foo(); |
| 193 | #pragma omp parallel for firstprivate(ca) // OK |
| 194 | for (i = 0; i < argc; ++i) |
| 195 | foo(); |
| 196 | #pragma omp parallel for firstprivate(da) // OK |
| 197 | for (i = 0; i < argc; ++i) |
| 198 | foo(); |
| 199 | int xa; |
| 200 | #pragma omp parallel for firstprivate(xa) // OK |
| 201 | for (i = 0; i < argc; ++i) |
| 202 | foo(); |
| 203 | #pragma omp parallel for firstprivate(S2::S2s) // OK |
| 204 | for (i = 0; i < argc; ++i) |
| 205 | foo(); |
| 206 | #pragma omp parallel for firstprivate(S2::S2sc) // OK |
| 207 | for (i = 0; i < argc; ++i) |
| 208 | foo(); |
| 209 | #pragma omp parallel for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp parallel for'}} |
| 210 | for (i = 0; i < argc; ++i) |
| 211 | foo(); |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 212 | #pragma omp parallel for firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 213 | for (i = 0; i < argc; ++i) |
| 214 | foo(); |
| 215 | #pragma omp parallel for firstprivate(m) // OK |
| 216 | for (i = 0; i < argc; ++i) |
| 217 | foo(); |
Pirama Arumuga Nainar | 33337ca | 2015-05-06 11:48:57 -0700 | [diff] [blame] | 218 | #pragma omp parallel for firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 219 | for (i = 0; i < argc; ++i) |
| 220 | foo(); |
| 221 | #pragma omp parallel for private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}} |
| 222 | for (i = 0; i < argc; ++i) |
| 223 | foo(); |
| 224 | #pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}} |
| 225 | for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}} |
| 226 | foo(); |
| 227 | #pragma omp parallel shared(xa) |
| 228 | #pragma omp parallel for firstprivate(xa) // OK: may be firstprivate |
| 229 | for (i = 0; i < argc; ++i) |
| 230 | foo(); |
| 231 | #pragma omp parallel for firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}} |
| 232 | for (i = 0; i < argc; ++i) |
| 233 | foo(); |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 234 | #pragma omp parallel for lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}} |
Stephen Hines | c568f1e | 2014-07-21 00:47:37 -0700 | [diff] [blame] | 235 | for (i = 0; i < argc; ++i) |
| 236 | foo(); |
| 237 | #pragma omp parallel for lastprivate(n) firstprivate(n) // OK |
| 238 | for (i = 0; i < argc; ++i) |
| 239 | foo(); |
| 240 | #pragma omp parallel |
| 241 | { |
| 242 | int v = 0; |
| 243 | int i; |
| 244 | #pragma omp parallel for firstprivate(i) |
| 245 | for (int k = 0; k < argc; ++k) { |
| 246 | i = k; |
| 247 | v += i; |
| 248 | } |
| 249 | } |
| 250 | #pragma omp parallel private(i) |
| 251 | #pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}} |
| 252 | for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}} |
| 253 | foo(); |
| 254 | #pragma omp parallel reduction(+ : i) |
| 255 | #pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}} |
| 256 | for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}} |
| 257 | foo(); |
| 258 | |
| 259 | return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}} |
| 260 | } |