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
)
20 #pragma omp target parallel for simd aligned(B:bfoo())
21 for (int i
= 0; i
< 10; ++i
) ;
22 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}}
23 #pragma omp target parallel for simd aligned(B::ib:B:bfoo())
24 for (int i
= 0; i
< 10; ++i
) ;
25 #pragma omp target parallel for simd aligned(B:B::bfoo())
26 for (int i
= 0; i
< 10; ++i
) ;
27 // expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}}
28 #pragma omp target parallel for simd aligned(z:B:bfoo())
29 for (int i
= 0; i
< 10; ++i
) ;
30 #pragma omp target parallel for simd aligned(B:B::bfoo())
31 for (int i
= 0; i
< 10; ++i
) ;
32 // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'int **'}}
33 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'B'}}
34 #pragma omp target parallel for simd aligned(X::x : ::z)
35 for (int i
= 0; i
< 10; ++i
) ;
36 // expected-error@+1 {{integral constant expression must have integral or unscoped enumeration type, not 'B'}}
37 #pragma omp target parallel for simd aligned(B,rp,::z: X::x)
38 for (int i
= 0; i
< 10; ++i
) ;
39 #pragma omp target parallel for simd aligned(::z)
40 for (int i
= 0; i
< 10; ++i
) ;
41 // expected-error@+1 {{expected variable name}}
42 #pragma omp target parallel for simd aligned(B::bfoo())
43 for (int i
= 0; i
< 10; ++i
) ;
44 // expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
45 #pragma omp target parallel for simd aligned(B::ib,B:C1+C2)
46 for (int i
= 0; i
< 10; ++i
) ;
49 // expected-note@+1 {{'num' defined here}}
50 template<int L
, class T
, class N
> T
test_template(T
* arr
, N num
) {
54 // Negative number is passed as L.
55 // expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}}
56 #pragma omp target parallel for simd aligned(arr:L)
57 for (i
= 0; i
< num
; ++i
) {
58 T cur
= arr
[(int)ind2
];
62 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
63 #pragma omp target parallel for simd aligned(num:4)
64 for (i
= 0; i
< num
; ++i
);
68 template<int LEN
> int test_warn() {
70 // expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}}
71 #pragma omp target parallel for simd aligned(ind2:LEN)
72 for (int i
= 0; i
< 100; i
++) {
78 struct S1
; // expected-note 2 {{declared here}}
79 extern S1 a
; // expected-note {{'a' declared here}}
85 const S2 b
; // expected-note 1 {{'b' defined here}}
106 S3 h
; // expected-note 2 {{'h' defined here}}
107 #pragma omp threadprivate(h)
109 template<class I
, class C
> int foomain(I argc
, C
**argv
) {
112 int i
; // expected-note {{'i' defined here}}
113 // expected-note@+1 {{declared here}}
115 #pragma omp target parallel for simd aligned // expected-error {{expected '(' after 'aligned'}}
116 for (I k
= 0; k
< argc
; ++k
) ++k
;
117 #pragma omp target parallel for simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
118 for (I k
= 0; k
< argc
; ++k
) ++k
;
119 #pragma omp target parallel for simd aligned () // expected-error {{expected expression}}
120 for (I k
= 0; k
< argc
; ++k
) ++k
;
121 #pragma omp target parallel for simd aligned (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
122 for (I k
= 0; k
< argc
; ++k
) ++k
;
123 #pragma omp target parallel for simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
124 for (I k
= 0; k
< argc
; ++k
) ++k
;
125 // FIXME: Should argc really be a pointer?
126 #pragma omp target parallel for simd aligned (*argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
127 for (I k
= 0; k
< argc
; ++k
) ++k
;
128 #pragma omp target parallel for simd aligned (argc : 5) // expected-warning {{aligned clause will be ignored because the requested alignment is not a power of 2}}
129 for (I k
= 0; k
< argc
; ++k
) ++k
;
130 #pragma omp target parallel for simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
131 for (I k
= 0; k
< argc
; ++k
) ++k
;
132 #pragma omp target parallel for simd aligned (argv[1]) // expected-error {{expected variable name}}
133 for (I k
= 0; k
< argc
; ++k
) ++k
;
134 #pragma omp target parallel for simd aligned(e, g)
135 for (I k
= 0; k
< argc
; ++k
) ++k
;
136 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}}
137 #pragma omp target parallel for simd aligned(h)
138 for (I k
= 0; k
< argc
; ++k
) ++k
;
139 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
140 #pragma omp target parallel for simd aligned(i)
141 for (I k
= 0; k
< argc
; ++k
) ++k
;
146 #pragma omp target parallel for simd aligned(v:16)
147 for (I k
= 0; k
< argc
; ++k
) { i
= k
; v
+= 2; }
150 #pragma omp target parallel for simd aligned(f)
151 for (I k
= 0; k
< argc
; ++k
) ++k
;
153 // expected-note@+2 {{initializer of 'j' is not a constant expression}}
154 // expected-error@+1 {{integral constant expression}}
155 #pragma omp target parallel for simd aligned(f:j)
156 for (I k
= 0; k
< argc
; ++k
) { ++k
; v
+= j
; }
157 #pragma omp target parallel for simd aligned(f)
158 for (I k
= 0; k
< argc
; ++k
) ++k
;
162 // expected-note@+1 2 {{'argc' defined here}}
163 int main(int argc
, char **argv
) {
165 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}}
166 test_template
<-4>(darr
, 4);
167 test_warn
<4>(); // ok
168 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}}
173 #pragma omp target parallel for simd aligned // expected-error {{expected '(' after 'aligned'}}
174 for (int k
= 0; k
< argc
; ++k
) ++k
;
175 #pragma omp target parallel for simd aligned ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
176 for (int k
= 0; k
< argc
; ++k
) ++k
;
177 #pragma omp target parallel for simd aligned () // expected-error {{expected expression}}
178 for (int k
= 0; k
< argc
; ++k
) ++k
;
179 #pragma omp target parallel for simd aligned (argv // expected-error {{expected ')'}} expected-note {{to match this '('}}
180 for (int k
= 0; k
< argc
; ++k
) ++k
;
181 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
182 #pragma omp target parallel for simd aligned (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
183 for (int k
= 0; k
< argc
; ++k
) ++k
;
184 #pragma omp target parallel for simd aligned (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
185 for (int k
= 0; k
< argc
; ++k
) ++k
;
186 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
187 #pragma omp target parallel for simd aligned (argc)
188 for (int k
= 0; k
< argc
; ++k
) ++k
;
189 #pragma omp target parallel for simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
190 for (int k
= 0; k
< argc
; ++k
) ++k
;
191 // expected-error@+2 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S1'}}
192 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S2'}}
193 #pragma omp target parallel for simd aligned (a, b)
194 for (int k
= 0; k
< argc
; ++k
) ++k
;
195 #pragma omp target parallel for simd aligned (argv[1]) // expected-error {{expected variable name}}
196 for (int k
= 0; k
< argc
; ++k
) ++k
;
197 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'S3'}}
198 #pragma omp target parallel for simd aligned(h)
199 for (int k
= 0; k
< argc
; ++k
) ++k
;
201 // expected-note@+1 {{in instantiation of function template specialization 'foomain<int *, char>' requested here}}
202 foomain
<int*,char>(pargc
,argv
);