1// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value -triple spir-unknown-unknown
2
3#pragma OPENCL EXTENSION cl_khr_fp16 : disable
4constant float f = 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}}
5
6half half_disabled(half *p, // expected-error{{declaring function return value of type 'half' is not allowed}}
7                   half h)  // expected-error{{declaring function parameter of type 'half' is not allowed}}
8{
9  half a[2]; // expected-error{{declaring variable of type 'half [2]' is not allowed}}
10  half b;    // expected-error{{declaring variable of type 'half' is not allowed}}
11  *p; // expected-error{{loading directly from pointer to type 'half' requires cl_khr_fp16. Use vector data load builtin functions instead}}
12  *p = 0; // expected-error{{assigning directly to pointer to type 'half' requires cl_khr_fp16. Use vector data store builtin functions instead}}
13  p[1]; // expected-error{{loading directly from pointer to type 'half' requires cl_khr_fp16. Use vector data load builtin functions instead}}
14  p[1] = 0; // expected-error{{assigning directly to pointer to type 'half' requires cl_khr_fp16. Use vector data store builtin functions instead}}
15
16  float c = 1.0f;
17  b = (half) c;  // expected-error{{casting to type 'half' is not allowed}}
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}}
20
21  half *allowed = &p[1];
22  half *allowed2 = &*p;
23  half *allowed3 = p + 1;
24
25  return h;
26}
27
28kernel void half_disabled_kernel(global half *p,
29                                 half h);  // expected-error{{declaring function parameter of type 'half' is not allowed; did you forget * ?}}
30
31// Exactly the same as above but with the cl_khr_fp16 extension enabled.
32#pragma OPENCL EXTENSION cl_khr_fp16 : enable
33constant half a = 1.0h;
34half half_enabled(half *p, half h)
35{
36  half a[2];
37  half b;
38  *p;
39  *p = 0;
40  p[1];
41  p[1] = 0;
42
43  float c = 1.0f;
44  b = (half) c;
45  c = (float) 1.0h;
46  b = 1.0h;
47
48  half *allowed = &p[1];
49  half *allowed2 = &*p;
50  half *allowed3 = p + 1;
51
52  return h;
53}
54
55kernel void half_enabled_kernel(global half *p,
56                                half h);
57
58