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