diff options
| author | Hans Wennborg <hans@hanshq.net> | 2015-08-28 21:47:01 +0000 |
|---|---|---|
| committer | Hans Wennborg <hans@hanshq.net> | 2015-08-28 21:47:01 +0000 |
| commit | 6eaa8323a887a878f54dfcc65d4fff72c0f5c161 (patch) | |
| tree | 7dda0796d6e35b1752714167c273cb6bf0010ffc /clang/test/SemaCXX/dllimport.cpp | |
| parent | e235d4502665e377cc920049dc33dfb693ad2067 (diff) | |
| download | bcm5719-llvm-6eaa8323a887a878f54dfcc65d4fff72c0f5c161.tar.gz bcm5719-llvm-6eaa8323a887a878f54dfcc65d4fff72c0f5c161.zip | |
Allow TLS vars in dllimport/export functions; only inline dllimport functions when safe (PR24593)
This patch does two things:
1) Don't error about dllimport/export on thread-local static local variables.
We put those attributes on static locals in dllimport/export functions
implicitly in case the function gets inlined. Now, for TLS variables this
is a problem because we can't import such variables, but it's a benign
problem becase:
2) Make sure we never inline a dllimport function TLS static locals. In fact,
never inline a dllimport function that references a non-imported function
or variable (because these are not defined in the importing library). This
seems to match MSVC's behaviour.
Differential Revision: http://reviews.llvm.org/D12422
llvm-svn: 246338
Diffstat (limited to 'clang/test/SemaCXX/dllimport.cpp')
| -rw-r--r-- | clang/test/SemaCXX/dllimport.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/dllimport.cpp b/clang/test/SemaCXX/dllimport.cpp index 2fa10756da4..f17c2e22414 100644 --- a/clang/test/SemaCXX/dllimport.cpp +++ b/clang/test/SemaCXX/dllimport.cpp @@ -93,6 +93,18 @@ __declspec(dllimport) auto InternalAutoTypeGlobal = Internal(); // expected-erro // Thread local variables are invalid. __declspec(dllimport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllimport'}} +inline void InlineWithThreadLocal() { + static __declspec(dllimport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllimport'}} +} + +// But if they're in a dllimported function, it's OK because we will not inline the function. +// This doesn't work on MinGW, because there, dllimport on the inline function is ignored. +#ifndef GNU +inline void __declspec(dllimport) ImportedInlineWithThreadLocal() { + static __declspec(dllimport) __thread int OK1; // no-error + static __thread int OK2; // no-error +} +#endif // Import in local scope. __declspec(dllimport) float LocalRedecl1; // expected-note{{previous declaration is here}} |

