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