From bdf2bba1cb8c6347f43a3caa36e801b1d86450d0 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 27 May 2013 14:50:21 +0000 Subject: [PATCH] Fix the linkage of local types in inline VisibleNoLinkage functions. We were handling only local types in inline External functions before. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182737 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/Decl.cpp | 2 +- test/CodeGenCXX/linkage.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 5e0ffdacf0..4f98ff34b4 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -1070,7 +1070,7 @@ static LinkageInfo getLVForLocalDecl(const NamedDecl *D, if (!FD || !FD->isInlined()) return LinkageInfo::none(); LinkageInfo LV = FD->getLinkageAndVisibility(); - if (LV.getLinkage() != ExternalLinkage) + if (!isExternallyVisible(LV.getLinkage())) return LinkageInfo::none(); return LinkageInfo(VisibleNoLinkage, LV.getVisibility(), LV.isVisibilityExplicit()); diff --git a/test/CodeGenCXX/linkage.cpp b/test/CodeGenCXX/linkage.cpp index c803a94161..9d66934a24 100644 --- a/test/CodeGenCXX/linkage.cpp +++ b/test/CodeGenCXX/linkage.cpp @@ -143,3 +143,19 @@ namespace test11 { } void *h() { return g(); } } + +namespace test12 { + // CHECK-DAG: define linkonce_odr void @_ZN6test123fooIZNS_3barIZNS_3zedEvE2S2EEPvvE2S1EEvv + template void foo() {} + template inline void *bar() { + enum S1 { + }; + return reinterpret_cast(foo); + } + inline void *zed() { + enum S2 { + }; + return reinterpret_cast(bar); + } + void *h() { return zed(); } +} -- 2.40.0