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