]> granicus.if.org Git - clang/commitdiff
Fix the linkage of local types in inline VisibleNoLinkage functions.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 27 May 2013 14:50:21 +0000 (14:50 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 27 May 2013 14:50:21 +0000 (14:50 +0000)
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
test/CodeGenCXX/linkage.cpp

index 5e0ffdacf091ffbb29bc451d9159d3c70a6e8586..4f98ff34b4b2840cfa6d314e653a6f89ea9d89ba 100644 (file)
@@ -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());
index c803a941614a9ecba6945649f9cf7a7a15620fea..9d66934a243e48bb9eb268ebb85f8a984bbca54e 100644 (file)
@@ -143,3 +143,19 @@ namespace test11 {
   }
   void *h() { return g(); }
 }
+
+namespace test12 {
+  // CHECK-DAG: define linkonce_odr void @_ZN6test123fooIZNS_3barIZNS_3zedEvE2S2EEPvvE2S1EEvv
+  template <typename T> void foo() {}
+  template <typename T> inline void *bar() {
+    enum S1 {
+    };
+    return reinterpret_cast<void *>(foo<S1>);
+  }
+  inline void *zed() {
+    enum S2 {
+    };
+    return reinterpret_cast<void *>(bar<S2>);
+  }
+  void *h() { return zed(); }
+}