]> granicus.if.org Git - clang/commitdiff
Allow dllimport on function definitions when they're template instantiations
authorHans Wennborg <hans@hanshq.net>
Mon, 19 May 2014 20:14:13 +0000 (20:14 +0000)
committerHans Wennborg <hans@hanshq.net>
Mon, 19 May 2014 20:14:13 +0000 (20:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209157 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/CodeGenCXX/dllimport.cpp

index 5276cafcf72e8fa3188194c6ba564817fa00c287..44ca495cb152d3a275c13df863775a638f608025 100644 (file)
@@ -9766,7 +9766,8 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D) {
     ResolveExceptionSpec(D->getLocation(), FPT);
 
   // dllimport cannot be applied to non-inline function definitions.
-  if (FD->hasAttr<DLLImportAttr>() && !FD->isInlined()) {
+  if (FD->hasAttr<DLLImportAttr>() && !FD->isInlined() &&
+      !FD->isTemplateInstantiation()) {
     assert(!FD->hasAttr<DLLExportAttr>());
     Diag(FD->getLocation(), diag::err_attribute_dllimport_function_definition);
     FD->setInvalidDecl();
index d8e58f71903761d50b70641f8ebae250208421dc..c4640c1af5dcb5e69a0a986023d79ead54bfc742 100644 (file)
@@ -8,7 +8,7 @@ void DLLIMPORT a();
 inline void DLLIMPORT b() {}
 // CHECK-DAG: define available_externally dllimport void @"\01?b@@YAXXZ"()
 
-template <typename T> inline void c() {} // FIXME: MSVC accepts this without 'inline' too.
+template <typename T> void c() {}
 template void DLLIMPORT c<int>();
 // CHECK-DAG: define available_externally dllimport void @"\01??$c@H@@YAXXZ"()