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
6 static int ib
[20]; // expected-note 0 {{'B::ib' declared here}}
7 static constexpr int bfoo() { return 8; }
10 B x
; // expected-note {{'x' defined here}}
12 constexpr int bfoo() { return 4; }
17 void test_aligned_colons(int *&rp
)
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
) {
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
];
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
);
72 template<int LEN
> int test_warn() {
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
++) {
81 struct S1
; // expected-note 2 {{declared here}}
82 extern S1 a
; // expected-note {{'a' declared here}}
88 const S2 b
; // expected-note 1 {{'b' defined here}}
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
) {
115 int i
; // expected-note {{'i' defined here}}
116 // expected-note@+1 {{declared here}}
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
;
160 #pragma omp target teams distribute simd aligned(v:16)
161 for (I k
= 0; k
< argc
; ++k
) { i
= k
; v
+= 2; }
165 #pragma omp target teams distribute simd aligned(f)
166 for (I k
= 0; k
< argc
; ++k
) ++k
;
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
;
180 // expected-note@+1 2 {{'argc' defined here}}
181 int main(int argc
, char **argv
) {
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}}
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
;
228 // expected-note@+1 {{in instantiation of function template specialization 'foomain<int *, char>' requested here}}
229 foomain
<int*,char>(pargc
,argv
);