• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  // RUN: %clang_cc1 -verify -fopenmp %s
2  
foo()3  void foo() {
4  }
5  
foobool(int argc)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:
S2()16    S2() : a(0) {}
S2(const S2 & s2)17    S2(const S2 &s2) : a(s2.a) {}
18    static float S2s;
19    static const float S2sc;
20  };
21  const float S2::S2sc = 0;
22  const S2 b;
23  const S2 ba[5];
24  class S3 {
25    int a;
26    S3 &operator=(const S3 &s3);
27  
28  public:
S3()29    S3() : a(0) {} // expected-note 2 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
S3(S3 & s3)30    S3(S3 &s3) : a(s3.a) {} // expected-note 2 {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
31  };
32  const S3 c;
33  const S3 ca[5];
34  extern const int f;
35  class S4 {
36    int a;
37    S4();
38    S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
39  
40  public:
S4(int v)41    S4(int v) : a(v) {}
42  };
43  class S5 {
44    int a;
S5(const S5 & s5)45    S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}
46  
47  public:
S5()48    S5() : a(0) {}
S5(int v)49    S5(int v) : a(v) {}
50  };
51  class S6 {
52    int a;
S6()53    S6() : a(0) {}
54  
55  public:
S6(const S6 & s6)56    S6(const S6 &s6) : a(s6.a) {}
S6(int v)57    S6(int v) : a(v) {}
58  };
59  
60  S3 h;
61  #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
62  
63  template <class I, class C>
foomain(int argc,char ** argv)64  int foomain(int argc, char **argv) {
65    I e(4);
66    C g(5);
67    int i;
68    int &j = i;
69  #pragma omp parallel
70  #pragma omp taskloop firstprivate // expected-error {{expected '(' after 'firstprivate'}}
71    for (int k = 0; k < argc; ++k)
72      ++k;
73  #pragma omp parallel
74  #pragma omp taskloop firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
75    for (int k = 0; k < argc; ++k)
76      ++k;
77  #pragma omp parallel
78  #pragma omp taskloop firstprivate() // expected-error {{expected expression}}
79    for (int k = 0; k < argc; ++k)
80      ++k;
81  #pragma omp parallel
82  #pragma omp taskloop firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
83    for (int k = 0; k < argc; ++k)
84      ++k;
85  #pragma omp parallel
86  #pragma omp taskloop firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
87    for (int k = 0; k < argc; ++k)
88      ++k;
89  #pragma omp parallel
90  #pragma omp taskloop firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
91    for (int k = 0; k < argc; ++k)
92      ++k;
93  #pragma omp parallel
94  #pragma omp taskloop firstprivate(argc)
95    for (int k = 0; k < argc; ++k)
96      ++k;
97  #pragma omp parallel
98  #pragma omp taskloop firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
99    for (int k = 0; k < argc; ++k)
100      ++k;
101  #pragma omp parallel
102  #pragma omp taskloop firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
103    for (int k = 0; k < argc; ++k)
104      ++k;
105  #pragma omp parallel
106  #pragma omp taskloop firstprivate(argv[1]) // expected-error {{expected variable name}}
107    for (int k = 0; k < argc; ++k)
108      ++k;
109  #pragma omp parallel
110  #pragma omp taskloop firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
111    for (int k = 0; k < argc; ++k)
112      ++k;
113  #pragma omp parallel
114  #pragma omp taskloop firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
115    for (int k = 0; k < argc; ++k)
116      ++k;
117  #pragma omp parallel
118    {
119      int v = 0;
120      int i;
121  #pragma omp taskloop firstprivate(i)
122      for (int k = 0; k < argc; ++k) {
123        i = k;
124        v += i;
125      }
126    }
127  #pragma omp parallel shared(i)
128  #pragma omp parallel private(i)
129  #pragma omp taskloop firstprivate(j)
130    for (int k = 0; k < argc; ++k)
131      ++k;
132  #pragma omp parallel
133  #pragma omp taskloop firstprivate(i)
134    for (int k = 0; k < argc; ++k)
135      ++k;
136  #pragma omp parallel
137  #pragma omp taskloop lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
138    for (i = 0; i < argc; ++i)
139      foo();
140  #pragma omp parallel private(i)
141  #pragma omp taskloop firstprivate(i) // expected-note {{defined as firstprivate}}
142    for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp taskloop' directive may not be firstprivate, predetermined as private}}
143      foo();
144  #pragma omp parallel reduction(+ : i)
145  #pragma omp taskloop firstprivate(i) // expected-note {{defined as firstprivate}}
146    for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp taskloop' directive may not be firstprivate, predetermined as private}}
147      foo();
148    return 0;
149  }
150  
bar(S4 a[2])151  void bar(S4 a[2]) {
152  #pragma omp parallel
153  #pragma omp taskloop firstprivate(a)
154    for (int i = 0; i < 2; ++i)
155      foo();
156  }
157  
158  namespace A {
159  double x;
160  #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
161  }
162  namespace B {
163  using A::x;
164  }
165  
main(int argc,char ** argv)166  int main(int argc, char **argv) {
167    const int d = 5;
168    const int da[5] = {0};
169    S4 e(4);
170    S5 g(5);
171    S3 m;
172    S6 n(2);
173    int i;
174    int &j = i;
175  #pragma omp parallel
176  #pragma omp taskloop firstprivate // expected-error {{expected '(' after 'firstprivate'}}
177    for (i = 0; i < argc; ++i)
178      foo();
179  #pragma omp parallel
180  #pragma omp taskloop firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
181    for (i = 0; i < argc; ++i)
182      foo();
183  #pragma omp parallel
184  #pragma omp taskloop firstprivate() // expected-error {{expected expression}}
185    for (i = 0; i < argc; ++i)
186      foo();
187  #pragma omp parallel
188  #pragma omp taskloop firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
189    for (i = 0; i < argc; ++i)
190      foo();
191  #pragma omp parallel
192  #pragma omp taskloop firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
193    for (i = 0; i < argc; ++i)
194      foo();
195  #pragma omp parallel
196  #pragma omp taskloop firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
197    for (i = 0; i < argc; ++i)
198      foo();
199  #pragma omp parallel
200  #pragma omp taskloop firstprivate(argc)
201    for (i = 0; i < argc; ++i)
202      foo();
203  #pragma omp parallel
204  #pragma omp taskloop firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
205    for (i = 0; i < argc; ++i)
206      foo();
207  #pragma omp parallel
208  #pragma omp taskloop firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{no matching constructor for initialization of 'S3'}}
209    for (i = 0; i < argc; ++i)
210      foo();
211  #pragma omp parallel
212  #pragma omp taskloop firstprivate(argv[1]) // expected-error {{expected variable name}}
213    for (i = 0; i < argc; ++i)
214      foo();
215  #pragma omp parallel
216  #pragma omp taskloop firstprivate(2 * 2) // expected-error {{expected variable name}}
217    for (i = 0; i < argc; ++i)
218      foo();
219  #pragma omp parallel
220  #pragma omp taskloop firstprivate(ba) // OK
221    for (i = 0; i < argc; ++i)
222      foo();
223  #pragma omp parallel
224  #pragma omp taskloop firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}}
225    for (i = 0; i < argc; ++i)
226      foo();
227  #pragma omp parallel
228  #pragma omp taskloop firstprivate(da) // OK
229    for (i = 0; i < argc; ++i)
230      foo();
231    int xa;
232  #pragma omp parallel
233  #pragma omp taskloop firstprivate(xa) // OK
234    for (i = 0; i < argc; ++i)
235      foo();
236  #pragma omp parallel
237  #pragma omp taskloop firstprivate(S2::S2s) // OK
238    for (i = 0; i < argc; ++i)
239      foo();
240  #pragma omp parallel
241  #pragma omp taskloop firstprivate(S2::S2sc) // OK
242    for (i = 0; i < argc; ++i)
243      foo();
244  #pragma omp parallel
245  #pragma omp taskloop safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp taskloop'}}
246    for (i = 0; i < argc; ++i)
247      foo();
248  #pragma omp parallel
249  #pragma omp taskloop firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
250    for (i = 0; i < argc; ++i)
251      foo();
252  #pragma omp parallel
253  #pragma omp taskloop firstprivate(m) // OK
254    for (i = 0; i < argc; ++i)
255      foo();
256  #pragma omp parallel
257  #pragma omp taskloop firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
258    for (i = 0; i < argc; ++i)
259      foo();
260  #pragma omp parallel
261  #pragma omp taskloop private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
262    for (i = 0; i < argc; ++i)
263      foo();
264  #pragma omp parallel
265  #pragma omp taskloop firstprivate(i) // expected-note {{defined as firstprivate}}
266    for (i = 0; i < argc; ++i)    // expected-error {{loop iteration variable in the associated loop of 'omp taskloop' directive may not be firstprivate, predetermined as private}}
267      foo();
268  #pragma omp parallel shared(xa)
269  #pragma omp taskloop firstprivate(xa) // OK: may be firstprivate
270    for (i = 0; i < argc; ++i)
271      foo();
272  #pragma omp parallel
273  #pragma omp taskloop firstprivate(j)
274    for (i = 0; i < argc; ++i)
275      foo();
276  #pragma omp parallel
277  #pragma omp taskloop lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
278    for (i = 0; i < argc; ++i)
279      foo();
280  #pragma omp parallel
281  #pragma omp taskloop lastprivate(n) firstprivate(n) // OK
282    for (i = 0; i < argc; ++i)
283      foo();
284  #pragma omp parallel
285    {
286      int v = 0;
287      int i;
288  #pragma omp taskloop firstprivate(i)
289      for (int k = 0; k < argc; ++k) {
290        i = k;
291        v += i;
292      }
293    }
294  #pragma omp parallel private(i)
295  #pragma omp taskloop firstprivate(i) // expected-note {{defined as firstprivate}}
296    for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp taskloop' directive may not be firstprivate, predetermined as private}}
297      foo();
298  #pragma omp parallel reduction(+ : i) // expected-note 4 {{defined as reduction}}
299  #pragma omp taskloop firstprivate(i) //expected-error {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
300    for (i = 0; i < argc; ++i) // expected-error 3 {{reduction variables may not be accessed in an explicit task}}
301      foo();
302  #pragma omp parallel
303  #pragma omp taskloop firstprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
304    for (i = 0; i < argc; ++i)
305      foo();
306    static int si;
307  #pragma omp taskloop firstprivate(si) // OK
308    for (i = 0; i < argc; ++i)
309      si = i + 1;
310  
311    return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
312  }
313  
314