From 30cd91ebc297f21d5a1b6a60fdfe3227b7471bcb Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Mon, 19 May 2014 20:14:13 +0000 Subject: [PATCH] Allow dllimport on function definitions when they're template instantiations git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209157 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 3 ++- test/CodeGenCXX/dllimport.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 5276cafcf7..44ca495cb1 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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() && !FD->isInlined()) { + if (FD->hasAttr() && !FD->isInlined() && + !FD->isTemplateInstantiation()) { assert(!FD->hasAttr()); Diag(FD->getLocation(), diag::err_attribute_dllimport_function_definition); FD->setInvalidDecl(); diff --git a/test/CodeGenCXX/dllimport.cpp b/test/CodeGenCXX/dllimport.cpp index d8e58f7190..c4640c1af5 100644 --- a/test/CodeGenCXX/dllimport.cpp +++ b/test/CodeGenCXX/dllimport.cpp @@ -8,7 +8,7 @@ void DLLIMPORT a(); inline void DLLIMPORT b() {} // CHECK-DAG: define available_externally dllimport void @"\01?b@@YAXXZ"() -template inline void c() {} // FIXME: MSVC accepts this without 'inline' too. +template void c() {} template void DLLIMPORT c(); // CHECK-DAG: define available_externally dllimport void @"\01??$c@H@@YAXXZ"() -- 2.50.1