summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/AST/Decl.cpp9
-rw-r--r--clang/test/CXX/basic/basic.link/p8.cpp9
2 files changed, 13 insertions, 5 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 3f9eaf28ef9..f77345f9c2d 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -871,12 +871,11 @@ LinkageComputer::getLVForClassMember(const NamedDecl *D,
LinkageInfo classLV =
getLVForDecl(cast<RecordDecl>(D->getDeclContext()), classComputation);
- // If the class already has unique-external linkage, we can't improve.
- if (classLV.getLinkage() == UniqueExternalLinkage)
- return LinkageInfo::uniqueExternal();
-
+ // The member has the same linkage as the class. If that's not externally
+ // visible, we don't need to compute anything about the linkage.
+ // FIXME: If we're only computing linkage, can we bail out here?
if (!isExternallyVisible(classLV.getLinkage()))
- return LinkageInfo::none();
+ return classLV;
// Otherwise, don't merge in classLV yet, because in certain cases
diff --git a/clang/test/CXX/basic/basic.link/p8.cpp b/clang/test/CXX/basic/basic.link/p8.cpp
index 317fb31fb03..54b977d77f6 100644
--- a/clang/test/CXX/basic/basic.link/p8.cpp
+++ b/clang/test/CXX/basic/basic.link/p8.cpp
@@ -67,3 +67,12 @@ void use_inline_vars() {
defined_after_use = 2;
}
inline int defined_after_use;
+
+namespace {
+ template<typename T> struct A {
+ static const int n;
+ };
+ template<typename T> const int A<T>::n = 3;
+ static_assert(A<int>::n == 3);
+ int k = A<float>::n;
+}
OpenPOWER on IntegriCloud