From b0769101ac05792ccc539bc7359b1927b3fd4aca Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 6 May 2010 23:13:35 +0000 Subject: [PATCH] Do not give implicitly-defined virtual members functions available_externally linkage, since they may not have been given a strong definition in another translation unit. Without this patch, the following test case fails to link with a GCC-compiled libstdc++: #include int main() { std::basic_stringbuf bs; } Fixes the last problem with the Boost.IO library. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103208 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 4 ++-- test/CodeGenCXX/template-linkage.cpp | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 9c84bcec05..6cbc3f67c2 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -322,8 +322,8 @@ GetLinkageForFunction(ASTContext &Context, const FunctionDecl *FD, // only for inlining and analysis. This is the semantics of c99 inline. if (const CXXMethodDecl *MD = dyn_cast(FD)) { const CXXRecordDecl *RD = MD->getParent(); - if (MD->isVirtual() && - CodeGenVTables::isKeyFunctionInAnotherTU(Context, RD)) + if (MD->isVirtual() && !MD->isImplicit() && + CodeGenVTables::isKeyFunctionInAnotherTU(Context, RD)) return CodeGenModule::GVA_C99Inline; } diff --git a/test/CodeGenCXX/template-linkage.cpp b/test/CodeGenCXX/template-linkage.cpp index ccd61a7bbe..63a5c09cd7 100644 --- a/test/CodeGenCXX/template-linkage.cpp +++ b/test/CodeGenCXX/template-linkage.cpp @@ -22,3 +22,23 @@ template void f(int); template inline void g(T) { } template void g(int); +template +struct X0 { + virtual ~X0() { } +}; + +template +struct X1 : X0 { + virtual void blarg(); +}; + +template void X1::blarg() { } + +extern template struct X0; +extern template struct X1; + +// CHECK: define linkonce_odr void @_ZN2X1IcED1Ev( +void test_X1() { + X1 i1c; +} + -- 2.40.0