Fix assert when instantiating a default argument of a template defined in a
module.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187556 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 4ecb41b..772f735 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -1959,7 +1959,10 @@
}
MemberSpecializationInfo *VarDecl::getMemberSpecializationInfo() const {
- return getASTContext().getInstantiatedFromStaticDataMember(this);
+ if (isStaticDataMember())
+ return getASTContext().getInstantiatedFromStaticDataMember(this);
+
+ return 0;
}
void VarDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK,
diff --git a/test/Modules/Inputs/cxx-templates-a.h b/test/Modules/Inputs/cxx-templates-a.h
index cc83d7b..aaafc1b 100644
--- a/test/Modules/Inputs/cxx-templates-a.h
+++ b/test/Modules/Inputs/cxx-templates-a.h
@@ -20,3 +20,5 @@
typename T::Inner inner;
FoundByADL(t);
}
+
+template<typename T> void PerformDelayedLookupInDefaultArgument(T &t, int a = (FoundByADL(T()), 0)) {}
diff --git a/test/Modules/cxx-templates.cpp b/test/Modules/cxx-templates.cpp
index bb8ba03..79052dd 100644
--- a/test/Modules/cxx-templates.cpp
+++ b/test/Modules/cxx-templates.cpp
@@ -51,6 +51,9 @@
// 'common'. That type is not visible here.
PerformDelayedLookup(defined_in_common);
+ // Likewise, but via a default argument.
+ PerformDelayedLookupInDefaultArgument(defined_in_common);
+
// Trigger the instantiation of a template in 'b' that uses a type defined in
// 'b_impl'. That type is not visible here.
UseDefinedInBImpl<int>();