master_taskloop_simd_private_messages.cpp 8.8 KB

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