Yaxun Liu | f7449a1 | 2016-05-20 19:54:38 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fsyntax-only %s |
Sven van Haastregt | 1076cc2 | 2018-09-20 10:07:27 +0000 | [diff] [blame^] | 2 | // RUN: %clang_cc1 -Wconversion -verify -fsyntax-only -cl-std=CL2.0 %s |
Yaxun Liu | f7449a1 | 2016-05-20 19:54:38 +0000 | [diff] [blame] | 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 |
Richard Smith | 289728d | 2017-10-04 01:58:22 +0000 | [diff] [blame] | 13 | // expected-warning@-2{{implicit declaration of function 'to_global' is invalid in OpenCL}} |
Anastasia Stulova | 7f8d6dc | 2016-07-04 16:07:18 +0000 | [diff] [blame] | 14 | // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}} |
Yaxun Liu | f7449a1 | 2016-05-20 19:54:38 +0000 | [diff] [blame] | 15 | #else |
Anastasia Stulova | 7f8d6dc | 2016-07-04 16:07:18 +0000 | [diff] [blame] | 16 | // expected-error@-5{{invalid number of arguments to function: 'to_global'}} |
Yaxun Liu | f7449a1 | 2016-05-20 19:54:38 +0000 | [diff] [blame] | 17 | #endif |
| 18 | |
| 19 | int x; |
| 20 | glob = to_global(x); |
| 21 | #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 |
Anastasia Stulova | 7f8d6dc | 2016-07-04 16:07:18 +0000 | [diff] [blame] | 22 | // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}} |
Yaxun Liu | f7449a1 | 2016-05-20 19:54:38 +0000 | [diff] [blame] | 23 | #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 Stulova | 7f8d6dc | 2016-07-04 16:07:18 +0000 | [diff] [blame] | 29 | // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}} |
Yaxun Liu | f7449a1 | 2016-05-20 19:54:38 +0000 | [diff] [blame] | 30 | #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 Stulova | 7f8d6dc | 2016-07-04 16:07:18 +0000 | [diff] [blame] | 36 | // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}} |
Yaxun Liu | f7449a1 | 2016-05-20 19:54:38 +0000 | [diff] [blame] | 37 | #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 Stulova | 7f8d6dc | 2016-07-04 16:07:18 +0000 | [diff] [blame] | 43 | // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}} |
Yaxun Liu | f7449a1 | 2016-05-20 19:54:38 +0000 | [diff] [blame] | 44 | #else |
| 45 | // expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}} |
Sven van Haastregt | 1076cc2 | 2018-09-20 10:07:27 +0000 | [diff] [blame^] | 46 | // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}} |
Yaxun Liu | f7449a1 | 2016-05-20 19:54:38 +0000 | [diff] [blame] | 47 | #endif |
| 48 | |
| 49 | global char *glob_c = to_global(loc); |
| 50 | #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 |
Anastasia Stulova | 7f8d6dc | 2016-07-04 16:07:18 +0000 | [diff] [blame] | 51 | // expected-warning@-2{{incompatible integer to pointer conversion initializing '__global char *' with an expression of type 'int'}} |
Yaxun Liu | f7449a1 | 2016-05-20 19:54:38 +0000 | [diff] [blame] | 52 | #else |
| 53 | // expected-warning@-4{{incompatible pointer types initializing '__global char *' with an expression of type '__global int *'}} |
Sven van Haastregt | 1076cc2 | 2018-09-20 10:07:27 +0000 | [diff] [blame^] | 54 | // expected-warning@-5{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}} |
Yaxun Liu | f7449a1 | 2016-05-20 19:54:38 +0000 | [diff] [blame] | 55 | #endif |
| 56 | |
| 57 | } |