Skip to content

Commit 4b61b5d

Browse files
Fix failing tests and clang-format
1 parent 4eca6f1 commit 4b61b5d

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,12 +2475,14 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
24752475

24762476
} // namespace
24772477

2478-
class SYCLKernelNameTypeVisitor : public TypeVisitor<SYCLKernelNameTypeVisitor>,
2479-
public ConstTemplateArgumentVisitor<SYCLKernelNameTypeVisitor> {
2478+
class SYCLKernelNameTypeVisitor
2479+
: public TypeVisitor<SYCLKernelNameTypeVisitor>,
2480+
public ConstTemplateArgumentVisitor<SYCLKernelNameTypeVisitor> {
24802481
Sema &S;
24812482
SourceLocation Loc;
24822483
using InnerTypeVisitor = TypeVisitor<SYCLKernelNameTypeVisitor>;
2483-
using InnerTAVisitor = ConstTemplateArgumentVisitor<SYCLKernelNameTypeVisitor>;
2484+
using InnerTAVisitor =
2485+
ConstTemplateArgumentVisitor<SYCLKernelNameTypeVisitor>;
24842486

24852487
public:
24862488
SYCLKernelNameTypeVisitor(Sema &S, SourceLocation Loc) : S(S), Loc(Loc) {}
@@ -2524,6 +2526,7 @@ class SYCLKernelNameTypeVisitor : public TypeVisitor<SYCLKernelNameTypeVisitor>,
25242526
bool UnnamedLambdaEnabled =
25252527
S.getASTContext().getLangOpts().SYCLUnnamedLambda;
25262528
if (Tag && !Tag->getDeclContext()->isTranslationUnit() &&
2529+
!dyn_cast_or_null<NamespaceDecl>(Tag->getDeclContext()) &&
25272530
!UnnamedLambdaEnabled) {
25282531
const bool KernelNameIsMissing = Tag->getName().empty();
25292532
if (KernelNameIsMissing) {
@@ -2553,7 +2556,7 @@ class SYCLKernelNameTypeVisitor : public TypeVisitor<SYCLKernelNameTypeVisitor>,
25532556
}
25542557
return;
25552558
}
2556-
2559+
25572560
void VisitIntegralTemplateArgument(const TemplateArgument &TA) {
25582561
QualType T = TA.getIntegralType();
25592562
if (const EnumType *ET = T->getAs<EnumType>()) {

clang/test/SemaSYCL/args-size-overflow.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ void use() {
3434
int Array[1991];
3535
} Args;
3636
auto L = [=]() { (void)Args; };
37-
#if defined(GPU) || defined(ERROR)
38-
// expected-note@+2 {{in instantiation of function template specialization 'parallel_for<Foo}}
37+
#ifdef GPU
38+
// expected-note@+8 {{in instantiation of function template specialization 'parallel_for<Foo}}
39+
#elif ERROR
40+
// expected-note@+6 {{Foo declared here}}
41+
// expected-error@22 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}}
42+
// expected-note@+4 {{in instantiation of function template specialization 'parallel_for<Foo}}
43+
#else
44+
// expected-no-diagnostics
3945
#endif
4046
parallel_for<class Foo>(L);
4147
}

clang/test/SemaSYCL/unnamed-kernel.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ struct MyWrapper {
6666

6767
using ValidAlias = MyWrapper;
6868
q.submit([&](cl::sycl::handler &h) {
69-
7069
h.single_task<ValidAlias>([] {});
7170
});
7271

@@ -102,8 +101,8 @@ struct MyWrapper {
102101
int main() {
103102
cl::sycl::queue q;
104103
#ifndef __SYCL_UNNAMED_LAMBDA__
105-
// expected-error@Inputs/sycl.hpp:220 {{kernel name is missing}}
106-
// expected-note@+2{{in instantiation of function template specialization}}
104+
// expected-error@Inputs/sycl.hpp:220 {{kernel name is missing}}
105+
// expected-note@+2{{in instantiation of function template specialization}}
107106
#endif
108107
q.submit([&](cl::sycl::handler &h) { h.single_task([] {}); });
109108

0 commit comments

Comments
 (0)