From: Rafael Espindola Date: Tue, 28 May 2013 02:22:10 +0000 (+0000) Subject: Propagate VisibleNoLinkage down to class members. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e8328540cffa6b5b5f7d07e2e7d2f3503500a383;p=clang Propagate VisibleNoLinkage down to class members. Fixes PR16114. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182750 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 57eda43a95..089622fb18 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -789,13 +789,14 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, LinkageInfo classLV = getLVForDecl(cast(D->getDeclContext()), classComputation); - if (!isExternalFormalLinkage(classLV.getLinkage())) - return LinkageInfo::none(); - // If the class already has unique-external linkage, we can't improve. if (classLV.getLinkage() == UniqueExternalLinkage) return LinkageInfo::uniqueExternal(); + if (!isExternallyVisible(classLV.getLinkage())) + return LinkageInfo::none(); + + // Otherwise, don't merge in classLV yet, because in certain cases // we need to completely ignore the visibility from it. diff --git a/test/CodeGenCXX/linkage.cpp b/test/CodeGenCXX/linkage.cpp index 9d66934a24..a481b00123 100644 --- a/test/CodeGenCXX/linkage.cpp +++ b/test/CodeGenCXX/linkage.cpp @@ -159,3 +159,14 @@ namespace test12 { } void *h() { return zed(); } } + +namespace test13 { + // CHECK-DAG: define linkonce_odr void @_ZZN6test133fooEvEN1S3barEv( + inline void *foo() { + struct S { + static void bar() {} + }; + return (void *)S::bar; + } + void *zed() { return foo(); } +}