blob: a145626cfcee425099c307e6bef5216bd56963f0 [file] [log] [blame]
Yaxun Liuf7449a12016-05-20 19:54:38 +00001// RUN: %clang_cc1 -verify -fsyntax-only %s
2// RUN: %clang_cc1 -verify -fsyntax-only -cl-std=CL2.0 %s
3
4void 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
Anastasia Stulova7f8d6dc2016-07-04 16:07:18 +000013 // 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'}}
Yaxun Liuf7449a12016-05-20 19:54:38 +000015#else
Anastasia Stulova7f8d6dc2016-07-04 16:07:18 +000016 // expected-error@-5{{invalid number of arguments to function: 'to_global'}}
Yaxun Liuf7449a12016-05-20 19:54:38 +000017#endif
18
19 int x;
20 glob = to_global(x);
21#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
Anastasia Stulova7f8d6dc2016-07-04 16:07:18 +000022 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
Yaxun Liuf7449a12016-05-20 19:54:38 +000023#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
Anastasia Stulova7f8d6dc2016-07-04 16:07:18 +000029 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
Yaxun Liuf7449a12016-05-20 19:54:38 +000030#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
Anastasia Stulova7f8d6dc2016-07-04 16:07:18 +000036 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
Yaxun Liuf7449a12016-05-20 19:54:38 +000037#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
Anastasia Stulova7f8d6dc2016-07-04 16:07:18 +000043 // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}}
Yaxun Liuf7449a12016-05-20 19:54:38 +000044#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
Anastasia Stulova7f8d6dc2016-07-04 16:07:18 +000050 // expected-warning@-2{{incompatible integer to pointer conversion initializing '__global char *' with an expression of type 'int'}}
Yaxun Liuf7449a12016-05-20 19:54:38 +000051#else
52 // expected-warning@-4{{incompatible pointer types initializing '__global char *' with an expression of type '__global int *'}}
53#endif
54
55}