Template functions (and member functions of class templates) present the same
problem as inline functions. They need to be uniqued, so we need to assign
VisibleNoLinkage linkage to types defined in them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183222
91177308-0d34-0410-b5e6-
96231b3b80d8
return LinkageInfo::none();
const FunctionDecl *FD = getOutermostFunctionContext(D);
- if (!FD || !FD->isInlined())
+ if (!FD)
+ return LinkageInfo::none();
+
+ if (!FD->isInlined() && FD->getTemplateSpecializationKind() == TSK_Undeclared)
return LinkageInfo::none();
+
LinkageInfo LV = getLVForDecl(FD, computation);
if (!isExternallyVisible(LV.getLinkage()))
return LinkageInfo::none();
}
void h() { f(); }
}
+
+namespace test15 {
+ // CHECK-DAG: define linkonce_odr void @_ZN6test153zedIZNS_3fooIiEEPvvE3bar_9EEvv(
+ template <class T> void zed() {}
+ template <class T> void *foo() {
+ class bar {
+ };
+ return reinterpret_cast<void *>(zed<bar>);
+ }
+ void test() { foo<int>(); }
+}
+
+namespace test16 {
+ // CHECK-DAG: define linkonce_odr void @_ZN6test163zedIZNS_3fooIiE3barEvE1S__10_EEvv(
+ template <class T> void zed() {}
+ template <class T> struct foo {
+ static void *bar();
+ };
+ template <class T> void *foo<T>::bar() {
+ class S {
+ };
+ return reinterpret_cast<void *>(zed<S>);
+ }
+ void *test() { return foo<int>::bar(); }
+}