1 // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %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 {{declared here}} expected-note{{forward declaration of 'S1'}}
11 extern S1 a;
12 class S2 {
13 mutable int a;
14 public:
S2()15 S2():a(0) { }
S2(S2 & s2)16 S2(S2 &s2):a(s2.a) { }
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:
S3()26 S3():a(0) { }
S3(S3 & s3)27 S3(S3 &s3):a(s3.a) { }
28 };
29 const S3 c;
30 const S3 ca[5];
31 extern const int f;
32 class S4 { // expected-note {{'S4' declared here}}
33 int a;
34 S4();
35 S4(const S4 &s4);
36 public:
S4(int v)37 S4(int v):a(v) { }
38 };
39 class S5 { // expected-note {{'S5' declared here}}
40 int a;
S5()41 S5():a(0) {}
S5(const S5 & s5)42 S5(const S5 &s5):a(s5.a) { }
43 public:
S5(int v)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
main(int argc,char ** argv)50 int main(int argc, char **argv) {
51 const int d = 5;
52 const int da[5] = { 0 };
53 S4 e(4); // expected-note {{'e' defined here}}
54 S5 g(5); // expected-note {{'g' defined here}}
55 int i;
56 int &j = i; // expected-note {{'j' defined here}}
57 #pragma omp parallel firstprivate // expected-error {{expected '(' after 'firstprivate'}}
58 #pragma omp parallel firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
59 #pragma omp parallel firstprivate () // expected-error {{expected expression}}
60 #pragma omp parallel firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
61 #pragma omp parallel firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
62 #pragma omp parallel firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
63 #pragma omp parallel firstprivate (argc)
64 #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
65 #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
66 #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected variable name}}
67 #pragma omp parallel firstprivate(ba)
68 #pragma omp parallel firstprivate(ca)
69 #pragma omp parallel firstprivate(da)
70 #pragma omp parallel firstprivate(S2::S2s)
71 #pragma omp parallel firstprivate(S2::S2sc)
72 #pragma omp parallel firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
73 #pragma omp parallel firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
74 #pragma omp parallel private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
75 foo();
76 #pragma omp parallel shared(i)
77 #pragma omp parallel firstprivate(i)
78 #pragma omp parallel firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
79 foo();
80
81 return 0;
82 }
83