blob: 79ba957a520b788fe7b4e46d4f4dfea4b4160a22 [file] [log] [blame]
Alexey Bataevd158cf62019-09-13 20:18:17 +00001// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c -std=c99 -fms-extensions -Wno-pragma-pack %s
2
3// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp-simd -x c -std=c99 -fms-extensions -Wno-pragma-pack %s
4
5// expected-error@+1 {{expected an OpenMP directive}}
6#pragma omp declare
7
8int foo(void);
9
10#pragma omp declare variant // expected-error {{expected '(' after 'declare variant'}}
11#pragma omp declare variant( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
12#pragma omp declare variant(foo // expected-error {{expected ')'}} expected-error {{expected 'match' clause on 'omp declare variant' directive}} expected-note {{to match this '('}}
13#pragma omp declare variant(x) // expected-error {{use of undeclared identifier 'x'}}
14#pragma omp declare variant(foo) // expected-error {{expected 'match' clause on 'omp declare variant' directive}}
15#pragma omp declare variant(foo) // expected-error {{expected 'match' clause on 'omp declare variant' directive}}
16#pragma omp declare variant(foo) xxx // expected-error {{expected 'match' clause on 'omp declare variant' directive}}
17#pragma omp declare variant(foo) match // expected-error {{expected '(' after 'match'}}
18#pragma omp declare variant(foo) match( // expected-error {{expected context selector in 'match' clause on 'omp declare variant' directive}}
Alexey Bataev0736f7f2019-09-18 16:24:31 +000019#pragma omp declare variant(foo) match() // expected-error {{expected context selector in 'match' clause on 'omp declare variant' directive}}
20#pragma omp declare variant(foo) match(xxx) // expected-error {{expected '=' after 'xxx' context selector set name on 'omp declare variant' directive}}
21#pragma omp declare variant(foo) match(xxx=) // expected-error {{expected '{' after '='}}
22#pragma omp declare variant(foo) match(xxx=yyy) // expected-error {{expected '{' after '='}}
23#pragma omp declare variant(foo) match(xxx=yyy}) // expected-error {{expected '{' after '='}}
Alexey Bataev70d2e542019-10-08 17:47:52 +000024#pragma omp declare variant(foo) match(xxx={) // expected-error {{expected '}' or ',' after ')'}} expected-error {{expected '}'}} expected-note {{to match this '{'}}
Alexey Bataevd158cf62019-09-13 20:18:17 +000025#pragma omp declare variant(foo) match(xxx={})
Alexey Bataev70d2e542019-10-08 17:47:52 +000026#pragma omp declare variant(foo) match(xxx={vvv, vvv})
Alexey Bataev5d154c32019-10-08 15:56:43 +000027#pragma omp declare variant(foo) match(xxx={vvv} xxx) // expected-error {{expected ','}} expected-error {{expected '=' after 'xxx' context selector set name on 'omp declare variant' directive}} expected-error {{context selector set 'xxx' is used already in the same 'omp declare variant' directive}} expected-note {{previously context selector set 'xxx' used here}}
Alexey Bataevd158cf62019-09-13 20:18:17 +000028#pragma omp declare variant(foo) 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 +000029#pragma omp declare variant(foo) match(implementation={xxx}) // expected-warning {{unknown context selector in 'implementation' context selector set of 'omp declare variant' directive, ignored}}
Alexey Bataev1c9e1732019-10-04 15:58:45 +000030#pragma omp declare variant(foo) 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 ')' or ',' after 'vendor name'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
31#pragma omp declare variant(foo) match(implementation={vendor(}) // expected-error {{expected vendor identifier in 'vendor' context selector of 'implementation' selector set of 'omp declare variant' directive}} expected-error {{expected ')' or ',' after 'vendor name'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Alexey Bataev9ff34742019-09-25 19:43:37 +000032#pragma omp declare variant(foo) 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 +000033#pragma omp declare variant(foo) match(implementation={vendor(score ibm)}) // expected-error {{expected '(' after 'score'}} expected-warning {{missing ':' after context selector score clause - ignoring}}
Alexey Bataev1c9e1732019-10-04 15:58:45 +000034#pragma omp declare variant(foo) match(implementation={vendor(score( ibm)}) // expected-error {{expected ')' or ',' after 'vendor name'}} 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 '('}}
35#pragma omp declare variant(foo) match(implementation={vendor(score(2 ibm)}) // expected-error {{expected ')' or ',' after 'vendor name'}} 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 '('}}
Alexey Bataeva15a1412019-10-02 18:19:02 +000036#pragma omp declare variant(foo) match(implementation={vendor(score(foo()) ibm)}) // expected-warning {{missing ':' after context selector score clause - ignoring}} expected-error {{expression is not an integer constant expression}}
Alexey Bataev70d2e542019-10-08 17:47:52 +000037#pragma omp declare variant(foo) match(implementation={vendor(score(5): ibm), vendor(llvm)}) // expected-error {{context trait selector 'vendor' is used already in the same 'implementation' context selector set of 'omp declare variant' directive}} expected-note {{previously context trait selector 'vendor' used here}}
Alexey Bataev4e8231b2019-11-05 15:13:30 -050038#pragma omp declare variant(foo) match(implementation={vendor(score(5): ibm), kind(cpu)}) // expected-warning {{unknown context selector in 'implementation' context selector set of 'omp declare variant' directive, ignored}}
39#pragma omp declare variant(foo) match(device={xxx}) // expected-warning {{unknown context selector in 'device' context selector set of 'omp declare variant' directive, ignored}}
40#pragma omp declare variant(foo) match(device={kind}) // expected-error {{expected '(' after 'kind'}} expected-error {{expected 'host', 'nohost', 'cpu', 'gpu', or 'fpga' in 'kind' context selector of 'device' selector set of 'omp declare variant' directive}} expected-error {{expected ')'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
41#pragma omp declare variant(foo) match(device={kind(}) // expected-error {{expected 'host', 'nohost', 'cpu', 'gpu', or 'fpga' in 'kind' context selector of 'device' selector set of 'omp declare variant' directive}} expected-error 2 {{expected ')'}} expected-note {{to match this '('}}
42#pragma omp declare variant(foo) match(device={kind()}) // expected-error {{expected 'host', 'nohost', 'cpu', 'gpu', or 'fpga' in 'kind' context selector of 'device' selector set of 'omp declare variant' directive}}
43#pragma omp declare variant(foo) match(device={kind(score cpu)}) // expected-error {{expected ')' or ',' after 'score'}} expected-error {{unknown 'score' device kind trait in the 'device' context selector set, expected one of 'host', 'nohost', 'cpu', 'gpu' or 'fpga'}}
44#pragma omp declare variant(foo) match(device={kind(score( ibm)}) // expected-error 2 {{expected ')'}} expected-note {{to match this '('}} expected-error {{unknown 'score' device kind trait in the 'device' context selector set, expected one of 'host', 'nohost', 'cpu', 'gpu' or 'fpga'}}
45#pragma omp declare variant(foo) match(device={kind(score(2 gpu)}) // expected-error 2 {{expected ')'}} expected-note {{to match this '('}} expected-error {{unknown 'score' device kind trait in the 'device' context selector set, expected one of 'host', 'nohost', 'cpu', 'gpu' or 'fpga'}}
46#pragma omp declare variant(foo) match(device={kind(score(foo()) ibm)}) // expected-error {{expected ')' or ',' after 'score'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{unknown 'score' device kind trait in the 'device' context selector set, expected one of 'host', 'nohost', 'cpu', 'gpu' or 'fpga'}}
47#pragma omp declare variant(foo) match(device={kind(score(5): host), kind(llvm)}) // expected-error {{context trait selector 'kind' is used already in the same 'device' context selector set of 'omp declare variant' directive}} expected-note {{previously context trait selector 'kind' used here}} expected-error {{expected ')' or ',' after 'score'}} expected-note {{to match this '('}} expected-error {{expected ')'}} expected-error {{unknown 'score' device kind trait in the 'device' context selector set, expected one of 'host', 'nohost', 'cpu', 'gpu' or 'fpga'}} expected-error {{unknown 'llvm' device kind trait in the 'device' context selector set, expected one of 'host', 'nohost', 'cpu', 'gpu' or 'fpga'}}
48#pragma omp declare variant(foo) match(device={kind(score(5): nohost), vendor(llvm)}) // expected-warning {{unknown context selector in 'device' context selector set of 'omp declare variant' directive, ignored}} expected-error {{expected ')' or ',' after 'score'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{unknown 'score' device kind trait in the 'device' context selector set, expected one of 'host', 'nohost', 'cpu', 'gpu' or 'fpga'}}}
Alexey Bataevd158cf62019-09-13 20:18:17 +000049int bar(void);
50
51// expected-error@+2 {{'#pragma omp declare variant' can only be applied to functions}}
52#pragma omp declare variant(foo) match(xxx={})
53int a;
54// expected-error@+2 {{'#pragma omp declare variant' can only be applied to functions}}
55#pragma omp declare variant(foo) match(xxx={})
56#pragma omp threadprivate(a)
57int var;
58#pragma omp threadprivate(var)
59
60// expected-error@+2 {{expected an OpenMP directive}} expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
61#pragma omp declare variant(foo) match(xxx={})
62#pragma omp declare
63
64// expected-error@+3 {{function declaration is expected after 'declare variant' directive}}
65// expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
66#pragma omp declare variant(foo) match(xxx={})
67#pragma omp declare variant(foo) match(xxx={})
68#pragma options align=packed
69int main();
70
71// expected-error@+3 {{function declaration is expected after 'declare variant' directive}}
72// expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
73#pragma omp declare variant(foo) match(xxx={})
74#pragma omp declare variant(foo) match(xxx={})
75#pragma init_seg(compiler)
76int main();
77
78// expected-error@+1 {{single declaration is expected after 'declare variant' directive}}
79#pragma omp declare variant(foo) match(xxx={})
80int b, c;
81
82int no_proto();
83
84// expected-error@+3 {{function with '#pragma omp declare variant' must have a prototype}}
85// expected-note@+1 {{'#pragma omp declare variant' for function specified here}}
86#pragma omp declare variant(no_proto) match(xxx={})
87int no_proto_too();
88
89int after_use_variant(void);
90int after_use();
91int bar() {
92 return after_use();
93}
94
Alexey Bataev12026142019-09-26 20:04:15 +000095// 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 +000096#pragma omp declare variant(after_use_variant) match(xxx={})
97int after_use(void);
Alexey Bataev12026142019-09-26 20:04:15 +000098#pragma omp declare variant(after_use_variant) match(xxx={})
99int defined(void) { return 0; }
Alexey Bataev218bea92019-09-30 18:24:35 +0000100int defined1(void) { return 0; }
101// expected-warning@+1 {{#pragma omp declare variant' cannot be applied to the function that was defined already; the original function might be used}}
102#pragma omp declare variant(after_use_variant) match(xxx={})
103int defined1(void);
104
Alexey Bataevd158cf62019-09-13 20:18:17 +0000105
106int diff_cc_variant(void);
107// expected-error@+1 {{function with '#pragma omp declare variant' has a different calling convention}}
108#pragma omp declare variant(diff_cc_variant) match(xxx={})
109__vectorcall int diff_cc(void);
110
111int diff_ret_variant(void);
112// expected-error@+1 {{function with '#pragma omp declare variant' has a different return type}}
113#pragma omp declare variant(diff_ret_variant) match(xxx={})
114void diff_ret(void);
115
Alexey Bataevbf5d4292019-09-17 17:36:49 +0000116void marked(void);
117void not_marked(void);
118// expected-note@+1 {{marked as 'declare variant' here}}
Alexey Bataev4e8231b2019-11-05 15:13:30 -0500119#pragma omp declare variant(not_marked) match(implementation={vendor(unknown)}, device={kind(cpu)})
Alexey Bataevbf5d4292019-09-17 17:36:49 +0000120void marked_variant(void);
121// expected-warning@+1 {{variant function in '#pragma omp declare variant' is itself marked as '#pragma omp declare variant'}}
122#pragma omp declare variant(marked_variant) match(xxx={})
123void marked(void);
124
Alexey Bataevd158cf62019-09-13 20:18:17 +0000125// expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
126#pragma omp declare variant
127// expected-error@+1 {{function declaration is expected after 'declare variant' directive}}
128#pragma omp declare variant