1 // RUN: %clang_cc1 -x c++ -std=c++11 -verify=expected,expectedw -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp %s -Wuninitialized -Wno-openmp-clauses
3 // RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp %s -Wuninitialized -Wno-openmp
5 // RUN: %clang_cc1 -x c++ -std=c++11 -verify=expected,expectedw -fopenmp-simd %s -Wuninitialized
8 static int ib
[20]; // expected-note 0 {{'B::ib' declared here}}
9 static constexpr int bfoo() { return 8; }
12 B x
; // expected-note {{'x' defined here}}
14 constexpr int bfoo() { return 4; }
19 void test_aligned_colons(int *&rp
)
22 #pragma omp simd aligned(B:bfoo())
23 for (int i
= 0; i
< 10; ++i
) ;
24 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
25 #pragma omp simd aligned(B::ib:B:bfoo())
26 for (int i
= 0; i
< 10; ++i
) ;
27 #pragma omp simd aligned(B:B::bfoo())
28 for (int i
= 0; i
< 10; ++i
) ;
29 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
30 #pragma omp simd aligned(z:B:bfoo())
31 for (int i
= 0; i
< 10; ++i
) ;
32 #pragma omp simd aligned(B:B::bfoo())
33 for (int i
= 0; i
< 10; ++i
) ;
34 // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'int **'}}
35 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'B'}}
36 #pragma omp simd aligned(X::x : ::z)
37 for (int i
= 0; i
< 10; ++i
) ;
38 // expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'B'}}
39 #pragma omp simd aligned(B,rp,::z: X::x)
40 for (int i
= 0; i
< 10; ++i
) ;
41 #pragma omp simd aligned(::z)
42 for (int i
= 0; i
< 10; ++i
) ;
43 // expected-error@+1 {{expected variable name}}
44 #pragma omp simd aligned(B::bfoo())
45 for (int i
= 0; i
< 10; ++i
) ;
46 // expectedw-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
47 #pragma omp simd aligned(B::ib,B:C1+C2)
48 for (int i
= 0; i
< 10; ++i
) ;
51 // expected-note@+1 {{'num' defined here}}
52 template<int L
, class T
, class N
> T
test_template(T
* arr
, N num
) {
56 // Negative number is passed as L.
57 // expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}}
58 #pragma omp simd aligned(arr:L)
59 for (i
= 0; i
< num
; ++i
) {
60 T cur
= arr
[(int)ind2
];
64 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
65 #pragma omp simd aligned(num:4)
66 for (i
= 0; i
< num
; ++i
);
70 template<int LEN
> int test_warn() {
72 // expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}}
73 #pragma omp simd aligned(ind2:LEN)
74 for (int i
= 0; i
< 100; i
++) {
80 struct S1
; // expected-note 2 {{declared here}}
81 extern S1 a
; // expected-note {{'a' declared here}}
87 const S2 b
; // expected-note 1 {{'b' defined here}}
108 S3 h
; // expected-note 2 {{'h' defined here}}
109 #pragma omp threadprivate(h)
111 template<class I
, class C
> int foomain(I argc
, C
**argv
) {
114 int i
; // expected-note {{'i' defined here}}
115 // expected-note@+1 {{declared here}}
117 #pragma omp simd aligned // expected-error {{expected '(' after 'aligned'}}
118 for (I k
= 0; k
< argc
; ++k
) ++k
;
119 #pragma omp simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
120 for (I k
= 0; k
< argc
; ++k
) ++k
;
121 #pragma omp simd aligned () // expected-error {{expected expression}}
122 for (I k
= 0; k
< argc
; ++k
) ++k
;
123 #pragma omp simd aligned (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
124 for (I k
= 0; k
< argc
; ++k
) ++k
;
125 #pragma omp simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
126 for (I k
= 0; k
< argc
; ++k
) ++k
;
127 // FIXME: Should argc really be a pointer?
128 #pragma omp simd aligned (*argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
129 for (I k
= 0; k
< argc
; ++k
) ++k
;
130 #pragma omp simd aligned (argc : 5) // expectedw-warning {{aligned clause will be ignored because the requested alignment is not a power of 2}}
131 for (I k
= 0; k
< argc
; ++k
) ++k
;
132 #pragma omp simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
133 for (I k
= 0; k
< argc
; ++k
) ++k
;
134 #pragma omp simd aligned (argv[1]) // expected-error {{expected variable name}}
135 for (I k
= 0; k
< argc
; ++k
) ++k
;
136 #pragma omp simd aligned(e, g)
137 for (I k
= 0; k
< argc
; ++k
) ++k
;
138 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}}
139 #pragma omp simd aligned(h)
140 for (I k
= 0; k
< argc
; ++k
) ++k
;
141 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
142 #pragma omp simd aligned(i)
143 for (I k
= 0; k
< argc
; ++k
) ++k
;
148 #pragma omp simd aligned(v:16)
149 for (I k
= 0; k
< argc
; ++k
) { i
= k
; v
+= 2; }
152 #pragma omp simd aligned(f)
153 for (I k
= 0; k
< argc
; ++k
) ++k
;
155 // expected-note@+2 {{initializer of 'j' is not a constant expression}}
156 // expected-error@+1 {{integral constant expression}}
157 #pragma omp simd aligned(f:j)
158 for (I k
= 0; k
< argc
; ++k
) { ++k
; v
+= j
; }
159 #pragma omp simd aligned(f)
160 for (I k
= 0; k
< argc
; ++k
) ++k
;
164 // expected-note@+1 2 {{'argc' defined here}}
165 int main(int argc
, char **argv
) {
167 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
168 test_template
<-4>(darr
, 4);
169 test_warn
<4>(); // ok
170 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
175 #pragma omp simd aligned // expected-error {{expected '(' after 'aligned'}}
176 for (int k
= 0; k
< argc
; ++k
) ++k
;
177 #pragma omp simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
178 for (int k
= 0; k
< argc
; ++k
) ++k
;
179 #pragma omp simd aligned () // expected-error {{expected expression}}
180 for (int k
= 0; k
< argc
; ++k
) ++k
;
181 #pragma omp simd aligned (argv // expected-error {{expected ')'}} expected-note {{to match this '('}}
182 for (int k
= 0; k
< argc
; ++k
) ++k
;
183 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
184 #pragma omp simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
185 for (int k
= 0; k
< argc
; ++k
) ++k
;
186 #pragma omp simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
187 for (int k
= 0; k
< argc
; ++k
) ++k
;
188 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
189 #pragma omp simd aligned (argc)
190 for (int k
= 0; k
< argc
; ++k
) ++k
;
191 #pragma omp simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
192 for (int k
= 0; k
< argc
; ++k
) ++k
;
193 // expected-error@+2 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S1'}}
194 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S2'}}
195 #pragma omp simd aligned (a, b)
196 for (int k
= 0; k
< argc
; ++k
) ++k
;
197 #pragma omp simd aligned (argv[1]) // expected-error {{expected variable name}}
198 for (int k
= 0; k
< argc
; ++k
) ++k
;
199 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}}
200 #pragma omp simd aligned(h)
201 for (int k
= 0; k
< argc
; ++k
) ++k
;
203 // expected-note@+1 {{in instantiation of function template specialization 'foomain<int *, char>' requested here}}
204 foomain
<int*,char>(pargc
,argv
);