Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,8 @@ class SingleDeviceFunctionTracker {
// false-positives.
if (isSYCLKernelBodyFunction(CurrentDecl)) {
Comment thread
elizabethandrews marked this conversation as resolved.
// This is a direct callee of the kernel.
if (CallStack.size() == 1) {
if (CallStack.size() == 1 &&
CallStack.back()->hasAttr<SYCLKernelAttr>()) {
assert(!KernelBody && "inconsistent call graph - only one kernel body "
"function can be called");
KernelBody = CurrentDecl;
Expand Down
21 changes: 21 additions & 0 deletions clang/test/SemaSYCL/non-kernel-functor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -verify %s
Comment thread
elizabethandrews marked this conversation as resolved.
Outdated

// Test to verify that non-kernel functors are not processed as SYCL kernel
// functors

// expected-no-diagnostics
Comment thread
Fznamznon marked this conversation as resolved.
class First {
public:
void operator()() { return; }
};

class Second {
public:
First operator()() { return First(); }
};

SYCL_EXTERNAL
void foo() {
Second NonKernelFunctorObj;
NonKernelFunctorObj()();
}