================
@@ -0,0 +1,122 @@
+// 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) {}
+
+// Check that reference captures of kernel that defined as lambda are 
diagnosed.
+namespace badref1 {
+void test() {
+  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;
+      });
+}
+} // namespace badref1
+
+// Check reference kernel parameters witin structs or lambdas;
+namespace badref2 {
+struct S { // expected-note 2{{within field of type 'S' declared here}}
+  int a;
+  int &b; //expected-error 2{{'int &' cannot be used as the type of a kernel 
parameter}}
+};
+
+void test() {
+  int p = 0;
+  auto L = [&]() { (void)p;}; // expected-error {{'int &' cannot be used as 
the type of a kernel parameter}}
+                               // expected-note@-1 {{within field of type}}
+  S Str {p, p};
+  kernel_single_task<class KN<2>>( // expected-note {{requested here}}
+      [=] { // expected-note 2{{within field of type}}
+        (void)L;
+        (void)Str; // no error because fail for L already
----------------
tahonermann wrote:

I think this comment is outdated. If I'm reading correctly, a diagnostic will 
be issued for both `L` and `Str`.

```suggestion
        (void)Str;
```

https://github.com/llvm/llvm-project/pull/192957
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to