xref: /llvm-project/clang/test/SemaSYCL/prohibit-thread-local.cpp (revision c165a99a1b8861af87e0509a2e14debf2764804b)
1 // RUN: %clang_cc1 -fsycl-is-device -triple spir64 -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 
foo()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 
bar()23 void bar() { thread_local int allow_local; }
24 
usage()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;
36 }
37 
38 template <typename name, typename Func>
39 __attribute__((sycl_kernel))
40 // expected-note@+2 2{{called by}}
41 void
kernel_single_task(Func kernelFunc)42 kernel_single_task(Func kernelFunc) { kernelFunc(); }
43 
main()44 int main() {
45   // expected-note@+1 2{{called by}}
46   kernel_single_task<class fake_kernel>([]() { usage(); });
47   return 0;
48 }
49