Home | History | Annotate | Download | only in SemaCXX
      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;
      7 int foo();
      8 __declspec(thread) int e = foo(); // expected-error {{must be a constant expression}} expected-note {{thread_local}}
      9 
     10 struct HasCtor { HasCtor(); int x; };
     11 __declspec(thread) HasCtor f; // expected-error {{must be a constant expression}} expected-note {{thread_local}}
     12 
     13 struct HasDtor { ~HasDtor(); int x; };
     14 __declspec(thread) HasDtor g; // expected-error {{non-trivial destruction}} expected-note {{thread_local}}
     15 
     16 struct HasDefaultedDefaultCtor {
     17   HasDefaultedDefaultCtor() = default;
     18   int x;
     19 };
     20 __declspec(thread) HasDefaultedDefaultCtor h;
     21 
     22 struct HasConstexprCtor {
     23   constexpr HasConstexprCtor(int x) : x(x) {}
     24   int x;
     25 };
     26 __declspec(thread) HasConstexprCtor i(42);
     27 
     28 int foo() {
     29   __declspec(thread) int a; // expected-error {{must have global storage}}
     30   static __declspec(thread) int b;
     31 }
     32 
     33 extern __declspec(thread) int fwd_thread_var;
     34 __declspec(thread) int fwd_thread_var = 5;
     35 
     36 extern 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 
     39 extern __declspec(thread) int thread_mismatch_2; // expected-note {{previous declaration}}
     40 int thread_mismatch_2 = 5; // expected-error-re {{non-thread-local {{.*}} follows thread-local}}
     41 
     42 typedef __declspec(thread) int tls_int_t; // expected-warning {{only applies to variables}}
     43