aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateInstantiate.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-07-01 00:28:38 +0000
committerDouglas Gregor <dgregor@apple.com>2009-07-01 00:28:38 +0000
commit16134c62ef3d146e0dd0c76aafb906ff12c0a15d (patch)
tree26dc8e696987010c71d8423aece3da4aa3a9862a /lib/Sema/SemaTemplateInstantiate.cpp
parent6db8ed4498b83fe9336e3855a4ba1a298b04ee00 (diff)
Cope with explicitly-specified function template arguments when there
are fewer template arguments than there are template parameters for that function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74578 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index ff01e41214..3bc1cf9504 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -584,6 +584,15 @@ InstantiateTemplateTypeParmType(const TemplateTypeParmType *T) const {
if (T->getDepth() == 0) {
// Replace the template type parameter with its corresponding
// template argument.
+
+ // If the corresponding template argument is NULL or doesn't exist, it's
+ // because we are performing instantiation from explicitly-specified
+ // template arguments in a function template class, but there were some
+ // arguments left unspecified.
+ if (T->getIndex() >= TemplateArgs.size() ||
+ TemplateArgs[T->getIndex()].isNull())
+ return QualType(T, 0); // Would be nice to keep the original type here
+
assert(TemplateArgs[T->getIndex()].getKind() == TemplateArgument::Type &&
"Template argument kind mismatch");
return TemplateArgs[T->getIndex()].getAsType();