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