-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Fix crash caused by functor without call operator as Kernel (#…
…7104) When a named function object without a call operator defined is used as a kernel, the compiler causes a `crash`. With the changes in this PR, a compiler `error` is thrown when a lambda or function object without a call operator defined is used as a kernel. Co-authored-by: premanandrao <premanand.m.rao@intel.com>
- Loading branch information
1 parent
c49eeda
commit 490ee55
Showing
2 changed files
with
67 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -sycl-std=2020 -verify -fsyntax-only %s | ||
// This test checks that an error is thrown when a functor without a call operator defined is used as a kernel. | ||
|
||
#include "sycl.hpp" | ||
|
||
using namespace sycl; | ||
queue q; | ||
|
||
struct FunctorWithoutCallOperator; // expected-note {{forward declaration of 'FunctorWithoutCallOperator'}} | ||
|
||
struct StructDefined { | ||
int x; | ||
}; | ||
|
||
class FunctorWithCallOpDefined { | ||
int x; | ||
public: | ||
void operator()() const {} | ||
}; | ||
|
||
int main() { | ||
|
||
q.submit([&](sycl::handler &cgh) { | ||
// expected-error@#KernelSingleTask {{kernel parameter must be a lambda or function object}} | ||
// expected-error@+2 {{invalid use of incomplete type 'FunctorWithoutCallOperator'}} | ||
// expected-note@+1 {{in instantiation of function template specialization}} | ||
cgh.single_task(FunctorWithoutCallOperator{}); | ||
}); | ||
|
||
q.submit([&](sycl::handler &cgh) { | ||
// expected-error@#KernelSingleTask {{kernel parameter must be a lambda or function object}} | ||
// expected-note@+1 {{in instantiation of function template specialization}} | ||
cgh.single_task(StructDefined{}); | ||
}); | ||
|
||
q.submit([&](sycl::handler &cgh) { | ||
cgh.single_task(FunctorWithCallOpDefined{}); | ||
}); | ||
|
||
} |