| 1 |
// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c++ -std=c++11 -fms-extensions -Wno-pragma-pack %s |
| 2 |
|
| 3 |
// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp-simd -x c++ -std=c++11 -fms-extensions -Wno-pragma-pack %s |
| 4 |
|
| 5 |
// expected-error@+1 {{expected an OpenMP directive}} |
| 6 |
#pragma omp declare |
| 7 |
|
| 8 |
// expected-error@+2 {{'#pragma omp declare simd' can only be applied to functions}} |
| 9 |
#pragma omp declare simd |
| 10 |
int a; |
| 11 |
// expected-error@+2 {{'#pragma omp declare simd' can only be applied to functions}} |
| 12 |
#pragma omp declare simd |
| 13 |
#pragma omp threadprivate(a) |
| 14 |
int var; |
| 15 |
#pragma omp threadprivate(var) |
| 16 |
|
| 17 |
// expected-error@+2 {{expected an OpenMP directive}} expected-error@+1 {{function declaration is expected after 'declare simd' directive}} |
| 18 |
#pragma omp declare simd |
| 19 |
#pragma omp declare |
| 20 |
|
| 21 |
// expected-error@+3 {{function declaration is expected after 'declare simd' directive}} |
| 22 |
// expected-error@+1 {{function declaration is expected after 'declare simd' directive}} |
| 23 |
#pragma omp declare simd |
| 24 |
#pragma omp declare simd |
| 25 |
#pragma options align=packed |
| 26 |
int main(); |
| 27 |
|
| 28 |
// expected-error@+3 {{function declaration is expected after 'declare simd' directive}} |
| 29 |
// expected-error@+1 {{function declaration is expected after 'declare simd' directive}} |
| 30 |
#pragma omp declare simd |
| 31 |
#pragma omp declare simd |
| 32 |
#pragma init_seg(compiler) |
| 33 |
int main(); |
| 34 |
|
| 35 |
struct A { |
| 36 |
#pragma omp declare simd |
| 37 |
template<typename T> |
| 38 |
T infunc1(T a); |
| 39 |
}; |
| 40 |
|
| 41 |
// expected-error@+1 {{single declaration is expected after 'declare simd' directive}} |
| 42 |
#pragma omp declare simd |
| 43 |
// expected-note@+1 {{declared here}} |
| 44 |
int b, c; |
| 45 |
|
| 46 |
// expected-error@+1 {{'C' does not refer to a value}} |
| 47 |
#pragma omp declare simd simdlen(C) |
| 48 |
// expected-note@+1 {{declared here}} |
| 49 |
template <class C> |
| 50 |
void h(C *hp, C *hp2, C *hq, C *lin) { |
| 51 |
b = 0; |
| 52 |
} |
| 53 |
|
| 54 |
#pragma omp declare simd |
| 55 |
template <> |
| 56 |
void h(int *hp, int *hp2, int *hq, int *lin) { |
| 57 |
h((float *)hp, (float *)hp2, (float *)hq, (float *)lin); |
| 58 |
} |
| 59 |
|
| 60 |
#pragma omp declare simd inbranch inbranch |
| 61 |
#pragma omp declare simd notinbranch notinbranch |
| 62 |
#pragma omp declare simd inbranch inbranch notinbranch // expected-error {{unexpected 'notinbranch' clause, 'inbranch' is specified already}} |
| 63 |
#pragma omp declare simd notinbranch notinbranch inbranch // expected-error {{unexpected 'inbranch' clause, 'notinbranch' is specified already}} |
| 64 |
// expected-note@+2 {{read of non-const variable 'b' is not allowed in a constant expression}} |
| 65 |
// expected-error@+1 {{integral constant expression}} |
| 66 |
#pragma omp declare simd simdlen(b) |
| 67 |
// expected-error@+1 {{directive '#pragma omp declare simd' cannot contain more than one 'simdlen' clause}} |
| 68 |
#pragma omp declare simd simdlen(32) simdlen(c) |
| 69 |
// expected-error@+1 {{expected '(' after 'simdlen'}} |
| 70 |
#pragma omp declare simd simdlen |
| 71 |
// expected-note@+3 {{to match this '('}} |
| 72 |
// expected-error@+2 {{expected ')'}} |
| 73 |
// expected-error@+1 {{expected expression}} |
| 74 |
#pragma omp declare simd simdlen( |
| 75 |
// expected-error@+2 {{expected '(' after 'simdlen'}} |
| 76 |
// expected-error@+1 {{expected expression}} |
| 77 |
#pragma omp declare simd simdlen(), simdlen |
| 78 |
// expected-error@+1 2 {{expected expression}} |
| 79 |
#pragma omp declare simd simdlen(), simdlen() |
| 80 |
// expected-warning@+3 {{extra tokens at the end of '#pragma omp declare simd' are ignored}} |
| 81 |
// expected-error@+2 {{expected '(' after 'simdlen'}} |
| 82 |
// expected-error@+1 {{expected expression}} |
| 83 |
#pragma omp declare simd simdlen() simdlen) |
| 84 |
void foo(); |
| 85 |
|
| 86 |
// expected-error@+3 4 {{expected reference to one of the parameters of function 'foo'}} |
| 87 |
// expected-error@+2 {{invalid use of 'this' outside of a non-static member function}} |
| 88 |
// expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}} |
| 89 |
#pragma omp declare simd simdlen(N) uniform(this, var) aligned(var) |
| 90 |
template<int N> |
| 91 |
void foo() {} |
| 92 |
|
| 93 |
void test() { |
| 94 |
// expected-note@+1 {{in instantiation of function template specialization 'foo<-3>' requested here}} |
| 95 |
foo<-3>(); |
| 96 |
} |
| 97 |
|
| 98 |
// expected-error@+1 {{expected '(' after 'uniform'}} |
| 99 |
#pragma omp declare simd uniform |
| 100 |
// expected-note@+3 {{to match this '('}} |
| 101 |
// expected-error@+2 {{expected ')'}} |
| 102 |
// expected-error@+1 {{expected expression}} |
| 103 |
#pragma omp declare simd uniform( |
| 104 |
// expected-error@+1 {{expected expression}} |
| 105 |
#pragma omp declare simd uniform() |
| 106 |
// expected-note@+3 {{to match this '('}} |
| 107 |
// expected-error@+2 {{expected ')'}} |
| 108 |
// expected-error@+1 {{invalid use of 'this' outside of a non-static member function}} |
| 109 |
#pragma omp declare simd uniform(this |
| 110 |
// expected-note@+3 {{to match this '('}} |
| 111 |
// expected-error@+2 {{expected ')'}} |
| 112 |
// expected-error@+1 {{invalid use of 'this' outside of a non-static member function}} |
| 113 |
#pragma omp declare simd uniform(this,a |
| 114 |
// expected-error@+1 {{expected expression}} |
| 115 |
#pragma omp declare simd uniform(,a) |
| 116 |
// expected-error@+1 {{expected '(' after 'aligned'}} |
| 117 |
#pragma omp declare simd aligned |
| 118 |
// expected-note@+3 {{to match this '('}} |
| 119 |
// expected-error@+2 {{expected ')'}} |
| 120 |
// expected-error@+1 {{expected expression}} |
| 121 |
#pragma omp declare simd aligned( |
| 122 |
// expected-error@+1 {{expected expression}} |
| 123 |
#pragma omp declare simd aligned() |
| 124 |
// expected-error@+4 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} |
| 125 |
// expected-note@+3 {{to match this '('}} |
| 126 |
// expected-error@+2 {{expected ')'}} |
| 127 |
// expected-error@+1 {{expected expression}} |
| 128 |
#pragma omp declare simd aligned(a: |
| 129 |
// expected-error@+1 {{expected expression}} expected-error@+1 {{argument of aligned clause should be array, pointer, reference to array or reference to pointer, not 'int'}} |
| 130 |
#pragma omp declare simd aligned(a:) |
| 131 |
// expected-warning@+2 {{extra tokens at the end of '#pragma omp declare simd' are ignored}} |
| 132 |
// expected-error@+1 {{expected '(' after 'aligned'}} |
| 133 |
#pragma omp declare simd aligned :) |
| 134 |
// expected-note@+3 {{to match this '('}} |
| 135 |
// expected-error@+2 {{expected ')'}} |
| 136 |
// expected-error@+1 {{invalid use of 'this' outside of a non-static member function}} |
| 137 |
#pragma omp declare simd aligned(this |
| 138 |
// expected-note@+3 {{to match this '('}} |
| 139 |
// expected-error@+2 {{expected ')'}} |
| 140 |
// expected-error@+1 {{invalid use of 'this' outside of a non-static member function}} |
| 141 |
#pragma omp declare simd aligned(this,b |
| 142 |
// expected-error@+1 {{expected expression}} |
| 143 |
#pragma omp declare simd aligned(, b) |
| 144 |
// expected-note@+4 {{defined as aligned}} |
| 145 |
// expected-error@+3 {{a parameter cannot appear in more than one aligned clause}} |
| 146 |
// expected-error@+2 {{expected expression}} |
| 147 |
// expected-error@+1 {{expected ',' or ')' in 'aligned' clause}} |
| 148 |
#pragma omp declare simd aligned(b) aligned(b ; 64) |
| 149 |
// expected-note@+2 {{defined as aligned}} |
| 150 |
// expected-error@+1 {{a parameter cannot appear in more than one aligned clause}} |
| 151 |
#pragma omp declare simd aligned(b) aligned(b: 64) |
| 152 |
// expected-error@+1 {{argument to 'aligned' clause must be a strictly positive integer value}} |
| 153 |
#pragma omp declare simd aligned(b: -1) |
| 154 |
// expected-warning@+1 {{aligned clause will be ignored because the requested alignment is not a power of 2}} |
| 155 |
#pragma omp declare simd aligned(b: 3) |
| 156 |
// expected-error@+1 {{expected '(' after 'linear'}} |
| 157 |
#pragma omp declare simd linear |
| 158 |
// expected-note@+3 {{to match this '('}} |
| 159 |
// expected-error@+2 {{expected ')'}} |
| 160 |
// expected-error@+1 {{expected expression}} |
| 161 |
#pragma omp declare simd linear( |
| 162 |
// expected-error@+1 {{expected expression}} |
| 163 |
#pragma omp declare simd linear() |
| 164 |
// expected-note@+3 {{to match this '('}} |
| 165 |
// expected-error@+2 {{expected ')'}} |
| 166 |
// expected-error@+1 {{expected expression}} |
| 167 |
#pragma omp declare simd linear(a: |
| 168 |
// expected-error@+1 {{expected expression}} |
| 169 |
#pragma omp declare simd linear(a:) |
| 170 |
// expected-warning@+2 {{extra tokens at the end of '#pragma omp declare simd' are ignored}} |
| 171 |
// expected-error@+1 {{expected '(' after 'linear'}} |
| 172 |
#pragma omp declare simd linear :) |
| 173 |
// expected-note@+3 {{to match this '('}} |
| 174 |
// expected-error@+2 {{expected ')'}} |
| 175 |
// expected-error@+1 {{invalid use of 'this' outside of a non-static member function}} |
| 176 |
#pragma omp declare simd linear(this |
| 177 |
// expected-note@+3 {{to match this '('}} |
| 178 |
// expected-error@+2 {{expected ')'}} |
| 179 |
// expected-error@+1 {{invalid use of 'this' outside of a non-static member function}} |
| 180 |
#pragma omp declare simd linear(this,b |
| 181 |
// expected-error@+1 {{expected expression}} |
| 182 |
#pragma omp declare simd linear(, b) |
| 183 |
// expected-note@+4 {{defined as linear}} |
| 184 |
// expected-error@+3 {{linear variable cannot be linear}} |
| 185 |
// expected-error@+2 {{expected expression}} |
| 186 |
// expected-error@+1 {{expected ',' or ')' in 'linear' clause}} |
| 187 |
#pragma omp declare simd linear(b) linear(b ; 64) |
| 188 |
// expected-note@+2 {{defined as linear}} |
| 189 |
// expected-error@+1 {{linear variable cannot be linear}} |
| 190 |
#pragma omp declare simd linear(b) linear(b: 64) |
| 191 |
#pragma omp declare simd linear(b: -1) |
| 192 |
#pragma omp declare simd linear(b: 3) |
| 193 |
// expected-error@+1 {{expected a reference to a parameter specified in a 'uniform' clause}} |
| 194 |
#pragma omp declare simd linear(b: a) |
| 195 |
// expected-note@+2 {{defined as uniform}} |
| 196 |
// expected-error@+1 {{linear variable cannot be uniform}} |
| 197 |
#pragma omp declare simd uniform(a), linear(a: 4) |
| 198 |
// expected-note@+2 {{defined as uniform}} |
| 199 |
// expected-error@+1 {{linear variable cannot be uniform}} |
| 200 |
#pragma omp declare simd linear(a: 4) uniform(a) |
| 201 |
// expected-error@+1 {{variable of non-reference type 'int *' can be used only with 'val' modifier, but used with 'uval'}} |
| 202 |
#pragma omp declare simd linear(uval(b)) |
| 203 |
// expected-error@+1 {{variable of non-reference type 'int *' can be used only with 'val' modifier, but used with 'ref'}} |
| 204 |
#pragma omp declare simd linear(ref(b)) |
| 205 |
// expected-error@+1 {{expected one of 'ref', val' or 'uval' modifiers}} expected-warning@+1 {{extra tokens at the end of '#pragma omp declare simd' are ignored}} |
| 206 |
#pragma omp declare simd linear(uref(b)) allocate(b) |
| 207 |
#pragma omp declare simd linear(ref(c)) |
| 208 |
// expected-note@+2 {{'a' declared here}} |
| 209 |
// expected-note@+1 {{'a' declared here}} |
| 210 |
void bar(int a, int *b, float &c); |
| 211 |
|
| 212 |
template <class T> |
| 213 |
struct St { |
| 214 |
// expected-error@+2 {{function declaration is expected after 'declare simd' directive}} |
| 215 |
#pragma init_seg(compiler) |
| 216 |
#pragma omp declare simd |
| 217 |
#pragma init_seg(compiler) |
| 218 |
// expected-note@+7 {{defined as uniform}} |
| 219 |
// expected-error@+6 {{expected a reference to a parameter specified in a 'uniform' clause}} |
| 220 |
// expected-error@+5 {{linear variable cannot be uniform}} |
| 221 |
// expected-note@+4 {{defined as aligned}} |
| 222 |
// expected-error@+3 {{argument to 'aligned' clause must be a strictly positive integer value}} |
| 223 |
// expected-error@+2 {{'this' cannot appear in more than one aligned clause}} |
| 224 |
// expected-error@+1 {{use of undeclared identifier 't'}} |
| 225 |
#pragma omp declare simd uniform(this, t) aligned(this: 4) aligned(this: -4) linear(this: hp) |
| 226 |
void h(T *hp) { |
| 227 |
// expected-error@+1 {{unexpected OpenMP directive '#pragma omp declare simd'}} |
| 228 |
#pragma omp declare simd |
| 229 |
*hp = *t; |
| 230 |
} |
| 231 |
|
| 232 |
private: |
| 233 |
T t; |
| 234 |
}; |
| 235 |
|
| 236 |
namespace N { |
| 237 |
// expected-error@+1 {{function declaration is expected after 'declare simd' directive}} |
| 238 |
#pragma omp declare simd |
| 239 |
} |
| 240 |
// expected-error@+1 {{function declaration is expected after 'declare simd' directive}} |
| 241 |
#pragma omp declare simd |
| 242 |
// expected-error@+1 {{function declaration is expected after 'declare simd' directive}} |
| 243 |
#pragma omp declare simd |