Accept __declspec(dllimport) for function defined at class scope in Microsoft mode.
This fixes a bunch of errors when compiling MSVC header files with the -DDLL flag.
llvm-svn: 128457
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 7a1492a..e52082bbb 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5701,7 +5701,9 @@
DLLImportAttr *DA = FD->getAttr<DLLImportAttr>();
if (DA && (!FD->getAttr<DLLExportAttr>())) {
// dllimport attribute cannot be directly applied to definition.
- if (!DA->isInherited()) {
+ // Microsoft accepts dllimport for functions defined within class scope.
+ if (!DA->isInherited() &&
+ !(LangOpts.Microsoft && FD->getLexicalDeclContext()->isRecord())) {
Diag(FD->getLocation(),
diag::err_attribute_can_be_applied_only_to_symbol_declaration)
<< "dllimport";