1 // RUN: %clang_cc1 -verify -fsyntax-only %s 2 // RUN: %clang_cc1 -verify -fsyntax-only -cl-std=CL2.0 %s 3 4 void test(void) { 5 global int *glob; 6 local int *loc; 7 constant int *con; 8 typedef constant int const_int_ty; 9 const_int_ty *con_typedef; 10 11 glob = to_global(glob, loc); 12 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 13 // expected-warning@-2{{implicit declaration of function 'to_global' is invalid in C99}} 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 19 int x; 20 glob = to_global(x); 21 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 22 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}} 23 #else 24 // expected-error@-4{{invalid argument x to function: 'to_global', expecting a generic pointer argument}} 25 #endif 26 27 glob = to_global(con); 28 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 29 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}} 30 #else 31 // expected-error@-4{{invalid argument con to function: 'to_global', expecting a generic pointer argument}} 32 #endif 33 34 glob = to_global(con_typedef); 35 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 36 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}} 37 #else 38 // expected-error@-4{{invalid argument con_typedef to function: 'to_global', expecting a generic pointer argument}} 39 #endif 40 41 loc = to_global(glob); 42 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 43 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}} 44 #else 45 // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}} 46 #endif 47 48 global char *glob_c = to_global(loc); 49 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 50 // expected-warning@-2{{incompatible integer to pointer conversion initializing '__global char *' with an expression of type 'int'}} 51 #else 52 // expected-warning@-4{{incompatible pointer types initializing '__global char *' with an expression of type '__global int *'}} 53 #endif 54 55 } 56