MS ABI: Propagate class-level DLL attributes to class template specialization bases...
authorHans Wennborg <hans@hanshq.net>
Wed, 25 Jun 2014 18:25:57 +0000 (18:25 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 25 Jun 2014 18:25:57 +0000 (18:25 +0000)
commit9bea9cc73bd0e31fe8e332c6a9673068eaaca393
tree34ab75159d7dbc97c58d936bd71e9611f55eb728
parent2952956fd88d5428765d6cf76b6afd66d9f5dfee
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

llvm-svn: 211725
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/CodeGenCXX/dllexport.cpp
clang/test/CodeGenCXX/dllimport.cpp
clang/test/SemaCXX/dllexport.cpp
clang/test/SemaCXX/dllimport.cpp