]> granicus.if.org Git - clang/commitdiff
Propagate VisibleNoLinkage down to class members.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 28 May 2013 02:22:10 +0000 (02:22 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 28 May 2013 02:22:10 +0000 (02:22 +0000)
Fixes PR16114.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182750 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp
test/CodeGenCXX/linkage.cpp

index 57eda43a9522ec44a69eeba9a8a8a79af5503e22..089622fb186670886e319e836408562c0556309b 100644 (file)
@@ -789,13 +789,14 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D,
 
   LinkageInfo classLV =
     getLVForDecl(cast<RecordDecl>(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.
 
index 9d66934a243e48bb9eb268ebb85f8a984bbca54e..a481b00123b5d73a35bb538c17d1e57e507ea1b6 100644 (file)
@@ -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(); }
+}