@@ -2412,9 +2412,15 @@ static bool isESIMDKernelType(const CXXRecordDecl *KernelObjType) {
2412
2412
return (OpParens != nullptr ) && OpParens->hasAttr <SYCLSimdAttr>();
2413
2413
}
2414
2414
2415
- static bool isSYCLKernelDefinedAsAFunctor (const CXXRecordDecl *KernelObjType) {
2416
- const CXXMethodDecl *OpParens = getOperatorParens (KernelObjType);
2417
- return (OpParens != nullptr );
2415
+ // Fetch the associated call operator of the kernel object
2416
+ // (of either the lambda or the function object).
2417
+ static bool IsCallOperatorDefined (const CXXRecordDecl *KernelObjType) {
2418
+ const CXXMethodDecl *CallOperator = nullptr ;
2419
+ if (KernelObjType->isLambda ())
2420
+ CallOperator = KernelObjType->getLambdaCallOperator ();
2421
+ else
2422
+ CallOperator = getOperatorParens (KernelObjType);
2423
+ return (CallOperator != nullptr );
2418
2424
}
2419
2425
2420
2426
class SyclKernelBodyCreator : public SyclKernelFieldHandler {
@@ -3462,8 +3468,8 @@ void Sema::CheckSYCLKernelCall(FunctionDecl *KernelFunc, SourceRange CallLoc,
3462
3468
const CXXRecordDecl *KernelObj =
3463
3469
GetSYCLKernelObjectType (KernelFunc)->getAsCXXRecordDecl ();
3464
3470
3465
- bool IsKernelAValidFunctor = isSYCLKernelDefinedAsAFunctor (KernelObj);
3466
- if (!KernelObj || !IsKernelAValidFunctor ) {
3471
+ bool IsKernelTypeValid = IsCallOperatorDefined (KernelObj);
3472
+ if (!KernelObj || !IsKernelTypeValid ) {
3467
3473
Diag (Args[0 ]->getExprLoc (), diag::err_sycl_kernel_not_function_object);
3468
3474
KernelFunc->setInvalidDecl ();
3469
3475
return ;
0 commit comments