Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fopenmp %s |
| 2 | |
| 3 | struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} |
| 4 | extern S1 a; |
| 5 | class S2 { |
| 6 | mutable int a; |
| 7 | |
| 8 | public: |
| 9 | S2() : a(0) {} |
| 10 | }; |
| 11 | const S2 b; |
| 12 | const S2 ba[5]; |
| 13 | class S3 { |
| 14 | int a; |
| 15 | |
| 16 | public: |
| 17 | S3() : a(0) {} |
| 18 | }; |
| 19 | const S3 ca[5]; |
| 20 | class S4 { |
| 21 | int a; |
| 22 | S4(); // expected-note {{implicitly declared private here}} |
| 23 | |
| 24 | public: |
Alexey Bataev | 48c0bfb | 2016-01-20 09:07:54 +0000 | [diff] [blame] | 25 | S4(int v) : a(v) { |
| 26 | #pragma omp target private(a) private(this->a) |
| 27 | for (int k = 0; k < v; ++k) |
| 28 | ++this->a; |
| 29 | } |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 30 | }; |
| 31 | class S5 { |
| 32 | int a; |
| 33 | S5() : a(0) {} // expected-note {{implicitly declared private here}} |
| 34 | |
| 35 | public: |
| 36 | S5(int v) : a(v) {} |
Alexey Bataev | 48c0bfb | 2016-01-20 09:07:54 +0000 | [diff] [blame] | 37 | S5 &operator=(S5 &s) { |
| 38 | #pragma omp target private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}} |
| 39 | for (int k = 0; k < s.a; ++k) |
| 40 | ++s.a; |
| 41 | return *this; |
| 42 | } |
| 43 | }; |
| 44 | |
| 45 | template <typename T> |
| 46 | class S6 { |
| 47 | public: |
| 48 | T a; |
| 49 | |
| 50 | S6() : a(0) {} |
| 51 | S6(T v) : a(v) { |
| 52 | #pragma omp target private(a) private(this->a) |
| 53 | for (int k = 0; k < v; ++k) |
| 54 | ++this->a; |
| 55 | } |
| 56 | S6 &operator=(S6 &s) { |
| 57 | #pragma omp target private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}} |
| 58 | for (int k = 0; k < s.a; ++k) |
| 59 | ++s.a; |
| 60 | return *this; |
| 61 | } |
| 62 | }; |
| 63 | |
| 64 | template <typename T> |
| 65 | class S7 : public T { |
| 66 | T a; |
| 67 | S7() : a(0) {} |
| 68 | |
| 69 | public: |
| 70 | S7(T v) : a(v) { |
| 71 | #pragma omp target private(a) private(this->a) private(T::a) |
| 72 | for (int k = 0; k < a.a; ++k) |
| 73 | ++this->a.a; |
| 74 | } |
| 75 | S7 &operator=(S7 &s) { |
| 76 | #pragma omp target private(a) private(this->a) private(s.a) private(s.T::a) // expected-error 2 {{expected variable name or data member of current class}} |
| 77 | for (int k = 0; k < s.a.a; ++k) |
| 78 | ++s.a.a; |
| 79 | return *this; |
| 80 | } |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | S3 h; |
| 84 | #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} |
| 85 | |
| 86 | template <class I, class C> |
| 87 | int foomain(I argc, C **argv) { |
| 88 | I e(4); |
| 89 | I g(5); |
| 90 | int i; |
| 91 | int &j = i; |
| 92 | #pragma omp target private // expected-error {{expected '(' after 'private'}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 93 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 94 | #pragma omp target private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 95 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 96 | #pragma omp target private() // expected-error {{expected expression}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 97 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 98 | #pragma omp target private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 99 | {} |
Alexey Bataev | c597062 | 2016-04-01 08:43:42 +0000 | [diff] [blame] | 100 | #pragma omp target private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 101 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 102 | #pragma omp target private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 103 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 104 | #pragma omp target private(argc) |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 105 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 106 | #pragma omp target private(S1) // expected-error {{'S1' does not refer to a value}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 107 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 108 | #pragma omp target private(a, b) // expected-error {{private variable with incomplete type 'S1'}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 109 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 110 | #pragma omp target private(argv[1]) // expected-error {{expected variable name}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 111 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 112 | #pragma omp target private(e, g) |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 113 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 114 | #pragma omp target private(h) // expected-error {{threadprivate or thread local variable cannot be private}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 115 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 116 | #pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}} |
| 117 | #pragma omp parallel |
| 118 | { |
| 119 | int v = 0; |
| 120 | int i; |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 121 | } |
| 122 | #pragma omp parallel shared(i) |
| 123 | #pragma omp parallel private(i) |
| 124 | #pragma omp target private(j) |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 125 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 126 | #pragma omp target private(i) |
| 127 | {} |
| 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | void bar(S4 a[2]) { |
| 132 | #pragma omp parallel |
| 133 | #pragma omp target private(a) |
| 134 | {} |
| 135 | } |
| 136 | |
| 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 | |
| 145 | int main(int argc, char **argv) { |
| 146 | S4 e(4); |
| 147 | S5 g(5); |
Alexey Bataev | 48c0bfb | 2016-01-20 09:07:54 +0000 | [diff] [blame] | 148 | S6<float> s6(0.0) , s6_0(1.0); |
| 149 | S7<S6<float> > s7(0.0) , s7_0(1.0); |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 150 | int i; |
| 151 | int &j = i; |
| 152 | #pragma omp target private // expected-error {{expected '(' after 'private'}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 153 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 154 | #pragma omp target private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 155 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 156 | #pragma omp target private() // expected-error {{expected expression}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 157 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 158 | #pragma omp target private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 159 | {} |
Alexey Bataev | c597062 | 2016-04-01 08:43:42 +0000 | [diff] [blame] | 160 | #pragma omp target private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 161 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 162 | #pragma omp target private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 163 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 164 | #pragma omp target private(argc) |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 165 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 166 | #pragma omp target private(S1) // expected-error {{'S1' does not refer to a value}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 167 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 168 | #pragma omp target private(a, b) // expected-error {{private variable with incomplete type 'S1'}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 169 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 170 | #pragma omp target private(argv[1]) // expected-error {{expected variable name}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 171 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 172 | #pragma omp target private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 173 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 174 | #pragma omp target private(h) // expected-error {{threadprivate or thread local variable cannot be private}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 175 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 176 | #pragma omp target private(B::x) // expected-error {{threadprivate or thread local variable cannot be private}} |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 177 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 178 | #pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}} |
| 179 | #pragma omp parallel |
| 180 | { |
| 181 | int i; |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 182 | } |
| 183 | #pragma omp parallel shared(i) |
| 184 | #pragma omp parallel private(i) |
| 185 | #pragma omp target private(j) |
Arpith Chacko Jacob | 3d58f26 | 2016-02-02 04:00:47 +0000 | [diff] [blame] | 186 | {} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 187 | #pragma omp target private(i) |
| 188 | {} |
| 189 | static int si; |
| 190 | #pragma omp target private(si) // OK |
| 191 | {} |
Carlo Bertolli | b74bfc8 | 2016-03-18 21:43:32 +0000 | [diff] [blame] | 192 | #pragma omp target map(i) private(i) // expected-error {{private variable cannot be in a map clause in '#pragma omp target' directive}} |
| 193 | {} |
Alexey Bataev | 48c0bfb | 2016-01-20 09:07:54 +0000 | [diff] [blame] | 194 | s6 = s6_0; // expected-note {{in instantiation of member function 'S6<float>::operator=' requested here}} |
| 195 | s7 = s7_0; // expected-note {{in instantiation of member function 'S7<S6<float> >::operator=' requested here}} |
| 196 | return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}} |
Carlo Bertolli | 9e8c6c1 | 2016-01-19 16:53:55 +0000 | [diff] [blame] | 197 | } |
| 198 | |