1*67e74705SXin Li// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value -triple spir-unknown-unknown 2*67e74705SXin Li 3*67e74705SXin Li#pragma OPENCL EXTENSION cl_khr_fp16 : disable 4*67e74705SXin Liconstant float f = 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}} 5*67e74705SXin Li 6*67e74705SXin Lihalf half_disabled(half *p, // expected-error{{declaring function return value of type 'half' is not allowed}} 7*67e74705SXin Li half h) // expected-error{{declaring function parameter of type 'half' is not allowed}} 8*67e74705SXin Li{ 9*67e74705SXin Li half a[2]; // expected-error{{declaring variable of type 'half [2]' is not allowed}} 10*67e74705SXin Li half b; // expected-error{{declaring variable of type 'half' is not allowed}} 11*67e74705SXin Li *p; // expected-error{{loading directly from pointer to type 'half' is not allowed}} 12*67e74705SXin Li p[1]; // expected-error{{loading directly from pointer to type 'half' is not allowed}} 13*67e74705SXin Li 14*67e74705SXin Li float c = 1.0f; 15*67e74705SXin Li b = (half) c; // expected-error{{casting to type 'half' is not allowed}} 16*67e74705SXin Li c = (float) 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}} 17*67e74705SXin Li b = 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}} 18*67e74705SXin Li 19*67e74705SXin Li half *allowed = &p[1]; 20*67e74705SXin Li half *allowed2 = &*p; 21*67e74705SXin Li half *allowed3 = p + 1; 22*67e74705SXin Li 23*67e74705SXin Li return h; 24*67e74705SXin Li} 25*67e74705SXin Li 26*67e74705SXin Li// Exactly the same as above but with the cl_khr_fp16 extension enabled. 27*67e74705SXin Li#pragma OPENCL EXTENSION cl_khr_fp16 : enable 28*67e74705SXin Liconstant half a = 1.0h; 29*67e74705SXin Lihalf half_enabled(half *p, half h) 30*67e74705SXin Li{ 31*67e74705SXin Li half a[2]; 32*67e74705SXin Li half b; 33*67e74705SXin Li *p; 34*67e74705SXin Li p[1]; 35*67e74705SXin Li 36*67e74705SXin Li float c = 1.0f; 37*67e74705SXin Li b = (half) c; 38*67e74705SXin Li c = (float) 1.0h; 39*67e74705SXin Li b = 1.0h; 40*67e74705SXin Li 41*67e74705SXin Li half *allowed = &p[1]; 42*67e74705SXin Li half *allowed2 = &*p; 43*67e74705SXin Li half *allowed3 = p + 1; 44*67e74705SXin Li 45*67e74705SXin Li return h; 46*67e74705SXin Li} 47