diff options
| author | Hans Wennborg <hans@hanshq.net> | 2015-09-04 19:59:39 +0000 |
|---|---|---|
| committer | Hans Wennborg <hans@hanshq.net> | 2015-09-04 19:59:39 +0000 |
| commit | 5427a695453c85a45a0d92c892e3f3c25885fe18 (patch) | |
| tree | bd529451f4b0943886d25fa11974d2cf16488647 /clang/test/Sema | |
| parent | 0fccef6ac2fc87f4dd29a1d098723cd2869a09ab (diff) | |
| download | bcm5719-llvm-5427a695453c85a45a0d92c892e3f3c25885fe18.tar.gz bcm5719-llvm-5427a695453c85a45a0d92c892e3f3c25885fe18.zip | |
Don't allow dllexport/import on static local variables
They might technically have external linkage, but it still doesn't make sense
for the user to try and export such variables. This matches MSVC's and MinGW's
behaviour.
llvm-svn: 246864
Diffstat (limited to 'clang/test/Sema')
| -rw-r--r-- | clang/test/Sema/dllexport.c | 5 | ||||
| -rw-r--r-- | clang/test/Sema/dllimport.c | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/Sema/dllexport.c b/clang/test/Sema/dllexport.c index 69aad2eb54c..56c9e74225f 100644 --- a/clang/test/Sema/dllexport.c +++ b/clang/test/Sema/dllexport.c @@ -109,6 +109,11 @@ __declspec(dllexport) void redecl6(); // expected-warning{{redeclaration of 'red // External linkage is required. __declspec(dllexport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllexport'}} +// Static locals don't count as having external linkage. +void staticLocalFunc() { + __declspec(dllexport) static int staticLocal; // expected-error{{'staticLocal' must have external linkage when declared 'dllexport'}} +} + //===----------------------------------------------------------------------===// diff --git a/clang/test/Sema/dllimport.c b/clang/test/Sema/dllimport.c index d81aecd604c..f863499cf84 100644 --- a/clang/test/Sema/dllimport.c +++ b/clang/test/Sema/dllimport.c @@ -168,3 +168,8 @@ __declspec(dllimport) inline void redecl7() {} // External linkage is required. __declspec(dllimport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllimport'}} + +// Static locals don't count as having external linkage. +void staticLocalFunc() { + __declspec(dllimport) static int staticLocal; // expected-error{{'staticLocal' must have external linkage when declared 'dllimport'}} +} |

