• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
4 
5 // RUN: %clang_cc1 -x c++ -std=c++11 -verify=expected,expectedw -fopenmp-simd %s -Wuninitialized
6 
7 struct B {
8   static int ib[20]; // expected-note 0 {{'B::ib' declared here}}
bfooB9   static constexpr int bfoo() { return 8; }
10 };
11 namespace X {
12   B x; // expected-note {{'x' defined here}}
13 };
bfoo()14 constexpr int bfoo() { return 4; }
15 
16 int **z;
17 const int C1 = 1;
18 const int C2 = 2;
test_aligned_colons(int * & rp)19 void test_aligned_colons(int *&rp)
20 {
21   int *B = 0;
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) ;
49 }
50 
51 // expected-note@+1 {{'num' defined here}}
test_template(T * arr,N num)52 template<int L, class T, class N> T test_template(T* arr, N num) {
53   N i;
54   T sum = (T)0;
55   T ind2 = - num * L;
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];
61     ind2 += L;
62     sum += cur;
63   }
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);
67   return T();
68 }
69 
test_warn()70 template<int LEN> int test_warn() {
71   int *ind2 = 0;
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++) {
75     ind2 += LEN;
76   }
77   return 0;
78 }
79 
80 struct S1; // expected-note 2 {{declared here}}
81 extern S1 a; // expected-note {{'a' declared here}}
82 class S2 {
83   mutable int a;
84 public:
S2()85   S2():a(0) { }
86 };
87 const S2 b; // expected-note 1 {{'b' defined here}}
88 const S2 ba[5];
89 class S3 {
90   int a;
91 public:
S3()92   S3():a(0) { }
93 };
94 const S3 ca[5];
95 class S4 {
96   int a;
97   S4();
98 public:
S4(int v)99   S4(int v):a(v) { }
100 };
101 class S5 {
102   int a;
S5()103   S5():a(0) {}
104 public:
S5(int v)105   S5(int v):a(v) { }
106 };
107 
108 S3 h; // expected-note 2 {{'h' defined here}}
109 #pragma omp threadprivate(h)
110 
foomain(I argc,C ** argv)111 template<class I, class C> int foomain(I argc, C **argv) {
112   I e(argc);
113   I g(argc);
114   int i; // expected-note {{'i' defined here}}
115   // expected-note@+1 {{declared here}}
116   int &j = i;
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;
144   #pragma omp parallel
145   {
146     int *v = 0;
147     I i;
148     #pragma omp simd aligned(v:16)
149     for (I k = 0; k < argc; ++k) { i = k; v += 2; }
150   }
151   float *f;
152   #pragma omp simd aligned(f)
153   for (I k = 0; k < argc; ++k) ++k;
154   int v = 0;
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;
161   return 0;
162 }
163 
164 // expected-note@+1 2 {{'argc' defined here}}
main(int argc,char ** argv)165 int main(int argc, char **argv) {
166   double darr[100];
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}}
171   test_warn<0>();
172 
173   int i;
174   int &j = i;
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;
202   int *pargc = &argc;
203   // expected-note@+1 {{in instantiation of function template specialization 'foomain<int *, char>' requested here}}
204   foomain<int*,char>(pargc,argv);
205   return 0;
206 }
207 
208