Skip to content

[SYCL] Improve diagnostics for invalid kernel names #4769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all 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/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -11433,7 +11433,8 @@ def err_invalid_std_type_in_sycl_kernel : Error<"%0 is an invalid kernel name, "
def err_sycl_kernel_incorrectly_named : Error<
"%select{%1 should be globally visible"
"|unscoped enum %1 requires fixed underlying type"
"|unnamed lambda %1 used"
"|unnamed type %1 is invalid; provide a kernel name, or use "
"'-fsycl-unnamed-lambda' to enable unnamed kernel lambdas"
"}0">;

def err_sycl_kernel_not_function_object
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3690,8 +3690,7 @@ class SYCLKernelNameTypeVisitor
if (UnnamedLambdaUsed) {
S.Diag(KernelInvocationFuncLoc,
diag::err_sycl_kernel_incorrectly_named)
<< /* unnamed lambda used */ 2 << KernelNameType;

<< /* unnamed type is invalid */ 2 << KernelNameType;
IsInvalid = true;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions clang/test/SemaSYCL/unnamed-kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ struct MyWrapper {

// This errors because const decltype(SomeLambda) != decltype(SomeLambda),
// so this is not the unnamed lambda situation.
// expected-error@#KernelSingleTask {{unnamed lambda 'const}}
// expected-error@#KernelSingleTask {{unnamed type 'const}}
// expected-note@+3{{in instantiation of function template specialization}}
q.submit([&](cl::sycl::handler &h) {
auto SomeLambda = []() {};
Expand All @@ -150,7 +150,7 @@ struct MyWrapper {
int main() {
cl::sycl::queue q;
#ifndef __SYCL_UNNAMED_LAMBDA__
// expected-error-re@#KernelSingleTask {{unnamed lambda '(lambda at {{.*}}unnamed-kernel.cpp{{.*}}' used}}
// expected-error-re@#KernelSingleTask {{unnamed type '(lambda at {{.*}}unnamed-kernel.cpp{{.*}}' is invalid; provide a kernel name, or use '-fsycl-unnamed-lambda' to enable unnamed kernel lambdas}}
// expected-note@+2{{in instantiation of function template specialization}}
#endif
q.submit([&](cl::sycl::handler &h) { h.single_task([] {}); });
Expand Down