================
@@ -0,0 +1,93 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++17 -fsyntax-only
-Wno-vla-cxx-extension -fsycl-is-host -verify %s
+// RUN: %clang_cc1 -triple spirv64 -std=c++17 -fsyntax-only
-Wno-vla-cxx-extension -fsycl-is-device -verify %s
+
+// A unique kernel name type is required for each declared kernel entry point.
+template<int, int = 0> struct KN;
+
+// A generic kernel launch function.
+template<typename KNT, typename... Ts>
+void sycl_kernel_launch(const char *, Ts...) {}
+
+// Kernel entry point template definition.
+template<typename KNT, typename T>
+[[clang::sycl_kernel_entry_point(KNT)]]
+void kernel_single_task(T) {}
+
+struct S { // expected-note 3{{within field of type 'S' declared here}}
+ int a;
+ int &b; //expected-error 3{{'int &' cannot be used as the type of a kernel
parameter}}
+};
+
+void fooarr(int (&arr)[5]) {
+}
+
+template <typename T> class Callable { // expected-note 2{{within field of
type 'Callable<int &>' declared here}}
+ T data; // expected-error 2{{'int &' cannot be used as the type of a kernel
parameter}}
+public:
+ Callable(T d) : data(d) {}
+ void operator()() {
+ }
+};
+
+class Derived1 : Callable<int> { // expected-note {{within field of type
'Derived1' declared here}}
+ int &a; // expected-error {{'int &' cannot be used as the type of a kernel
parameter}}
+public:
+ Derived1(int d, int &b) : Callable<int>(d), a(b) {}
+};
+
+class Derived2 : Callable<int&> { // expected-note {{within base of type
'Callable<int &>' declared here}}
+ int a;
+public:
+ Derived2(int d, int &b) : Callable<int&>(b), a(d) {}
+};
+
+void refCases(int AS) {
+ int p = 0;
+ double q = 0;
+ float s = 0;
+ kernel_single_task<class KN<1>>( // expected-note {{requested here}}
+ [ // expected-note2{{within field of type}}
+ // expected-error@+1 {{'int &' cannot be used as the type of a
kernel parameter}}
+ &p, q,
+ // expected-error@+1 {{'float &' cannot be used as the type of a
kernel parameter}}
+ &s] {
+ (void)q;
+ (void)p;
+ (void)s;
+ });
----------------
Fznamznon wrote:
> from the user perspective, it might not be well understood how captures end
> up becoming kernel arguments.
But, that is literally in the spec
(https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:kernel.parameter.passing)
:
> If the kernel is a lambda expression, any variables captured by the lambda
> become parameters to the kernel.
> How would you feel about limiting tests to references within types that are
> captured by value (which includes cases like L below that exercise capturing
> a non-kernel lambda by value)?
I'm not sure what is the point of testing less. I think leaving them as is and
seeing the test failures when we switch to another message will just help to
confirm that the implementation is correct.
https://github.com/llvm/llvm-project/pull/192957
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits