• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c++ -std=c++11 -fms-extensions %s
2 
3 // expected-error@+1 {{expected an OpenMP directive}}
4 #pragma omp declare
5 
6 // expected-error@+2 {{'#pragma omp declare simd' can only be applied to functions}}
7 #pragma omp declare simd
8 int a;
9 // expected-error@+2 {{'#pragma omp declare simd' can only be applied to functions}}
10 #pragma omp declare simd
11 #pragma omp threadprivate(a)
12 int var;
13 #pragma omp threadprivate(var)
14 
15 // expected-error@+2 {{expected an OpenMP directive}} expected-error@+1 {{function declaration is expected after 'declare simd' directive}}
16 #pragma omp declare simd
17 #pragma omp declare
18 
19 // expected-error@+3 {{function declaration is expected after 'declare simd' directive}}
20 // expected-error@+1 {{function declaration is expected after 'declare simd' directive}}
21 #pragma omp declare simd
22 #pragma omp declare simd
23 #pragma options align=packed
24 int main();
25 
26 // expected-error@+3 {{function declaration is expected after 'declare simd' directive}}
27 // expected-error@+1 {{function declaration is expected after 'declare simd' directive}}
28 #pragma omp declare simd
29 #pragma omp declare simd
30 #pragma init_seg(compiler)
31 int main();
32 
33 // expected-error@+1 {{single declaration is expected after 'declare simd' directive}}
34 #pragma omp declare simd
35 // expected-note@+1 {{declared here}}
36 int b, c;
37 
38 // expected-error@+1 {{'C' does not refer to a value}}
39 #pragma omp declare simd simdlen(C)
40 // expected-note@+1 {{declared here}}
41 template <class C>
h(C * hp,C * hp2,C * hq,C * lin)42 void h(C *hp, C *hp2, C *hq, C *lin) {
43   b = 0;
44 }
45 
46 #pragma omp declare simd
47 template <>
h(int * hp,int * hp2,int * hq,int * lin)48 void h(int *hp, int *hp2, int *hq, int *lin) {
49   h((float *)hp, (float *)hp2, (float *)hq, (float *)lin);
50 }
51 
52 #pragma omp declare simd inbranch inbranch
53 #pragma omp declare simd notinbranch notinbranch
54 #pragma omp declare simd inbranch inbranch notinbranch // expected-error {{unexpected 'notinbranch' clause, 'inbranch' is specified already}}
55 #pragma omp declare simd notinbranch notinbranch inbranch // expected-error {{unexpected 'inbranch' clause, 'notinbranch' is specified already}}
56 // expected-note@+2 {{read of non-const variable 'b' is not allowed in a constant expression}}
57 // expected-error@+1 {{expression is not an integral constant expression}}
58 #pragma omp declare simd simdlen(b)
59 // expected-error@+1 {{directive '#pragma omp declare simd' cannot contain more than one 'simdlen' clause}}
60 #pragma omp declare simd simdlen(32) simdlen(c)
61 // expected-error@+1 {{expected '(' after 'simdlen'}}
62 #pragma omp declare simd simdlen
63 // expected-note@+3 {{to match this '('}}
64 // expected-error@+2 {{expected ')'}}
65 // expected-error@+1 {{expected expression}}
66 #pragma omp declare simd simdlen(
67 // expected-error@+2 {{expected '(' after 'simdlen'}}
68 // expected-error@+1 {{expected expression}}
69 #pragma omp declare simd simdlen(), simdlen
70 // expected-error@+1 2 {{expected expression}}
71 #pragma omp declare simd simdlen(), simdlen()
72 // expected-warning@+3 {{extra tokens at the end of '#pragma omp declare simd' are ignored}}
73 // expected-error@+2 {{expected '(' after 'simdlen'}}
74 // expected-error@+1 {{expected expression}}
75 #pragma omp declare simd simdlen() simdlen)
76 void foo();
77 
78 // expected-error@+3 4 {{expected reference to one of the parameters of function 'foo'}}
79 // expected-error@+2 {{invalid use of 'this' outside of a non-static member function}}
80 // expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
81 #pragma omp declare simd simdlen(N) uniform(this, var) aligned(var)
82 template<int N>
foo()83 void foo() {}
84 
test()85 void test() {
86   // expected-note@+1 {{in instantiation of function template specialization 'foo<-3>' requested here}}
87   foo<-3>();
88 }
89 
90 // expected-error@+1 {{expected '(' after 'uniform'}}
91 #pragma omp declare simd uniform
92 // expected-note@+3 {{to match this '('}}
93 // expected-error@+2 {{expected ')'}}
94 // expected-error@+1 {{expected expression}}
95 #pragma omp declare simd uniform(
96 // expected-error@+1 {{expected expression}}
97 #pragma omp declare simd uniform()
98 // expected-note@+3 {{to match this '('}}
99 // expected-error@+2 {{expected ')'}}
100 // expected-error@+1 {{invalid use of 'this' outside of a non-static member function}}
101 #pragma omp declare simd uniform(this
102 // expected-note@+3 {{to match this '('}}
103 // expected-error@+2 {{expected ')'}}
104 // expected-error@+1 {{invalid use of 'this' outside of a non-static member function}}
105 #pragma omp declare simd uniform(this,a
106 // expected-error@+1 {{expected expression}}
107 #pragma omp declare simd uniform(,a)
108 // expected-error@+1 {{expected '(' after 'aligned'}}
109 #pragma omp declare simd aligned
110 // expected-note@+3 {{to match this '('}}
111 // expected-error@+2 {{expected ')'}}
112 // expected-error@+1 {{expected expression}}
113 #pragma omp declare simd aligned(
114 // expected-error@+1 {{expected expression}}
115 #pragma omp declare simd aligned()
116 // expected-note@+3 {{to match this '('}}
117 // expected-error@+2 {{expected ')'}}
118 // expected-error@+1 {{expected expression}}
119 #pragma omp declare simd aligned(a:
120 // expected-error@+1 {{expected expression}}
121 #pragma omp declare simd aligned(a:)
122 // expected-warning@+2 {{extra tokens at the end of '#pragma omp declare simd' are ignored}}
123 // expected-error@+1 {{expected '(' after 'aligned'}}
124 #pragma omp declare simd aligned :)
125 // expected-note@+3 {{to match this '('}}
126 // expected-error@+2 {{expected ')'}}
127 // expected-error@+1 {{invalid use of 'this' outside of a non-static member function}}
128 #pragma omp declare simd aligned(this
129 // expected-note@+3 {{to match this '('}}
130 // expected-error@+2 {{expected ')'}}
131 // expected-error@+1 {{invalid use of 'this' outside of a non-static member function}}
132 #pragma omp declare simd aligned(this,b
133 // expected-error@+1 {{expected expression}}
134 #pragma omp declare simd aligned(, b)
135 // expected-note@+4 {{defined as aligned}}
136 // expected-error@+3 {{a parameter cannot appear in more than one aligned clause}}
137 // expected-error@+2 {{expected expression}}
138 // expected-error@+1 {{expected ',' or ')' in 'aligned' clause}}
139 #pragma omp declare simd aligned(b) aligned(b ; 64)
140 // expected-note@+2 {{defined as aligned}}
141 // expected-error@+1 {{a parameter cannot appear in more than one aligned clause}}
142 #pragma omp declare simd aligned(b) aligned(b: 64)
143 // expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}}
144 #pragma omp declare simd aligned(b: -1)
145 // expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}}
146 #pragma omp declare simd aligned(b: 3)
147 // expected-error@+1 {{expected '(' after 'linear'}}
148 #pragma omp declare simd linear
149 // expected-note@+3 {{to match this '('}}
150 // expected-error@+2 {{expected ')'}}
151 // expected-error@+1 {{expected expression}}
152 #pragma omp declare simd linear(
153 // expected-error@+1 {{expected expression}}
154 #pragma omp declare simd linear()
155 // expected-note@+3 {{to match this '('}}
156 // expected-error@+2 {{expected ')'}}
157 // expected-error@+1 {{expected expression}}
158 #pragma omp declare simd linear(a:
159 // expected-error@+1 {{expected expression}}
160 #pragma omp declare simd linear(a:)
161 // expected-warning@+2 {{extra tokens at the end of '#pragma omp declare simd' are ignored}}
162 // expected-error@+1 {{expected '(' after 'linear'}}
163 #pragma omp declare simd linear :)
164 // expected-note@+3 {{to match this '('}}
165 // expected-error@+2 {{expected ')'}}
166 // expected-error@+1 {{invalid use of 'this' outside of a non-static member function}}
167 #pragma omp declare simd linear(this
168 // expected-note@+3 {{to match this '('}}
169 // expected-error@+2 {{expected ')'}}
170 // expected-error@+1 {{invalid use of 'this' outside of a non-static member function}}
171 #pragma omp declare simd linear(this,b
172 // expected-error@+1 {{expected expression}}
173 #pragma omp declare simd linear(, b)
174 // expected-note@+4 {{defined as linear}}
175 // expected-error@+3 {{linear variable cannot be linear}}
176 // expected-error@+2 {{expected expression}}
177 // expected-error@+1 {{expected ',' or ')' in 'linear' clause}}
178 #pragma omp declare simd linear(b) linear(b ; 64)
179 // expected-note@+2 {{defined as linear}}
180 // expected-error@+1 {{linear variable cannot be linear}}
181 #pragma omp declare simd linear(b) linear(b: 64)
182 #pragma omp declare simd linear(b: -1)
183 #pragma omp declare simd linear(b: 3)
184 // expected-error@+1 {{expected a reference to a parameter specified in a 'uniform' clause}}
185 #pragma omp declare simd linear(b: a)
186 // expected-note@+2 {{defined as uniform}}
187 // expected-error@+1 {{linear variable cannot be uniform}}
188 #pragma omp declare simd uniform(a), linear(a: 4)
189 // expected-note@+2 {{defined as uniform}}
190 // expected-error@+1 {{linear variable cannot be uniform}}
191 #pragma omp declare simd linear(a: 4) uniform(a)
192 // expected-error@+1 {{variable of non-reference type 'int *' can be used only with 'val' modifier, but used with 'uval'}}
193 #pragma omp declare simd linear(uval(b))
194 // expected-error@+1 {{variable of non-reference type 'int *' can be used only with 'val' modifier, but used with 'ref'}}
195 #pragma omp declare simd linear(ref(b))
196 // expected-error@+1 {{expected one of 'ref', val' or 'uval' modifiers}}
197 #pragma omp declare simd linear(uref(b))
198 void bar(int a, int *b);
199 
200 template <class T>
201 struct St {
202 // expected-error@+2 {{function declaration is expected after 'declare simd' directive}}
203 #pragma init_seg(compiler)
204 #pragma omp declare simd
205 #pragma init_seg(compiler)
206 // expected-note@+7 {{defined as uniform}}
207 // expected-error@+6 {{expected a reference to a parameter specified in a 'uniform' clause}}
208 // expected-error@+5 {{linear variable cannot be uniform}}
209 // expected-note@+4 {{defined as aligned}}
210 // expected-error@+3 {{argument to 'aligned' clause must be a strictly positive integer value}}
211 // expected-error@+2 {{'this' cannot appear in more than one aligned clause}}
212 // expected-error@+1 {{use of undeclared identifier 't'}}
213 #pragma omp declare simd uniform(this, t) aligned(this: 4) aligned(this: -4) linear(this: hp)
hSt214   void h(T *hp) {
215 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp declare simd'}}
216 #pragma omp declare simd
217     *hp = *t;
218   }
219 
220 private:
221   T t;
222 };
223 
224 namespace N {
225   // expected-error@+1 {{function declaration is expected after 'declare simd' directive}}
226   #pragma omp declare simd
227 }
228 // expected-error@+1 {{function declaration is expected after 'declare simd' directive}}
229 #pragma omp declare simd
230 // expected-error@+1 {{function declaration is expected after 'declare simd' directive}}
231 #pragma omp declare simd
232