1// RUN: %clang_cc1 -triple i686-pc-win32 -std=c++11 -fms-extensions -verify %s
2
3__thread __declspec(thread) int a; // expected-error {{already has a thread-local storage specifier}}
4__declspec(thread) __thread int b; // expected-error {{already has a thread-local storage specifier}}
5__declspec(thread) int c(); // expected-warning {{only applies to variables}}
6__declspec(thread) int d;
7int foo();
8__declspec(thread) int e = foo(); // expected-error {{must be a constant expression}} expected-note {{thread_local}}
9
10struct HasCtor { HasCtor(); int x; };
11__declspec(thread) HasCtor f; // expected-error {{must be a constant expression}} expected-note {{thread_local}}
12
13struct HasDtor { ~HasDtor(); int x; };
14__declspec(thread) HasDtor g; // expected-error {{non-trivial destruction}} expected-note {{thread_local}}
15
16struct HasDefaultedDefaultCtor {
17  HasDefaultedDefaultCtor() = default;
18  int x;
19};
20__declspec(thread) HasDefaultedDefaultCtor h;
21
22struct HasConstexprCtor {
23  constexpr HasConstexprCtor(int x) : x(x) {}
24  int x;
25};
26__declspec(thread) HasConstexprCtor i(42);
27
28int foo() {
29  __declspec(thread) int a; // expected-error {{must have global storage}}
30  static __declspec(thread) int b;
31}
32
33extern __declspec(thread) int fwd_thread_var;
34__declspec(thread) int fwd_thread_var = 5;
35
36extern int fwd_thread_var_mismatch; // expected-note {{previous declaration}}
37__declspec(thread) int fwd_thread_var_mismatch = 5; // expected-error-re {{thread-local {{.*}} follows non-thread-local}}
38
39extern __declspec(thread) int thread_mismatch_2; // expected-note {{previous declaration}}
40int thread_mismatch_2 = 5; // expected-error-re {{non-thread-local {{.*}} follows thread-local}}
41
42typedef __declspec(thread) int tls_int_t; // expected-warning {{only applies to variables}}
43