diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-04-06 22:40:38 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-04-06 22:40:38 +0000 |
commit | d2008e2c80d6c9282044ec873a937a17a0f33579 (patch) | |
tree | d3e119b536c83e6fd769fa31a3abac02892a2aed /lib/Sema/SemaTemplateInstantiate.cpp | |
parent | e35abe1fd3f867ae51d5c68d98578d537eb6beca (diff) |
Implement support for null non-type template arguments for non-type
template parameters of pointer, pointer-to-member, or nullptr_t
type in C++11. Fixes PR9700 / <rdar://problem/11193097>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154219 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index 307cccce8b..4740145fd5 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -1113,15 +1113,21 @@ ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef( type = argExpr->getType(); } else if (arg.getKind() == TemplateArgument::Declaration) { - ValueDecl *VD = cast<ValueDecl>(arg.getAsDecl()); - - // Find the instantiation of the template argument. This is - // required for nested templates. - VD = cast_or_null<ValueDecl>( - getSema().FindInstantiatedDecl(loc, VD, TemplateArgs)); - if (!VD) - return ExprError(); - + ValueDecl *VD; + if (Decl *D = arg.getAsDecl()) { + VD = cast<ValueDecl>(D); + + // Find the instantiation of the template argument. This is + // required for nested templates. + VD = cast_or_null<ValueDecl>( + getSema().FindInstantiatedDecl(loc, VD, TemplateArgs)); + if (!VD) + return ExprError(); + } else { + // Propagate NULL template argument. + VD = 0; + } + // Derive the type we want the substituted decl to have. This had // better be non-dependent, or these checks will have serious problems. if (parm->isExpandedParameterPack()) { |