[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaSYCL / prohibit-thread-local.cpp
blobe507489695f8acba79508977277b9e9e2c3d9451
1 // RUN: %clang_cc1 -fsycl-is-device -triple spir64 -verify -fsyntax-only %s
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;
7 struct S {
8 static const thread_local int prohibit_static_member;
9 static thread_local int prohibit_static_member2;
12 struct T {
13 static const thread_local int allow_static_member;
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;
23 void bar() { thread_local int allow_local; }
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@+1 {{thread-local storage is not supported for the current target}}
31 (void)prohobit_ns_scope2;
32 // expected-error@+1 {{thread-local storage is not supported for the current target}}
33 (void)S::prohibit_static_member;
34 // expected-error@+1 {{thread-local storage is not supported for the current target}}
35 (void)S::prohibit_static_member2;
38 template <typename name, typename Func>
39 __attribute__((sycl_kernel))
40 // expected-note@+2 2{{called by}}
41 void
42 kernel_single_task(Func kernelFunc) { kernelFunc(); }
44 int main() {
45 // expected-note@+1 2{{called by}}
46 kernel_single_task<class fake_kernel>([]() { usage(); });
47 return 0;