Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s |
Alexey Bataev | d195bc3 | 2013-10-01 05:32:34 +0000 | [diff] [blame] | 2 | |
| 3 | void foo() { |
| 4 | } |
| 5 | |
| 6 | bool foobool(int argc) { |
| 7 | return argc; |
| 8 | } |
| 9 | |
| 10 | struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}} |
| 11 | extern S1 a; |
| 12 | class S2 { |
| 13 | mutable int a; |
| 14 | public: |
| 15 | S2():a(0) { } |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 16 | S2(const S2 &s2):a(s2.a) { } |
Alexey Bataev | d195bc3 | 2013-10-01 05:32:34 +0000 | [diff] [blame] | 17 | static float S2s; |
| 18 | static const float S2sc; |
| 19 | }; |
| 20 | const float S2::S2sc = 0; |
| 21 | const S2 b; |
| 22 | const S2 ba[5]; |
| 23 | class S3 { |
| 24 | int a; |
| 25 | public: |
| 26 | S3():a(0) { } |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 27 | S3(const S3 &s3):a(s3.a) { } |
Alexey Bataev | d195bc3 | 2013-10-01 05:32:34 +0000 | [diff] [blame] | 28 | }; |
| 29 | const S3 c; |
| 30 | const S3 ca[5]; |
| 31 | extern const int f; |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 32 | class S4 { |
Alexey Bataev | d195bc3 | 2013-10-01 05:32:34 +0000 | [diff] [blame] | 33 | int a; |
| 34 | S4(); |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 35 | S4(const S4 &s4); // expected-note {{implicitly declared private here}} |
Alexey Bataev | d195bc3 | 2013-10-01 05:32:34 +0000 | [diff] [blame] | 36 | public: |
| 37 | S4(int v):a(v) { } |
| 38 | }; |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 39 | class S5 { |
Alexey Bataev | d195bc3 | 2013-10-01 05:32:34 +0000 | [diff] [blame] | 40 | int a; |
| 41 | S5():a(0) {} |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 42 | S5(const S5 &s5):a(s5.a) { } // expected-note {{implicitly declared private here}} |
Alexey Bataev | d195bc3 | 2013-10-01 05:32:34 +0000 | [diff] [blame] | 43 | public: |
| 44 | S5(int v):a(v) { } |
| 45 | }; |
| 46 | |
| 47 | S3 h; |
| 48 | #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} |
| 49 | |
Pirama Arumuga Nainar | 33337ca | 2015-05-06 11:48:57 -0700 | [diff] [blame] | 50 | namespace A { |
| 51 | double x; |
| 52 | #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} |
| 53 | } |
| 54 | namespace B { |
| 55 | using A::x; |
| 56 | } |
| 57 | |
Alexey Bataev | d195bc3 | 2013-10-01 05:32:34 +0000 | [diff] [blame] | 58 | int main(int argc, char **argv) { |
| 59 | const int d = 5; |
| 60 | const int da[5] = { 0 }; |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 61 | S4 e(4); |
| 62 | S5 g(5); |
Alexey Bataev | d195bc3 | 2013-10-01 05:32:34 +0000 | [diff] [blame] | 63 | int i; |
| 64 | int &j = i; // expected-note {{'j' defined here}} |
| 65 | #pragma omp parallel firstprivate // expected-error {{expected '(' after 'firstprivate'}} |
| 66 | #pragma omp parallel firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 67 | #pragma omp parallel firstprivate () // expected-error {{expected expression}} |
| 68 | #pragma omp parallel firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 69 | #pragma omp parallel firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 70 | #pragma omp parallel firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 71 | #pragma omp parallel firstprivate (argc) |
| 72 | #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}} |
| 73 | #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} |
| 74 | #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected variable name}} |
| 75 | #pragma omp parallel firstprivate(ba) |
| 76 | #pragma omp parallel firstprivate(ca) |
| 77 | #pragma omp parallel firstprivate(da) |
| 78 | #pragma omp parallel firstprivate(S2::S2s) |
| 79 | #pragma omp parallel firstprivate(S2::S2sc) |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 80 | #pragma omp parallel firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} |
Pirama Arumuga Nainar | 33337ca | 2015-05-06 11:48:57 -0700 | [diff] [blame] | 81 | #pragma omp parallel firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}} |
Alexey Bataev | d195bc3 | 2013-10-01 05:32:34 +0000 | [diff] [blame] | 82 | #pragma omp parallel private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}} |
| 83 | foo(); |
| 84 | #pragma omp parallel shared(i) |
| 85 | #pragma omp parallel firstprivate(i) |
| 86 | #pragma omp parallel firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}} |
| 87 | foo(); |
| 88 | |
| 89 | return 0; |
| 90 | } |