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