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