summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/Type.cpp6
-rw-r--r--clang/test/SemaTemplate/explicit-specialization-member.cpp11
2 files changed, 15 insertions, 2 deletions
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 8f22a1b197a..1d064b135e3 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3023,8 +3023,10 @@ static TagDecl *getInterestingTagDecl(TagDecl *decl) {
if (I->isCompleteDefinition() || I->isBeingDefined())
return I;
}
- // If there's no definition (not even in progress), return what we have.
- return decl;
+ // If there's no definition (not even in progress), return the most recent
+ // declaration. This is important for template specializations, in order to
+ // pick the declaration with the most complete TemplateSpecializationKind.
+ return decl->getMostRecentDecl();
}
TagDecl *TagType::getDecl() const {
diff --git a/clang/test/SemaTemplate/explicit-specialization-member.cpp b/clang/test/SemaTemplate/explicit-specialization-member.cpp
index f302836c7e4..4300ceb17ec 100644
--- a/clang/test/SemaTemplate/explicit-specialization-member.cpp
+++ b/clang/test/SemaTemplate/explicit-specialization-member.cpp
@@ -57,3 +57,14 @@ template<typename T> struct Helper {
template<typename T> void Helper<T>::func<2>() {} // expected-error {{cannot specialize a member}} \
// expected-error {{no function template matches}}
}
+
+namespace b35070233 {
+ template <typename T> struct Cls {
+ static void f() {}
+ };
+
+ void g(Cls<int>);
+
+ template<> struct Cls<int>; // expected-note {{forward declaration}}
+ template<> void Cls<int>::f(); // expected-error {{incomplete type}}
+}
OpenPOWER on IntegriCloud