Skip to content

Commit 501b219

Browse files
committed
address review comments
1 parent d463d3e commit 501b219

File tree

6 files changed

+24
-46
lines changed

6 files changed

+24
-46
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11430,11 +11430,11 @@ def err_nullptr_t_type_in_sycl_kernel : Error<"%0 is an invalid kernel name, "
1143011430
def err_invalid_std_type_in_sycl_kernel : Error<"%0 is an invalid kernel name, "
1143111431
"%q1 is declared in the 'std' namespace ">;
1143211432

11433-
def err_sycl_kernel_incorrectly_named : Error<"%0 is an invalid kernel name type">;
11434-
def note_invalid_type_in_sycl_kernel : Note<
11433+
def err_sycl_kernel_incorrectly_named : Error<
1143511434
"%select{%1 should be globally-visible"
1143611435
"|unscoped enum %1 requires fixed underlying type"
11437-
"|unnamed lambda is used in a SYCL kernel name"
11436+
"|unnamed type %1 is not valid in a SYCL kernel name, provide a kernel name "
11437+
"or enable unnamed kernel lambdas via -fsycl-unnamed-lambda"
1143811438
"}0">;
1143911439

1144011440
def err_sycl_kernel_not_function_object

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3657,10 +3657,8 @@ class SYCLKernelNameTypeVisitor
36573657
if (const auto *ED = dyn_cast<EnumDecl>(DeclNamed)) {
36583658
if (!ED->isScoped() && !ED->isFixed()) {
36593659
S.Diag(KernelInvocationFuncLoc, diag::err_sycl_kernel_incorrectly_named)
3660-
<< KernelNameType;
3661-
S.Diag(KernelInvocationFuncLoc, diag::note_invalid_type_in_sycl_kernel)
36623660
<< /* Unscoped enum requires fixed underlying type */ 1
3663-
<< QualType(ED->getTypeForDecl(), 0);
3661+
<< DeclNamed;
36643662
IsInvalid = true;
36653663
}
36663664
}
@@ -3692,25 +3690,19 @@ class SYCLKernelNameTypeVisitor
36923690
if (UnnamedLambdaUsed) {
36933691
S.Diag(KernelInvocationFuncLoc,
36943692
diag::err_sycl_kernel_incorrectly_named)
3695-
<< KernelNameType;
3696-
S.Diag(KernelInvocationFuncLoc,
3697-
diag::note_invalid_type_in_sycl_kernel)
3698-
<< /* unnamed lambda is used in a SYCL kernel name */ 2;
3693+
<< /* unnamed type is not valid in a SYCL kernel name */ 2
3694+
<< KernelNameType;
36993695
IsInvalid = true;
37003696
return;
37013697
}
3698+
37023699
// Check if the declaration is completely defined within a
37033700
// function or class/struct.
3704-
37053701
if (Tag->isCompleteDefinition()) {
37063702
S.Diag(KernelInvocationFuncLoc,
37073703
diag::err_sycl_kernel_incorrectly_named)
3708-
<< KernelNameType;
3709-
S.Diag(KernelInvocationFuncLoc,
3710-
diag::note_invalid_type_in_sycl_kernel)
37113704
<< /* kernel name should be globally visible */ 0
3712-
<< QualType(Tag->getTypeForDecl(), 0);
3713-
3705+
<< KernelNameType;
37143706
IsInvalid = true;
37153707
} else {
37163708
S.Diag(KernelInvocationFuncLoc, diag::warn_sycl_implicit_decl);

clang/test/SemaSYCL/implicit_kernel_type.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ int main() {
2323
queue q;
2424

2525
#if defined(WARN)
26-
// expected-error@#KernelSingleTask {{'InvalidKernelName1' is an invalid kernel name type}}
27-
// expected-note@#KernelSingleTask {{'InvalidKernelName1' should be globally-visible}}
28-
// expected-note@+8 {{in instantiation of function template specialization}}
26+
// expected-error@#KernelSingleTask {{'InvalidKernelName1' should be globally-visible}}
27+
// expected-note@+7 {{in instantiation of function template specialization}}
2928
#elif defined(ERROR)
30-
// expected-error@#KernelSingleTask {{'InvalidKernelName1' is an invalid kernel name type}}
31-
// expected-note@#KernelSingleTask {{'InvalidKernelName1' should be globally-visible}}
29+
// expected-error@#KernelSingleTask {{'InvalidKernelName1' should be globally-visible}}
3230
// expected-note@+4 {{in instantiation of function template specialization}}
3331
#endif
3432
class InvalidKernelName1 {};

clang/test/SemaSYCL/kernelname-enum.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,13 @@ int main() {
6969
});
7070

7171
q.submit([&](cl::sycl::handler &cgh) {
72-
// expected-error@#KernelSingleTask {{'dummy_functor_2<val_3>' is an invalid kernel name type}}
73-
// expected-note@#KernelSingleTask {{unscoped enum 'unscoped_enum_no_type_set' requires fixed underlying type}}
72+
// expected-error@#KernelSingleTask {{unscoped enum 'unscoped_enum_no_type_set' requires fixed underlying type}}
7473
// expected-note@+1{{in instantiation of function template specialization}}
7574
cgh.single_task(f2);
7675
});
7776

7877
q.submit([&](cl::sycl::handler &cgh) {
79-
// expected-error@#KernelSingleTask {{'templated_functor<dummy_functor_2>' is an invalid kernel name type}}
80-
// expected-note@#KernelSingleTask {{unscoped enum 'unscoped_enum_no_type_set' requires fixed underlying type}}
78+
// expected-error@#KernelSingleTask {{unscoped enum 'unscoped_enum_no_type_set' requires fixed underlying type}}
8179
// expected-note@+1{{in instantiation of function template specialization}}
8280
cgh.single_task(f5);
8381
});

clang/test/SemaSYCL/nested-anon-and-std-ns.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ struct MyWrapper {
3737
h.single_task<ValidNS::StructinValidNS>([] {});
3838
});
3939

40-
// expected-error@#KernelSingleTask {{'ParentStruct::ChildStruct' is an invalid kernel name type}}
41-
// expected-note@#KernelSingleTask {{'ParentStruct::ChildStruct' should be globally-visible}}
40+
// expected-error@#KernelSingleTask {{'ParentStruct::ChildStruct' should be globally-visible}}
4241
// expected-note@+2{{in instantiation of function template specialization}}
4342
q.submit([&](cl::sycl::handler &h) {
4443
h.single_task<ParentStruct::ChildStruct>([] {});

clang/test/SemaSYCL/unnamed-kernel.cpp

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,27 @@ struct MyWrapper {
3232
public:
3333
void test() {
3434
cl::sycl::queue q;
35-
// expected-error@#KernelSingleTask {{'InvalidKernelName1' is an invalid kernel name type}}
36-
// expected-note@#KernelSingleTask {{'InvalidKernelName1' should be globally-visible}}
35+
// expected-error@#KernelSingleTask {{'InvalidKernelName1' should be globally-visible}}
3736
// expected-note@+3{{in instantiation of function template specialization}}
3837
class InvalidKernelName1 {};
3938
q.submit([&](cl::sycl::handler &h) {
4039
h.single_task<InvalidKernelName1>([] {});
4140
});
4241

43-
// expected-error@#KernelSingleTask {{'namespace1::KernelName<InvalidKernelName2>' is an invalid kernel name type}}
44-
// expected-note@#KernelSingleTask {{'InvalidKernelName2' should be globally-visible}}
42+
// expected-error@#KernelSingleTask {{'namespace1::KernelName<InvalidKernelName2>' should be globally-visible}}
4543
// expected-note@+3{{in instantiation of function template specialization}}
4644
class InvalidKernelName2 {};
4745
q.submit([&](cl::sycl::handler &h) {
4846
h.single_task<namespace1::KernelName<InvalidKernelName2>>([] {});
4947
});
5048

51-
// expected-error@#KernelSingleTask {{'MyWrapper::InvalidKernelName0' is an invalid kernel name type}}
52-
// expected-note@#KernelSingleTask {{'MyWrapper::InvalidKernelName0' should be globally-visible}}
49+
// expected-error@#KernelSingleTask {{'MyWrapper::InvalidKernelName0' should be globally-visible}}
5350
// expected-note@+2{{in instantiation of function template specialization}}
5451
q.submit([&](cl::sycl::handler &h) {
5552
h.single_task<InvalidKernelName0>([] {});
5653
});
5754

58-
// expected-error@#KernelSingleTask {{'namespace1::KernelName<MyWrapper::InvalidKernelName3>' is an invalid kernel name type}}
59-
// expected-note@#KernelSingleTask {{'MyWrapper::InvalidKernelName3' should be globally-visible}}
55+
// expected-error@#KernelSingleTask {{'namespace1::KernelName<MyWrapper::InvalidKernelName3>' should be globally-visible}}
6056
// expected-note@+2{{in instantiation of function template specialization}}
6157
q.submit([&](cl::sycl::handler &h) {
6258
h.single_task<namespace1::KernelName<InvalidKernelName3>>([] {});
@@ -67,29 +63,26 @@ struct MyWrapper {
6763
h.single_task<ValidAlias>([] {});
6864
});
6965

70-
// expected-error@#KernelSingleTask {{'std::max_align_t' is an invalid kernel name, 'std::(anonymous)' is declared in the 'std' namespace}}
66+
// expected-error@#KernelSingleTask {{'MyWrapper::InvalidKernelName4' should be globally-visible}}
7167
// expected-note@+2{{in instantiation of function template specialization}}
7268
q.submit([&](cl::sycl::handler &h) {
7369
h.single_task<std::max_align_t>([] {});
7470
});
7571

7672
using InvalidAlias = InvalidKernelName4;
77-
// expected-error@#KernelSingleTask {{'MyWrapper::InvalidKernelName4' is an invalid kernel name type}}
78-
// expected-note@#KernelSingleTask {{'MyWrapper::InvalidKernelName4' should be globally-visible}}
73+
// expected-error@#KernelSingleTask {{'std::max_align_t' is an invalid kernel name, 'std::(anonymous)' is declared in the 'std' namespace}}
7974
// expected-note@+2{{in instantiation of function template specialization}}
8075
q.submit([&](cl::sycl::handler &h) {
8176
h.single_task<InvalidAlias>([] {});
8277
});
8378

8479
using InvalidAlias1 = InvalidKernelName5;
85-
// expected-error@#KernelSingleTask {{'namespace1::KernelName<MyWrapper::InvalidKernelName5>' is an invalid kernel name type}}
86-
// expected-note@#KernelSingleTask {{'MyWrapper::InvalidKernelName5' should be globally-visible}}
80+
// expected-error@#KernelSingleTask {{'namespace1::KernelName<MyWrapper::InvalidKernelName5>' should be globally-visible}}
8781
// expected-note@+2{{in instantiation of function template specialization}}
8882
q.submit([&](cl::sycl::handler &h) {
8983
h.single_task<namespace1::KernelName<InvalidAlias1>>([] {});
9084
});
91-
// expected-error@#KernelSingleTask {{'Templated_kernel_name2<Templated_kernel_name<InvalidKernelName1>>' is an invalid kernel name type}}
92-
// expected-note@#KernelSingleTask {{'InvalidKernelName1' should be globally-visible}}
85+
// expected-error@#KernelSingleTask {{'Templated_kernel_name2<Templated_kernel_name<InvalidKernelName1>>' should be globally-visible}}
9386
// expected-note@+2{{in instantiation of function template specialization}}
9487
q.submit([&](cl::sycl::handler &h) {
9588
h.single_task<Templated_kernel_name2<Templated_kernel_name<InvalidKernelName1>>>([] {});
@@ -144,8 +137,7 @@ struct MyWrapper {
144137

145138
// This errors because const decltype(SomeLambda) != decltype(SomeLambda),
146139
// so this is not the unnamed lambda situation.
147-
// expected-error-re@#KernelSingleTask {{'const (lambda at {{.*}}unnamed-kernel.cpp{{.*}}' is an invalid kernel name type}}
148-
// expected-note@#KernelSingleTask {{unnamed lambda is used in a SYCL kernel name}}
140+
// expected-error@#KernelSingleTask {{unnamed type 'const}}
149141
// expected-note@+3{{in instantiation of function template specialization}}
150142
q.submit([&](cl::sycl::handler &h) {
151143
auto SomeLambda = []() {};
@@ -158,8 +150,7 @@ struct MyWrapper {
158150
int main() {
159151
cl::sycl::queue q;
160152
#ifndef __SYCL_UNNAMED_LAMBDA__
161-
// expected-error-re@#KernelSingleTask {{'(lambda at {{.*}}unnamed-kernel.cpp{{.*}}' is an invalid kernel name type}}
162-
// expected-note@#KernelSingleTask {{unnamed lambda is used in a SYCL kernel name}}
153+
// expected-error-re@#KernelSingleTask {{unnamed type '(lambda at {{.*}}unnamed-kernel.cpp{{.*}}' is not valid in a SYCL kernel name, provide a kernel name or enable unnamed kernel lambdas via -fsycl-unnamed-lambda}}
163154
// expected-note@+2{{in instantiation of function template specialization}}
164155
#endif
165156
q.submit([&](cl::sycl::handler &h) { h.single_task([] {}); });

0 commit comments

Comments
 (0)