1 // RUN: %clang_cc1 -verify -fopenmp %s 2 3 // RUN: %clang_cc1 -verify -fopenmp-simd %s 4 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) {} 19 }; 20 const S2 b; 21 const S2 ba[5]; 22 class S3 { 23 int a; 24 25 public: 26 S3() : a(0) {} 27 }; 28 const S3 ca[5]; 29 class S4 { 30 int a; 31 S4(); // expected-note {{implicitly declared private here}} 32 33 public: 34 S4(int v) : a(v) { 35 #pragma omp parallel for simd private(a) private(this->a) 36 for (int k = 0; k < v; ++k) 37 ++this->a; 38 } 39 }; 40 class S5 { 41 int a; 42 S5() : a(0) {} // expected-note {{implicitly declared private here}} 43 44 public: 45 S5(int v) : a(v) {} 46 S5 &operator=(S5 &s) { 47 #pragma omp parallel for simd private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}} 48 for (int k = 0; k < s.a; ++k) 49 ++s.a; 50 return *this; 51 } 52 }; 53 54 template <typename T> 55 class S6 { 56 public: 57 T a; 58 59 S6() : a(0) {} 60 S6(T v) : a(v) { 61 #pragma omp parallel for simd private(a) private(this->a) 62 for (int k = 0; k < v; ++k) 63 ++this->a; 64 } 65 S6 &operator=(S6 &s) { 66 #pragma omp parallel for simd private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}} 67 for (int k = 0; k < s.a; ++k) 68 ++s.a; 69 return *this; 70 } 71 }; 72 73 template <typename T> 74 class S7 : public T { 75 T a; 76 S7() : a(0) {} 77 78 public: 79 S7(T v) : a(v) { 80 #pragma omp parallel for simd private(a) private(this->a) private(T::a) 81 for (int k = 0; k < a.a; ++k) 82 ++this->a.a; 83 } 84 S7 &operator=(S7 &s) { 85 #pragma omp parallel for simd private(a) private(this->a) private(s.a) private(s.T::a) // expected-error 2 {{expected variable name or data member of current class}} 86 for (int k = 0; k < s.a.a; ++k) 87 ++s.a.a; 88 return *this; 89 } 90 }; 91 92 S3 h; 93 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} 94 95 template <class I, class C> 96 int foomain(I argc, C **argv) { 97 I e(4); 98 I g(5); 99 int i; 100 int &j = i; 101 #pragma omp parallel for simd private // expected-error {{expected '(' after 'private'}} 102 for (int k = 0; k < argc; ++k) 103 ++k; 104 #pragma omp parallel for simd private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 105 for (int k = 0; k < argc; ++k) 106 ++k; 107 #pragma omp parallel for simd private() // expected-error {{expected expression}} 108 for (int k = 0; k < argc; ++k) 109 ++k; 110 #pragma omp parallel for simd private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 111 for (int k = 0; k < argc; ++k) 112 ++k; 113 #pragma omp parallel for simd private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 114 for (int k = 0; k < argc; ++k) 115 ++k; 116 #pragma omp parallel for simd private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 117 for (int k = 0; k < argc; ++k) 118 ++k; 119 #pragma omp parallel for simd private(argc) 120 for (int k = 0; k < argc; ++k) 121 ++k; 122 #pragma omp parallel for simd private(S1) // expected-error {{'S1' does not refer to a value}} 123 for (int k = 0; k < argc; ++k) 124 ++k; 125 #pragma omp parallel for simd private(a, b) // expected-error {{private variable with incomplete type 'S1'}} 126 for (int k = 0; k < argc; ++k) 127 ++k; 128 #pragma omp parallel for simd private(argv[1]) // expected-error {{expected variable name}} 129 for (int k = 0; k < argc; ++k) 130 ++k; 131 #pragma omp parallel for simd private(e, g) 132 for (int k = 0; k < argc; ++k) 133 ++k; 134 #pragma omp parallel for simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}} 135 for (int k = 0; k < argc; ++k) 136 ++k; 137 #pragma omp parallel for simd nowait // expected-error {{unexpected OpenMP clause 'nowait' in directive '#pragma omp parallel for simd'}} 138 for (int k = 0; k < argc; ++k) 139 ++k; 140 #pragma omp parallel 141 { 142 int v = 0; 143 int i; 144 #pragma omp parallel for simd private(i) 145 for (int k = 0; k < argc; ++k) { 146 i = k; 147 v += i; 148 } 149 } 150 #pragma omp parallel shared(i) 151 #pragma omp parallel private(i) 152 #pragma omp parallel for simd private(j) 153 for (int k = 0; k < argc; ++k) 154 ++k; 155 #pragma omp parallel for simd private(i) 156 for (int k = 0; k < argc; ++k) 157 ++k; 158 return 0; 159 } 160 161 namespace A { 162 double x; 163 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} 164 } 165 namespace B { 166 using A::x; 167 } 168 169 int main(int argc, char **argv) { 170 S4 e(4); 171 S5 g(5); 172 S6<float> s6(0.0) , s6_0(1.0); 173 S7<S6<float> > s7(0.0) , s7_0(1.0); 174 int i; 175 int &j = i; 176 #pragma omp parallel for simd private // expected-error {{expected '(' after 'private'}} 177 for (int k = 0; k < argc; ++k) 178 ++k; 179 #pragma omp parallel for simd private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 180 for (int k = 0; k < argc; ++k) 181 ++k; 182 #pragma omp parallel for simd private() // expected-error {{expected expression}} 183 for (int k = 0; k < argc; ++k) 184 ++k; 185 #pragma omp parallel for simd private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 186 for (int k = 0; k < argc; ++k) 187 ++k; 188 #pragma omp parallel for simd private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 189 for (int k = 0; k < argc; ++k) 190 ++k; 191 #pragma omp parallel for simd private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 192 for (int k = 0; k < argc; ++k) 193 ++k; 194 #pragma omp parallel for simd private(argc) 195 for (int k = 0; k < argc; ++k) 196 ++k; 197 #pragma omp parallel for simd private(S1) // expected-error {{'S1' does not refer to a value}} 198 for (int k = 0; k < argc; ++k) 199 ++k; 200 #pragma omp parallel for simd private(a, b) // expected-error {{private variable with incomplete type 'S1'}} 201 for (int k = 0; k < argc; ++k) 202 ++k; 203 #pragma omp parallel for simd private(argv[1]) // expected-error {{expected variable name}} 204 for (int k = 0; k < argc; ++k) 205 ++k; 206 #pragma omp parallel for simd private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} 207 for (int k = 0; k < argc; ++k) 208 ++k; 209 #pragma omp parallel for simd private(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}} 210 for (int k = 0; k < argc; ++k) 211 ++k; 212 #pragma omp parallel for simd nowait // expected-error {{unexpected OpenMP clause 'nowait' in directive '#pragma omp parallel for simd'}} 213 for (int k = 0; k < argc; ++k) 214 ++k; 215 #pragma omp parallel 216 { 217 int i; 218 #pragma omp parallel for simd private(i) 219 for (int k = 0; k < argc; ++k) 220 ++k; 221 } 222 #pragma omp parallel shared(i) 223 #pragma omp parallel private(i) 224 #pragma omp parallel for simd private(j) 225 for (int k = 0; k < argc; ++k) 226 ++k; 227 #pragma omp parallel for simd private(i) 228 for (int k = 0; k < argc; ++k) 229 ++k; 230 static int m; 231 #pragma omp parallel for simd private(m) // OK 232 for (int k = 0; k < argc; ++k) 233 m = k + 3; 234 235 s6 = s6_0; // expected-note {{in instantiation of member function 'S6<float>::operator=' requested here}} 236 s7 = s7_0; // expected-note {{in instantiation of member function 'S7<S6<float> >::operator=' requested here}} 237 return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}} 238 } 239 240