2016-05-17 01:06:34 +08:00
|
|
|
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value -triple spir-unknown-unknown
|
2013-01-23 19:56:20 +08:00
|
|
|
|
|
|
|
#pragma OPENCL EXTENSION cl_khr_fp16 : disable
|
2016-02-17 19:34:37 +08:00
|
|
|
constant float f = 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}}
|
2013-01-23 19:56:20 +08:00
|
|
|
|
|
|
|
half half_disabled(half *p, // expected-error{{declaring function return value of type 'half' is not allowed}}
|
2014-05-12 00:06:11 +08:00
|
|
|
half h) // expected-error{{declaring function parameter of type 'half' is not allowed}}
|
2013-01-23 19:56:20 +08:00
|
|
|
{
|
|
|
|
half a[2]; // expected-error{{declaring variable of type 'half [2]' is not allowed}}
|
|
|
|
half b; // expected-error{{declaring variable of type 'half' is not allowed}}
|
2016-09-19 22:54:41 +08:00
|
|
|
*p; // expected-error{{loading directly from pointer to type 'half' requires cl_khr_fp16. Use vector data load builtin functions instead}}
|
|
|
|
*p = 0; // expected-error{{assigning directly to pointer to type 'half' requires cl_khr_fp16. Use vector data store builtin functions instead}}
|
|
|
|
p[1]; // expected-error{{loading directly from pointer to type 'half' requires cl_khr_fp16. Use vector data load builtin functions instead}}
|
|
|
|
p[1] = 0; // expected-error{{assigning directly to pointer to type 'half' requires cl_khr_fp16. Use vector data store builtin functions instead}}
|
2013-01-23 19:56:20 +08:00
|
|
|
|
|
|
|
float c = 1.0f;
|
|
|
|
b = (half) c; // expected-error{{casting to type 'half' is not allowed}}
|
2016-02-17 19:34:37 +08:00
|
|
|
c = (float) 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}}
|
|
|
|
b = 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}}
|
2013-02-12 09:29:43 +08:00
|
|
|
|
|
|
|
half *allowed = &p[1];
|
|
|
|
half *allowed2 = &*p;
|
|
|
|
half *allowed3 = p + 1;
|
2013-01-23 19:56:20 +08:00
|
|
|
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
2016-09-20 01:11:22 +08:00
|
|
|
kernel void half_disabled_kernel(global half *p,
|
|
|
|
half h); // expected-error{{declaring function parameter of type 'half' is not allowed; did you forget * ?}}
|
|
|
|
|
2013-01-23 19:56:20 +08:00
|
|
|
// Exactly the same as above but with the cl_khr_fp16 extension enabled.
|
|
|
|
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
|
2016-02-17 19:34:37 +08:00
|
|
|
constant half a = 1.0h;
|
2013-01-23 19:56:20 +08:00
|
|
|
half half_enabled(half *p, half h)
|
|
|
|
{
|
|
|
|
half a[2];
|
|
|
|
half b;
|
2013-02-12 09:29:43 +08:00
|
|
|
*p;
|
2016-09-19 22:54:41 +08:00
|
|
|
*p = 0;
|
2013-02-12 09:29:43 +08:00
|
|
|
p[1];
|
2016-09-19 22:54:41 +08:00
|
|
|
p[1] = 0;
|
2013-01-23 19:56:20 +08:00
|
|
|
|
|
|
|
float c = 1.0f;
|
|
|
|
b = (half) c;
|
2016-02-17 19:34:37 +08:00
|
|
|
c = (float) 1.0h;
|
|
|
|
b = 1.0h;
|
2013-02-12 09:29:43 +08:00
|
|
|
|
|
|
|
half *allowed = &p[1];
|
|
|
|
half *allowed2 = &*p;
|
|
|
|
half *allowed3 = p + 1;
|
2013-01-23 19:56:20 +08:00
|
|
|
|
|
|
|
return h;
|
|
|
|
}
|
2016-09-20 01:11:22 +08:00
|
|
|
|
|
|
|
kernel void half_enabled_kernel(global half *p,
|
|
|
|
half h);
|
|
|
|
|