diff options
| author | Nico Rieck <nico.rieck@gmail.com> | 2014-03-31 14:56:15 +0000 |
|---|---|---|
| committer | Nico Rieck <nico.rieck@gmail.com> | 2014-03-31 14:56:15 +0000 |
| commit | 82f0b06749e57467a730a7be9afe9a5ad539ebdc (patch) | |
| tree | 60f5c77bcee188defa2566a97ea23d9c0b297237 /clang/test/SemaCXX/dllexport.cpp | |
| parent | c991305cc975aec8e76e5f1031dab470c5dcc35f (diff) | |
| download | bcm5719-llvm-82f0b06749e57467a730a7be9afe9a5ad539ebdc.tar.gz bcm5719-llvm-82f0b06749e57467a730a7be9afe9a5ad539ebdc.zip | |
Sema: Check dll attributes on redeclarations
A redeclaration may not add dllimport or dllexport attributes. dllexport is
sticky and can be omitted on redeclarations while dllimport cannot.
llvm-svn: 205197
Diffstat (limited to 'clang/test/SemaCXX/dllexport.cpp')
| -rw-r--r-- | clang/test/SemaCXX/dllexport.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/clang/test/SemaCXX/dllexport.cpp b/clang/test/SemaCXX/dllexport.cpp index 64763834956..acbd4ce78f4 100644 --- a/clang/test/SemaCXX/dllexport.cpp +++ b/clang/test/SemaCXX/dllexport.cpp @@ -43,6 +43,16 @@ int __declspec(dllexport) GlobalInit2 = 1; __declspec(dllexport) extern int GlobalDeclInit; int GlobalDeclInit = 1; +// Redeclarations +__declspec(dllexport) extern int GlobalRedecl1; +__declspec(dllexport) int GlobalRedecl1; + +__declspec(dllexport) extern int GlobalRedecl2; + int GlobalRedecl2; + + extern int GlobalRedecl3; // expected-note{{previous declaration is here}} +__declspec(dllexport) extern int GlobalRedecl3; // expected-error{{redeclaration of 'GlobalRedecl3' cannot add 'dllexport' attribute}} + // Export in local scope. void functionScope() { __declspec(dllexport) extern int ExternLocalVarDecl; @@ -84,6 +94,22 @@ __declspec(dllexport) void redecl1() {} __declspec(dllexport) void redecl2(); void redecl2() {} + void redecl3(); // expected-note{{previous declaration is here}} +__declspec(dllexport) void redecl3(); // expected-error{{redeclaration of 'redecl3' cannot add 'dllexport' attribute}} + +// Friend functions +struct FuncFriend { + friend __declspec(dllexport) void friend1(); + friend __declspec(dllexport) void friend2(); + friend void friend3(); // expected-note{{previous declaration is here}} +}; +__declspec(dllexport) void friend1() {} + void friend2() {} +__declspec(dllexport) void friend3() {} // expected-error{{redeclaration of 'friend3' cannot add 'dllexport' attribute}} + +// Implicit declarations can be redeclared with dllexport. +__declspec(dllexport) void* operator new(__SIZE_TYPE__ n); + //===----------------------------------------------------------------------===// @@ -104,8 +130,18 @@ template<typename T> __declspec(dllexport) void funcTmplRedecl1() {} template<typename T> __declspec(dllexport) void funcTmplRedecl2(); template<typename T> void funcTmplRedecl2() {} -template<typename T> __declspec(dllexport) void funcTmplRedecl3(); -template<typename T> void funcTmplRedecl3() {} +template<typename T> void funcTmplRedecl3(); // expected-note{{previous declaration is here}} +template<typename T> __declspec(dllexport) void funcTmplRedecl3(); // expected-error{{redeclaration of 'funcTmplRedecl3' cannot add 'dllexport' attribute}} + +// Function template friends +struct FuncTmplFriend { + template<typename T> friend __declspec(dllexport) void funcTmplFriend1(); + template<typename T> friend __declspec(dllexport) void funcTmplFriend2(); + template<typename T> friend void funcTmplFriend3(); // expected-note{{previous declaration is here}} +}; +template<typename T> __declspec(dllexport) void funcTmplFriend1() {} +template<typename T> void funcTmplFriend2() {} +template<typename T> __declspec(dllexport) void funcTmplFriend3() {} // expected-error{{redeclaration of 'funcTmplFriend3' cannot add 'dllexport' attribute}} template<typename T> void funcTmpl() {} |

