1 // RUN: %clang_cc1 -verify -fopenmp %s
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s
3 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s
5 // RUN: %clang_cc1 -verify -fopenmp-simd %s
6 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 %s
7 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s
12 bool foobool(int argc) {
16 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
20 S2 &operator+(const S2 &arg) { return (*this); } // expected-note 3 {{implicitly declared private here}}
24 S2(S2 &s2) : a(s2.a) {}
25 static float S2s; // expected-note 2 {{static data member is predetermined as shared}}
26 static const float S2sc; // expected-note 2 {{'S2sc' declared here}}
28 const float S2::S2sc = 0;
29 S2 b; // expected-note 3 {{'b' defined here}}
30 const S2 ba[5]; // expected-note 2 {{'ba' defined here}}
37 S3(const S3 &s3) : a(s3.a) {}
38 S3 operator+(const S3 &arg1) { return arg1; }
40 int operator+(const S3 &arg1, const S3 &arg2) { return 5; }
41 S3 c; // expected-note 3 {{'c' defined here}}
42 const S3 ca[5]; // expected-note 2 {{'ca' defined here}}
43 extern const int f; // expected-note 4 {{'f' declared here}}
46 S4(); // expected-note {{implicitly declared private here}}
48 S4 &operator+(const S4 &arg) { return (*this); }
53 S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
56 S5() : a(0) {} // expected-note {{implicitly declared private here}}
57 S5(const S5 &s5) : a(s5.a) {}
58 S5 &operator+(const S5 &arg);
63 class S6 { // expected-note 3 {{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'int' to 'const S6' for 1st argument}}
64 #if __cplusplus >= 201103L // C++11 or later
65 // expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}}
71 operator int() { return 6; }
75 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
77 template <class T> // expected-note {{declared here}}
79 const T d = T(); // expected-note 4 {{'d' defined here}}
80 const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
83 T &j = i; // expected-note 4 {{'j' defined here}}
84 S3 &p = k; // expected-note 2 {{'p' defined here}}
85 const T &r = da[(int)i]; // expected-note 2 {{'r' defined here}}
86 T &q = qa[(int)i]; // expected-note 2 {{'q' defined here}}
88 #pragma omp target teams distribute simd reduction // expected-error {{expected '(' after 'reduction'}}
89 for (int j=0; j<100; j++) foo();
90 #pragma omp target teams distribute simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
91 for (int j=0; j<100; j++) foo();
92 #pragma omp target teams distribute simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
93 for (int j=0; j<100; j++) foo();
94 #pragma omp target teams distribute simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
95 for (int j=0; j<100; j++) foo();
96 #pragma omp target teams distribute simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
97 for (int j=0; j<100; j++) foo();
98 #pragma omp target teams distribute simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
99 for (int j=0; j<100; j++) foo();
100 #pragma omp target teams distribute simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
101 for (int j=0; j<100; j++) foo();
102 #pragma omp target teams distribute simd reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
103 for (int j=0; j<100; j++) foo();
104 #pragma omp target teams distribute simd reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
105 for (int j=0; j<100; j++) foo();
106 #pragma omp target teams distribute simd reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}
107 for (int j=0; j<100; j++) foo();
108 #pragma omp target teams distribute simd reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}}
109 for (int j=0; j<100; j++) foo();
110 #pragma omp target teams distribute simd reduction(&& : argc)
111 for (int j=0; j<100; j++) foo();
112 #pragma omp target teams distribute simd reduction(^ : T) // expected-error {{'T' does not refer to a value}}
113 for (int j=0; j<100; j++) foo();
114 #pragma omp target teams distribute simd reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 3 {{const-qualified list item cannot be reduction}} expected-error 2 {{'operator+' is a private member of 'S2'}}
115 for (int j=0; j<100; j++) foo();
116 #pragma omp target teams distribute simd reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 4 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified list item cannot be reduction}}
117 for (int j=0; j<100; j++) foo();
118 #pragma omp target teams distribute simd reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
119 for (int j=0; j<100; j++) foo();
120 #pragma omp target teams distribute simd reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
121 for (int j=0; j<100; j++) foo();
122 #pragma omp target teams distribute simd reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
123 for (int j=0; j<100; j++) foo();
124 #pragma omp target teams distribute simd reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} expected-error {{const-qualified list item cannot be reduction}}
125 for (int j=0; j<100; j++) foo();
126 #pragma omp target teams distribute simd reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
127 for (int j=0; j<100; j++) foo();
128 #pragma omp target teams distribute simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
129 for (int j=0; j<100; j++) foo();
130 #pragma omp target teams distribute simd reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
131 for (int j=0; j<100; j++) foo();
132 #pragma omp target teams distribute simd reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
133 for (int j=0; j<100; j++) foo();
134 #pragma omp target teams distribute simd reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}
135 for (int j=0; j<100; j++) foo();
136 #pragma omp target teams distribute simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
137 for (int j=0; j<100; j++) foo();
138 #pragma omp parallel private(k)
139 #pragma omp target teams distribute simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
140 for (int j=0; j<100; j++) foo();
141 #pragma omp target teams distribute simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}}
142 for (int j=0; j<100; j++) foo();
143 #pragma omp target teams distribute simd reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}}
144 for (int j=0; j<100; j++) foo();
145 #pragma omp parallel shared(i)
146 #pragma omp parallel reduction(min : i)
147 #pragma omp target teams distribute simd reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
148 for (int j=0; j<100; j++) foo();
149 #pragma omp target teams distribute simd reduction(+ : fl)
150 for (int j=0; j<100; j++) foo();
157 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
163 int main(int argc, char **argv) {
164 const int d = 5; // expected-note 2 {{'d' defined here}}
165 const int da[5] = {0}; // expected-note {{'da' defined here}}
170 int &j = i; // expected-note 2 {{'j' defined here}}
171 S3 &p = k; // expected-note 2 {{'p' defined here}}
172 const int &r = da[i]; // expected-note {{'r' defined here}}
173 int &q = qa[i]; // expected-note {{'q' defined here}}
175 #pragma omp target teams distribute simd reduction // expected-error {{expected '(' after 'reduction'}}
176 for (int j=0; j<100; j++) foo();
177 #pragma omp target teams distribute simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
178 for (int j=0; j<100; j++) foo();
179 #pragma omp target teams distribute simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
180 for (int j=0; j<100; j++) foo();
181 #pragma omp target teams distribute simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
182 for (int j=0; j<100; j++) foo();
183 #pragma omp target teams distribute simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
184 for (int j=0; j<100; j++) foo();
185 #pragma omp target teams distribute simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
186 for (int j=0; j<100; j++) foo();
187 #pragma omp target teams distribute simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
188 for (int j=0; j<100; j++) foo();
189 #pragma omp target teams distribute simd reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
190 for (int j=0; j<100; j++) foo();
191 #pragma omp target teams distribute simd reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
192 for (int j=0; j<100; j++) foo();
193 #pragma omp target teams distribute simd reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
194 for (int j=0; j<100; j++) foo();
195 #pragma omp target teams distribute simd reduction(~ : argc) // expected-error {{expected unqualified-id}}
196 for (int j=0; j<100; j++) foo();
197 #pragma omp target teams distribute simd reduction(&& : argc)
198 for (int j=0; j<100; j++) foo();
199 #pragma omp target teams distribute simd reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
200 for (int j=0; j<100; j++) foo();
201 #pragma omp target teams distribute simd reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{const-qualified list item cannot be reduction}} expected-error {{'operator+' is a private member of 'S2'}}
202 for (int j=0; j<100; j++) foo();
203 #pragma omp target teams distribute simd reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 2 {{const-qualified list item cannot be reduction}}
204 for (int j=0; j<100; j++) foo();
205 #pragma omp target teams distribute simd reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
206 for (int j=0; j<100; j++) foo();
207 #pragma omp target teams distribute simd reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
208 for (int j=0; j<100; j++) foo();
209 #pragma omp target teams distribute simd reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
210 for (int j=0; j<100; j++) foo();
211 #pragma omp target teams distribute simd reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}}
212 for (int j=0; j<100; j++) foo();
213 #pragma omp target teams distribute simd reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
214 for (int j=0; j<100; j++) foo();
215 #pragma omp target teams distribute simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
216 for (int j=0; j<100; j++) foo();
217 #pragma omp target teams distribute simd reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
218 for (int j=0; j<100; j++) foo();
219 #pragma omp target teams distribute simd reduction(& : e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{invalid operands to binary expression ('S4' and 'S4')}} expected-error {{calling a private constructor of class 'S5'}} expected-error {{invalid operands to binary expression ('S5' and 'S5')}}
220 for (int j=0; j<100; j++) foo();
221 #pragma omp target teams distribute simd reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
222 for (int j=0; j<100; j++) foo();
223 #pragma omp target teams distribute simd reduction(+ : o) // expected-error {{no viable overloaded '='}}
224 for (int j=0; j<100; j++) foo();
225 #pragma omp target teams distribute simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
226 for (int j=0; j<100; j++) foo();
227 #pragma omp parallel private(k)
228 #pragma omp target teams distribute simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
229 for (int j=0; j<100; j++) foo();
230 #pragma omp target teams distribute simd reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
231 for (int j=0; j<100; j++) foo();
232 #pragma omp target teams distribute simd reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}}
233 for (int j=0; j<100; j++) foo();
234 #pragma omp parallel shared(i)
235 #pragma omp parallel reduction(min : i)
236 #pragma omp target teams distribute simd reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
237 for (int j=0; j<100; j++) foo();
238 #pragma omp target teams distribute simd reduction(+ : fl)
239 for (int j=0; j<100; j++) foo();
241 #pragma omp target teams distribute simd reduction(+ : m) // OK
242 for (int j=0; j<100; j++) foo();
244 return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<float>' requested here}}