Skip to content

Commit 3eecf94

Browse files
Address review comments
1 parent aa0a48b commit 3eecf94

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,8 @@ static CXXMethodDecl *getOperatorParens(const CXXRecordDecl *Rec) {
986986

987987
// Fetch the associated call operator of the kernel object
988988
// (of either the lambda or the function object).
989-
CXXMethodDecl *IsCallOperatorDefined(const CXXRecordDecl *KernelObjType) {
989+
CXXMethodDecl *
990+
GetCallOperatorOfKernelObject(const CXXRecordDecl *KernelObjType) {
990991
CXXMethodDecl *CallOperator = nullptr;
991992
if (!KernelObjType)
992993
return CallOperator;
@@ -2509,7 +2510,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
25092510
// (of either the lambda or the function object).
25102511
CXXRecordDecl *KernelObj =
25112512
GetSYCLKernelObjectType(KernelCallerFunc)->getAsCXXRecordDecl();
2512-
CXXMethodDecl *WGLambdaFn = IsCallOperatorDefined(KernelObj);
2513+
CXXMethodDecl *WGLambdaFn = GetCallOperatorOfKernelObject(KernelObj);
25132514

25142515
assert(WGLambdaFn && "non callable object is passed as kernel obj");
25152516
// Mark the function that it "works" in a work group scope:
@@ -3467,8 +3468,7 @@ void Sema::CheckSYCLKernelCall(FunctionDecl *KernelFunc, SourceRange CallLoc,
34673468
CXXRecordDecl *KernelObj =
34683469
GetSYCLKernelObjectType(KernelFunc)->getAsCXXRecordDecl();
34693470

3470-
CXXMethodDecl *CallOperator = IsCallOperatorDefined(KernelObj);
3471-
if (!CallOperator) {
3471+
if (!GetCallOperatorOfKernelObject(KernelObj)) {
34723472
Diag(Args[0]->getExprLoc(), diag::err_sycl_kernel_not_function_object);
34733473
KernelFunc->setInvalidDecl();
34743474
return;

clang/test/SemaSYCL/undefined-functor.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,23 @@ queue q;
88

99
struct FunctorWithoutCallOperator; // expected-note {{forward declaration of 'FunctorWithoutCallOperator'}}
1010

11+
struct StructDefined {
12+
int x;
13+
};
14+
1115
int main() {
12-
// expected-error@#KernelSingleTask {{kernel parameter must be a lambda or function object}}
16+
1317
q.submit([&](sycl::handler &cgh) {
18+
// expected-error@#KernelSingleTask {{kernel parameter must be a lambda or function object}}
1419
// expected-error@+2 {{invalid use of incomplete type 'FunctorWithoutCallOperator'}}
1520
// expected-note@+1 {{in instantiation of function template specialization}}
1621
cgh.single_task(FunctorWithoutCallOperator{});
1722
});
1823

24+
q.submit([&](sycl::handler &cgh) {
25+
// expected-error@#KernelSingleTask {{kernel parameter must be a lambda or function object}}
26+
// expected-note@+1 {{in instantiation of function template specialization}}
27+
cgh.single_task(StructDefined{});
28+
});
29+
1930
}

0 commit comments

Comments
 (0)