to_addr_builtin.cl 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // RUN: %clang_cc1 -verify -fsyntax-only %s
  2. // RUN: %clang_cc1 -Wconversion -verify -fsyntax-only -cl-std=CL2.0 %s
  3. void test(void) {
  4. global int *glob;
  5. local int *loc;
  6. constant int *con;
  7. private int *priv;
  8. global float *glob_wrong_ty;
  9. typedef constant int const_int_ty;
  10. const_int_ty *con_typedef;
  11. glob = to_global(glob, loc);
  12. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  13. // expected-error@-2{{implicit declaration of function 'to_global' is invalid in OpenCL}}
  14. // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
  15. #else
  16. // expected-error@-5{{invalid number of arguments to function: 'to_global'}}
  17. #endif
  18. int x;
  19. glob = to_global(x);
  20. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  21. // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
  22. #else
  23. // expected-error@-4{{invalid argument x to function: 'to_global', expecting a generic pointer argument}}
  24. #endif
  25. glob = to_global(con);
  26. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  27. // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
  28. #else
  29. // expected-error@-4{{invalid argument con to function: 'to_global', expecting a generic pointer argument}}
  30. #endif
  31. glob = to_global(con_typedef);
  32. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  33. // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
  34. #else
  35. // expected-error@-4{{invalid argument con_typedef to function: 'to_global', expecting a generic pointer argument}}
  36. #endif
  37. loc = to_global(glob);
  38. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  39. // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}}
  40. #else
  41. // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}}
  42. // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
  43. #endif
  44. loc = to_private(glob);
  45. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  46. // expected-error@-2{{implicit declaration of function 'to_private' is invalid in OpenCL}}
  47. // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}}
  48. #else
  49. // expected-error@-5{{assigning 'int *' to '__local int *' changes address space of pointer}}
  50. // expected-warning@-6{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}}
  51. #endif
  52. loc = to_local(glob);
  53. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  54. // expected-error@-2{{implicit declaration of function 'to_local' is invalid in OpenCL}}
  55. // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}}
  56. // expected-note@-4{{did you mean 'to_global'}}
  57. // expected-note@13{{'to_global' declared here}}
  58. #else
  59. // expected-warning@-7{{passing non-generic address space pointer to to_local may cause dynamic conversion affecting performance}}
  60. #endif
  61. priv = to_global(glob);
  62. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  63. // expected-warning@-2{{incompatible integer to pointer conversion assigning to 'int *' from 'int'}}
  64. #else
  65. // expected-error@-4{{assigning '__global int *' to 'int *' changes address space of pointer}}
  66. // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
  67. #endif
  68. priv = to_private(glob);
  69. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  70. // expected-warning@-2{{incompatible integer to pointer conversion assigning to 'int *' from 'int'}}
  71. #else
  72. // expected-warning@-4{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}}
  73. #endif
  74. priv = to_local(glob);
  75. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  76. // expected-warning@-2{{incompatible integer to pointer conversion assigning to 'int *' from 'int'}}
  77. #else
  78. // expected-error@-4{{assigning '__local int *' to 'int *' changes address space of pointer}}
  79. // expected-warning@-5{{passing non-generic address space pointer to to_local may cause dynamic conversion affecting performance}}
  80. #endif
  81. glob = to_global(glob);
  82. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  83. // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
  84. #else
  85. // expected-warning@-4{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
  86. #endif
  87. glob = to_private(glob);
  88. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  89. // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
  90. #else
  91. // expected-error@-4{{assigning 'int *' to '__global int *' changes address space of pointer}}
  92. // expected-warning@-5{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}}
  93. #endif
  94. glob = to_local(glob);
  95. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  96. // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
  97. #else
  98. // expected-error@-4{{assigning '__local int *' to '__global int *' changes address space of pointer}}
  99. // expected-warning@-5{{passing non-generic address space pointer to to_local may cause dynamic conversion affecting performance}}
  100. #endif
  101. global char *glob_c = to_global(loc);
  102. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  103. // expected-warning@-2{{incompatible integer to pointer conversion initializing '__global char *' with an expression of type 'int'}}
  104. #else
  105. // expected-warning@-4{{incompatible pointer types initializing '__global char *' with an expression of type '__global int *'}}
  106. // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
  107. #endif
  108. glob_wrong_ty = to_global(glob);
  109. #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
  110. // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global float *' from 'int'}}
  111. #else
  112. // expected-warning@-4{{incompatible pointer types assigning to '__global float *' from '__global int *'}}
  113. // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
  114. #endif
  115. }