Skip to content

Commit b1ce9b1

Browse files
Fix unnamed-kenel.cpp
1 parent 2c63209 commit b1ce9b1

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2523,7 +2523,8 @@ class SYCLTypeVisitor : public TypeVisitor<SYCLTypeVisitor>,
25232523
void VisitTagDecl(const TagDecl *Tag) {
25242524
bool UnnamedLambdaEnabled =
25252525
S.getASTContext().getLangOpts().SYCLUnnamedLambda;
2526-
if (Tag && !UnnamedLambdaEnabled) {
2526+
if (Tag && !Tag->getDeclContext()->isTranslationUnit() &&
2527+
!UnnamedLambdaEnabled) {
25272528
const bool KernelNameIsMissing = Tag->getName().empty();
25282529
if (KernelNameIsMissing) {
25292530
S.Diag(Loc, diag::err_sycl_kernel_incorrectly_named)

clang/test/SemaSYCL/unnamed-kernel.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace namespace1 {
1010
template <typename T>
1111
class KernelName;
1212
}
13-
// expected-note@14 {{MyWrapper declared here}}
13+
1414
struct MyWrapper {
1515
private:
1616
class InvalidKernelName0 {};
@@ -23,65 +23,65 @@ struct MyWrapper {
2323
cl::sycl::queue q;
2424
#ifndef __SYCL_UNNAMED_LAMBDA__
2525
// expected-error@Inputs/sycl.hpp:220 {{kernel needs to have a globally-visible name}}
26-
// expected-note@+2 {{InvalidKernelName1 declared here}}
26+
// expected-note@+3 {{InvalidKernelName1 declared here}}
27+
// expected-note@+4{{in instantiation of function template specialization}}
2728
#endif
2829
class InvalidKernelName1 {};
2930
q.submit([&](cl::sycl::handler &h) {
30-
// expected-note@+1{{in instantiation of function template specialization}}
3131
h.single_task<InvalidKernelName1>([] {});
3232
});
3333

3434
#ifndef __SYCL_UNNAMED_LAMBDA__
3535
// expected-error@Inputs/sycl.hpp:220 {{kernel needs to have a globally-visible name}}
36-
// expected-note@+2 {{InvalidKernelName2 declared here}}
36+
// expected-note@+3 {{InvalidKernelName2 declared here}}
37+
// expected-note@+4{{in instantiation of function template specialization}}
3738
#endif
3839
class InvalidKernelName2 {};
3940
q.submit([&](cl::sycl::handler &h) {
40-
// expected-note@+1{{in instantiation of function template specialization}}
4141
h.single_task<namespace1::KernelName<InvalidKernelName2>>([] {});
4242
});
4343

4444
#ifndef __SYCL_UNNAMED_LAMBDA__
4545
// expected-error@Inputs/sycl.hpp:220 {{kernel needs to have a globally-visible name}}
4646
// expected-note@16 {{InvalidKernelName0 declared here}}
47+
// expected-note@+3{{in instantiation of function template specialization}}
4748
#endif
4849
q.submit([&](cl::sycl::handler &h) {
49-
// expected-note@+1{{in instantiation of function template specialization}}
5050
h.single_task<InvalidKernelName0>([] {});
5151
});
5252

5353
#ifndef __SYCL_UNNAMED_LAMBDA__
5454
// expected-error@Inputs/sycl.hpp:220 {{kernel needs to have a globally-visible name}}
5555
// expected-note@17 {{InvalidKernelName3 declared here}}
56+
// expected-note@+3{{in instantiation of function template specialization}}
5657
#endif
5758
q.submit([&](cl::sycl::handler &h) {
58-
// expected-note@+1{{in instantiation of function template specialization}}
5959
h.single_task<namespace1::KernelName<InvalidKernelName3>>([] {});
6060
});
6161

62-
/* using ValidAlias = MyWrapper;
62+
using ValidAlias = MyWrapper;
6363
q.submit([&](cl::sycl::handler &h) {
6464

6565
h.single_task<ValidAlias>([] {});
66-
}); */
66+
});
6767

6868
using InvalidAlias = InvalidKernelName4;
6969
#ifndef __SYCL_UNNAMED_LAMBDA__
7070
// expected-error@Inputs/sycl.hpp:220 {{kernel needs to have a globally-visible name}}
7171
// expected-note@18 {{InvalidKernelName4 declared here}}
72+
// expected-note@+3{{in instantiation of function template specialization}}
7273
#endif
7374
q.submit([&](cl::sycl::handler &h) {
74-
// expected-note@+1{{in instantiation of function template specialization}}
7575
h.single_task<InvalidAlias>([] {});
7676
});
7777

7878
using InvalidAlias1 = InvalidKernelName5;
7979
#ifndef __SYCL_UNNAMED_LAMBDA__
8080
// expected-error@Inputs/sycl.hpp:220 {{kernel needs to have a globally-visible name}}
8181
// expected-note@19 {{InvalidKernelName5 declared here}}
82+
// expected-note@+3{{in instantiation of function template specialization}}
8283
#endif
8384
q.submit([&](cl::sycl::handler &h) {
84-
// expected-note@+1{{in instantiation of function template specialization}}
8585
h.single_task<namespace1::KernelName<InvalidAlias1>>([] {});
8686
});
8787
}
@@ -91,8 +91,8 @@ int main() {
9191
cl::sycl::queue q;
9292
#ifndef __SYCL_UNNAMED_LAMBDA__
9393
// expected-error@Inputs/sycl.hpp:220 {{kernel name is missing}}
94+
// expected-note@+2{{in instantiation of function template specialization}}
9495
#endif
95-
// expected-note@+1{{in instantiation of function template specialization}}
9696
q.submit([&](cl::sycl::handler &h) { h.single_task([] {}); });
9797

9898
return 0;

0 commit comments

Comments
 (0)