|
| 1 | +// RUN: %clang_cc1 -I %S/Inputs -fsycl -fsycl-is-device -fsycl-int-header=%t.h -fsyntax-only -verify %s -Werror=sycl-strict -DERROR |
| 2 | +// RUN: %clang_cc1 -I %S/Inputs -fsycl -fsycl-is-device -fsycl-int-header=%t.h -fsyntax-only -verify %s -Wsycl-strict -DWARN |
| 3 | +// RUN: %clang_cc1 -I %S/Inputs -fsycl -fsycl-is-device -fsycl-int-header=%t.h -fsycl-unnamed-lambda -fsyntax-only -verify %s -Werror=sycl-strict |
| 4 | +#include <sycl.hpp> |
| 5 | + |
| 6 | +#ifdef __SYCL_UNNAMED_LAMBDA__ |
| 7 | +// expected-no-diagnostics |
| 8 | +#endif |
| 9 | + |
| 10 | +using namespace cl::sycl; |
| 11 | + |
| 12 | +void function() { |
| 13 | +} |
| 14 | + |
| 15 | +// user-defined class |
| 16 | +struct myWrapper { |
| 17 | +}; |
| 18 | + |
| 19 | +// user-declared class |
| 20 | +class myWrapper2; |
| 21 | + |
| 22 | +int main() { |
| 23 | + cl::sycl::queue q; |
| 24 | +#ifndef __SYCL_UNNAMED_LAMBDA__ |
| 25 | + // expected-note@+1 {{InvalidKernelName1 declared here}} |
| 26 | + class InvalidKernelName1 {}; |
| 27 | + q.submit([&](cl::sycl::handler &h) { |
| 28 | + // expected-error@+1 {{kernel needs to have a globally-visible name}} |
| 29 | + h.single_task<InvalidKernelName1>([]() {}); |
| 30 | + }); |
| 31 | +#endif |
| 32 | +#if defined(WARN) |
| 33 | + // expected-warning@+6 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}} |
| 34 | + // expected-note@+5 {{fake_kernel declared here}} |
| 35 | +#elif defined(ERROR) |
| 36 | + // expected-error@+3 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}} |
| 37 | + // expected-note@+2 {{fake_kernel declared here}} |
| 38 | +#endif |
| 39 | + cl::sycl::kernel_single_task<class fake_kernel>([]() { function(); }); |
| 40 | +#if defined(WARN) |
| 41 | + // expected-warning@+6 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}} |
| 42 | + // expected-note@+5 {{fake_kernel2 declared here}} |
| 43 | +#elif defined(ERROR) |
| 44 | + // expected-error@+3 {{SYCL 1.2.1 specification requires an explicit forward declaration for a kernel type name; your program may not be portable}} |
| 45 | + // expected-note@+2 {{fake_kernel2 declared here}} |
| 46 | +#endif |
| 47 | + cl::sycl::kernel_single_task<class fake_kernel2>([]() { |
| 48 | + auto l = [](auto f) { f(); }; |
| 49 | + }); |
| 50 | + cl::sycl::kernel_single_task<class myWrapper>([]() { function(); }); |
| 51 | + cl::sycl::kernel_single_task<class myWrapper2>([]() { function(); }); |
| 52 | + return 0; |
| 53 | +} |
0 commit comments