| 1 |
// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized |
| 2 |
// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp -fopenmp-version=52 -DOMP52 %s -Wuninitialized |
| 3 |
|
| 4 |
// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized |
| 5 |
// RUN: %clang_cc1 -verify=expected,omp52 -fopenmp-simd -fopenmp-version=52 -DOMP52 %s -Wuninitialized |
| 6 |
|
| 7 |
extern int omp_default_mem_alloc; |
| 8 |
void xxx(int argc) { |
| 9 |
int i, lin, step_sz; // expected-note {{initialize the variable 'lin' to silence this warning}} expected-note {{initialize the variable 'step_sz' to silence this warning}} |
| 10 |
#pragma omp simd linear(i, lin : step_sz) // expected-warning {{variable 'lin' is uninitialized when used here}} expected-warning {{variable 'step_sz' is uninitialized when used here}} |
| 11 |
for (i = 0; i < 10; ++i) |
| 12 |
; |
| 13 |
} |
| 14 |
|
| 15 |
namespace X { |
| 16 |
int x; |
| 17 |
}; |
| 18 |
|
| 19 |
struct B { |
| 20 |
static int ib; // expected-note {{'B::ib' declared here}} |
| 21 |
static int bfoo() { return 8; } |
| 22 |
}; |
| 23 |
|
| 24 |
int bfoo() { return 4; } |
| 25 |
|
| 26 |
int z; |
| 27 |
const int C1 = 1; |
| 28 |
const int C2 = 2; |
| 29 |
void test_linear_colons() |
| 30 |
{ |
| 31 |
int B = 0; |
| 32 |
#pragma omp simd linear(B:bfoo()) |
| 33 |
for (int i = 0; i < 10; ++i) ; |
| 34 |
// expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'}} |
| 35 |
#pragma omp simd linear(B::ib:B:bfoo()) |
| 36 |
for (int i = 0; i < 10; ++i) ; |
| 37 |
// expected-error@+1 {{use of undeclared identifier 'ib'; did you mean 'B::ib'}} |
| 38 |
#pragma omp simd linear(B:ib) |
| 39 |
for (int i = 0; i < 10; ++i) ; |
| 40 |
// expected-error@+1 {{unexpected ':' in nested name specifier; did you mean '::'?}} |
| 41 |
#pragma omp simd linear(z:B:ib) |
| 42 |
for (int i = 0; i < 10; ++i) ; |
| 43 |
#pragma omp simd linear(B:B::bfoo()) |
| 44 |
for (int i = 0; i < 10; ++i) ; |
| 45 |
#pragma omp simd linear(X::x : ::z) |
| 46 |
for (int i = 0; i < 10; ++i) ; |
| 47 |
#pragma omp simd linear(B,::z, X::x) |
| 48 |
for (int i = 0; i < 10; ++i) ; |
| 49 |
#pragma omp simd linear(::z) |
| 50 |
for (int i = 0; i < 10; ++i) ; |
| 51 |
// expected-error@+1 {{expected variable name}} |
| 52 |
#pragma omp simd linear(B::bfoo()) |
| 53 |
for (int i = 0; i < 10; ++i) ; |
| 54 |
#pragma omp simd linear(B::ib,B:C1+C2) |
| 55 |
for (int i = 0; i < 10; ++i) ; |
| 56 |
} |
| 57 |
|
| 58 |
template<int L, class T, class N> T test_template(T* arr, N num) { |
| 59 |
N i; |
| 60 |
T sum = (T)0; |
| 61 |
T ind2 = - num * L; // expected-note {{'ind2' defined here}} |
| 62 |
// expected-error@+1 {{argument of a linear clause should be of integral or pointer type}} |
| 63 |
#pragma omp simd linear(ind2:L) |
| 64 |
for (i = 0; i < num; ++i) { |
| 65 |
T cur = arr[(int)ind2]; |
| 66 |
ind2 += L; |
| 67 |
sum += cur; |
| 68 |
} |
| 69 |
return T(); |
| 70 |
} |
| 71 |
|
| 72 |
template<int LEN> int test_warn() { |
| 73 |
int ind2 = 0; |
| 74 |
// expected-warning@+1 {{zero linear step ('ind2' should probably be const)}} |
| 75 |
#pragma omp simd linear(ind2:LEN) |
| 76 |
for (int i = 0; i < 100; i++) { |
| 77 |
ind2 += LEN; |
| 78 |
} |
| 79 |
return ind2; |
| 80 |
} |
| 81 |
|
| 82 |
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} |
| 83 |
extern S1 a; |
| 84 |
class S2 { |
| 85 |
mutable int a; |
| 86 |
public: |
| 87 |
S2():a(0) { } |
| 88 |
}; |
| 89 |
const S2 b; // expected-note 2 {{'b' defined here}} |
| 90 |
const S2 ba[5]; |
| 91 |
class S3 { |
| 92 |
int a; |
| 93 |
public: |
| 94 |
S3():a(0) { } |
| 95 |
}; |
| 96 |
const S3 ca[5]; |
| 97 |
class S4 { |
| 98 |
int a; |
| 99 |
S4(); |
| 100 |
public: |
| 101 |
S4(int v):a(v) { } |
| 102 |
}; |
| 103 |
class S5 { |
| 104 |
int a; |
| 105 |
S5():a(0) {} |
| 106 |
public: |
| 107 |
S5(int v):a(v) { } |
| 108 |
}; |
| 109 |
|
| 110 |
S3 h; |
| 111 |
#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} |
| 112 |
|
| 113 |
template<class I, class C> int foomain(I argc, C **argv) { |
| 114 |
I e(4); |
| 115 |
I g(5); |
| 116 |
int i, z; |
| 117 |
int &j = i; |
| 118 |
#pragma omp simd linear // expected-error {{expected '(' after 'linear'}} |
| 119 |
for (int k = 0; k < argc; ++k) ++k; |
| 120 |
#pragma omp simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 121 |
for (int k = 0; k < argc; ++k) ++k; |
| 122 |
#pragma omp simd linear (val // expected-error {{use of undeclared identifier 'val'}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 123 |
for (int k = 0; k < argc; ++k) ++k; |
| 124 |
#pragma omp simd linear (uval( // expected-error {{expected expression}} expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 125 |
for (int k = 0; k < argc; ++k) ++k; |
| 126 |
#pragma omp simd linear (ref() // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 127 |
for (int k = 0; k < argc; ++k) ++k; |
| 128 |
#pragma omp simd linear (foo() // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 129 |
for (int k = 0; k < argc; ++k) ++k; |
| 130 |
#pragma omp simd linear () // expected-error {{expected expression}} |
| 131 |
for (int k = 0; k < argc; ++k) ++k; |
| 132 |
#pragma omp simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 133 |
for (int k = 0; k < argc; ++k) ++k; |
| 134 |
#pragma omp simd linear (val argc // expected-error {{use of undeclared identifier 'val'}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 135 |
for (int k = 0; k < argc; ++k) ++k; |
| 136 |
#pragma omp simd linear (val(argc, // expected-error {{expected expression}} expected-error 2 {{expected ')'}} expected-note 2 {{to match this '('}} omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 137 |
for (int k = 0; k < argc; ++k) ++k; |
| 138 |
#pragma omp simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 139 |
for (int k = 0; k < argc; ++k) ++k; |
| 140 |
#pragma omp simd linear (argc : 5) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}} |
| 141 |
for (int k = 0; k < argc; ++k) ++k; |
| 142 |
#pragma omp simd linear (S1) // expected-error {{'S1' does not refer to a value}} |
| 143 |
for (int k = 0; k < argc; ++k) ++k; |
| 144 |
#if defined(OMP52) |
| 145 |
// omp52-error@+3{{step simple modifier is exclusive and cannot be use with 'val', 'uval' or 'ref' modifier}} |
| 146 |
// expected-error@+2 {{linear variable with incomplete type 'S1'}} |
| 147 |
// expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}} |
| 148 |
#pragma omp simd linear (a, b: val, B::ib) |
| 149 |
#else |
| 150 |
// omp52-error@+3 {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 151 |
// expected-error@+2 {{linear variable with incomplete type 'S1'}} |
| 152 |
// expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}} |
| 153 |
#pragma omp simd linear (val(a, b):B::ib) |
| 154 |
#endif |
| 155 |
for (int k = 0; k < argc; ++k) ++k; |
| 156 |
#pragma omp simd linear (argv[1]) // expected-error {{expected variable name}} |
| 157 |
for (int k = 0; k < argc; ++k) ++k; |
| 158 |
#pragma omp simd linear(ref(e, g)) // expected-error 2 {{variable of non-reference type 'int' can be used only with 'val' modifier, but used with 'ref'}} omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 159 |
for (int k = 0; k < argc; ++k) ++k; |
| 160 |
#pragma omp simd linear(h, z) // expected-error {{threadprivate or thread local variable cannot be linear}} |
| 161 |
for (int k = 0; k < argc; ++k) ++k; |
| 162 |
#pragma omp simd linear(uval(i)) // expected-error {{variable of non-reference type 'int' can be used only with 'val' modifier, but used with 'uval'}} omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 163 |
for (int k = 0; k < argc; ++k) ++k; |
| 164 |
#pragma omp parallel |
| 165 |
{ |
| 166 |
int v = 0; |
| 167 |
int i; |
| 168 |
#pragma omp simd linear(v:i) |
| 169 |
for (int k = 0; k < argc; ++k) { i = k; v += i; } |
| 170 |
} |
| 171 |
#pragma omp simd linear(ref(j)) // omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 172 |
for (int k = 0; k < argc; ++k) ++k; |
| 173 |
#pragma omp simd linear(uval(j)) // omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 174 |
for (int k = 0; k < argc; ++k) ++k; |
| 175 |
int v = 0; |
| 176 |
#pragma omp simd linear(v:j) |
| 177 |
for (int k = 0; k < argc; ++k) { ++k; v += j; } |
| 178 |
#pragma omp simd linear(i) |
| 179 |
for (int k = 0; k < argc; ++k) ++k; |
| 180 |
return 0; |
| 181 |
} |
| 182 |
|
| 183 |
namespace A { |
| 184 |
double x; |
| 185 |
#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} |
| 186 |
} |
| 187 |
namespace C { |
| 188 |
using A::x; |
| 189 |
} |
| 190 |
|
| 191 |
void linear_modifiers(int argc) { |
| 192 |
int &f = argc; |
| 193 |
#pragma omp simd linear(f) |
| 194 |
for (int k = 0; k < argc; ++k) ++k; |
| 195 |
#pragma omp simd linear(val(f)) // omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 196 |
for (int k = 0; k < argc; ++k) ++k; |
| 197 |
#pragma omp simd linear(uval(f)) // omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 198 |
for (int k = 0; k < argc; ++k) ++k; |
| 199 |
#pragma omp simd linear(ref(f)) // omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 200 |
for (int k = 0; k < argc; ++k) ++k; |
| 201 |
#pragma omp simd linear(foo(f)) // expected-error {{expected one of 'ref', val' or 'uval' modifiers}} omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 202 |
for (int k = 0; k < argc; ++k) ++k; |
| 203 |
} |
| 204 |
|
| 205 |
int f; |
| 206 |
int main(int argc, char **argv) { |
| 207 |
double darr[100]; |
| 208 |
// expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}} |
| 209 |
test_template<-4>(darr, 4); |
| 210 |
// expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}} |
| 211 |
test_warn<0>(); |
| 212 |
|
| 213 |
S4 e(4); // expected-note {{'e' defined here}} |
| 214 |
S5 g(5); // expected-note {{'g' defined here}} |
| 215 |
int i, z; |
| 216 |
int &j = i; |
| 217 |
#pragma omp simd linear(f) linear(f) // expected-error {{linear variable cannot be linear}} expected-note {{defined as linear}} |
| 218 |
for (int k = 0; k < argc; ++k) ++k; |
| 219 |
#pragma omp simd linear // expected-error {{expected '(' after 'linear'}} |
| 220 |
for (int k = 0; k < argc; ++k) ++k; |
| 221 |
#pragma omp simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 222 |
for (int k = 0; k < argc; ++k) ++k; |
| 223 |
#pragma omp simd linear () // expected-error {{expected expression}} |
| 224 |
for (int k = 0; k < argc; ++k) ++k; |
| 225 |
#pragma omp simd linear (val // expected-error {{use of undeclared identifier 'val'}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 226 |
for (int k = 0; k < argc; ++k) ++k; |
| 227 |
#pragma omp simd linear (ref()) // expected-error {{expected expression}} omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 228 |
for (int k = 0; k < argc; ++k) ++k; |
| 229 |
#pragma omp simd linear (foo()) // expected-error {{expected expression}} omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 230 |
for (int k = 0; k < argc; ++k) ++k; |
| 231 |
#pragma omp simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 232 |
for (int k = 0; k < argc; ++k) ++k; |
| 233 |
#pragma omp simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 234 |
for (int k = 0; k < argc; ++k) ++k; |
| 235 |
#pragma omp simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 236 |
for (int k = 0; k < argc; ++k) ++k; |
| 237 |
#pragma omp simd linear (argc) |
| 238 |
for (int k = 0; k < argc; ++k) ++k; |
| 239 |
#pragma omp simd linear (S1) // expected-error {{'S1' does not refer to a value}} |
| 240 |
for (int k = 0; k < argc; ++k) ++k; |
| 241 |
// expected-error@+2 {{linear variable with incomplete type 'S1'}} |
| 242 |
// expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S2'}} |
| 243 |
#pragma omp simd linear(a, b, z) |
| 244 |
for (int k = 0; k < argc; ++k) ++k; |
| 245 |
#pragma omp simd linear (argv[1]) // expected-error {{expected variable name}} |
| 246 |
for (int k = 0; k < argc; ++k) ++k; |
| 247 |
// omp52-error@+3 {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 248 |
// expected-error@+2 {{argument of a linear clause should be of integral or pointer type, not 'S4'}} |
| 249 |
// expected-error@+1 {{argument of a linear clause should be of integral or pointer type, not 'S5'}} |
| 250 |
#pragma omp simd linear(val(e, g)) |
| 251 |
for (int k = 0; k < argc; ++k) ++k; |
| 252 |
#pragma omp simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}} |
| 253 |
for (int k = 0; k < argc; ++k) ++k; |
| 254 |
#pragma omp parallel |
| 255 |
{ |
| 256 |
int i; |
| 257 |
#pragma omp simd linear(val(i)) // omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 258 |
for (int k = 0; k < argc; ++k) ++k; |
| 259 |
#ifdef OMP52 |
| 260 |
#pragma omp simd linear(i : uval, step(4)) // expected-error {{variable of non-reference type 'int' can be used only with 'val' modifier, but used with 'uval'}} |
| 261 |
#else |
| 262 |
#pragma omp simd linear(uval(i) : 4) // expected-error {{variable of non-reference type 'int' can be used only with 'val' modifier, but used with 'uval'}} omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 263 |
#endif |
| 264 |
for (int k = 0; k < argc; ++k) { ++k; i += 4; } |
| 265 |
} |
| 266 |
#ifdef OMP52 |
| 267 |
#pragma omp simd linear(j: ref) |
| 268 |
#else |
| 269 |
#pragma omp simd linear(ref(j)) // omp52-error {{old syntax 'linear-modifier(list)' on 'linear' clause was deprecated, use new syntax 'linear(list: [linear-modifier,] step(step-size))'}} |
| 270 |
#endif |
| 271 |
for (int k = 0; k < argc; ++k) ++k; |
| 272 |
#ifdef OMP52 |
| 273 |
#pragma omp simd linear(i: step(1), step(2)) // omp52-error {{multiple 'step size' found in linear clause}} |
| 274 |
#else |
| 275 |
#pragma omp simd linear(i) |
| 276 |
#endif |
| 277 |
for (int k = 0; k < argc; ++k) ++k; |
| 278 |
#ifdef OMP52 |
| 279 |
#pragma omp simd linear(i: val, val) // omp52-error {{multiple 'linear modifier' found in linear clause}} |
| 280 |
for (int k = 0; k < argc; ++k) ++k; |
| 281 |
#pragma omp simd linear(j: step()) // omp52-error 2 {{expected expression}} |
| 282 |
for (int k = 0; k < argc; ++k) ++k; |
| 283 |
#pragma omp simd linear(j: pval) // omp52-error {{use of undeclared identifier 'pval'}} |
| 284 |
for (int k = 0; k < argc; ++k) ++k; |
| 285 |
#pragma omp simd linear(i: val, step(2 // omp52-error {{expected ')' or ',' after 'step expression'}} omp52-error 2 {{expected ')'}} omp52-note 2 {{to match this '('}} |
| 286 |
for (int k = 0; k < argc; ++k) ++k; |
| 287 |
#endif |
| 288 |
|
| 289 |
foomain<int,char>(argc,argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}} |
| 290 |
return 0; |
| 291 |
} |