target_parallel_for_simd_map_messages.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. // RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-target
  2. // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-target
  3. void foo() {
  4. }
  5. bool foobool(int argc) {
  6. return argc;
  7. }
  8. struct S1; // expected-note 2 {{declared here}}
  9. extern S1 a;
  10. class S2 {
  11. mutable int a;
  12. public:
  13. S2():a(0) { }
  14. S2(S2 &s2):a(s2.a) { }
  15. static float S2s;
  16. static const float S2sc;
  17. };
  18. const float S2::S2sc = 0;
  19. const S2 b;
  20. const S2 ba[5];
  21. class S3 {
  22. int a;
  23. public:
  24. S3():a(0) { }
  25. S3(S3 &s3):a(s3.a) { }
  26. };
  27. const S3 c;
  28. const S3 ca[5];
  29. extern const int f;
  30. class S4 {
  31. int a;
  32. S4();
  33. S4(const S4 &s4);
  34. public:
  35. S4(int v):a(v) { }
  36. };
  37. class S5 {
  38. int a;
  39. S5():a(0) {}
  40. S5(const S5 &s5):a(s5.a) { }
  41. public:
  42. S5(int v):a(v) { }
  43. };
  44. S3 h;
  45. #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
  46. typedef int from;
  47. template <typename T, int I> // expected-note {{declared here}}
  48. T tmain(T argc) {
  49. const T d = 5;
  50. const T da[5] = { 0 };
  51. S4 e(4);
  52. S5 g(5);
  53. T i, t[20];
  54. T &j = i;
  55. T *k = &j;
  56. T x;
  57. T y;
  58. T to, tofrom, always;
  59. const T (&l)[5] = da;
  60. #pragma omp target parallel for simd map // expected-error {{expected '(' after 'map'}}
  61. for (i = 0; i < argc; ++i) foo();
  62. #pragma omp target parallel for simd map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
  63. for (i = 0; i < argc; ++i) foo();
  64. #pragma omp target parallel for simd map() // expected-error {{expected expression}}
  65. for (i = 0; i < argc; ++i) foo();
  66. #pragma omp target parallel for simd map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
  67. for (i = 0; i < argc; ++i) foo();
  68. #pragma omp target parallel for simd map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
  69. for (i = 0; i < argc; ++i) foo();
  70. #pragma omp target parallel for simd map(to:) // expected-error {{expected expression}}
  71. for (i = 0; i < argc; ++i) foo();
  72. #pragma omp target parallel for simd map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
  73. for (i = 0; i < argc; ++i) foo();
  74. #pragma omp target parallel for simd map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
  75. for (i = 0; i < argc; ++i) foo();
  76. #pragma omp target parallel for simd map(l[-1:]) // expected-error 2 {{array section must be a subset of the original array}}
  77. for (i = 0; i < argc; ++i) foo();
  78. #pragma omp target parallel for simd map(l[:-1]) // expected-error 2 {{section length is evaluated to a negative value -1}}
  79. for (i = 0; i < argc; ++i) foo();
  80. #pragma omp target parallel for simd map(x)
  81. for (i = 0; i < argc; ++i) foo();
  82. #pragma omp target parallel for simd map(tofrom: t[:I])
  83. for (i = 0; i < argc; ++i) foo();
  84. #pragma omp target parallel for simd map(T: a) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} expected-error {{incomplete type 'S1' where a complete type is required}}
  85. for (i = 0; i < argc; ++i) foo();
  86. #pragma omp target parallel for simd map(T) // expected-error {{'T' does not refer to a value}}
  87. for (i = 0; i < argc; ++i) foo();
  88. #pragma omp target parallel for simd map(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
  89. for (i = 0; i < argc; ++i) foo();
  90. #pragma omp target parallel for simd map(S2::S2s)
  91. for (i = 0; i < argc; ++i) foo();
  92. #pragma omp target parallel for simd map(S2::S2sc)
  93. for (i = 0; i < argc; ++i) foo();
  94. #pragma omp target parallel for simd map(x)
  95. for (i = 0; i < argc; ++i) foo();
  96. #pragma omp target parallel for simd map(to: x)
  97. for (i = 0; i < argc; ++i) foo();
  98. #pragma omp target parallel for simd map(to: to)
  99. for (i = 0; i < argc; ++i) foo();
  100. #pragma omp target parallel for simd map(to)
  101. for (i = 0; i < argc; ++i) foo();
  102. #pragma omp target parallel for simd map(to, x)
  103. for (i = 0; i < argc; ++i) foo();
  104. #pragma omp target parallel for simd map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
  105. for (i = 0; i < argc; ++i) foo();
  106. #pragma omp target parallel for simd map(tofrom: argc > 0 ? x : y) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
  107. for (i = 0; i < argc; ++i) foo();
  108. #pragma omp target parallel for simd map(argc)
  109. for (i = 0; i < argc; ++i) foo();
  110. #pragma omp target parallel for simd map(S1) // expected-error {{'S1' does not refer to a value}}
  111. for (i = 0; i < argc; ++i) foo();
  112. #pragma omp target parallel for simd map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
  113. for (i = 0; i < argc; ++i) foo();
  114. #pragma omp target parallel for simd map(ba)
  115. for (i = 0; i < argc; ++i) foo();
  116. #pragma omp target parallel for simd map(ca)
  117. for (i = 0; i < argc; ++i) foo();
  118. #pragma omp target parallel for simd map(da)
  119. for (i = 0; i < argc; ++i) foo();
  120. #pragma omp target parallel for simd map(S2::S2s)
  121. for (i = 0; i < argc; ++i) foo();
  122. #pragma omp target parallel for simd map(S2::S2sc)
  123. for (i = 0; i < argc; ++i) foo();
  124. #pragma omp target parallel for simd map(e, g)
  125. for (i = 0; i < argc; ++i) foo();
  126. #pragma omp target parallel for simd map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
  127. for (i = 0; i < argc; ++i) foo();
  128. #pragma omp target parallel for simd map(k), map(k) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
  129. for (i = 0; i < argc; ++i) foo();
  130. #pragma omp target parallel for simd map(k), map(k[:5]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} expected-note 2 {{used here}}
  131. for (i = 0; i < argc; ++i) foo();
  132. #pragma omp target parallel for simd map(da)
  133. for (i = 0; i < argc; ++i) foo();
  134. #pragma omp target parallel for simd map(da[:4])
  135. for (i = 0; i < argc; ++i) foo();
  136. #pragma omp target data map(k, j, l) // expected-note 2 {{used here}}
  137. #pragma omp target parallel for simd map(k[:4]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
  138. for (i = 0; i < argc; ++i) foo();
  139. #pragma omp target parallel for simd map(j)
  140. for (i = 0; i < argc; ++i) foo();
  141. #pragma omp target parallel for simd map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
  142. for (i = 0; i < argc; ++i) foo();
  143. #pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
  144. {
  145. #pragma omp target parallel for simd map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
  146. for (i = 0; i < argc; ++i) foo();
  147. #pragma omp target parallel for simd map(j)
  148. for (i = 0; i < argc; ++i) foo();
  149. #pragma omp target parallel for simd map(l)
  150. for (i = 0; i < argc; ++i) foo();
  151. }
  152. #pragma omp target parallel for simd map(always, tofrom: x)
  153. for (i = 0; i < argc; ++i) foo();
  154. #pragma omp target parallel for simd map(always: x) // expected-error {{missing map type}}
  155. for (i = 0; i < argc; ++i) foo();
  156. #pragma omp target parallel for simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always' or 'close'}} expected-error {{missing map type}}
  157. for (i = 0; i < argc; ++i) foo();
  158. #pragma omp target parallel for simd map(always, tofrom: always, tofrom, x)
  159. for (i = 0; i < argc; ++i) foo();
  160. #pragma omp target parallel for simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
  161. for (i = 0; i < argc; ++i) foo();
  162. return 0;
  163. }
  164. int main(int argc, char **argv) {
  165. const int d = 5;
  166. const int da[5] = { 0 };
  167. S4 e(4);
  168. S5 g(5);
  169. int i;
  170. int &j = i;
  171. int *k = &j;
  172. int x;
  173. int y;
  174. int to, tofrom, always;
  175. const int (&l)[5] = da;
  176. #pragma omp target parallel for simd map // expected-error {{expected '(' after 'map'}}
  177. for (i = 0; i < argc; ++i) foo();
  178. #pragma omp target parallel for simd map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
  179. for (i = 0; i < argc; ++i) foo();
  180. #pragma omp target parallel for simd map() // expected-error {{expected expression}}
  181. for (i = 0; i < argc; ++i) foo();
  182. #pragma omp target parallel for simd map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
  183. for (i = 0; i < argc; ++i) foo();
  184. #pragma omp target parallel for simd map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
  185. for (i = 0; i < argc; ++i) foo();
  186. #pragma omp target parallel for simd map(to:) // expected-error {{expected expression}}
  187. for (i = 0; i < argc; ++i) foo();
  188. #pragma omp target parallel for simd map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
  189. for (i = 0; i < argc; ++i) foo();
  190. #pragma omp target parallel for simd map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
  191. for (i = 0; i < argc; ++i) foo();
  192. #pragma omp target parallel map(l[-1:]) // expected-error {{array section must be a subset of the original array}}
  193. for (i = 0; i < argc; ++i) foo();
  194. #pragma omp target parallel map(l[:-1]) // expected-error {{section length is evaluated to a negative value -1}}
  195. for (i = 0; i < argc; ++i) foo();
  196. #pragma omp target parallel for simd map(x)
  197. for (i = 0; i < argc; ++i) foo();
  198. #pragma omp target parallel for simd map(to: x)
  199. for (i = 0; i < argc; ++i) foo();
  200. #pragma omp target parallel for simd map(to: to)
  201. for (i = 0; i < argc; ++i) foo();
  202. #pragma omp target parallel for simd map(to)
  203. for (i = 0; i < argc; ++i) foo();
  204. #pragma omp target parallel for simd map(to, x)
  205. for (i = 0; i < argc; ++i) foo();
  206. #pragma omp target parallel for simd map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
  207. for (i = 0; i < argc; ++i) foo();
  208. #pragma omp target parallel for simd map(tofrom: argc > 0 ? argv[1] : argv[2]) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}}
  209. for (i = 0; i < argc; ++i) foo();
  210. #pragma omp target parallel for simd map(argc)
  211. for (i = 0; i < argc; ++i) foo();
  212. #pragma omp target parallel for simd map(S1) // expected-error {{'S1' does not refer to a value}}
  213. for (i = 0; i < argc; ++i) foo();
  214. #pragma omp target parallel for simd map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
  215. for (i = 0; i < argc; ++i) foo();
  216. #pragma omp target parallel for simd map(argv[1])
  217. for (i = 0; i < argc; ++i) foo();
  218. #pragma omp target parallel for simd map(ba)
  219. for (i = 0; i < argc; ++i) foo();
  220. #pragma omp target parallel for simd map(ca)
  221. for (i = 0; i < argc; ++i) foo();
  222. #pragma omp target parallel for simd map(da)
  223. for (i = 0; i < argc; ++i) foo();
  224. #pragma omp target parallel for simd map(S2::S2s)
  225. for (i = 0; i < argc; ++i) foo();
  226. #pragma omp target parallel for simd map(S2::S2sc)
  227. for (i = 0; i < argc; ++i) foo();
  228. #pragma omp target parallel for simd map(e, g)
  229. for (i = 0; i < argc; ++i) foo();
  230. #pragma omp target parallel for simd map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
  231. for (i = 0; i < argc; ++i) foo();
  232. #pragma omp target parallel for simd map(k), map(k) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
  233. for (i = 0; i < argc; ++i) foo();
  234. #pragma omp target parallel for simd map(k), map(k[:5]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}}
  235. for (i = 0; i < argc; ++i) foo();
  236. #pragma omp target parallel for simd map(da)
  237. for (i = 0; i < argc; ++i) foo();
  238. #pragma omp target parallel for simd map(da[:4])
  239. for (i = 0; i < argc; ++i) foo();
  240. #pragma omp target data map(k, j, l) // expected-note {{used here}}
  241. #pragma omp target parallel for simd map(k[:4]) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
  242. for (i = 0; i < argc; ++i) foo();
  243. #pragma omp target parallel for simd map(j)
  244. for (i = 0; i < argc; ++i) foo();
  245. #pragma omp target parallel for simd map(l) map(l[:5]) // expected-error 1 {{variable already marked as mapped in current construct}} expected-note 1 {{used here}}
  246. for (i = 0; i < argc; ++i) foo();
  247. #pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}}
  248. {
  249. #pragma omp target parallel for simd map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
  250. for (i = 0; i < argc; ++i) foo();
  251. #pragma omp target parallel for simd map(j)
  252. for (i = 0; i < argc; ++i) foo();
  253. #pragma omp target parallel for simd map(l)
  254. for (i = 0; i < argc; ++i) foo();
  255. }
  256. #pragma omp target parallel for simd map(always, tofrom: x)
  257. for (i = 0; i < argc; ++i) foo();
  258. #pragma omp target parallel for simd map(always: x) // expected-error {{missing map type}}
  259. for (i = 0; i < argc; ++i) foo();
  260. #pragma omp target parallel for simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always' or 'close'}} expected-error {{missing map type}}
  261. for (i = 0; i < argc; ++i) foo();
  262. #pragma omp target parallel for simd map(always, tofrom: always, tofrom, x)
  263. for (i = 0; i < argc; ++i) foo();
  264. #pragma omp target parallel for simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
  265. for (i = 0; i < argc; ++i) foo();
  266. return tmain<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}}
  267. }