1 // RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp %s -Wuninitialized
2
3 // RUN: %clang_cc1 -x c++ -std=c++11 -verify -fopenmp-simd %s -Wuninitialized
4
5 struct B {
6 static int ib[20]; // expected-note 0 {{'B::ib' declared here}}
bfooB7 static constexpr int bfoo() { return 8; }
8 };
9 namespace X {
10 B x; // expected-note {{'x' defined here}}
11 };
bfoo()12 constexpr int bfoo() { return 4; }
13
14 int **z;
15 const int C1 = 1;
16 const int C2 = 2;
test_aligned_colons(int * & rp)17 void test_aligned_colons(int *&rp)
18 {
19 int *B = 0;
20 #pragma omp parallel master taskloop 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 parallel master taskloop simd aligned(B::ib:B:bfoo())
24 for (int i = 0; i < 10; ++i) ;
25 #pragma omp parallel master taskloop 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 parallel master taskloop simd aligned(z:B:bfoo())
29 for (int i = 0; i < 10; ++i) ;
30 #pragma omp parallel master taskloop 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 parallel master taskloop 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 parallel master taskloop simd aligned(B,rp,::z: X::x)
38 for (int i = 0; i < 10; ++i) ;
39 #pragma omp parallel master taskloop simd aligned(::z)
40 for (int i = 0; i < 10; ++i) ;
41 // expected-error@+1 {{expected variable name}}
42 #pragma omp parallel master taskloop 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 parallel master taskloop simd aligned(B::ib,B:C1+C2)
46 for (int i = 0; i < 10; ++i) ;
47 }
48
49 // expected-note@+1 {{'num' defined here}}
test_template(T * arr,N num)50 template<int L, class T, class N> T test_template(T* arr, N num) {
51 N i;
52 T sum = (T)0;
53 T ind2 = - num * L;
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 parallel master taskloop simd aligned(arr:L)
57 for (i = 0; i < num; ++i) {
58 T cur = arr[(int)ind2];
59 ind2 += L;
60 sum += cur;
61 }
62 // expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}}
63 #pragma omp parallel master taskloop simd aligned(num:4)
64 for (i = 0; i < num; ++i);
65 return T();
66 }
67
test_warn()68 template<int LEN> int test_warn() {
69 int *ind2 = 0;
70 // expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}}
71 #pragma omp parallel master taskloop simd aligned(ind2:LEN)
72 for (int i = 0; i < 100; i++) {
73 ind2 += LEN;
74 }
75 return 0;
76 }
77
78 struct S1; // expected-note 2 {{declared here}}
79 extern S1 a; // expected-note {{'a' declared here}}
80 class S2 {
81 mutable int a;
82 public:
S2()83 S2():a(0) { }
84 };
85 const S2 b; // expected-note 1 {{'b' defined here}}
86 const S2 ba[5];
87 class S3 {
88 int a;
89 public:
S3()90 S3():a(0) { }
91 };
92 const S3 ca[5];
93 class S4 {
94 int a;
95 S4();
96 public:
S4(int v)97 S4(int v):a(v) { }
98 };
99 class S5 {
100 int a;
S5()101 S5():a(0) {}
102 public:
S5(int v)103 S5(int v):a(v) { }
104 };
105
106 S3 h; // expected-note 2 {{'h' defined here}}
107 #pragma omp threadprivate(h)
108
foomain(I argc,C ** argv)109 template<class I, class C> int foomain(I argc, C **argv) {
110 I e(argc);
111 I g(argc);
112 int i; // expected-note {{'i' defined here}}
113 // expected-note@+1 {{declared here}}
114 int &j = i;
115 #pragma omp parallel master taskloop simd aligned // expected-error {{expected '(' after 'aligned'}}
116 for (I k = 0; k < argc; ++k) ++k;
117 #pragma omp parallel master taskloop 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 parallel master taskloop simd aligned () // expected-error {{expected expression}}
120 for (I k = 0; k < argc; ++k) ++k;
121 #pragma omp parallel master taskloop simd aligned (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
122 for (I k = 0; k < argc; ++k) ++k;
123 #pragma omp parallel master taskloop 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 parallel master taskloop 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 parallel master taskloop 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 parallel master taskloop simd aligned (S1) // expected-error {{'S1' does not refer to a value}}
131 for (I k = 0; k < argc; ++k) ++k;
132 #pragma omp parallel master taskloop simd aligned (argv[1]) // expected-error {{expected variable name}}
133 for (I k = 0; k < argc; ++k) ++k;
134 #pragma omp parallel master taskloop 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 parallel master taskloop 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 parallel master taskloop simd aligned(i)
141 for (I k = 0; k < argc; ++k) ++k;
142 #pragma omp parallel
143 {
144 int *v = 0;
145 I i;
146 #pragma omp parallel master taskloop simd aligned(v:16)
147 for (I k = 0; k < argc; ++k) { i = k; v += 2; }
148 }
149 float *f;
150 #pragma omp parallel master taskloop simd aligned(f)
151 for (I k = 0; k < argc; ++k) ++k;
152 int v = 0;
153 // expected-note@+2 {{initializer of 'j' is not a constant expression}}
154 // expected-error@+1 {{integral constant expression}}
155 #pragma omp parallel master taskloop simd aligned(f:j)
156 for (I k = 0; k < argc; ++k) { ++k; v += j; }
157 #pragma omp parallel master taskloop simd aligned(f)
158 for (I k = 0; k < argc; ++k) ++k;
159 return 0;
160 }
161
162 // expected-note@+1 2 {{'argc' defined here}}
main(int argc,char ** argv)163 int main(int argc, char **argv) {
164 double darr[100];
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}}
169 test_warn<0>();
170
171 int i;
172 int &j = i;
173 #pragma omp parallel master taskloop simd aligned // expected-error {{expected '(' after 'aligned'}}
174 for (int k = 0; k < argc; ++k) ++k;
175 #pragma omp parallel master taskloop 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 parallel master taskloop simd aligned () // expected-error {{expected expression}}
178 for (int k = 0; k < argc; ++k) ++k;
179 #pragma omp parallel master taskloop 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 parallel master taskloop 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 parallel master taskloop 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 parallel master taskloop simd aligned (argc)
188 for (int k = 0; k < argc; ++k) ++k;
189 #pragma omp parallel master taskloop 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 parallel master taskloop simd aligned(a, b)
194 for (int k = 0; k < argc; ++k) ++k;
195 #pragma omp parallel master taskloop 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 parallel master taskloop simd aligned(h)
199 for (int k = 0; k < argc; ++k) ++k;
200 int *pargc = &argc;
201 // expected-note@+1 {{in instantiation of function template specialization 'foomain<int *, char>' requested here}}
202 foomain<int*,char>(pargc,argv);
203 return 0;
204 }
205
206