[NFC] Maintainers.rst: align email address formatting
[llvm-project.git] / clang / test / OpenMP / for_linear_messages.cpp
blobd8d3391c0c27150200a2d2e5b4edfe18a3ae0100
1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -DOMP52 %s -Wuninitialized
4 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
5 // RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -DOMP52 %s -Wuninitialized
7 extern int omp_default_mem_alloc;
9 void xxx(int argc) {
10 int i, lin, step_sz; // expected-note {{initialize the variable 'lin' to silence this warning}} expected-note {{initialize the variable 'step_sz' to silence this warning}}
11 #pragma omp for linear(lin : step_sz) // expected-warning {{variable 'lin' is uninitialized when used here}} expected-warning {{variable 'step_sz' is uninitialized when used here}}
12 for (i = 0; i < 10; ++i)
16 namespace X {
17 int x;
20 struct B {
21 static int ib; // expected-note {{'B::ib' declared here}}
22 static int bfoo() { return 8; }
25 int bfoo() { return 4; }
27 int z;
28 const int C1 = 1;
29 const int C2 = 2;
30 void test_linear_colons()
32 int B = 0;
33 #pragma omp for linear(B:bfoo())
34 for (int i = 0; i < 10; ++i) ;
35 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
36 #pragma omp for linear(B::ib:B:bfoo())
37 for (int i = 0; i < 10; ++i) ;
38 // expected-error@+1 {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
39 #pragma omp for linear(B:ib)
40 for (int i = 0; i < 10; ++i) ;
41 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
42 #pragma omp for linear(z:B:ib)
43 for (int i = 0; i < 10; ++i) ;
44 #pragma omp for linear(B:B::bfoo())
45 for (int i = 0; i < 10; ++i) ;
46 #pragma omp for linear(X::x : ::z)
47 for (int i = 0; i < 10; ++i) ;
48 #pragma omp for linear(B,::z, X::x)
49 for (int i = 0; i < 10; ++i) ;
50 #pragma omp for linear(::z)
51 for (int i = 0; i < 10; ++i) ;
52 // expected-error@+1 {{expected variable name}}
53 #pragma omp for linear(B::bfoo())
54 for (int i = 0; i < 10; ++i) ;
55 #pragma omp for linear(B::ib,B:C1+C2)
56 for (int i = 0; i < 10; ++i) ;
59 template<int L, class T, class N> T test_template(T* arr, N num) {
60 N i;
61 T sum = (T)0;
62 T ind2 = - num * L; // expected-note {{'ind2' defined here}}
63 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type}}
64 #pragma omp for linear(ind2:L)
65 for (i = 0; i < num; ++i) {
66 T cur = arr[(int)ind2];
67 ind2 += L;
68 sum += cur;
70 return T();
73 template<int LEN> int test_warn() {
74 int ind2 = 0;
75 // expected-warning@+1 {{zero linear step (ind2 should probably be const)}}
76 #pragma omp for linear(ind2:LEN)
77 for (int i = 0; i < 100; i++) {
78 ind2 += LEN;
80 return ind2;
83 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
84 extern S1 a;
85 class S2 {
86 mutable int a;
87 public:
88 S2():a(0) { }
90 const S2 b; // expected-note 2 {{'b' defined here}}
91 const S2 ba[5];
92 class S3 {
93 int a;
94 public:
95 S3():a(0) { }
97 const S3 ca[5];
98 class S4 {
99 int a;
100 S4();
101 public:
102 S4(int v):a(v) { }
104 class S5 {
105 int a;
106 S5():a(0) {}
107 public:
108 S5(int v):a(v) { }
111 S3 h;
112 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
114 template<class I, class C> int foomain(I argc, C **argv) {
115 I e(4);
116 I g(5);
117 int i, k;
118 int &j = i;
119 #pragma omp for linear // expected-error {{expected '(' after 'linear'}}
120 for (int k = 0; k < argc; ++k) ++k;
121 #pragma omp for linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
122 for (int k = 0; k < argc; ++k) ++k;
123 #pragma omp for linear () // expected-error {{expected expression}}
124 for (int k = 0; k < argc; ++k) ++k;
125 #pragma omp for linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
126 for (int k = 0; k < argc; ++k) ++k;
127 #pragma omp for linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
128 for (int k = 0; k < argc; ++k) ++k;
129 #pragma omp for linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
130 for (int k = 0; k < argc; ++k) ++k;
131 #pragma omp for linear (argc : 5) 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 '('}}
132 for (int k = 0; k < argc; ++k) ++k;
133 #pragma omp for linear (S1) // expected-error {{'S1' does not refer to a value}}
134 for (int k = 0; k < argc; ++k) ++k;
135 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
136 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
137 #pragma omp for linear (a, b:B::ib)
138 for (int k = 0; k < argc; ++k) ++k;
139 #pragma omp for linear (argv[1]) // expected-error {{expected variable name}}
140 for (int k = 0; k < argc; ++k) ++k;
141 #pragma omp for linear(e, g, k)
142 for (int k = 0; k < argc; ++k) ++k;
143 #pragma omp for linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
144 for (int k = 0; k < argc; ++k) ++k;
145 #pragma omp for linear(i)
146 for (int k = 0; k < argc; ++k) ++k;
147 #pragma omp parallel
149 int v = 0;
150 int i;
151 #pragma omp for linear(v:i)
152 for (int k = 0; k < argc; ++k) { i = k; v += i; }
154 #pragma omp for linear(j)
155 for (int k = 0; k < argc; ++k) ++k;
156 int v = 0;
157 #pragma omp for linear(v:j)
158 for (int k = 0; k < argc; ++k) { ++k; v += j; }
159 #pragma omp for linear(i)
160 for (int k = 0; k < argc; ++k) ++k;
161 #pragma omp for linear(i) ordered(1) // expected-error {{'linear' clause cannot be specified along with 'ordered' clause with a parameter}}
162 for (int k = 0; k < argc; ++k) ++k;
163 return 0;
166 namespace A {
167 double x;
168 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
170 namespace C {
171 using A::x;
174 int main(int argc, char **argv) {
175 double darr[100];
176 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
177 test_template<-4>(darr, 4);
178 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
179 test_warn<0>();
181 S4 e(4); // expected-note {{'e' defined here}}
182 S5 g(5); // expected-note {{'g' defined here}}
183 int i, k;
184 int &j = i;
185 #pragma omp for linear // expected-error {{expected '(' after 'linear'}}
186 for (int k = 0; k < argc; ++k) ++k;
187 #pragma omp for linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
188 for (int k = 0; k < argc; ++k) ++k;
189 #pragma omp for linear () // expected-error {{expected expression}}
190 for (int k = 0; k < argc; ++k) ++k;
191 #pragma omp for linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
192 for (int k = 0; k < argc; ++k) ++k;
193 #pragma omp for linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
194 for (int k = 0; k < argc; ++k) ++k;
195 #pragma omp for linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
196 for (int k = 0; k < argc; ++k) ++k;
197 #pragma omp for linear (argc)
198 for (int k = 0; k < argc; ++k) ++k;
199 #pragma omp for linear (S1) // expected-error {{'S1' does not refer to a value}}
200 for (int k = 0; k < argc; ++k) ++k;
201 // expected-error@+2 {{linear variable with incomplete type 'S1'}}
202 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}}
203 #pragma omp for linear(a, b, k)
204 for (int k = 0; k < argc; ++k) ++k;
205 #pragma omp for linear (argv[1]) // expected-error {{expected variable name}}
206 for (int k = 0; k < argc; ++k) ++k;
207 // expected-error@+2 {{argument of a linear clause should be of integral or pointer type, not 'S4'}}
208 // expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S5'}}
209 #pragma omp for linear(e, g)
210 for (int k = 0; k < argc; ++k) ++k;
211 #pragma omp for linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
212 for (int k = 0; k < argc; ++k) ++k;
213 #pragma omp parallel
215 int i;
216 #pragma omp for linear(i)
217 for (int k = 0; k < argc; ++k) ++k;
218 #pragma omp for linear(val(i)) // omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}}
219 for (int k = 0; k < argc; ++k) ++k;
220 #ifdef OMP52
221 #pragma omp for linear(i : step(4))
222 #else
223 #pragma omp for linear(i : 4)
224 #endif
225 for (int k = 0; k < argc; ++k) { ++k; i += 4; }
227 #ifdef OMP52
228 #pragma omp for linear(j: step() //omp52-error 2 {{expected expression}} omp52-error{{expected ')'}} omp52-note{{to match this '('}}
229 #else
230 #pragma omp for linear(j)
231 #endif
232 for (int k = 0; k < argc; ++k) ++k;
233 #ifdef OMP52
234 #pragma omp for linear(i: step(1), val)
235 #else
236 #pragma omp for linear(i)
237 #endif
238 for (int k = 0; k < argc; ++k) ++k;
239 #pragma omp for linear(i) ordered(1) // expected-error {{'linear' clause cannot be specified along with 'ordered' clause with a parameter}}
240 for (int k = 0; k < argc; ++k) ++k;
241 #ifdef OMP52
242 #pragma omp for linear(j: step()) // omp52-error 2 {{expected expression}}
243 for (int k = 0; k < argc; ++k) ++k;
244 #pragma omp for linear(j: step(1), step(2)) // omp52-error {{multiple 'step size' found in linear clause}}
245 for (int k = 0; k < argc; ++k) ++k;
246 #pragma omp for linear(j: val, val) // omp52-error {{multiple 'linear modifier' found in linear clause}}
247 for (int k = 0; k < argc; ++k) ++k;
248 #pragma omp for linear(j: pval) // omp52-error{{use of undeclared identifier 'pval'}}
249 for (int k = 0; k < argc; ++k) ++k;
250 #pragma omp for linear(i: val, step(2 // omp52-error 3 {{expected ')'}} omp52-note 2 {{to match this '('}}
251 for (int k = 0; k < argc; ++k) ++k;
252 #endif
254 foomain<int,char>(argc,argv); // expected-note {{n instantiation of function template specialization 'foomain<int, char>' requested here}}
255 return 0;