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