For non-template dllimport functions, MSVC allows providing an inline definition without spelling out the attribute again. In the example below, f remains a dllimport function.
__declspec(dllimport) int f(); inline int f() { return 42; } int useit() { return f(); }
However, for a function template, not putting dllimport on the redeclaration causes it to be dropped. In the example below, f is not dllimport.
template <typename> __declspec(dllimport) int f(); template <typename> inline int f() { return 42; } int useit() { return f<int>(); }
This patch makes Clang match MSVC for the second example.
MSVC does not warn about the attribute being dropped in the example above, but I think we should. (MSVC does warn if the inline keyword isn't used.)