Yaxun Liu | 39cf40f | 2016-05-16 17:06:34 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value -triple spir-unknown-unknown |
Sven van Haastregt | f0c69001 | 2020-11-17 12:07:40 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value -triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header |
Joey Gouly | dd7f456 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 3 | |
Anastasia Stulova | 5c1a2c5 | 2016-02-17 11:34:37 +0000 | [diff] [blame] | 4 | constant float f = 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}} |
Joey Gouly | dd7f456 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 5 | |
| 6 | half half_disabled(half *p, // expected-error{{declaring function return value of type 'half' is not allowed}} |
Anastasia Stulova | 869d17d | 2019-12-27 13:38:48 +0000 | [diff] [blame] | 7 | half h) // expected-error{{declaring function parameter of type '__private half' is not allowed}} |
Joey Gouly | dd7f456 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 8 | { |
Anastasia Stulova | 869d17d | 2019-12-27 13:38:48 +0000 | [diff] [blame] | 9 | half a[2]; // expected-error{{declaring variable of type '__private half [2]' is not allowed}} |
| 10 | half b; // expected-error{{declaring variable of type '__private half' is not allowed}} |
| 11 | *p; // expected-error{{loading directly from pointer to type '__private half' requires cl_khr_fp16. Use vector data load builtin functions instead}} |
Yaxun Liu | 6aaa01b | 2016-09-19 14:54:41 +0000 | [diff] [blame] | 12 | *p = 0; // expected-error{{assigning directly to pointer to type 'half' requires cl_khr_fp16. Use vector data store builtin functions instead}} |
Anastasia Stulova | 869d17d | 2019-12-27 13:38:48 +0000 | [diff] [blame] | 13 | p[1]; // expected-error{{loading directly from pointer to type '__private half' requires cl_khr_fp16. Use vector data load builtin functions instead}} |
Yaxun Liu | 6aaa01b | 2016-09-19 14:54:41 +0000 | [diff] [blame] | 14 | p[1] = 0; // expected-error{{assigning directly to pointer to type 'half' requires cl_khr_fp16. Use vector data store builtin functions instead}} |
Joey Gouly | dd7f456 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 15 | |
| 16 | float c = 1.0f; |
| 17 | b = (half) c; // expected-error{{casting to type 'half' is not allowed}} |
Anastasia Stulova | 5c1a2c5 | 2016-02-17 11:34:37 +0000 | [diff] [blame] | 18 | c = (float) 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}} |
| 19 | b = 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}} |
John McCall | 6ced97a | 2013-02-12 01:29:43 +0000 | [diff] [blame] | 20 | |
| 21 | half *allowed = &p[1]; |
| 22 | half *allowed2 = &*p; |
| 23 | half *allowed3 = p + 1; |
Joey Gouly | dd7f456 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 24 | |
| 25 | return h; |
| 26 | } |
| 27 | |
Yaxun Liu | 042acb2 | 2016-09-19 17:11:22 +0000 | [diff] [blame] | 28 | kernel void half_disabled_kernel(global half *p, |
Anastasia Stulova | 869d17d | 2019-12-27 13:38:48 +0000 | [diff] [blame] | 29 | half h); // expected-error{{declaring function parameter of type '__private half' is not allowed; did you forget * ?}} |
Yaxun Liu | 042acb2 | 2016-09-19 17:11:22 +0000 | [diff] [blame] | 30 | |
Joey Gouly | dd7f456 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 31 | // Exactly the same as above but with the cl_khr_fp16 extension enabled. |
| 32 | #pragma OPENCL EXTENSION cl_khr_fp16 : enable |
Anastasia Stulova | 5c1a2c5 | 2016-02-17 11:34:37 +0000 | [diff] [blame] | 33 | constant half a = 1.0h; |
Joey Gouly | dd7f456 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 34 | half half_enabled(half *p, half h) |
| 35 | { |
| 36 | half a[2]; |
| 37 | half b; |
John McCall | 6ced97a | 2013-02-12 01:29:43 +0000 | [diff] [blame] | 38 | *p; |
Yaxun Liu | 6aaa01b | 2016-09-19 14:54:41 +0000 | [diff] [blame] | 39 | *p = 0; |
John McCall | 6ced97a | 2013-02-12 01:29:43 +0000 | [diff] [blame] | 40 | p[1]; |
Yaxun Liu | 6aaa01b | 2016-09-19 14:54:41 +0000 | [diff] [blame] | 41 | p[1] = 0; |
Joey Gouly | dd7f456 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 42 | |
| 43 | float c = 1.0f; |
| 44 | b = (half) c; |
Anastasia Stulova | 5c1a2c5 | 2016-02-17 11:34:37 +0000 | [diff] [blame] | 45 | c = (float) 1.0h; |
| 46 | b = 1.0h; |
John McCall | 6ced97a | 2013-02-12 01:29:43 +0000 | [diff] [blame] | 47 | |
| 48 | half *allowed = &p[1]; |
| 49 | half *allowed2 = &*p; |
| 50 | half *allowed3 = p + 1; |
Joey Gouly | dd7f456 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 51 | |
| 52 | return h; |
| 53 | } |
Yaxun Liu | 042acb2 | 2016-09-19 17:11:22 +0000 | [diff] [blame] | 54 | |
| 55 | kernel void half_enabled_kernel(global half *p, |
| 56 | half h); |
| 57 | |