diff options
| author | Hans Wennborg <hans@hanshq.net> | 2014-06-25 18:25:57 +0000 |
|---|---|---|
| committer | Hans Wennborg <hans@hanshq.net> | 2014-06-25 18:25:57 +0000 |
| commit | e5fdb78baffc29df6c772dbe80c113bc22bd72c6 (patch) | |
| tree | 58027e501f90d4c522627694a29d701b6e5e0b64 /include | |
| parent | ccaf37e1c9c5e4bf74224ef779d62b3ba05e3615 (diff) | |
| download | clang-e5fdb78baffc29df6c772dbe80c113bc22bd72c6.tar.gz clang-e5fdb78baffc29df6c772dbe80c113bc22bd72c6.tar.bz2 clang-e5fdb78baffc29df6c772dbe80c113bc22bd72c6.tar.xz | |
MS ABI: Propagate class-level DLL attributes to class template specialization bases (PR11170)
Consider the following code:
template <typename T> class Base {};
class __declspec(dllexport) class Derived : public Base<int> {}
When the base of an exported or imported class is a class template
specialization, MSVC will propagate the dll attribute to the base.
In the example code, Base<int> becomes a dllexported class.
This commit makes Clang do the proopagation when the base hasn't been
instantiated yet, and warns about it being unsupported otherwise.
This is different from MSVC, which allows changing a specialization
back and forth between dllimport and dllexport and seems to let the
last one win. Changing the dll attribute after instantiation would be
hard for us, and doesn't seem to come up in practice, so I think this
is a reasonable limitation to have.
MinGW doesn't do this kind of propagation.
Differential Revision: http://reviews.llvm.org/D4264
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211725 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
| -rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index b240295e9c..c691921fa1 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -2130,6 +2130,11 @@ def warn_attribute_dllimport_static_field_definition : Warning< InGroup<DiagGroup<"dllimport-static-field-def">>; def err_attribute_dll_member_of_dll_class : Error< "attribute %q0 cannot be applied to member of %q1 class">; +def warn_attribute_dll_instantiated_base_class : Warning< + "propagating dll attribute to %select{already instantiated|explicitly specialized}0 " + "base class template " + "%select{without dll attribute|with different dll attribute}1 is unsupported">, + InGroup<DiagGroup<"unsupported-dll-base-class-template">>; def err_attribute_weakref_not_static : Error< "weakref declaration must have internal linkage">; def err_attribute_weakref_not_global_context : Error< @@ -3405,6 +3410,10 @@ def err_template_instantiate_undefined : Error< "%select{implicit|explicit}0 instantiation of undefined template %1">; def err_implicit_instantiate_member_undefined : Error< "implicit instantiation of undefined member %0">; +def note_template_class_instantiation_was_here : Note< + "class template %0 was instantiated here">; +def note_template_class_explicit_specialization_was_here : Note< + "class template %0 was explicitly specialized here">; def note_template_class_instantiation_here : Note< "in instantiation of template class %0 requested here">; def note_template_member_class_here : Note< |
