[PATCH] D146338: [MSVC compatibility][dllimport/dllexport][PS] Allow dllexport/dllimport for classes with UniqueExternalLinkage

Wolfgang Pieb via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 22 09:48:56 PDT 2023


wolfgangp added a comment.

In D146338#4206222 <https://reviews.llvm.org/D146338#4206222>, @hans wrote:

>> In D145271 <https://reviews.llvm.org/D145271> it was suggested that we drop the attribute in such contexts, and this is effectively what happens. The compiler does not produce any exported definitions (or import any symbols) for such classes. The patch is simply to suppress the diagnostic for MSVC mode and Playstation.



> With the current patch, we still end up with the attribute on the base class in the AST. Also, does this make the compiler accept dllexport of classes in anonymous namespaces? I'm not sure we want that.
> Is it not possible to check the linkage and bail out in `Sema::propagateDLLAttrToBaseClassTemplate` instead?

Actually, the compiler would (still) not accept explicit dll* attributes on the class in either function scopes or anon namespaces. This case is about classes with internal linkage deriving from exported/imported template classes that have been instantiated with a class with internal linkage. In the description, the classes B and C are such classes. They both derive from A, which is imported and instantiated with B and C as template parameters.

However, I think I have found a way to drop the attribute. I think it's equivalent to just suppressing the error message, but it's probably cleaner.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146338/new/

https://reviews.llvm.org/D146338



More information about the cfe-commits mailing list