| 1 |
// RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-mapping -Wuninitialized |
| 2 |
|
| 3 |
// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-mapping -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 target |
| 16 |
#pragma omp teams firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}} |
| 17 |
for (int i = 0; i < 10; ++i) |
| 18 |
; |
| 19 |
} |
| 20 |
|
| 21 |
struct S1; // expected-note {{declared here}} expected-note 2 {{forward declaration of 'S1'}} |
| 22 |
extern S1 a; |
| 23 |
class S2 { |
| 24 |
mutable int a; |
| 25 |
|
| 26 |
public: |
| 27 |
S2() : a(0) {} |
| 28 |
S2(const S2 &s2) : a(s2.a) {} |
| 29 |
static float S2s; |
| 30 |
static const float S2sc; |
| 31 |
}; |
| 32 |
const float S2::S2sc = 0; |
| 33 |
const S2 b; |
| 34 |
const S2 ba[5]; |
| 35 |
class S3 { |
| 36 |
int a; |
| 37 |
|
| 38 |
public: |
| 39 |
S3() : a(0) {} |
| 40 |
S3(const S3 &s3) : a(s3.a) {} |
| 41 |
}; |
| 42 |
const S3 c; |
| 43 |
const S3 ca[5]; |
| 44 |
extern const int f; |
| 45 |
class S4 { |
| 46 |
int a; |
| 47 |
S4(); |
| 48 |
S4(const S4 &s4); // expected-note {{implicitly declared private here}} |
| 49 |
public: |
| 50 |
S4(int v) : a(v) {} |
| 51 |
}; |
| 52 |
class S5 { |
| 53 |
int a; |
| 54 |
S5() : a(0) {} |
| 55 |
S5(const S5 &s5) : a(s5.a) {} // expected-note {{implicitly declared private here}} |
| 56 |
public: |
| 57 |
S5(int v) : a(v) {} |
| 58 |
}; |
| 59 |
|
| 60 |
S3 h; |
| 61 |
#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} |
| 62 |
|
| 63 |
namespace A { |
| 64 |
double x; |
| 65 |
#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} |
| 66 |
} |
| 67 |
namespace B { |
| 68 |
using A::x; |
| 69 |
} |
| 70 |
|
| 71 |
int main(int argc, char **argv) { |
| 72 |
const int d = 5; |
| 73 |
const int da[5] = {0}; |
| 74 |
S4 e(4); |
| 75 |
S5 g(5); |
| 76 |
int i, z; |
| 77 |
int &j = i; |
| 78 |
#pragma omp target |
| 79 |
#pragma omp teams firstprivate // expected-error {{expected '(' after 'firstprivate'}} |
| 80 |
foo(); |
| 81 |
#pragma omp target |
| 82 |
#pragma omp teams firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 83 |
foo(); |
| 84 |
#pragma omp target |
| 85 |
#pragma omp teams firstprivate() // expected-error {{expected expression}} |
| 86 |
foo(); |
| 87 |
#pragma omp target |
| 88 |
#pragma omp teams firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 89 |
foo(); |
| 90 |
#pragma omp target |
| 91 |
#pragma omp teams firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 92 |
foo(); |
| 93 |
#pragma omp target |
| 94 |
#pragma omp teams firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 95 |
foo(); |
| 96 |
#pragma omp target |
| 97 |
#pragma omp teams 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 '('}} |
| 98 |
foo(); |
| 99 |
#pragma omp target |
| 100 |
#pragma omp teams firstprivate(S1) // expected-error {{'S1' does not refer to a value}} |
| 101 |
foo(); |
| 102 |
#pragma omp target |
| 103 |
#pragma omp teams firstprivate(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error {{firstprivate variable with incomplete type 'S1'}} |
| 104 |
foo(); |
| 105 |
#pragma omp target |
| 106 |
#pragma omp teams firstprivate(argv[1]) // expected-error {{expected variable name}} |
| 107 |
foo(); |
| 108 |
#pragma omp target |
| 109 |
#pragma omp teams firstprivate(ba, z) |
| 110 |
foo(); |
| 111 |
#pragma omp target |
| 112 |
#pragma omp teams firstprivate(ca) |
| 113 |
foo(); |
| 114 |
#pragma omp target |
| 115 |
#pragma omp teams firstprivate(da) |
| 116 |
foo(); |
| 117 |
#pragma omp target |
| 118 |
#pragma omp teams firstprivate(S2::S2s) |
| 119 |
foo(); |
| 120 |
#pragma omp target |
| 121 |
#pragma omp teams firstprivate(S2::S2sc) |
| 122 |
foo(); |
| 123 |
#pragma omp target |
| 124 |
#pragma omp teams firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} |
| 125 |
foo(); |
| 126 |
#pragma omp target |
| 127 |
#pragma omp teams firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}} |
| 128 |
foo(); |
| 129 |
#pragma omp target |
| 130 |
#pragma omp teams private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}} |
| 131 |
foo(); |
| 132 |
#pragma omp target |
| 133 |
#pragma omp teams shared(i) |
| 134 |
foo(); |
| 135 |
#pragma omp target |
| 136 |
#pragma omp teams firstprivate(i) |
| 137 |
foo(); |
| 138 |
#pragma omp target |
| 139 |
#pragma omp teams firstprivate(j) |
| 140 |
foo(); |
| 141 |
static int m; |
| 142 |
#pragma omp target |
| 143 |
#pragma omp teams firstprivate(m) // OK |
| 144 |
foo(); |
| 145 |
|
| 146 |
return 0; |
| 147 |
} |