summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-08-01 04:12:04 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-08-01 04:12:04 +0000
commitb71782b7e510e6088b8970d20ebbf1bbcf662b98 (patch)
tree0f4240cb27233818c3cf4597212f6cf98c218902 /clang
parent302ae6b002522f07482697361af30890ee0af31e (diff)
downloadbcm5719-llvm-b71782b7e510e6088b8970d20ebbf1bbcf662b98.tar.gz
bcm5719-llvm-b71782b7e510e6088b8970d20ebbf1bbcf662b98.zip
Fix assert when instantiating a default argument of a template defined in a
module. llvm-svn: 187556
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/Decl.cpp5
-rw-r--r--clang/test/Modules/Inputs/cxx-templates-a.h2
-rw-r--r--clang/test/Modules/cxx-templates.cpp3
3 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 4ecb41b3f0b..772f7353c36 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1959,7 +1959,10 @@ TemplateSpecializationKind VarDecl::getTemplateSpecializationKind() const {
}
MemberSpecializationInfo *VarDecl::getMemberSpecializationInfo() const {
- return getASTContext().getInstantiatedFromStaticDataMember(this);
+ if (isStaticDataMember())
+ return getASTContext().getInstantiatedFromStaticDataMember(this);
+
+ return 0;
}
void VarDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK,
diff --git a/clang/test/Modules/Inputs/cxx-templates-a.h b/clang/test/Modules/Inputs/cxx-templates-a.h
index cc83d7bc034..aaafc1b1bdb 100644
--- a/clang/test/Modules/Inputs/cxx-templates-a.h
+++ b/clang/test/Modules/Inputs/cxx-templates-a.h
@@ -20,3 +20,5 @@ template<typename T> void PerformDelayedLookup(T &t) {
typename T::Inner inner;
FoundByADL(t);
}
+
+template<typename T> void PerformDelayedLookupInDefaultArgument(T &t, int a = (FoundByADL(T()), 0)) {}
diff --git a/clang/test/Modules/cxx-templates.cpp b/clang/test/Modules/cxx-templates.cpp
index bb8ba034be1..79052dd34bb 100644
--- a/clang/test/Modules/cxx-templates.cpp
+++ b/clang/test/Modules/cxx-templates.cpp
@@ -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>();
OpenPOWER on IntegriCloud