diff options
author | Hans Wennborg <hans@hanshq.net> | 2014-05-30 16:59:42 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2014-05-30 16:59:42 +0000 |
commit | 853ae946607ab370e10703f1550c72404374efd9 (patch) | |
tree | d1c19b4e23b8cb47c93bd337841f8420ebfc5079 /clang/test/SemaCXX/dllexport.cpp | |
parent | c002981084fc63573b6538415461af1783e5dc55 (diff) | |
download | bcm5719-llvm-853ae946607ab370e10703f1550c72404374efd9.tar.gz bcm5719-llvm-853ae946607ab370e10703f1550c72404374efd9.zip |
Start adding support for dllimport/dllexport on classes (PR11170)
This implements the central part of support for dllimport/dllexport on
classes: allowing the attribute on class declarations, inheriting it
to class members, and forcing emission of exported members. It's based
on Nico Rieck's patch from http://reviews.llvm.org/D1099.
This patch doesn't propagate dllexport to bases that are template
specializations, which is an interesting problem. It also doesn't
look at the rules when redeclaring classes with different attributes,
I'd like to do that separately.
Differential Revision: http://reviews.llvm.org/D3877
llvm-svn: 209908
Diffstat (limited to 'clang/test/SemaCXX/dllexport.cpp')
-rw-r--r-- | clang/test/SemaCXX/dllexport.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/clang/test/SemaCXX/dllexport.cpp b/clang/test/SemaCXX/dllexport.cpp index c637e63f8e0..75f9fa9d6df 100644 --- a/clang/test/SemaCXX/dllexport.cpp +++ b/clang/test/SemaCXX/dllexport.cpp @@ -16,13 +16,13 @@ struct External { int v; }; // Invalid usage. -__declspec(dllexport) typedef int typedef1; // expected-warning{{'dllexport' attribute only applies to variables and functions}} -typedef __declspec(dllexport) int typedef2; // expected-warning{{'dllexport' attribute only applies to variables and functions}} -typedef int __declspec(dllexport) typedef3; // expected-warning{{'dllexport' attribute only applies to variables and functions}} -typedef __declspec(dllexport) void (*FunTy)(); // expected-warning{{'dllexport' attribute only applies to variables and functions}} -enum __declspec(dllexport) Enum {}; // expected-warning{{'dllexport' attribute only applies to variables and functions}} +__declspec(dllexport) typedef int typedef1; // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} +typedef __declspec(dllexport) int typedef2; // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} +typedef int __declspec(dllexport) typedef3; // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} +typedef __declspec(dllexport) void (*FunTy)(); // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} +enum __declspec(dllexport) Enum {}; // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} #if __has_feature(cxx_strong_enums) - enum class __declspec(dllexport) EnumClass {}; // expected-warning{{'dllexport' attribute only applies to variables and functions}} + enum class __declspec(dllexport) EnumClass {}; // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} #endif @@ -311,6 +311,14 @@ template<> __declspec(dllexport) inline void funcTmpl<ExplicitSpec_InlineDef_Exp //===----------------------------------------------------------------------===// +// Classes +//===----------------------------------------------------------------------===// + +class __declspec(dllexport) ClassDecl; + +class __declspec(dllexport) ClassDef { }; + +//===----------------------------------------------------------------------===// // Precedence //===----------------------------------------------------------------------===// @@ -385,7 +393,7 @@ private: __declspec(dllexport) void privateDef(); public: - __declspec(dllexport) int Field; // expected-warning{{'dllexport' attribute only applies to variables and functions}} + __declspec(dllexport) int Field; // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} __declspec(dllexport) static int StaticField; __declspec(dllexport) static int StaticFieldDef; __declspec(dllexport) static const int StaticConstField; @@ -771,7 +779,7 @@ private: __declspec(dllexport) void privateDef(); public: - __declspec(dllexport) int Field; // expected-warning{{'dllexport' attribute only applies to variables and functions}} + __declspec(dllexport) int Field; // expected-warning{{'dllexport' attribute only applies to variables, functions and classes}} __declspec(dllexport) static int StaticField; __declspec(dllexport) static int StaticFieldDef; __declspec(dllexport) static const int StaticConstField; @@ -907,3 +915,5 @@ template<typename T> template<typename U> __declspec(dllexport) int CTMT template<typename T> template<typename U> __declspec(dllexport) const int CTMTR<T>::StaticConstField = 1; // expected-error{{redeclaration of 'CTMTR::StaticConstField' cannot add 'dllexport' attribute}} template<typename T> template<typename U> __declspec(dllexport) constexpr int CTMTR<T>::ConstexprField; // expected-error{{redeclaration of 'CTMTR::ConstexprField' cannot add 'dllexport' attribute}} #endif // __has_feature(cxx_variable_templates) + +// FIXME: Precedence rules seem to be different for classes. |