Skip to content

Commit 91dcdbb

Browse files
Add 'const' qualifier back and add more test cases.
1 parent 3eecf94 commit 91dcdbb

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,7 +2508,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
25082508

25092509
// Fetch the kernel object and the associated call operator
25102510
// (of either the lambda or the function object).
2511-
CXXRecordDecl *KernelObj =
2511+
const CXXRecordDecl *KernelObj =
25122512
GetSYCLKernelObjectType(KernelCallerFunc)->getAsCXXRecordDecl();
25132513
CXXMethodDecl *WGLambdaFn = GetCallOperatorOfKernelObject(KernelObj);
25142514

@@ -3042,7 +3042,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
30423042
static bool IsSYCLUnnamedKernel(Sema &SemaRef, const FunctionDecl *FD) {
30433043
if (!SemaRef.getLangOpts().SYCLUnnamedLambda)
30443044
return false;
3045-
QualType FunctorTy = GetSYCLKernelObjectType(FD);
3045+
const QualType FunctorTy = GetSYCLKernelObjectType(FD);
30463046
QualType TmplArgTy = calculateKernelNameType(SemaRef.Context, FD);
30473047
return SemaRef.Context.hasSameType(FunctorTy, TmplArgTy);
30483048
}
@@ -3465,7 +3465,7 @@ void Sema::CheckSYCLKernelCall(FunctionDecl *KernelFunc, SourceRange CallLoc,
34653465
if (!LangOpts.SYCLIsDevice)
34663466
return;
34673467

3468-
CXXRecordDecl *KernelObj =
3468+
const CXXRecordDecl *KernelObj =
34693469
GetSYCLKernelObjectType(KernelFunc)->getAsCXXRecordDecl();
34703470

34713471
if (!GetCallOperatorOfKernelObject(KernelObj)) {

clang/test/SemaSYCL/undefined-functor.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ struct StructDefined {
1212
int x;
1313
};
1414

15+
class FunctorWithCallOpDeclared {
16+
int x;
17+
public:
18+
void operator()() const {}
19+
};
20+
21+
class FunctorWithCallOpDefined {
22+
int x;
23+
public:
24+
void operator()() const {};
25+
};
26+
1527
int main() {
1628

1729
q.submit([&](sycl::handler &cgh) {
@@ -27,4 +39,12 @@ int main() {
2739
cgh.single_task(StructDefined{});
2840
});
2941

42+
q.submit([&](sycl::handler &cgh) {
43+
cgh.single_task(FunctorWithCallOpDeclared{});
44+
});
45+
46+
q.submit([&](sycl::handler &cgh) {
47+
cgh.single_task(FunctorWithCallOpDefined{});
48+
});
49+
3050
}

0 commit comments

Comments
 (0)