131 lines · plain
1// RUN: %clang_cc1 -verify -fsyntax-only %s2// RUN: %clang_cc1 -Wconversion -verify -fsyntax-only -cl-std=CL2.0 %s3// RUN: %clang_cc1 -Wconversion -verify -fsyntax-only -cl-std=CL3.0 -cl-ext=-all %s4// RUN: %clang_cc1 -Wconversion -verify -fsyntax-only -cl-std=CL3.0 %s5 6void test(void) {7 global int *glob;8 local int *loc;9 constant int *con;10 private int *priv;11 global float *glob_wrong_ty;12 typedef constant int const_int_ty;13 const_int_ty *con_typedef;14 15 glob = to_global(glob, loc);16#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))17 // expected-error@-2{{use of undeclared identifier 'to_global'}}18#else19 // expected-error@-4{{too many arguments to function call, expected 1, have 2}}20#endif21 22 int x;23 glob = to_global(x);24#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))25 // expected-error@-2{{use of undeclared identifier 'to_global'}}26#else27 // expected-error@-4{{invalid argument 'x' to function: 'to_global', expecting a generic pointer argument}}28#endif29 30 glob = to_global(con);31#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))32 // expected-error@-2{{use of undeclared identifier 'to_global'}}33#else34 // expected-error@-4{{invalid argument 'con' to function: 'to_global', expecting a generic pointer argument}}35#endif36 37 glob = to_global(con_typedef);38#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))39 // expected-error@-2{{use of undeclared identifier 'to_global'}}40#else41 // expected-error@-4{{invalid argument 'con_typedef' to function: 'to_global', expecting a generic pointer argument}}42#endif43 44 loc = to_global(glob);45#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))46 // expected-error@-2{{use of undeclared identifier 'to_global'}}47#else48 // expected-error@-4{{assigning '__global int *' to '__local int *__private' changes address space of pointer}}49 // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}50#endif51 52 loc = to_private(glob);53#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))54 // expected-error@-2{{use of undeclared identifier 'to_private'}}55#else56 // expected-error@-4{{assigning '__private int *' to '__local int *__private' changes address space of pointer}}57 // expected-warning@-5{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}}58#endif59 60 loc = to_local(glob);61#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))62 // expected-error@-2{{use of undeclared identifier 'to_local'}}63#else64 // expected-warning@-4{{passing non-generic address space pointer to to_local may cause dynamic conversion affecting performance}}65#endif66 67 priv = to_global(glob);68#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))69 // expected-error@-2{{use of undeclared identifier 'to_global'}}70#else71 // expected-error@-4{{assigning '__global int *' to '__private int *__private' changes address space of pointer}}72 // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}73#endif74 75 priv = to_private(glob);76#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))77 // expected-error@-2{{use of undeclared identifier 'to_private'}}78#else79 // expected-warning@-4{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}}80#endif81 82 83 priv = to_local(glob);84#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))85 // expected-error@-2{{use of undeclared identifier 'to_local'}}86#else87 // expected-error@-4{{assigning '__local int *' to '__private int *__private' changes address space of pointer}}88 // expected-warning@-5{{passing non-generic address space pointer to to_local may cause dynamic conversion affecting performance}}89#endif90 91 glob = to_global(glob);92#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))93 // expected-error@-2{{use of undeclared identifier 'to_global'}}94#else95 // expected-warning@-4{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}96#endif97 98 glob = to_private(glob);99#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))100 // expected-error@-2{{use of undeclared identifier 'to_private'}}101#else102 // expected-error@-4{{assigning '__private int *' to '__global int *__private' changes address space of pointer}}103 // expected-warning@-5{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}}104#endif105 106 glob = to_local(glob);107#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))108 // expected-error@-2{{use of undeclared identifier 'to_local'}}109#else110 // expected-error@-4{{assigning '__local int *' to '__global int *__private' changes address space of pointer}}111 // expected-warning@-5{{passing non-generic address space pointer to to_local may cause dynamic conversion affecting performance}}112#endif113 114 global char *glob_c = to_global(loc);115#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))116 // expected-error@-2{{use of undeclared identifier 'to_global'}}117#else118 // expected-error@-4{{incompatible pointer types initializing '__global char *__private' with an expression of type '__global int *'}}119 // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}120#endif121 122 glob_wrong_ty = to_global(glob);123#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))124 // expected-error@-2{{use of undeclared identifier 'to_global'}}125#else126 // expected-error@-4{{incompatible pointer types assigning to '__global float *__private' from '__global int *'}}127 // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}128#endif129 130}131