Alexey Bataev | d158cf6 | 2019-09-13 20:18:17 +0000 | [diff] [blame] | 1 | // 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 | |
| 8 | int foo(); |
| 9 | |
| 10 | template <typename T> |
Alexey Bataev | a15a141 | 2019-10-02 18:19:02 +0000 | [diff] [blame^] | 11 | T foofoo(); // expected-note 2 {{declared here}} |
Alexey Bataev | d158cf6 | 2019-09-13 20:18:17 +0000 | [diff] [blame] | 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 Bataev | 0736f7f | 2019-09-18 16:24:31 +0000 | [diff] [blame] | 22 | #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 Bataev | d158cf6 | 2019-09-13 20:18:17 +0000 | [diff] [blame] | 27 | #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 Bataev | 0736f7f | 2019-09-18 16:24:31 +0000 | [diff] [blame] | 30 | #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 Bataev | d158cf6 | 2019-09-13 20:18:17 +0000 | [diff] [blame] | 31 | #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 Bataev | 9ff3474 | 2019-09-25 19:43:37 +0000 | [diff] [blame] | 32 | #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 Bataev | a15a141 | 2019-10-02 18:19:02 +0000 | [diff] [blame^] | 36 | #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 Bataev | d158cf6 | 2019-09-13 20:18:17 +0000 | [diff] [blame] | 41 | int 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 Bataev | 0736f7f | 2019-09-18 16:24:31 +0000 | [diff] [blame] | 53 | #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 Bataev | d158cf6 | 2019-09-13 20:18:17 +0000 | [diff] [blame] | 56 | #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 Bataev | 0736f7f | 2019-09-18 16:24:31 +0000 | [diff] [blame] | 63 | #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 Bataev | d158cf6 | 2019-09-13 20:18:17 +0000 | [diff] [blame] | 64 | #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 Bataev | a15a141 | 2019-10-02 18:19:02 +0000 | [diff] [blame^] | 65 | #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)}) |
| 70 | template <typename T, int C> |
Alexey Bataev | d158cf6 | 2019-09-13 20:18:17 +0000 | [diff] [blame] | 71 | T 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 = {}) |
| 75 | int 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) |
| 79 | int 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 |
| 91 | int 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) |
| 98 | int main(); |
| 99 | |
| 100 | // expected-error@+1 {{single declaration is expected after 'declare variant' directive}} |
| 101 | #pragma omp declare variant(barbar <int>) match(xxx = {}) |
| 102 | int 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}} |
| 107 | template <class C> |
| 108 | void 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 = {}) |
| 114 | template <> |
Alexey Bataev | 1202614 | 2019-09-26 20:04:15 +0000 | [diff] [blame] | 115 | void h(int *hp, int *hp2, int *hq, int *lin); |
Alexey Bataev | d158cf6 | 2019-09-13 20:18:17 +0000 | [diff] [blame] | 116 | |
| 117 | int after_use_variant(void); |
| 118 | int after_use(); |
| 119 | int bar() { |
| 120 | return after_use(); |
| 121 | } |
| 122 | |
Alexey Bataev | 1202614 | 2019-09-26 20:04:15 +0000 | [diff] [blame] | 123 | // expected-warning@+1 {{'#pragma omp declare variant' cannot be applied for function after first usage; the original function might be used}} |
Alexey Bataev | d158cf6 | 2019-09-13 20:18:17 +0000 | [diff] [blame] | 124 | #pragma omp declare variant(after_use_variant) match(xxx = {}) |
| 125 | int after_use(void); |
| 126 | |
| 127 | int fn(); |
| 128 | int fn(int); |
| 129 | #pragma omp declare variant(fn) match(xxx = {}) |
| 130 | int overload(void); |
| 131 | |
| 132 | int fn1(); |
| 133 | int 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 = {}) |
| 136 | int overload1(float); |
| 137 | |
| 138 | int 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 = {}) |
| 141 | constexpr int fn_constexpr(); |
| 142 | |
| 143 | constexpr 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 = {}) |
| 146 | int fn_constexpr1(); |
| 147 | |
| 148 | int 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 = {}) |
| 151 | static int fn_sc(); |
| 152 | |
| 153 | static 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 = {}) |
| 156 | int fn_sc1(); |
| 157 | |
| 158 | int 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 = {}) |
| 161 | inline int fn_inline(); |
| 162 | |
| 163 | inline 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 = {}) |
| 166 | int fn_inline1(); |
| 167 | |
| 168 | int fn_linkage_variant(); |
| 169 | extern "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 = {}) |
| 172 | int fn_linkage(); |
| 173 | } |
| 174 | |
| 175 | extern "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 = {}) |
| 178 | int fn_linkage1(); |
| 179 | |
| 180 | auto fn_deduced_variant() { return 0; } |
| 181 | #pragma omp declare variant(fn_deduced_variant) match(xxx = {}) |
| 182 | int fn_deduced(); |
| 183 | |
| 184 | int fn_deduced_variant1(); |
Alexey Bataev | d158cf6 | 2019-09-13 20:18:17 +0000 | [diff] [blame] | 185 | #pragma omp declare variant(fn_deduced_variant1) match(xxx = {}) |
| 186 | auto fn_deduced1() { return 0; } |
| 187 | |
Alexey Bataev | 218bea9 | 2019-09-30 18:24:35 +0000 | [diff] [blame] | 188 | auto 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 = {}) |
| 191 | auto fn_deduced3(); |
| 192 | |
Alexey Bataev | d158cf6 | 2019-09-13 20:18:17 +0000 | [diff] [blame] | 193 | auto 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 = {}) |
| 196 | float fn_deduced2(); |
| 197 | |
| 198 | // expected-error@+1 {{exception specification in declaration does not match previous declaration}} |
| 199 | int fn_except_variant() noexcept(true); |
| 200 | // expected-note@+2 {{previous declaration is here}} |
| 201 | #pragma omp declare variant(fn_except_variant) match(xxx = {}) |
| 202 | int fn_except() noexcept(false); |
| 203 | |
| 204 | // expected-error@+1 {{exception specification in declaration does not match previous declaration}} |
| 205 | int fn_except_variant1() noexcept(false); |
| 206 | // expected-note@+2 {{previous declaration is here}} |
| 207 | #pragma omp declare variant(fn_except_variant1) match(xxx = {}) |
| 208 | int fn_except1() noexcept(true); |
| 209 | |
| 210 | struct 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 | |
| 235 | namespace 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 |