| 1 |
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized |
| 2 |
|
| 3 |
// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized |
| 4 |
|
| 5 |
extern int omp_default_mem_alloc; |
| 6 |
void foo() { |
| 7 |
} |
| 8 |
|
| 9 |
bool foobool(int argc) { |
| 10 |
return argc; |
| 11 |
} |
| 12 |
|
| 13 |
void xxx(int argc) { |
| 14 |
int fp; // expected-note {{initialize the variable 'fp' to silence this warning}} |
| 15 |
#pragma omp parallel firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}} |
| 16 |
for (int i = 0; i < 10; ++i) |
| 17 |
; |
| 18 |
} |
| 19 |
|
| 20 |
struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}} |
| 21 |
extern S1 a; |
| 22 |
class S2 { |
| 23 |
mutable int a; |
| 24 |
public: |
| 25 |
S2():a(0) { } |
| 26 |
S2(const S2 &s2):a(s2.a) { } |
| 27 |
static float S2s; |
| 28 |
static const float S2sc; |
| 29 |
}; |
| 30 |
const float S2::S2sc = 0; |
| 31 |
const S2 b; |
| 32 |
const S2 ba[5]; |
| 33 |
class S3 { |
| 34 |
int a; |
| 35 |
public: |
| 36 |
S3():a(0) { } |
| 37 |
S3(const S3 &s3):a(s3.a) { } |
| 38 |
}; |
| 39 |
const S3 c; |
| 40 |
const S3 ca[5]; |
| 41 |
extern const int f; |
| 42 |
class S4 { |
| 43 |
int a; |
| 44 |
S4(); |
| 45 |
S4(const S4 &s4); // expected-note {{implicitly declared private here}} |
| 46 |
public: |
| 47 |
S4(int v):a(v) { } |
| 48 |
}; |
| 49 |
class S5 { |
| 50 |
int a; |
| 51 |
S5():a(0) {} |
| 52 |
S5(const S5 &s5):a(s5.a) { } // expected-note {{implicitly declared private here}} |
| 53 |
public: |
| 54 |
S5(int v):a(v) { } |
| 55 |
}; |
| 56 |
|
| 57 |
S3 h; |
| 58 |
#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} |
| 59 |
|
| 60 |
namespace A { |
| 61 |
double x; |
| 62 |
#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} |
| 63 |
} |
| 64 |
namespace B { |
| 65 |
using A::x; |
| 66 |
} |
| 67 |
|
| 68 |
int main(int argc, char **argv) { |
| 69 |
const int d = 5; // expected-note {{variable 'd' declared const here}} |
| 70 |
const int da[5] = { 0 }; |
| 71 |
S4 e(4); |
| 72 |
S5 g(5); |
| 73 |
int i, z; |
| 74 |
int &j = i; |
| 75 |
static int m; |
| 76 |
#pragma omp parallel firstprivate // expected-error {{expected '(' after 'firstprivate'}} |
| 77 |
#pragma omp parallel firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 78 |
#pragma omp parallel firstprivate () // expected-error {{expected expression}} |
| 79 |
#pragma omp parallel firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 80 |
#pragma omp parallel firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 81 |
#pragma omp parallel firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 82 |
#pragma omp parallel firstprivate (argc) 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 '('}} |
| 83 |
#pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}} |
| 84 |
#pragma omp parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} |
| 85 |
#pragma omp parallel firstprivate (z, d) |
| 86 |
d = 5; // expected-error {{cannot assign to variable 'd' with const-qualified type}} |
| 87 |
#pragma omp parallel firstprivate (argv[1]) // expected-error {{expected variable name}} |
| 88 |
#pragma omp parallel firstprivate(ba) |
| 89 |
#pragma omp parallel firstprivate(ca) |
| 90 |
#pragma omp parallel firstprivate(da) |
| 91 |
#pragma omp parallel firstprivate(S2::S2s) |
| 92 |
#pragma omp parallel firstprivate(S2::S2sc) |
| 93 |
#pragma omp parallel firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} |
| 94 |
#pragma omp parallel firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}} |
| 95 |
#pragma omp parallel private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}} |
| 96 |
foo(); |
| 97 |
#pragma omp parallel shared(i) |
| 98 |
#pragma omp parallel firstprivate(i) |
| 99 |
#pragma omp parallel firstprivate(j) |
| 100 |
#pragma omp parallel firstprivate(m) |
| 101 |
foo(); |
| 102 |
|
| 103 |
return 0; |
| 104 |
} |