1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized 2 3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized 4 5 void xxx(int argc) { 6 int fp, fp1; // expected-note {{initialize the variable 'fp' to silence this warning}} expected-note {{initialize the variable 'fp1' to silence this warning}} 7 #pragma omp target firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}} 8 for (int i = 0; i < 10; ++i) 9 ++fp1; // expected-warning {{variable 'fp1' is uninitialized when used here}} 10 } 11 12 typedef void **omp_allocator_handle_t; 13 extern const omp_allocator_handle_t omp_default_mem_alloc; 14 extern const omp_allocator_handle_t omp_large_cap_mem_alloc; 15 extern const omp_allocator_handle_t omp_const_mem_alloc; 16 extern const omp_allocator_handle_t omp_high_bw_mem_alloc; 17 extern const omp_allocator_handle_t omp_low_lat_mem_alloc; 18 extern const omp_allocator_handle_t omp_cgroup_mem_alloc; 19 extern const omp_allocator_handle_t omp_pteam_mem_alloc; 20 extern const omp_allocator_handle_t omp_thread_mem_alloc; 21 22 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} 23 extern S1 a; 24 class S2 { 25 mutable int a; 26 27 public: 28 S2() : a(0) {} 29 }; 30 const S2 b; 31 const S2 ba[5]; 32 class S3 { 33 int a; 34 35 public: 36 S3() : a(0) {} 37 }; 38 const S3 ca[5]; 39 class S4 { 40 int a; 41 S4(); 42 43 public: 44 S4(int v) : a(v) { 45 #pragma omp target firstprivate(a) firstprivate(this->a) 46 for (int k = 0; k < v; ++k) 47 ++this->a; 48 } 49 }; 50 class S5 { 51 int a; 52 S5() : a(0) {} 53 54 public: 55 S5(int v) : a(v) {} 56 S5 &operator=(S5 &s) { 57 #pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) // expected-error {{expected variable name or data member of current class}} 58 for (int k = 0; k < s.a; ++k) // expected-warning {{Type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}} 59 ++s.a; 60 return *this; 61 } 62 }; 63 64 template <typename T> 65 class S6 { 66 public: 67 T a; 68 69 S6() : a(0) {} 70 S6(T v) : a(v) { 71 #pragma omp target firstprivate(a) firstprivate(this->a) 72 for (int k = 0; k < v; ++k) 73 ++this->a; 74 } 75 S6 &operator=(S6 &s) { 76 #pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) // expected-error {{expected variable name or data member of current class}} 77 for (int k = 0; k < s.a; ++k) 78 ++s.a; 79 return *this; 80 } 81 }; 82 83 template <typename T> 84 class S7 : public T { 85 T a; 86 S7() : a(0) {} 87 88 public: 89 S7(T v) : a(v) { 90 #pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(T::a) 91 for (int k = 0; k < a.a; ++k) 92 ++this->a.a; 93 } 94 S7 &operator=(S7 &s) { 95 #pragma omp target firstprivate(a) firstprivate(this->a) firstprivate(s.a) firstprivate(s.T::a) // expected-error 2 {{expected variable name or data member of current class}} 96 for (int k = 0; k < s.a.a; ++k) 97 ++s.a.a; 98 return *this; 99 } 100 }; 101 102 S3 h; 103 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} 104 105 template <class I, class C> 106 int foomain(I argc, C **argv) { 107 I e(4); 108 I g(5); 109 int i, z; 110 int &j = i; 111 #pragma omp target firstprivate // expected-error {{expected '(' after 'firstprivate'}} 112 {} 113 #pragma omp target firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 114 {} 115 #pragma omp target firstprivate() // expected-error {{expected expression}} 116 {} 117 #pragma omp target firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 118 {} 119 #pragma omp target firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 120 {} 121 #pragma omp target firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 122 {} 123 #pragma omp target 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 '('}} 124 {} 125 #pragma omp target firstprivate(S1) // expected-error {{'S1' does not refer to a value}} 126 {} 127 #pragma omp target firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}} 128 {} 129 #pragma omp target firstprivate(argv[1]) // expected-error {{expected variable name}} 130 {} 131 #pragma omp target firstprivate(e, g) allocate(omp_thread_mem_alloc: e) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target' directive}} 132 {} 133 #pragma omp target firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} 134 {} 135 #pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}} 136 #pragma omp parallel 137 { 138 int v = 0; 139 int i; 140 } 141 #pragma omp parallel shared(i, z) 142 #pragma omp parallel firstprivate(i, z) 143 #pragma omp target firstprivate(j) 144 {} 145 #pragma omp target firstprivate(i) 146 {} 147 return 0; 148 } 149 150 void bar(S4 a[2]) { 151 #pragma omp parallel 152 #pragma omp target firstprivate(a) 153 {} 154 } 155 156 namespace A { 157 double x; 158 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} 159 } 160 namespace B { 161 using A::x; 162 } 163 164 int main(int argc, char **argv) { 165 S4 e(4); 166 S5 g(5); 167 S6<float> s6(0.0) , s6_0(1.0); 168 S7<S6<float> > s7(0.0) , s7_0(1.0); 169 int i, z; 170 int &j = i; 171 #pragma omp target firstprivate // expected-error {{expected '(' after 'firstprivate'}} 172 {} 173 #pragma omp target firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 174 {} 175 #pragma omp target firstprivate() // expected-error {{expected expression}} 176 {} 177 #pragma omp target firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 178 {} 179 #pragma omp target firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 180 {} 181 #pragma omp target firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 182 {} 183 #pragma omp target firstprivate(argc, z) 184 {} 185 #pragma omp target firstprivate(S1) // expected-error {{'S1' does not refer to a value}} 186 {} 187 #pragma omp target firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}} 188 {} 189 #pragma omp target firstprivate(argv[1]) // expected-error {{expected variable name}} 190 {} 191 #pragma omp target firstprivate(e, g) 192 {} 193 #pragma omp target firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} 194 {} 195 #pragma omp target firstprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} 196 {} 197 #pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}} 198 #pragma omp parallel 199 { 200 int i; 201 } 202 #pragma omp parallel shared(i) 203 #pragma omp parallel firstprivate(i) 204 #pragma omp target firstprivate(j) 205 {} 206 #pragma omp target firstprivate(i) 207 {} 208 static int si; 209 #pragma omp target firstprivate(si) // OK 210 {} 211 #pragma omp target map(i) firstprivate(i) // expected-error {{firstprivate variable cannot be in a map clause in '#pragma omp target' directive}} 212 {} 213 s6 = s6_0; // expected-note {{in instantiation of member function 'S6<float>::operator=' requested here}} 214 s7 = s7_0; // expected-note {{in instantiation of member function 'S7<S6<float>>::operator=' requested here}} 215 return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}} 216 } 217 218