1 // RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
6 bool foobool(int argc) {
10 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
17 S2(const S2 &s2) : a(s2.a) {}
19 static const float S2sc;
21 const float S2::S2sc = 0;
26 S3 &operator=(const S3 &s3);
30 S3(const S3 &s3) : a(s3.a) {}
38 S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
45 S5(const S5 &s5) : a(s5.a) {} // expected-note 4 {{implicitly declared private here}}
56 S6(const S6 &s6) : a(s6.a) {}
61 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
63 template <class I, class C>
64 int foomain(int argc, char **argv) {
68 int &j = i; // expected-note {{'j' defined here}}
70 #pragma omp single firstprivate // expected-error {{expected '(' after 'firstprivate'}}
73 #pragma omp single firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
76 #pragma omp single firstprivate() // expected-error {{expected expression}}
79 #pragma omp single firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
82 #pragma omp single firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
85 #pragma omp single firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
88 #pragma omp single firstprivate(argc)
91 #pragma omp single firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
94 #pragma omp single firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
97 #pragma omp single firstprivate(argv[1]) // expected-error {{expected variable name}}
100 #pragma omp single firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
103 #pragma omp single firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
106 #pragma omp single linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp single'}}
111 int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp single' directive into a parallel or another task region?}}
112 #pragma omp single firstprivate(i) // expected-error {{private variable cannot be firstprivate}}
116 #pragma omp parallel shared(i)
117 #pragma omp parallel private(i)
118 #pragma omp single firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
121 #pragma omp single firstprivate(i)
124 #pragma omp single firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
126 #pragma omp parallel private(i) // expected-note {{defined as private}}
127 #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
129 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
130 #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
135 int main(int argc, char **argv) {
137 const int da[5] = {0};
143 int &j = i; // expected-note {{'j' defined here}}
145 #pragma omp single firstprivate // expected-error {{expected '(' after 'firstprivate'}}
148 #pragma omp single firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
151 #pragma omp single firstprivate() // expected-error {{expected expression}}
154 #pragma omp single firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
157 #pragma omp single firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
160 #pragma omp single firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
163 #pragma omp single firstprivate(argc)
166 #pragma omp single firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
169 #pragma omp single firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
172 #pragma omp single firstprivate(argv[1]) // expected-error {{expected variable name}}
175 #pragma omp single firstprivate(2 * 2) // expected-error {{expected variable name}}
178 #pragma omp single firstprivate(ba) // OK
181 #pragma omp single firstprivate(ca) // OK
184 #pragma omp single firstprivate(da) // OK
188 #pragma omp single firstprivate(xa) // OK
191 #pragma omp single firstprivate(S2::S2s) // OK
194 #pragma omp single firstprivate(S2::S2sc) // OK
197 #pragma omp single safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp single'}}
200 #pragma omp single firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
203 #pragma omp single firstprivate(m) // OK
206 #pragma omp single firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
209 #pragma omp single private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
211 #pragma omp parallel shared(xa)
212 #pragma omp single firstprivate(xa) // OK: may be firstprivate
215 #pragma omp single firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
218 #pragma omp single firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
221 #pragma omp single firstprivate(n) // OK
226 int i; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp single' directive into a parallel or another task region?}}
227 #pragma omp single firstprivate(i) // expected-error {{private variable cannot be firstprivate}}
231 #pragma omp parallel private(i) // expected-note {{defined as private}}
232 #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
234 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
235 #pragma omp single firstprivate(i) // expected-error {{firstprivate variable must be shared}}
238 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}