1 // RUN: %clang_cc1 -verify -fsyntax-only %s
2 // RUN: %clang_cc1 -Wconversion -verify -fsyntax-only -cl-std=CL2.0 %s
9 global float *glob_wrong_ty;
10 typedef constant int const_int_ty;
11 const_int_ty *con_typedef;
13 glob = to_global(glob, loc);
14 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
15 // expected-error@-2{{implicit declaration of function 'to_global' is invalid in OpenCL}}
16 // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
18 // expected-error@-5{{invalid number of arguments to function: 'to_global'}}
23 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
24 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
26 // expected-error@-4{{invalid argument x to function: 'to_global', expecting a generic pointer argument}}
29 glob = to_global(con);
30 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
31 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
33 // expected-error@-4{{invalid argument con to function: 'to_global', expecting a generic pointer argument}}
36 glob = to_global(con_typedef);
37 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
38 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
40 // expected-error@-4{{invalid argument con_typedef to function: 'to_global', expecting a generic pointer argument}}
43 loc = to_global(glob);
44 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
45 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}}
47 // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}}
48 // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
51 loc = to_private(glob);
52 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
53 // expected-error@-2{{implicit declaration of function 'to_private' is invalid in OpenCL}}
54 // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}}
56 // expected-error@-5{{assigning 'int *' to '__local int *' changes address space of pointer}}
57 // expected-warning@-6{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}}
61 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
62 // expected-error@-2{{implicit declaration of function 'to_local' is invalid in OpenCL}}
63 // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}}
64 // expected-note@-4{{did you mean 'to_global'}}
65 // expected-note@13{{'to_global' declared here}}
67 // expected-warning@-7{{passing non-generic address space pointer to to_local may cause dynamic conversion affecting performance}}
70 priv = to_global(glob);
71 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
72 // expected-warning@-2{{incompatible integer to pointer conversion assigning to 'int *' from 'int'}}
74 // expected-error@-4{{assigning '__global int *' to 'int *' changes address space of pointer}}
75 // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
78 priv = to_private(glob);
79 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
80 // expected-warning@-2{{incompatible integer to pointer conversion assigning to 'int *' from 'int'}}
82 // expected-warning@-4{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}}
86 priv = to_local(glob);
87 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
88 // expected-warning@-2{{incompatible integer to pointer conversion assigning to 'int *' from 'int'}}
90 // expected-error@-4{{assigning '__local int *' to 'int *' changes address space of pointer}}
91 // expected-warning@-5{{passing non-generic address space pointer to to_local may cause dynamic conversion affecting performance}}
94 glob = to_global(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'}}
98 // expected-warning@-4{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
101 glob = to_private(glob);
102 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
103 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
105 // expected-error@-4{{assigning 'int *' to '__global int *' changes address space of pointer}}
106 // expected-warning@-5{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}}
109 glob = to_local(glob);
110 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
111 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
113 // expected-error@-4{{assigning '__local int *' to '__global int *' changes address space of pointer}}
114 // expected-warning@-5{{passing non-generic address space pointer to to_local may cause dynamic conversion affecting performance}}
117 global char *glob_c = to_global(loc);
118 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
119 // expected-warning@-2{{incompatible integer to pointer conversion initializing '__global char *' with an expression of type 'int'}}
121 // expected-warning@-4{{incompatible pointer types initializing '__global char *' with an expression of type '__global int *'}}
122 // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
125 glob_wrong_ty = to_global(glob);
126 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
127 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global float *' from 'int'}}
129 // expected-warning@-4{{incompatible pointer types assigning to '__global float *' from '__global int *'}}
130 // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}