Clang Project

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