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> |
| 11 | T 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 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 | d158cf6 | 2019-09-13 20:18:17 +0000 | [diff] [blame] | 36 | int 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 Bataev | 0736f7f | 2019-09-18 16:24:31 +0000 | [diff] [blame] | 48 | #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 Bataev | d158cf6 | 2019-09-13 20:18:17 +0000 | [diff] [blame] | 51 | #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 Bataev | 0736f7f | 2019-09-18 16:24:31 +0000 | [diff] [blame] | 58 | #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] | 59 | #pragma omp declare variant(foofoo <T>) match(xxx = {vvv}) xxx // expected-warning {{extra tokens at the end of '#pragma omp declare variant' are ignored}} |
| 60 | template <typename T> |
| 61 | T 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 = {}) |
| 65 | int 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) |
| 69 | int 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 |
| 81 | int 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) |
| 88 | int main(); |
| 89 | |
| 90 | // expected-error@+1 {{single declaration is expected after 'declare variant' directive}} |
| 91 | #pragma omp declare variant(barbar <int>) match(xxx = {}) |
| 92 | int 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}} |
| 97 | template <class C> |
| 98 | void 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 = {}) |
| 104 | template <> |
| 105 | void h(int *hp, int *hp2, int *hq, int *lin) { |
| 106 | h((float *)hp, (float *)hp2, (float *)hq, (float *)lin); |
| 107 | } |
| 108 | |
| 109 | int after_use_variant(void); |
| 110 | int after_use(); |
| 111 | int 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 = {}) |
| 117 | int after_use(void); |
| 118 | |
| 119 | int fn(); |
| 120 | int fn(int); |
| 121 | #pragma omp declare variant(fn) match(xxx = {}) |
| 122 | int overload(void); |
| 123 | |
| 124 | int fn1(); |
| 125 | int 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 = {}) |
| 128 | int overload1(float); |
| 129 | |
| 130 | int 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 = {}) |
| 133 | constexpr int fn_constexpr(); |
| 134 | |
| 135 | constexpr 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 = {}) |
| 138 | int fn_constexpr1(); |
| 139 | |
| 140 | int 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 = {}) |
| 143 | static int fn_sc(); |
| 144 | |
| 145 | static 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 = {}) |
| 148 | int fn_sc1(); |
| 149 | |
| 150 | int 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 = {}) |
| 153 | inline int fn_inline(); |
| 154 | |
| 155 | inline 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 = {}) |
| 158 | int fn_inline1(); |
| 159 | |
| 160 | int fn_linkage_variant(); |
| 161 | extern "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 = {}) |
| 164 | int fn_linkage(); |
| 165 | } |
| 166 | |
| 167 | extern "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 = {}) |
| 170 | int fn_linkage1(); |
| 171 | |
| 172 | auto fn_deduced_variant() { return 0; } |
| 173 | #pragma omp declare variant(fn_deduced_variant) match(xxx = {}) |
| 174 | int fn_deduced(); |
| 175 | |
| 176 | int fn_deduced_variant1(); |
| 177 | #pragma omp declare variant(fn_deduced_variant1) match(xxx = {}) |
| 178 | auto fn_deduced1() { return 0; } |
| 179 | |
| 180 | auto 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 = {}) |
| 183 | float fn_deduced2(); |
| 184 | |
| 185 | // expected-error@+1 {{exception specification in declaration does not match previous declaration}} |
| 186 | int fn_except_variant() noexcept(true); |
| 187 | // expected-note@+2 {{previous declaration is here}} |
| 188 | #pragma omp declare variant(fn_except_variant) match(xxx = {}) |
| 189 | int fn_except() noexcept(false); |
| 190 | |
| 191 | // expected-error@+1 {{exception specification in declaration does not match previous declaration}} |
| 192 | int fn_except_variant1() noexcept(false); |
| 193 | // expected-note@+2 {{previous declaration is here}} |
| 194 | #pragma omp declare variant(fn_except_variant1) match(xxx = {}) |
| 195 | int fn_except1() noexcept(true); |
| 196 | |
| 197 | struct 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 | |
| 222 | namespace 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 |