diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-10-04 06:51:54 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-10-04 06:51:54 +0000 |
commit | 18fa1456dc3d536c2da0e040d54fab6b0bbe594f (patch) | |
tree | b47802eb1131cb36d1aa999bfbe0bd46bc906890 /test/Sema | |
parent | 751c0f0d3ce56463e443bc35b882eba99148386f (diff) | |
download | clang-18fa1456dc3d536c2da0e040d54fab6b0bbe594f.tar.gz |
MS ABI: Disallow dllimported/exported variables from having TLS
Windows TLS relies on indexing through a tls_index in order to get at
the DLL's thread local variables. However, this index is not exported
along with the variable: it is assumed that all accesses to thread local
variables are inside the same module which created the variable in the
first place.
While there are several implementation techniques we could adopt to fix
this (notably, the Itanium ABI gets this for free), it is not worth the
heroics.
Instead, let's just ban this combination. We could revisit this in the
future if we need to.
This fixes PR21111.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219049 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema')
-rw-r--r-- | test/Sema/dllexport.c | 3 | ||||
-rw-r--r-- | test/Sema/dllimport.c | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/test/Sema/dllexport.c b/test/Sema/dllexport.c index 6c71ad8298..76b6f6dc5a 100644 --- a/test/Sema/dllexport.c +++ b/test/Sema/dllexport.c @@ -49,6 +49,9 @@ __declspec(dllexport) extern int GlobalRedecl4; // expected-warning{{redeclarati // External linkage is required. __declspec(dllexport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllexport'}} +// Thread local variables are invalid. +__declspec(dllexport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllexport'}} + // Export in local scope. void functionScope() { __declspec(dllexport) int LocalVarDecl; // expected-error{{'LocalVarDecl' must have external linkage when declared 'dllexport'}} diff --git a/test/Sema/dllimport.c b/test/Sema/dllimport.c index d64c85953d..1b111077b6 100644 --- a/test/Sema/dllimport.c +++ b/test/Sema/dllimport.c @@ -77,6 +77,9 @@ __declspec(dllimport) extern int GlobalRedecl5; // expected-warning{{redeclarati // External linkage is required. __declspec(dllimport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllimport'}} +// Thread local variables are invalid. +__declspec(dllimport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllimport'}} + // Import in local scope. __declspec(dllimport) float LocalRedecl1; // expected-note{{previous definition is here}} __declspec(dllimport) float LocalRedecl2; // expected-note{{previous definition is here}} |