Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / target_teams_distribute_simd_aligned_messages.cpp
blob8f634db9aff0c17e2e3ba0215c07236e2c74c9a3
1 // RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp-simd %s -Wuninitialized
5 struct B {
6 static int ib[20]; // expected-note 0 {{'B::ib' declared here}}
7 static constexpr int bfoo() { return 8; }
8 };
9 namespace X {
10 B x; // expected-note {{'x' defined here}}
12 constexpr int bfoo() { return 4; }
14 int **z;
15 const int C1 = 1;
16 const int C2 = 2;
17 void test_aligned_colons(int *&rp)
19 int *B = 0;
21 #pragma omp target teams distribute simd aligned(B:bfoo())
22 for (int i = 0; i < 10; ++i) ;
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) ;
27 #pragma omp target teams distribute simd aligned(B:B::bfoo())
28 for (int i = 0; i < 10; ++i) ;
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) ;
33 #pragma omp target teams distribute simd aligned(B:B::bfoo())
34 for (int i = 0; i < 10; ++i) ;
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) ;
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) ;
42 #pragma omp target teams distribute simd aligned(::z)
43 for (int i = 0; i < 10; ++i) ;
45 #pragma omp target teams distribute simd aligned(B::bfoo()) // expected-error {{expected variable name}}
46 for (int i = 0; i < 10; ++i) ;
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) ;
52 // expected-note@+1 {{'num' defined here}}
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.
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;
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);
69 return T();
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;
78 return 0;
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:
86 S2():a(0) { }
88 const S2 b; // expected-note 1 {{'b' defined here}}
89 const S2 ba[5];
90 class S3 {
91 int a;
92 public:
93 S3():a(0) { }
95 const S3 ca[5];
96 class S4 {
97 int a;
98 S4();
99 public:
100 S4(int v):a(v) { }
102 class S5 {
103 int a;
104 S5():a(0) {}
105 public:
106 S5(int v):a(v) { }
109 S3 h; // expected-note 2 {{'h' defined here}}
110 #pragma omp threadprivate(h)
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;
119 #pragma omp target teams distribute simd aligned // expected-error {{expected '(' after 'aligned'}}
120 for (I k = 0; k < argc; ++k) ++k;
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;
125 #pragma omp target teams distribute simd aligned () // expected-error {{expected expression}}
126 for (I k = 0; k < argc; ++k) ++k;
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;
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;
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;
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;
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;
144 #pragma omp target teams distribute simd aligned (argv[1]) // expected-error {{expected variable name}}
145 for (I k = 0; k < argc; ++k) ++k;
147 #pragma omp target teams distribute simd aligned(e, g)
148 for (I k = 0; k < argc; ++k) ++k;
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;
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;
156 #pragma omp parallel
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; }
163 float *f;
165 #pragma omp target teams distribute simd aligned(f)
166 for (I k = 0; k < argc; ++k) ++k;
168 int v = 0;
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}}
172 for (I k = 0; k < argc; ++k) { ++k; v += j; }
174 #pragma omp target teams distribute simd aligned(f)
175 for (I k = 0; k < argc; ++k) ++k;
177 return 0;
180 // expected-note@+1 2 {{'argc' defined here}}
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>();
189 int i;
190 int &j = i;
192 #pragma omp target teams distribute simd aligned // expected-error {{expected '(' after 'aligned'}}
193 for (int k = 0; k < argc; ++k) ++k;
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;
198 #pragma omp target teams distribute simd aligned () // expected-error {{expected expression}}
199 for (int k = 0; k < argc; ++k) ++k;
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;
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;
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;
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;
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;
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;
221 #pragma omp target teams distribute simd aligned (argv[1]) // expected-error {{expected variable name}}
222 for (int k = 0; k < argc; ++k) ++k;
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;
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;