|
@@ -7526,7 +7526,7 @@ enum OpenCLParamType {
|
|
RecordKernelParam
|
|
RecordKernelParam
|
|
};
|
|
};
|
|
|
|
|
|
-static OpenCLParamType getOpenCLKernelParameterType(QualType PT) {
|
|
|
|
|
|
+static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
|
|
if (PT->isPointerType()) {
|
|
if (PT->isPointerType()) {
|
|
QualType PointeeType = PT->getPointeeType();
|
|
QualType PointeeType = PT->getPointeeType();
|
|
if (PointeeType->isPointerType())
|
|
if (PointeeType->isPointerType())
|
|
@@ -7547,7 +7547,10 @@ static OpenCLParamType getOpenCLKernelParameterType(QualType PT) {
|
|
if (PT->isEventT())
|
|
if (PT->isEventT())
|
|
return InvalidKernelParam;
|
|
return InvalidKernelParam;
|
|
|
|
|
|
- if (PT->isHalfType())
|
|
|
|
|
|
+ // OpenCL extension spec v1.2 s9.5:
|
|
|
|
+ // This extension adds support for half scalar and vector types as built-in
|
|
|
|
+ // types that can be used for arithmetic operations, conversions etc.
|
|
|
|
+ if (!S.getOpenCLOptions().cl_khr_fp16 && PT->isHalfType())
|
|
return InvalidKernelParam;
|
|
return InvalidKernelParam;
|
|
|
|
|
|
if (PT->isRecordType())
|
|
if (PT->isRecordType())
|
|
@@ -7568,7 +7571,7 @@ static void checkIsValidOpenCLKernelParameter(
|
|
if (ValidTypes.count(PT.getTypePtr()))
|
|
if (ValidTypes.count(PT.getTypePtr()))
|
|
return;
|
|
return;
|
|
|
|
|
|
- switch (getOpenCLKernelParameterType(PT)) {
|
|
|
|
|
|
+ switch (getOpenCLKernelParameterType(S, PT)) {
|
|
case PtrPtrKernelParam:
|
|
case PtrPtrKernelParam:
|
|
// OpenCL v1.2 s6.9.a:
|
|
// OpenCL v1.2 s6.9.a:
|
|
// A kernel function argument cannot be declared as a
|
|
// A kernel function argument cannot be declared as a
|
|
@@ -7595,7 +7598,10 @@ static void checkIsValidOpenCLKernelParameter(
|
|
// OpenCL v1.2 s6.8 n:
|
|
// OpenCL v1.2 s6.8 n:
|
|
// A kernel function argument cannot be declared
|
|
// A kernel function argument cannot be declared
|
|
// of event_t type.
|
|
// of event_t type.
|
|
- S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
|
|
|
|
|
|
+ // Do not diagnose half type since it is diagnosed as invalid argument
|
|
|
|
+ // type for any function elsewhere.
|
|
|
|
+ if (!PT->isHalfType())
|
|
|
|
+ S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
|
|
D.setInvalidType();
|
|
D.setInvalidType();
|
|
return;
|
|
return;
|
|
|
|
|
|
@@ -7651,7 +7657,7 @@ static void checkIsValidOpenCLKernelParameter(
|
|
if (ValidTypes.count(QT.getTypePtr()))
|
|
if (ValidTypes.count(QT.getTypePtr()))
|
|
continue;
|
|
continue;
|
|
|
|
|
|
- OpenCLParamType ParamType = getOpenCLKernelParameterType(QT);
|
|
|
|
|
|
+ OpenCLParamType ParamType = getOpenCLKernelParameterType(S, QT);
|
|
if (ParamType == ValidKernelParam)
|
|
if (ParamType == ValidKernelParam)
|
|
continue;
|
|
continue;
|
|
|
|
|