]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/SemaOpenCL/to_addr_builtin.cl
Vendor import of clang trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / test / SemaOpenCL / to_addr_builtin.cl
1 // RUN: %clang_cc1 -verify -fsyntax-only %s
2 // RUN: %clang_cc1 -Wconversion -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   private int *priv;
9   global float *glob_wrong_ty;
10   typedef constant int const_int_ty;
11   const_int_ty *con_typedef;
12
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'}}
17 #else
18   // expected-error@-5{{invalid number of arguments to function: 'to_global'}}
19 #endif
20
21   int x;
22   glob = to_global(x);
23 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
24   // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
25 #else
26   // expected-error@-4{{invalid argument x to function: 'to_global', expecting a generic pointer argument}}
27 #endif
28
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'}}
32 #else
33   // expected-error@-4{{invalid argument con to function: 'to_global', expecting a generic pointer argument}}
34 #endif
35
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'}}
39 #else
40   // expected-error@-4{{invalid argument con_typedef to function: 'to_global', expecting a generic pointer argument}}
41 #endif
42
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'}}
46 #else
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}}
49 #endif
50
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'}}
55 #else
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}}
58 #endif
59
60   loc = to_local(glob);
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}}
66 #else
67   // expected-warning@-7{{passing non-generic address space pointer to to_local may cause dynamic conversion affecting performance}}
68 #endif
69
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'}}
73 #else
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}}
76 #endif
77
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'}}
81 #else
82   // expected-warning@-4{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}}
83 #endif
84
85
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'}}
89 #else
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}}
92 #endif
93
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'}}
97 #else
98   // expected-warning@-4{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
99 #endif
100
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'}}
104 #else
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}}
107 #endif
108
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'}}
112 #else
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}}
115 #endif
116
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'}}
120 #else
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}}
123 #endif
124
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'}}
128 #else
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}}
131 #endif
132
133 }