Skip to content

Commit 915ac0e

Browse files
committed
[SYCL] Add test for SYCL kernels with accessor and spec constant
Clang used to crash in case SYCL kernel captures a specialization constant before an accessor. The tests checks that the crash is fixed. Signed-off-by: Alexey Sotkin <[email protected]>
1 parent 0052d08 commit 915ac0e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

clang/test/SemaSYCL/Inputs/sycl.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ class handler {
194194
}
195195
};
196196

197+
namespace experimental {
198+
199+
template <typename T, typename ID = T>
200+
class spec_constant {};
201+
} // namespace experimental
202+
197203
} // namespace sycl
198204
} // namespace cl
199205

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %clang_cc1 -fsycl -fsycl-is-device -fsyntax-only -I %S/Inputs -ast-dump %s | FileCheck %s
2+
// The test checks that Clang doesn't crash if a specialization constant gets
3+
// into the kernel capture list before an accessor
4+
5+
#include <sycl.hpp>
6+
7+
template <typename name, typename Func>
8+
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
9+
kernelFunc();
10+
}
11+
12+
int main() {
13+
cl::sycl::experimental::spec_constant<char, class MyInt32Const> spec_const;
14+
cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write> accessor;
15+
// CHECK: FieldDecl {{.*}} implicit referenced 'cl::sycl::experimental::spec_constant<char, class MyInt32Const>'
16+
// CHECK: FieldDecl {{.*}} implicit referenced 'cl::sycl::accessor<int, 1, cl::sycl::access::mode::read_write>'
17+
kernel<class MyKernel>([spec_const, accessor]() {});
18+
return 0;
19+
}

0 commit comments

Comments
 (0)