xref: /aosp_15_r20/external/clang/test/SemaCXX/cxx11-thread-local.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -std=c++11 -triple=x86_64-linux-gnu -verify %s
2*67e74705SXin Li 
3*67e74705SXin Li struct S {
4*67e74705SXin Li   static thread_local int a;
5*67e74705SXin Li   static int b; // expected-note {{here}}
6*67e74705SXin Li   thread_local int c; // expected-error {{'thread_local' is only allowed on variable declarations}}
7*67e74705SXin Li   static thread_local int d; // expected-note {{here}}
8*67e74705SXin Li };
9*67e74705SXin Li 
10*67e74705SXin Li thread_local int S::a;
11*67e74705SXin Li thread_local int S::b; // expected-error {{thread-local declaration of 'b' follows non-thread-local declaration}}
12*67e74705SXin Li thread_local int S::c; // expected-error {{non-static data member defined out-of-line}}
13*67e74705SXin Li int S::d; // expected-error {{non-thread-local declaration of 'd' follows thread-local declaration}}
14*67e74705SXin Li 
15*67e74705SXin Li thread_local int x[3];
16*67e74705SXin Li thread_local int y[3];
17*67e74705SXin Li thread_local int z[3]; // expected-note {{previous}}
18*67e74705SXin Li 
f()19*67e74705SXin Li void f() {
20*67e74705SXin Li   thread_local int x;
21*67e74705SXin Li   static thread_local int y;
22*67e74705SXin Li   extern thread_local int z; // expected-error {{redeclaration of 'z' with a different type}}
23*67e74705SXin Li }
24