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