r187556 - Fix assert when instantiating a default argument of a template defined in a
Richard Smith
richard-llvm at metafoo.co.uk
Wed Jul 31 21:12:04 PDT 2013
Author: rsmith
Date: Wed Jul 31 23:12:04 2013
New Revision: 187556
URL: http://llvm.org/viewvc/llvm-project?rev=187556&view=rev
Log:
Fix assert when instantiating a default argument of a template defined in a
module.
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/Modules/Inputs/cxx-templates-a.h
cfe/trunk/test/Modules/cxx-templates.cpp
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=187556&r1=187555&r2=187556&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Jul 31 23:12:04 2013
@@ -1959,7 +1959,10 @@ TemplateSpecializationKind VarDecl::getT
}
MemberSpecializationInfo *VarDecl::getMemberSpecializationInfo() const {
- return getASTContext().getInstantiatedFromStaticDataMember(this);
+ if (isStaticDataMember())
+ return getASTContext().getInstantiatedFromStaticDataMember(this);
+
+ return 0;
}
void VarDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK,
Modified: cfe/trunk/test/Modules/Inputs/cxx-templates-a.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/cxx-templates-a.h?rev=187556&r1=187555&r2=187556&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/cxx-templates-a.h (original)
+++ cfe/trunk/test/Modules/Inputs/cxx-templates-a.h Wed Jul 31 23:12:04 2013
@@ -20,3 +20,5 @@ template<typename T> void PerformDelayed
typename T::Inner inner;
FoundByADL(t);
}
+
+template<typename T> void PerformDelayedLookupInDefaultArgument(T &t, int a = (FoundByADL(T()), 0)) {}
Modified: cfe/trunk/test/Modules/cxx-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/cxx-templates.cpp?rev=187556&r1=187555&r2=187556&view=diff
==============================================================================
--- cfe/trunk/test/Modules/cxx-templates.cpp (original)
+++ cfe/trunk/test/Modules/cxx-templates.cpp Wed Jul 31 23:12:04 2013
@@ -51,6 +51,9 @@ void g() {
// '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>();
More information about the cfe-commits
mailing list