blob: 88e724d12470d5a952c86183c574a1df359f02ab [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>
Alexey Bataeva15a1412019-10-02 18:19:02 +000011T foofoo(); // expected-note 2 {{declared here}}
Alexey Bataevd158cf62019-09-13 20:18:17 +000012
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 Bataeva15a1412019-10-02 18:19:02 +000036#pragma omp declare variant(foofoo <int>) match(implementation={vendor(score ibm)}) // expected-error {{expected '(' after 'score'}} expected-warning {{missing ':' after context selector score clause - ignoring}}
37#pragma omp declare variant(foofoo <int>) match(implementation={vendor(score( ibm)}) // expected-error {{expected ')'}} expected-error {{use of undeclared identifier 'ibm'}} expected-error {{expected vendor identifier in 'vendor' context selector of 'implementation' selector set of 'omp declare variant' directive}} expected-warning {{missing ':' after context selector score clause - ignoring}} expected-note {{to match this '('}}
38#pragma omp declare variant(foofoo <int>) match(implementation={vendor(score(2 ibm)}) // expected-error 2 {{expected ')'}} expected-error {{expected vendor identifier in 'vendor' context selector of 'implementation' selector set of 'omp declare variant' directive}} expected-warning {{missing ':' after context selector score clause - ignoring}} expected-note 2 {{to match this '('}}
39#pragma omp declare variant(foofoo <int>) match(implementation={vendor(score(foofoo <int>()) ibm)}) // expected-warning {{missing ':' after context selector score clause - ignoring}} expected-error {{expression is not an integral constant expression}} expected-note {{non-constexpr function 'foofoo<int>' cannot be used in a constant expression}}
40#pragma omp declare variant(foofoo <int>) match(implementation={vendor(score(5): ibm)})
Alexey Bataevd158cf62019-09-13 20:18:17 +000041int bar();
42
43#pragma omp declare variant // expected-error {{expected '(' after 'declare variant'}}
44#pragma omp declare variant( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
45#pragma omp declare variant(foofoo <T> // expected-error {{expected ')'}} expected-error {{expected 'match' clause on 'omp declare variant' directive}} expected-note {{to match this '('}}
46#pragma omp declare variant(x) // expected-error {{use of undeclared identifier 'x'}}
47#pragma omp declare variant(foo) // expected-error {{expected 'match' clause on 'omp declare variant' directive}}
48#pragma omp declare variant(foofoo) // expected-error {{expected 'match' clause on 'omp declare variant' directive}}
49#pragma omp declare variant(foofoo <T>) // expected-error {{expected 'match' clause on 'omp declare variant' directive}}
50#pragma omp declare variant(foofoo <T>) xxx // expected-error {{expected 'match' clause on 'omp declare variant' directive}}
51#pragma omp declare variant(foofoo <T>) match // expected-error {{expected '(' after 'match'}}
52#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 +000053#pragma omp declare variant(foofoo <T>) match() // expected-error {{expected context selector in 'match' clause on 'omp declare variant' directive}}
54#pragma omp declare variant(foofoo <T>) match(xxx) // expected-error {{expected '=' after 'xxx' context selector set name on 'omp declare variant' directive}}
55#pragma omp declare variant(foofoo <T>) match(xxx =) // expected-error {{expected '{' after '='}}
Alexey Bataevd158cf62019-09-13 20:18:17 +000056#pragma omp declare variant(foofoo <T>) match(xxx = {) // expected-error {{expected '}'}} expected-note {{to match this '{'}}
57#pragma omp declare variant(foofoo <T>) match(xxx = {})
58#pragma omp declare variant(foofoo <T>) match(xxx = {vvv})
59#pragma omp declare variant(foofoo <T>) match(user = {score(<expr>) : condition(<expr>)})
60#pragma omp declare variant(foofoo <T>) match(user = {score(<expr>) : condition(<expr>)})
61#pragma omp declare variant(foofoo <T>) match(user = {condition(<expr>)})
62#pragma omp declare variant(foofoo <T>) match(user = {condition(<expr>)})
Alexey Bataev0736f7f2019-09-18 16:24:31 +000063#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 +000064#pragma omp declare variant(foofoo <T>) match(xxx = {vvv}) xxx // expected-warning {{extra tokens at the end of '#pragma omp declare variant' are ignored}}
Alexey Bataeva15a1412019-10-02 18:19:02 +000065#pragma omp declare variant(foofoo <int>) match(implementation={vendor(score ibm)}) // expected-error {{expected '(' after 'score'}} expected-warning {{missing ':' after context selector score clause - ignoring}}
66#pragma omp declare variant(foofoo <int>) match(implementation={vendor(score( ibm)}) // expected-error {{expected ')'}} expected-error {{use of undeclared identifier 'ibm'}} expected-error {{expected vendor identifier in 'vendor' context selector of 'implementation' selector set of 'omp declare variant' directive}} expected-warning {{missing ':' after context selector score clause - ignoring}} expected-note {{to match this '('}}
67#pragma omp declare variant(foofoo <int>) match(implementation={vendor(score(C ibm)}) // expected-error 2 {{expected ')'}} expected-error {{expected vendor identifier in 'vendor' context selector of 'implementation' selector set of 'omp declare variant' directive}} expected-warning {{missing ':' after context selector score clause - ignoring}} expected-note 2 {{to match this '('}}
68#pragma omp declare variant(foofoo <int>) match(implementation={vendor(score(foofoo <int>()) ibm)}) // expected-warning {{missing ':' after context selector score clause - ignoring}} expected-error {{expression is not an integral constant expression}} expected-note {{non-constexpr function 'foofoo<int>' cannot be used in a constant expression}}
69#pragma omp declare variant(foofoo <int>) match(implementation={vendor(score(C+5): ibm)})
70template <typename T, int C>
Alexey Bataevd158cf62019-09-13 20:18:17 +000071T barbar();
72
73// expected-error@+2 {{'#pragma omp declare variant' can only be applied to functions}}
74#pragma omp declare variant(barbar <int>) match(xxx = {})
75int a;
76// expected-error@+2 {{'#pragma omp declare variant' can only be applied to functions}}
77#pragma omp declare variant(barbar <int>) match(xxx = {})
78#pragma omp threadprivate(a)
79int var;
80#pragma omp threadprivate(var)
81
82// expected-error@+2 {{expected an OpenMP directive}} expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
83#pragma omp declare variant(barbar <int>) match(xxx = {})
84#pragma omp declare
85
86// expected-error@+3 {{function declaration is expected after 'declare variant' directive}}
87// expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
88#pragma omp declare variant(barbar <int>) match(xxx = {})
89#pragma omp declare variant(barbar <int>) match(xxx = {})
90#pragma options align = packed
91int main();
92
93// expected-error@+3 {{function declaration is expected after 'declare variant' directive}}
94// expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
95#pragma omp declare variant(barbar <int>) match(xxx = {})
96#pragma omp declare variant(barbar <int>) match(xxx = {})
97#pragma init_seg(compiler)
98int main();
99
100// expected-error@+1 {{single declaration is expected after 'declare variant' directive}}
101#pragma omp declare variant(barbar <int>) match(xxx = {})
102int b, c;
103
104// expected-error@+1 {{'C' does not refer to a value}}
105#pragma omp declare variant(C) match(xxx = {})
106// expected-note@+1 {{declared here}}
107template <class C>
108void h(C *hp, C *hp2, C *hq, C *lin) {
109 b = 0;
110}
111
112// expected-error@+1 {{variant in '#pragma omp declare variant' with type '<overloaded function type>' is incompatible with type 'void (*)(int *, int *, int *, int *)'}}
113#pragma omp declare variant(barbar <int>) match(xxx = {})
114template <>
Alexey Bataev12026142019-09-26 20:04:15 +0000115void h(int *hp, int *hp2, int *hq, int *lin);
Alexey Bataevd158cf62019-09-13 20:18:17 +0000116
117int after_use_variant(void);
118int after_use();
119int bar() {
120 return after_use();
121}
122
Alexey Bataev12026142019-09-26 20:04:15 +0000123// expected-warning@+1 {{'#pragma omp declare variant' cannot be applied for function after first usage; the original function might be used}}
Alexey Bataevd158cf62019-09-13 20:18:17 +0000124#pragma omp declare variant(after_use_variant) match(xxx = {})
125int after_use(void);
126
127int fn();
128int fn(int);
129#pragma omp declare variant(fn) match(xxx = {})
130int overload(void);
131
132int fn1();
133int fn1(int);
134// expected-error@+1 {{variant in '#pragma omp declare variant' with type '<overloaded function type>' is incompatible with type 'int (*)(float)'}}
135#pragma omp declare variant(fn1) match(xxx = {})
136int overload1(float);
137
138int fn_constexpr_variant();
139// expected-error@+2 {{'#pragma omp declare variant' does not support constexpr functions}}
140#pragma omp declare variant(fn_constexpr_variant) match(xxx = {})
141constexpr int fn_constexpr();
142
143constexpr int fn_constexpr_variant1();
144// expected-error@+1 {{'#pragma omp declare variant' does not support constexpr functions}}
145#pragma omp declare variant(fn_constexpr_variant1) match(xxx = {})
146int fn_constexpr1();
147
148int fn_sc_variant();
149// expected-error@+1 {{function with '#pragma omp declare variant' has a different storage class}}
150#pragma omp declare variant(fn_sc_variant) match(xxx = {})
151static int fn_sc();
152
153static int fn_sc_variant1();
154// expected-error@+1 {{function with '#pragma omp declare variant' has a different storage class}}
155#pragma omp declare variant(fn_sc_variant1) match(xxx = {})
156int fn_sc1();
157
158int fn_inline_variant();
159// expected-error@+1 {{function with '#pragma omp declare variant' has a different inline specification}}
160#pragma omp declare variant(fn_inline_variant) match(xxx = {})
161inline int fn_inline();
162
163inline int fn_inline_variant1();
164// expected-error@+1 {{function with '#pragma omp declare variant' has a different inline specification}}
165#pragma omp declare variant(fn_inline_variant1) match(xxx = {})
166int fn_inline1();
167
168int fn_linkage_variant();
169extern "C" {
170// expected-error@+1 {{function with '#pragma omp declare variant' has a different linkage}}
171#pragma omp declare variant(fn_linkage_variant) match(xxx = {})
172int fn_linkage();
173}
174
175extern "C" int fn_linkage_variant1();
176// expected-error@+1 {{function with '#pragma omp declare variant' has a different linkage}}
177#pragma omp declare variant(fn_linkage_variant1) match(xxx = {})
178int fn_linkage1();
179
180auto fn_deduced_variant() { return 0; }
181#pragma omp declare variant(fn_deduced_variant) match(xxx = {})
182int fn_deduced();
183
184int fn_deduced_variant1();
Alexey Bataevd158cf62019-09-13 20:18:17 +0000185#pragma omp declare variant(fn_deduced_variant1) match(xxx = {})
186auto fn_deduced1() { return 0; }
187
Alexey Bataev218bea92019-09-30 18:24:35 +0000188auto fn_deduced3() { return 0; }
189// expected-warning@+1 {{'#pragma omp declare variant' cannot be applied to the function that was defined already; the original function might be used}}
190#pragma omp declare variant(fn_deduced_variant1) match(xxx = {})
191auto fn_deduced3();
192
Alexey Bataevd158cf62019-09-13 20:18:17 +0000193auto fn_deduced_variant2() { return 0; }
194// expected-error@+1 {{variant in '#pragma omp declare variant' with type 'int ()' is incompatible with type 'float (*)()'}}
195#pragma omp declare variant(fn_deduced_variant2) match(xxx = {})
196float fn_deduced2();
197
198// expected-error@+1 {{exception specification in declaration does not match previous declaration}}
199int fn_except_variant() noexcept(true);
200// expected-note@+2 {{previous declaration is here}}
201#pragma omp declare variant(fn_except_variant) match(xxx = {})
202int fn_except() noexcept(false);
203
204// expected-error@+1 {{exception specification in declaration does not match previous declaration}}
205int fn_except_variant1() noexcept(false);
206// expected-note@+2 {{previous declaration is here}}
207#pragma omp declare variant(fn_except_variant1) match(xxx = {})
208int fn_except1() noexcept(true);
209
210struct SpecialFuncs {
211 void vd();
212 // expected-error@+2 {{'#pragma omp declare variant' does not support constructors}}
213#pragma omp declare variant(SpecialFuncs::vd) match(xxx = {})
214 SpecialFuncs();
215 // expected-error@+2 {{'#pragma omp declare variant' does not support destructors}}
216#pragma omp declare variant(SpecialFuncs::vd) match(xxx = {})
217 ~SpecialFuncs();
218
219 void baz();
220 void bar();
221 void bar(int);
222#pragma omp declare variant(SpecialFuncs::baz) match(xxx = {})
223#pragma omp declare variant(SpecialFuncs::bar) match(xxx = {})
224 void foo1();
225 SpecialFuncs& foo(const SpecialFuncs&);
226 SpecialFuncs& bar(SpecialFuncs&&);
227 // expected-error@+2 {{'#pragma omp declare variant' does not support defaulted functions}}
228#pragma omp declare variant(SpecialFuncs::foo) match(xxx = {})
229 SpecialFuncs& operator=(const SpecialFuncs&) = default;
230 // expected-error@+2 {{'#pragma omp declare variant' does not support deleted functions}}
231#pragma omp declare variant(SpecialFuncs::bar) match(xxx = {})
232 SpecialFuncs& operator=(SpecialFuncs&&) = delete;
233};
234
235namespace N {
236// expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
237#pragma omp declare variant
238} // namespace N
239// expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
240#pragma omp declare variant
241// expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
242#pragma omp declare variant