blob: bd01270b0785802657423c9a707779331ff568d8 [file] [log] [blame]
Alexey Bataevd158cf62019-09-13 20:18:17 +00001// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c++ -std=c++14 -fms-extensions -Wno-pragma-pack -fexceptions -fcxx-exceptions %s
2
3// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp-simd -x c++ -std=c++14 -fms-extensions -Wno-pragma-pack -fexceptions -fcxx-exceptions %s
4
5// expected-error@+1 {{expected an OpenMP directive}}
6#pragma omp declare
7
8int foo();
9
10template <typename T>
11T foofoo();
12
13#pragma omp declare variant // expected-error {{expected '(' after 'declare variant'}}
14#pragma omp declare variant( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
15#pragma omp declare variant(foo // expected-error {{expected ')'}} expected-error {{expected 'match' clause on 'omp declare variant' directive}} expected-note {{to match this '('}}
16#pragma omp declare variant(x) // expected-error {{use of undeclared identifier 'x'}}
17#pragma omp declare variant(foo) // expected-error {{expected 'match' clause on 'omp declare variant' directive}}
18#pragma omp declare variant(foofoo <int>) // expected-error {{expected 'match' clause on 'omp declare variant' directive}}
19#pragma omp declare variant(foofoo <int>) xxx // expected-error {{expected 'match' clause on 'omp declare variant' directive}}
20#pragma omp declare variant(foofoo <int>) match // expected-error {{expected '(' after 'match'}}
21#pragma omp declare variant(foofoo <int>) match( // expected-error {{expected context selector in 'match' clause on 'omp declare variant' directive}}
Alexey Bataev0736f7f2019-09-18 16:24:31 +000022#pragma omp declare variant(foofoo <int>) match() // expected-error {{expected context selector in 'match' clause on 'omp declare variant' directive}}
23#pragma omp declare variant(foofoo <int>) match(xxx) // expected-error {{expected '=' after 'xxx' context selector set name on 'omp declare variant' directive}}
24#pragma omp declare variant(foofoo <int>) match(xxx =) // expected-error {{expected '{' after '='}}
25#pragma omp declare variant(foofoo <int>) match(xxx = yyy) // expected-error {{expected '{' after '='}}
26#pragma omp declare variant(foofoo <int>) match(xxx = yyy }) // expected-error {{expected '{' after '='}}
Alexey Bataevd158cf62019-09-13 20:18:17 +000027#pragma omp declare variant(foofoo <int>) match(xxx = {) // expected-error {{expected '}'}} expected-note {{to match this '{'}}
28#pragma omp declare variant(foofoo <int>) match(xxx = {})
29#pragma omp declare variant(foofoo <int>) match(xxx = {vvv})
Alexey Bataev0736f7f2019-09-18 16:24:31 +000030#pragma omp declare variant(foofoo <int>) match(xxx = {vvv} xxx) // expected-error {{expected ','}} expected-error {{expected '=' after 'xxx' context selector set name on 'omp declare variant' directive}}
Alexey Bataevd158cf62019-09-13 20:18:17 +000031#pragma omp declare variant(foofoo <int>) match(xxx = {vvv}) xxx // expected-warning {{extra tokens at the end of '#pragma omp declare variant' are ignored}}
Alexey Bataev9ff34742019-09-25 19:43:37 +000032#pragma omp declare variant(foofoo <int>) match(implementation={xxx}) // expected-warning {{unknown context selector in 'implementation' context selector set of 'omp declare variant' directive, ignored}}
33#pragma omp declare variant(foofoo <int>) match(implementation={vendor}) // expected-error {{expected '(' after 'vendor'}} expected-error {{expected vendor identifier in 'vendor' context selector of 'implementation' selector set of 'omp declare variant' directive}} expected-error {{expected ')'}} expected-note {{to match this '('}}
34#pragma omp declare variant(foofoo <int>) match(implementation={vendor(}) // expected-error {{expected vendor identifier in 'vendor' context selector of 'implementation' selector set of 'omp declare variant' directive}} expected-error {{expected ')'}} expected-note {{to match this '('}}
35#pragma omp declare variant(foofoo <int>) match(implementation={vendor()}) // expected-error {{expected vendor identifier in 'vendor' context selector of 'implementation' selector set of 'omp declare variant' directive}}
Alexey Bataevd158cf62019-09-13 20:18:17 +000036int bar();
37
38#pragma omp declare variant // expected-error {{expected '(' after 'declare variant'}}
39#pragma omp declare variant( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
40#pragma omp declare variant(foofoo <T> // expected-error {{expected ')'}} expected-error {{expected 'match' clause on 'omp declare variant' directive}} expected-note {{to match this '('}}
41#pragma omp declare variant(x) // expected-error {{use of undeclared identifier 'x'}}
42#pragma omp declare variant(foo) // expected-error {{expected 'match' clause on 'omp declare variant' directive}}
43#pragma omp declare variant(foofoo) // expected-error {{expected 'match' clause on 'omp declare variant' directive}}
44#pragma omp declare variant(foofoo <T>) // expected-error {{expected 'match' clause on 'omp declare variant' directive}}
45#pragma omp declare variant(foofoo <T>) xxx // expected-error {{expected 'match' clause on 'omp declare variant' directive}}
46#pragma omp declare variant(foofoo <T>) match // expected-error {{expected '(' after 'match'}}
47#pragma omp declare variant(foofoo <T>) match( // expected-error {{expected context selector in 'match' clause on 'omp declare variant' directive}}
Alexey Bataev0736f7f2019-09-18 16:24:31 +000048#pragma omp declare variant(foofoo <T>) match() // expected-error {{expected context selector in 'match' clause on 'omp declare variant' directive}}
49#pragma omp declare variant(foofoo <T>) match(xxx) // expected-error {{expected '=' after 'xxx' context selector set name on 'omp declare variant' directive}}
50#pragma omp declare variant(foofoo <T>) match(xxx =) // expected-error {{expected '{' after '='}}
Alexey Bataevd158cf62019-09-13 20:18:17 +000051#pragma omp declare variant(foofoo <T>) match(xxx = {) // expected-error {{expected '}'}} expected-note {{to match this '{'}}
52#pragma omp declare variant(foofoo <T>) match(xxx = {})
53#pragma omp declare variant(foofoo <T>) match(xxx = {vvv})
54#pragma omp declare variant(foofoo <T>) match(user = {score(<expr>) : condition(<expr>)})
55#pragma omp declare variant(foofoo <T>) match(user = {score(<expr>) : condition(<expr>)})
56#pragma omp declare variant(foofoo <T>) match(user = {condition(<expr>)})
57#pragma omp declare variant(foofoo <T>) match(user = {condition(<expr>)})
Alexey Bataev0736f7f2019-09-18 16:24:31 +000058#pragma omp declare variant(foofoo <T>) match(xxx = {vvv} xxx) // expected-error {{expected ','}} expected-error {{expected '=' after 'xxx' context selector set name on 'omp declare variant' directive}}
Alexey Bataevd158cf62019-09-13 20:18:17 +000059#pragma omp declare variant(foofoo <T>) match(xxx = {vvv}) xxx // expected-warning {{extra tokens at the end of '#pragma omp declare variant' are ignored}}
60template <typename T>
61T barbar();
62
63// expected-error@+2 {{'#pragma omp declare variant' can only be applied to functions}}
64#pragma omp declare variant(barbar <int>) match(xxx = {})
65int a;
66// expected-error@+2 {{'#pragma omp declare variant' can only be applied to functions}}
67#pragma omp declare variant(barbar <int>) match(xxx = {})
68#pragma omp threadprivate(a)
69int var;
70#pragma omp threadprivate(var)
71
72// expected-error@+2 {{expected an OpenMP directive}} expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
73#pragma omp declare variant(barbar <int>) match(xxx = {})
74#pragma omp declare
75
76// expected-error@+3 {{function declaration is expected after 'declare variant' directive}}
77// expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
78#pragma omp declare variant(barbar <int>) match(xxx = {})
79#pragma omp declare variant(barbar <int>) match(xxx = {})
80#pragma options align = packed
81int main();
82
83// expected-error@+3 {{function declaration is expected after 'declare variant' directive}}
84// expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
85#pragma omp declare variant(barbar <int>) match(xxx = {})
86#pragma omp declare variant(barbar <int>) match(xxx = {})
87#pragma init_seg(compiler)
88int main();
89
90// expected-error@+1 {{single declaration is expected after 'declare variant' directive}}
91#pragma omp declare variant(barbar <int>) match(xxx = {})
92int b, c;
93
94// expected-error@+1 {{'C' does not refer to a value}}
95#pragma omp declare variant(C) match(xxx = {})
96// expected-note@+1 {{declared here}}
97template <class C>
98void h(C *hp, C *hp2, C *hq, C *lin) {
99 b = 0;
100}
101
102// expected-error@+1 {{variant in '#pragma omp declare variant' with type '<overloaded function type>' is incompatible with type 'void (*)(int *, int *, int *, int *)'}}
103#pragma omp declare variant(barbar <int>) match(xxx = {})
104template <>
105void h(int *hp, int *hp2, int *hq, int *lin) {
106 h((float *)hp, (float *)hp2, (float *)hq, (float *)lin);
107}
108
109int after_use_variant(void);
110int after_use();
111int bar() {
112 return after_use();
113}
114
115// expected-error@+1 {{'#pragma omp declare variant' cannot be applied for function after first usage}}
116#pragma omp declare variant(after_use_variant) match(xxx = {})
117int after_use(void);
118
119int fn();
120int fn(int);
121#pragma omp declare variant(fn) match(xxx = {})
122int overload(void);
123
124int fn1();
125int fn1(int);
126// expected-error@+1 {{variant in '#pragma omp declare variant' with type '<overloaded function type>' is incompatible with type 'int (*)(float)'}}
127#pragma omp declare variant(fn1) match(xxx = {})
128int overload1(float);
129
130int fn_constexpr_variant();
131// expected-error@+2 {{'#pragma omp declare variant' does not support constexpr functions}}
132#pragma omp declare variant(fn_constexpr_variant) match(xxx = {})
133constexpr int fn_constexpr();
134
135constexpr int fn_constexpr_variant1();
136// expected-error@+1 {{'#pragma omp declare variant' does not support constexpr functions}}
137#pragma omp declare variant(fn_constexpr_variant1) match(xxx = {})
138int fn_constexpr1();
139
140int fn_sc_variant();
141// expected-error@+1 {{function with '#pragma omp declare variant' has a different storage class}}
142#pragma omp declare variant(fn_sc_variant) match(xxx = {})
143static int fn_sc();
144
145static int fn_sc_variant1();
146// expected-error@+1 {{function with '#pragma omp declare variant' has a different storage class}}
147#pragma omp declare variant(fn_sc_variant1) match(xxx = {})
148int fn_sc1();
149
150int fn_inline_variant();
151// expected-error@+1 {{function with '#pragma omp declare variant' has a different inline specification}}
152#pragma omp declare variant(fn_inline_variant) match(xxx = {})
153inline int fn_inline();
154
155inline int fn_inline_variant1();
156// expected-error@+1 {{function with '#pragma omp declare variant' has a different inline specification}}
157#pragma omp declare variant(fn_inline_variant1) match(xxx = {})
158int fn_inline1();
159
160int fn_linkage_variant();
161extern "C" {
162// expected-error@+1 {{function with '#pragma omp declare variant' has a different linkage}}
163#pragma omp declare variant(fn_linkage_variant) match(xxx = {})
164int fn_linkage();
165}
166
167extern "C" int fn_linkage_variant1();
168// expected-error@+1 {{function with '#pragma omp declare variant' has a different linkage}}
169#pragma omp declare variant(fn_linkage_variant1) match(xxx = {})
170int fn_linkage1();
171
172auto fn_deduced_variant() { return 0; }
173#pragma omp declare variant(fn_deduced_variant) match(xxx = {})
174int fn_deduced();
175
176int fn_deduced_variant1();
177#pragma omp declare variant(fn_deduced_variant1) match(xxx = {})
178auto fn_deduced1() { return 0; }
179
180auto fn_deduced_variant2() { return 0; }
181// expected-error@+1 {{variant in '#pragma omp declare variant' with type 'int ()' is incompatible with type 'float (*)()'}}
182#pragma omp declare variant(fn_deduced_variant2) match(xxx = {})
183float fn_deduced2();
184
185// expected-error@+1 {{exception specification in declaration does not match previous declaration}}
186int fn_except_variant() noexcept(true);
187// expected-note@+2 {{previous declaration is here}}
188#pragma omp declare variant(fn_except_variant) match(xxx = {})
189int fn_except() noexcept(false);
190
191// expected-error@+1 {{exception specification in declaration does not match previous declaration}}
192int fn_except_variant1() noexcept(false);
193// expected-note@+2 {{previous declaration is here}}
194#pragma omp declare variant(fn_except_variant1) match(xxx = {})
195int fn_except1() noexcept(true);
196
197struct SpecialFuncs {
198 void vd();
199 // expected-error@+2 {{'#pragma omp declare variant' does not support constructors}}
200#pragma omp declare variant(SpecialFuncs::vd) match(xxx = {})
201 SpecialFuncs();
202 // expected-error@+2 {{'#pragma omp declare variant' does not support destructors}}
203#pragma omp declare variant(SpecialFuncs::vd) match(xxx = {})
204 ~SpecialFuncs();
205
206 void baz();
207 void bar();
208 void bar(int);
209#pragma omp declare variant(SpecialFuncs::baz) match(xxx = {})
210#pragma omp declare variant(SpecialFuncs::bar) match(xxx = {})
211 void foo1();
212 SpecialFuncs& foo(const SpecialFuncs&);
213 SpecialFuncs& bar(SpecialFuncs&&);
214 // expected-error@+2 {{'#pragma omp declare variant' does not support defaulted functions}}
215#pragma omp declare variant(SpecialFuncs::foo) match(xxx = {})
216 SpecialFuncs& operator=(const SpecialFuncs&) = default;
217 // expected-error@+2 {{'#pragma omp declare variant' does not support deleted functions}}
218#pragma omp declare variant(SpecialFuncs::bar) match(xxx = {})
219 SpecialFuncs& operator=(SpecialFuncs&&) = delete;
220};
221
222namespace N {
223// expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
224#pragma omp declare variant
225} // namespace N
226// expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
227#pragma omp declare variant
228// expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
229#pragma omp declare variant