]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/OpenMP/target_teams_distribute_simd_linear_messages.cpp
Vendor import of clang trunk r338150:
[FreeBSD/FreeBSD.git] / test / OpenMP / target_teams_distribute_simd_linear_messages.cpp
1 // RUN: %clang_cc1 -verify -fopenmp %s
2
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s
4
5 namespace X {
6   int x;
7 };
8
9 struct B {
10   static int ib; // expected-note {{'B::ib' declared here}}
11   static int bfoo() { return 8; }
12 };
13
14 int bfoo() { return 4; }
15
16 int z;
17 const int C1 = 1;
18 const int C2 = 2;
19 void test_linear_colons()
20 {
21   int B = 0;
22
23 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
24 #pragma omp target teams distribute simd linear(B:bfoo())
25   for (int i = 0; i < 10; ++i) ;
26
27 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
28 #pragma omp target teams distribute simd linear(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}}
29   for (int i = 0; i < 10; ++i) ;
30
31 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
32 #pragma omp target teams distribute simd linear(B:ib) // expected-error {{use of undeclared identifier 'ib'; did you mean 'B::ib'}}
33   for (int i = 0; i < 10; ++i) ;
34
35 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
36 #pragma omp target teams distribute simd linear(z:B:ib) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}}
37   for (int i = 0; i < 10; ++i) ;
38
39 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
40 #pragma omp target teams distribute simd linear(B:B::bfoo())
41   for (int i = 0; i < 10; ++i) ;
42
43 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
44 #pragma omp target teams distribute simd linear(X::x : ::z)
45   for (int i = 0; i < 10; ++i) ;
46
47 // expected-error@+1 3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
48 #pragma omp target teams distribute simd linear(B,::z, X::x)
49   for (int i = 0; i < 10; ++i) ;
50
51 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
52 #pragma omp target teams distribute simd linear(::z)
53   for (int i = 0; i < 10; ++i) ;
54
55 #pragma omp target teams distribute simd linear(B::bfoo()) // expected-error {{expected variable name}}
56   for (int i = 0; i < 10; ++i) ;
57
58 // expected-error@+1 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
59 #pragma omp target teams distribute simd linear(B::ib,B:C1+C2)
60   for (int i = 0; i < 10; ++i) ;
61 }
62
63 template<int L, class T, class N> T test_template(T* arr, N num) {
64   N i;
65   T sum = (T)0;
66   T ind2 = - num * L; // expected-note {{'ind2' defined here}}
67
68 #pragma omp target teams distribute simd linear(ind2:L) // expected-error {{argument of a linear clause should be of integral or pointer type}}
69   for (i = 0; i < num; ++i) {
70     T cur = arr[(int)ind2];
71     ind2 += L;
72     sum += cur;
73   }
74   return T();
75 }
76
77 template<int LEN> int test_warn() {
78   int ind2 = 0;
79 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
80   #pragma omp target teams distribute simd linear(ind2:LEN) // expected-warning {{zero linear step (ind2 should probably be const)}}
81   for (int i = 0; i < 100; i++) {
82     ind2 += LEN;
83   }
84   return ind2;
85 }
86
87 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
88 extern S1 a;
89 class S2 {
90   mutable int a;
91 public:
92   S2():a(0) { }
93 };
94 const S2 b; // expected-note 2 {{'b' defined here}}
95 const S2 ba[5];
96 class S3 {
97   int a;
98 public:
99   S3():a(0) { }
100 };
101 const S3 ca[5];
102 class S4 {
103   int a;
104   S4();
105 public:
106   S4(int v):a(v) { }
107 };
108 class S5 {
109   int a;
110   S5():a(0) {}
111 public:
112   S5(int v):a(v) { }
113 };
114
115 S3 h;
116 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
117
118 template<class I, class C> int foomain(I argc, C **argv) {
119   I e(4);
120   I g(5);
121   int i;
122   int &j = i;
123
124 #pragma omp target teams distribute simd linear // expected-error {{expected '(' after 'linear'}}
125   for (int k = 0; k < argc; ++k) ++k;
126
127 #pragma omp target teams distribute simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
128   for (int k = 0; k < argc; ++k) ++k;
129
130 #pragma omp target teams distribute simd linear () // expected-error {{expected expression}}
131   for (int k = 0; k < argc; ++k) ++k;
132
133 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
134 #pragma omp target teams distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
135   for (int k = 0; k < argc; ++k) ++k;
136
137 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
138 #pragma omp target teams distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
139   for (int k = 0; k < argc; ++k) ++k;
140
141 #pragma omp target teams distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
142   for (int k = 0; k < argc; ++k) ++k;
143
144 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
145 #pragma omp target teams distribute simd linear (argc : 5)
146   for (int k = 0; k < argc; ++k) ++k;
147
148 #pragma omp target teams distribute simd linear (S1) // expected-error {{'S1' does not refer to a value}}
149   for (int k = 0; k < argc; ++k) ++k;
150
151 #pragma omp target teams distribute simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}}
152   for (int k = 0; k < argc; ++k) ++k;
153
154 #pragma omp target teams distribute simd linear (argv[1]) // expected-error {{expected variable name}}
155   for (int k = 0; k < argc; ++k) ++k;
156
157 // expected-error@+1 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
158 #pragma omp target teams distribute simd linear(e, g)
159   for (int k = 0; k < argc; ++k) ++k;
160
161 #pragma omp target teams distribute simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}}
162   for (int k = 0; k < argc; ++k) ++k;
163
164 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
165 #pragma omp target teams distribute simd linear(i)
166   for (int k = 0; k < argc; ++k) ++k;
167
168   return 0;
169 }
170
171 namespace A {
172 double x;
173 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
174 }
175 namespace C {
176 using A::x;
177 }
178
179 int main(int argc, char **argv) {
180   double darr[100];
181   // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
182   test_template<-4>(darr, 4);
183   // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
184   test_warn<0>();
185
186   S4 e(4); // expected-note {{'e' defined here}}
187   S5 g(5); // expected-note {{'g' defined here}}
188   int i;
189   int &j = i;
190
191 #pragma omp target teams distribute simd linear // expected-error {{expected '(' after 'linear'}}
192   for (int k = 0; k < argc; ++k) ++k;
193
194 #pragma omp target teams distribute simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
195   for (int k = 0; k < argc; ++k) ++k;
196
197 #pragma omp target teams distribute simd linear () // expected-error {{expected expression}}
198   for (int k = 0; k < argc; ++k) ++k;
199
200 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
201 #pragma omp target teams distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
202   for (int k = 0; k < argc; ++k) ++k;
203
204 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
205 #pragma omp target teams distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
206   for (int k = 0; k < argc; ++k) ++k;
207
208 #pragma omp target teams distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
209   for (int k = 0; k < argc; ++k) ++k;
210
211 // expected-error@+1 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}}
212 #pragma omp target teams distribute simd linear (argc)
213   for (int k = 0; k < argc; ++k) ++k;
214
215 #pragma omp target teams distribute simd linear (S1) // expected-error {{'S1' does not refer to a value}}
216   for (int k = 0; k < argc; ++k) ++k;
217
218
219 #pragma omp target teams distribute simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{const-qualified variable cannot be linear}}
220   for (int k = 0; k < argc; ++k) ++k;
221
222 #pragma omp target teams distribute simd linear (argv[1]) // expected-error {{expected variable name}}
223   for (int k = 0; k < argc; ++k) ++k;
224
225 #pragma omp target teams distribute simd linear(e, g) // expected-error {{argument of a linear clause should be of integral or pointer type, not 'S4'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S5'}}
226   for (int k = 0; k < argc; ++k) ++k;
227
228 #pragma omp target teams distribute simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}}
229   for (int k = 0; k < argc; ++k) ++k;
230
231   foomain<int,char>(argc,argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}
232   return 0;
233 }
234