[PATCH] MS ABI: Propagate class-level DLL attributes to class template specialization bases (PR11170)

Hans Wennborg hans at chromium.org
Mon Jun 23 16:22:01 PDT 2014


Hi rnk, nrieck,

This implements what I believe is the final piece of 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.

My patch does this when the base hasn't been instantiated yet (unless that instantiation already has the attribute), and warns 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 propagation thing.

http://reviews.llvm.org/D4264

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclCXX.cpp
  test/CodeGenCXX/dllexport.cpp
  test/CodeGenCXX/dllimport.cpp
  test/SemaCXX/dllexport.cpp
  test/SemaCXX/dllimport.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4264.10771.patch
Type: text/x-patch
Size: 17391 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140623/3caf989b/attachment.bin>


More information about the cfe-commits mailing list