John McCall | 9dd74c5 | 2013-02-12 01:29:43 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value |
Joey Gouly | 19dbb20 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 2 | |
| 3 | #pragma OPENCL EXTENSION cl_khr_fp16 : disable |
| 4 | |
| 5 | half half_disabled(half *p, // expected-error{{declaring function return value of type 'half' is not allowed}} |
| 6 | half h) // expected-error{{declaring function argument of type 'half' is not allowed}} |
| 7 | { |
| 8 | half a[2]; // expected-error{{declaring variable of type 'half [2]' is not allowed}} |
| 9 | half b; // expected-error{{declaring variable of type 'half' is not allowed}} |
John McCall | 9dd74c5 | 2013-02-12 01:29:43 +0000 | [diff] [blame^] | 10 | *p; // expected-error{{loading directly from pointer to type 'half' is not allowed}} |
| 11 | p[1]; // expected-error{{loading directly from pointer to type 'half' is not allowed}} |
Joey Gouly | 19dbb20 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 12 | |
| 13 | float c = 1.0f; |
| 14 | b = (half) c; // expected-error{{casting to type 'half' is not allowed}} |
John McCall | 9dd74c5 | 2013-02-12 01:29:43 +0000 | [diff] [blame^] | 15 | |
| 16 | half *allowed = &p[1]; |
| 17 | half *allowed2 = &*p; |
| 18 | half *allowed3 = p + 1; |
Joey Gouly | 19dbb20 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 19 | |
| 20 | return h; |
| 21 | } |
| 22 | |
| 23 | // Exactly the same as above but with the cl_khr_fp16 extension enabled. |
| 24 | #pragma OPENCL EXTENSION cl_khr_fp16 : enable |
| 25 | half half_enabled(half *p, half h) |
| 26 | { |
| 27 | half a[2]; |
| 28 | half b; |
John McCall | 9dd74c5 | 2013-02-12 01:29:43 +0000 | [diff] [blame^] | 29 | *p; |
| 30 | p[1]; |
Joey Gouly | 19dbb20 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 31 | |
| 32 | float c = 1.0f; |
| 33 | b = (half) c; |
John McCall | 9dd74c5 | 2013-02-12 01:29:43 +0000 | [diff] [blame^] | 34 | |
| 35 | half *allowed = &p[1]; |
| 36 | half *allowed2 = &*p; |
| 37 | half *allowed3 = p + 1; |
Joey Gouly | 19dbb20 | 2013-01-23 11:56:20 +0000 | [diff] [blame] | 38 | |
| 39 | return h; |
| 40 | } |