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