1 // RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp %s
4 static int ib[20]; // expected-note 0 {{'B::ib' declared here}}
5 static constexpr int bfoo() { return 8; }
8 B x; // expected-note {{'x' defined here}}
10 constexpr int bfoo() { return 4; }
15 void test_aligned_colons(int *&rp)
18 #pragma omp taskloop simd aligned(B:bfoo())
19 for (int i = 0; i < 10; ++i) ;
20 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
21 #pragma omp taskloop simd aligned(B::ib:B:bfoo())
22 for (int i = 0; i < 10; ++i) ;
23 #pragma omp taskloop simd aligned(B:B::bfoo())
24 for (int i = 0; i < 10; ++i) ;
25 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
26 #pragma omp taskloop simd aligned(z:B:bfoo())
27 for (int i = 0; i < 10; ++i) ;
28 #pragma omp taskloop simd aligned(B:B::bfoo())
29 for (int i = 0; i < 10; ++i) ;
30 // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'int **'}}
31 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'B'}}
32 #pragma omp taskloop simd aligned(X::x : ::z)
33 for (int i = 0; i < 10; ++i) ;
34 // expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'B'}}
35 #pragma omp taskloop simd aligned(B,rp,::z: X::x)
36 for (int i = 0; i < 10; ++i) ;
37 #pragma omp taskloop simd aligned(::z)
38 for (int i = 0; i < 10; ++i) ;
39 // expected-error@+1 {{expected variable name}}
40 #pragma omp taskloop simd aligned(B::bfoo())
41 for (int i = 0; i < 10; ++i) ;
42 // expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
43 #pragma omp taskloop simd aligned(B::ib,B:C1+C2)
44 for (int i = 0; i < 10; ++i) ;
47 // expected-note@+1 {{'num' defined here}}
48 template<int L, class T, class N> T test_template(T* arr, N num) {
52 // Negative number is passed as L.
53 // expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}}
54 #pragma omp taskloop simd aligned(arr:L)
55 for (i = 0; i < num; ++i) {
56 T cur = arr[(int)ind2];
60 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
61 #pragma omp taskloop simd aligned(num:4)
62 for (i = 0; i < num; ++i);
66 template<int LEN> int test_warn() {
68 // expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}}
69 #pragma omp taskloop simd aligned(ind2:LEN)
70 for (int i = 0; i < 100; i++) {
76 struct S1; // expected-note 2 {{declared here}}
77 extern S1 a; // expected-note {{'a' declared here}}
83 const S2 b; // expected-note 1 {{'b' defined here}}
104 S3 h; // expected-note 2 {{'h' defined here}}
105 #pragma omp threadprivate(h)
107 template<class I, class C> int foomain(I argc, C **argv) {
110 int i; // expected-note {{declared here}} expected-note {{'i' defined here}}
111 // expected-note@+2 {{declared here}}
112 // expected-note@+1 {{reference to 'i' is not a constant expression}}
114 #pragma omp taskloop simd aligned // expected-error {{expected '(' after 'aligned'}}
115 for (I k = 0; k < argc; ++k) ++k;
116 #pragma omp taskloop simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
117 for (I k = 0; k < argc; ++k) ++k;
118 #pragma omp taskloop simd aligned () // expected-error {{expected expression}}
119 for (I k = 0; k < argc; ++k) ++k;
120 #pragma omp taskloop simd aligned (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
121 for (I k = 0; k < argc; ++k) ++k;
122 #pragma omp taskloop simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
123 for (I k = 0; k < argc; ++k) ++k;
124 #pragma omp taskloop simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
125 for (I k = 0; k < argc; ++k) ++k;
126 #pragma omp taskloop simd aligned (argc : 5) // expected-warning {{aligned clause will be ignored because the requested alignment is not a power of 2}}
127 for (I k = 0; k < argc; ++k) ++k;
128 #pragma omp taskloop simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
129 for (I k = 0; k < argc; ++k) ++k;
130 #pragma omp taskloop simd aligned (argv[1]) // expected-error {{expected variable name}}
131 for (I k = 0; k < argc; ++k) ++k;
132 #pragma omp taskloop simd aligned(e, g)
133 for (I k = 0; k < argc; ++k) ++k;
134 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}}
135 #pragma omp taskloop simd aligned(h)
136 for (I k = 0; k < argc; ++k) ++k;
137 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
138 #pragma omp taskloop simd aligned(i)
139 for (I k = 0; k < argc; ++k) ++k;
144 #pragma omp taskloop simd aligned(v:16)
145 for (I k = 0; k < argc; ++k) { i = k; v += 2; }
148 #pragma omp taskloop simd aligned(f)
149 for (I k = 0; k < argc; ++k) ++k;
151 // expected-note@+2 {{initializer of 'j' is not a constant expression}}
152 // expected-error@+1 {{expression is not an integral constant expression}}
153 #pragma omp taskloop simd aligned(f:j)
154 for (I k = 0; k < argc; ++k) { ++k; v += j; }
155 #pragma omp taskloop simd aligned(f)
156 for (I k = 0; k < argc; ++k) ++k;
160 // expected-note@+1 2 {{'argc' defined here}}
161 int main(int argc, char **argv) {
163 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
164 test_template<-4>(darr, 4);
165 test_warn<4>(); // ok
166 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
171 #pragma omp taskloop simd aligned // expected-error {{expected '(' after 'aligned'}}
172 for (int k = 0; k < argc; ++k) ++k;
173 #pragma omp taskloop simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
174 for (int k = 0; k < argc; ++k) ++k;
175 #pragma omp taskloop simd aligned () // expected-error {{expected expression}}
176 for (int k = 0; k < argc; ++k) ++k;
177 #pragma omp taskloop simd aligned (argv // expected-error {{expected ')'}} expected-note {{to match this '('}}
178 for (int k = 0; k < argc; ++k) ++k;
179 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
180 #pragma omp taskloop simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
181 for (int k = 0; k < argc; ++k) ++k;
182 #pragma omp taskloop simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
183 for (int k = 0; k < argc; ++k) ++k;
184 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
185 #pragma omp taskloop simd aligned (argc)
186 for (int k = 0; k < argc; ++k) ++k;
187 #pragma omp taskloop simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
188 for (int k = 0; k < argc; ++k) ++k;
189 // expected-error@+2 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S1'}}
190 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S2'}}
191 #pragma omp taskloop simd aligned (a, b)
192 for (int k = 0; k < argc; ++k) ++k;
193 #pragma omp taskloop simd aligned (argv[1]) // expected-error {{expected variable name}}
194 for (int k = 0; k < argc; ++k) ++k;
195 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}}
196 #pragma omp taskloop simd aligned(h)
197 for (int k = 0; k < argc; ++k) ++k;
199 // expected-note@+1 {{in instantiation of function template specialization 'foomain<int *, char>' requested here}}
200 foomain<int*,char>(pargc,argv);