[MinGW] Fix dllexport of explicit template instantiation
authorMartin Storsjo <martin@martin.st>
Fri, 26 Apr 2019 08:09:51 +0000 (08:09 +0000)
committerMartin Storsjo <martin@martin.st>
Fri, 26 Apr 2019 08:09:51 +0000 (08:09 +0000)
commit5be69bc68a6581897d7fa5068059aa8e723c6ce7
treebc7a1b7ace9d742554d2656c863e35e5c5627e8d
parentc316b22496017c48aba08de1fb69554404bc311b
[MinGW] Fix dllexport of explicit template instantiation

Contrary to MSVC, GCC/MinGW needs to have the dllexport attribute
on the template instantiation declaration, not on the definition.

Previously clang never marked explicit template instantiations as
dllexport in MinGW mode, if the instantiation had a previous
declaration, regardless of where the attribute was placed. This
makes Clang behave like GCC in this regard, and allows using the
same attribute form for both MinGW compilers.

This fixes PR40256.

Differential Revision: https://reviews.llvm.org/D61118

llvm-svn: 359285
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/CodeGenCXX/mingw-template-dllexport.cpp [new file with mode: 0644]
clang/test/SemaCXX/dllexport.cpp