|
| 1 | +// RUN: %clang_cc1 -fsycl-is-device -verify -fsyntax-only %s |
| 2 | + |
| 3 | +thread_local const int prohobit_ns_scope = 0; |
| 4 | +thread_local int prohobit_ns_scope2 = 0; |
| 5 | +thread_local const int allow_ns_scope = 0; |
| 6 | + |
| 7 | +struct S { |
| 8 | + static const thread_local int prohibit_static_member; |
| 9 | + static thread_local int prohibit_static_member2; |
| 10 | +}; |
| 11 | + |
| 12 | +struct T { |
| 13 | + static const thread_local int allow_static_member; |
| 14 | +}; |
| 15 | + |
| 16 | +void foo() { |
| 17 | + // expected-error@+1{{thread-local storage is not supported for the current target}} |
| 18 | + thread_local const int prohibit_local = 0; |
| 19 | + // expected-error@+1{{thread-local storage is not supported for the current target}} |
| 20 | + thread_local int prohibit_local2; |
| 21 | +} |
| 22 | + |
| 23 | +void bar() { thread_local int allow_local; } |
| 24 | + |
| 25 | +void usage() { |
| 26 | + // expected-note@+1 {{called by}} |
| 27 | + foo(); |
| 28 | + // expected-error@+1 {{thread-local storage is not supported for the current target}} |
| 29 | + (void)prohobit_ns_scope; |
| 30 | + // expected-error@+2 {{SYCL kernel cannot use a non-const global variable}} |
| 31 | + // expected-error@+1 {{thread-local storage is not supported for the current target}} |
| 32 | + (void)prohobit_ns_scope2; |
| 33 | + // expected-error@+1 {{thread-local storage is not supported for the current target}} |
| 34 | + (void)S::prohibit_static_member; |
| 35 | + // expected-error@+2 {{SYCL kernel cannot use a non-const static data variable}} |
| 36 | + // expected-error@+1 {{thread-local storage is not supported for the current target}} |
| 37 | + (void)S::prohibit_static_member2; |
| 38 | +} |
| 39 | + |
| 40 | +template <typename name, typename Func> |
| 41 | +__attribute__((sycl_kernel)) |
| 42 | +// expected-note@+2 2{{called by}} |
| 43 | +void |
| 44 | +kernel_single_task(Func kernelFunc) { kernelFunc(); } |
| 45 | + |
| 46 | +int main() { |
| 47 | + // expected-note@+1 2{{called by}} |
| 48 | + kernel_single_task<class fake_kernel>([]() { usage(); }); |
| 49 | + return 0; |
| 50 | +} |
0 commit comments