1 // RUN: %clang_cc1 -verify -fopenmp -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
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
27 public:
S3()28 S3() : a(0) {}
S3(const S3 & s3)29 S3(const S3 &s3) : a(s3.a) {}
30 };
31 const S3 c;
32 const S3 ca[5];
33 extern const int f;
34 class S4 {
35 int a;
36 S4();
37 S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
38
39 public:
S4(int v)40 S4(int v) : a(v) {}
41 };
42 class S5 {
43 int a;
S5()44 S5() : a(0) {}
S5(const S5 & s5)45 S5(const S5 &s5) : a(s5.a) {} // expected-note 2 {{implicitly declared private here}}
46
47 public:
S5(int v)48 S5(int v) : a(v) {}
49 };
50
51 S3 h;
52 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
53
bar(int n,int b[n])54 void bar(int n, int b[n]) {
55 #pragma omp task firstprivate(b)
56 foo();
57 }
58
59 namespace A {
60 double x;
61 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
62 }
63 namespace B {
64 using A::x;
65 }
66
main(int argc,char ** argv)67 int main(int argc, char **argv) {
68 const int d = 5;
69 const int da[5] = {0};
70 S4 e(4);
71 S5 g(5);
72 int i;
73 int &j = i;
74 static int m;
75 #pragma omp task firstprivate // expected-error {{expected '(' after 'firstprivate'}}
76 #pragma omp task firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
77 #pragma omp task firstprivate() // expected-error {{expected expression}}
78 #pragma omp task firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
79 #pragma omp task firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
80 #pragma omp task firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
81 #pragma omp task firstprivate(argc)
82 #pragma omp task firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
83 #pragma omp task firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
84 #pragma omp task firstprivate(argv[1]) // expected-error {{expected variable name}}
85 #pragma omp task firstprivate(ba)
86 #pragma omp task firstprivate(ca)
87 #pragma omp task firstprivate(da)
88 #pragma omp task firstprivate(S2::S2s)
89 #pragma omp task firstprivate(S2::S2sc)
90 #pragma omp task firstprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}} expected-error 2 {{calling a private constructor of class 'S5'}}
91 #pragma omp task firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
92 #pragma omp task private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
93 foo();
94 #pragma omp task shared(i)
95 #pragma omp task firstprivate(i)
96 #pragma omp task firstprivate(j)
97 #pragma omp task firstprivate(m) // OK
98 foo();
99
100 return 0;
101 }
102