Diagnose the declaration of explicit specializations after an implicit
instantiation has already been required. To do so, keep track of the
point of instantiation for anything that can be instantiated.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83890 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 64e8000..b9a87ae 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -434,13 +434,16 @@
}
CXXRecordDecl *CXXRecordDecl::getInstantiatedFromMemberClass() const {
- if (MemberSpecializationInfo *MSInfo
- = TemplateOrInstantiation.dyn_cast<MemberSpecializationInfo *>())
+ if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo())
return cast<CXXRecordDecl>(MSInfo->getInstantiatedFrom());
return 0;
}
+MemberSpecializationInfo *CXXRecordDecl::getMemberSpecializationInfo() const {
+ return TemplateOrInstantiation.dyn_cast<MemberSpecializationInfo *>();
+}
+
void
CXXRecordDecl::setInstantiationOfMemberClass(CXXRecordDecl *RD,
TemplateSpecializationKind TSK) {
@@ -456,8 +459,7 @@
= dyn_cast<ClassTemplateSpecializationDecl>(this))
return Spec->getSpecializationKind();
- if (MemberSpecializationInfo *MSInfo
- = TemplateOrInstantiation.dyn_cast<MemberSpecializationInfo *>())
+ if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo())
return MSInfo->getTemplateSpecializationKind();
return TSK_Undeclared;
@@ -471,8 +473,7 @@
return;
}
- if (MemberSpecializationInfo *MSInfo
- = TemplateOrInstantiation.dyn_cast<MemberSpecializationInfo *>()) {
+ if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo()) {
MSInfo->setTemplateSpecializationKind(TSK);
return;
}