Skip to content

Commit e77b134

Browse files
Fix failing tests
1 parent b2bf167 commit e77b134

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,9 +2412,15 @@ static bool isESIMDKernelType(const CXXRecordDecl *KernelObjType) {
24122412
return (OpParens != nullptr) && OpParens->hasAttr<SYCLSimdAttr>();
24132413
}
24142414

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);
24182424
}
24192425

24202426
class SyclKernelBodyCreator : public SyclKernelFieldHandler {
@@ -3462,8 +3468,8 @@ void Sema::CheckSYCLKernelCall(FunctionDecl *KernelFunc, SourceRange CallLoc,
34623468
const CXXRecordDecl *KernelObj =
34633469
GetSYCLKernelObjectType(KernelFunc)->getAsCXXRecordDecl();
34643470

3465-
bool IsKernelAValidFunctor = isSYCLKernelDefinedAsAFunctor(KernelObj);
3466-
if (!KernelObj || !IsKernelAValidFunctor) {
3471+
bool IsKernelTypeValid = IsCallOperatorDefined(KernelObj);
3472+
if (!KernelObj || !IsKernelTypeValid) {
34673473
Diag(Args[0]->getExprLoc(), diag::err_sycl_kernel_not_function_object);
34683474
KernelFunc->setInvalidDecl();
34693475
return;

0 commit comments

Comments
 (0)