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