Yaxun Liu | f7449a1 | 2016-05-20 19:54:38 +0000 | [diff] [blame] | 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-error@-2{{'to_global' requires OpenCL version 2.0 or above}} |
| 14 | #else |
| 15 | // expected-error@-4{{invalid number of arguments to function: 'to_global'}} |
| 16 | #endif |
| 17 | |
| 18 | int x; |
| 19 | glob = to_global(x); |
| 20 | #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 |
| 21 | // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}} |
| 22 | #else |
| 23 | // expected-error@-4{{invalid argument x to function: 'to_global', expecting a generic pointer argument}} |
| 24 | #endif |
| 25 | |
| 26 | glob = to_global(con); |
| 27 | #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 |
| 28 | // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}} |
| 29 | #else |
| 30 | // expected-error@-4{{invalid argument con to function: 'to_global', expecting a generic pointer argument}} |
| 31 | #endif |
| 32 | |
| 33 | glob = to_global(con_typedef); |
| 34 | #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 |
| 35 | // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}} |
| 36 | #else |
| 37 | // expected-error@-4{{invalid argument con_typedef to function: 'to_global', expecting a generic pointer argument}} |
| 38 | #endif |
| 39 | |
| 40 | loc = to_global(glob); |
| 41 | #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 |
| 42 | // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}} |
| 43 | #else |
| 44 | // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}} |
| 45 | #endif |
| 46 | |
| 47 | global char *glob_c = to_global(loc); |
| 48 | #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 |
| 49 | // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}} |
| 50 | #else |
| 51 | // expected-warning@-4{{incompatible pointer types initializing '__global char *' with an expression of type '__global int *'}} |
| 52 | #endif |
| 53 | |
| 54 | } |