blob: 830d178d7c6f3fe072aa110740876f03fe1e33a6 [file] [log] [blame]
Joey Gouly19dbb202013-01-23 11:56:20 +00001// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
2
3#pragma OPENCL EXTENSION cl_khr_fp16 : disable
4
5half 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}}
10
11 b = *p; // expected-error{{dereferencing pointer of type 'half *' is not allowed}}
12 *p = b; // expected-error{{dereferencing pointer of type 'half *' is not allowed}}
13
14 b = p[1]; // expected-error {{subscript to array of type 'half' is not allowed}}
15 p[1] = b; // expected-error {{subscript to array of type 'half' is not allowed}}
16
17 float c = 1.0f;
18 b = (half) c; // expected-error{{casting to type 'half' is not allowed}}
19 c = (float) h; // expected-error{{casting from type 'half' is not allowed}}
20
21 return h;
22}
23
24// Exactly the same as above but with the cl_khr_fp16 extension enabled.
25#pragma OPENCL EXTENSION cl_khr_fp16 : enable
26half half_enabled(half *p, half h)
27{
28 half a[2];
29 half b;
30
31 b = *p;
32 *p = b;
33
34 b = p[1];
35 p[1] = b;
36
37 float c = 1.0f;
38 b = (half) c;
39 c = (float) h;
40
41 return h;
42}