diff options
author | David Blaikie <dblaikie@gmail.com> | 2013-02-27 22:10:40 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2013-02-27 22:10:40 +0000 |
commit | c0cedbe537e4b25eeb8d61d0c30a2ac31a7fddab (patch) | |
tree | 0f02bbd12a8c752a02bff7bafe2c0aa86795c029 /lib/Sema/SemaTemplate.cpp | |
parent | 98b879af5bfb50123a668dc1de6dd86feb9991c5 (diff) |
PR15360: nullptr as a non-type template argument to a function type non-type template parameter
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176216 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 61fd826360..4b766a9fde 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -4495,6 +4495,16 @@ ExprResult Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, QualType ParamType, SourceLocation Loc) { + // C++ [temp.param]p8: + // + // A non-type template-parameter of type "array of T" or + // "function returning T" is adjusted to be of type "pointer to + // T" or "pointer to function returning T", respectively. + if (ParamType->isArrayType()) + ParamType = Context.getArrayDecayedType(ParamType); + else if (ParamType->isFunctionType()) + ParamType = Context.getPointerType(ParamType); + // For a NULL non-type template argument, return nullptr casted to the // parameter's type. if (Arg.getKind() == TemplateArgument::NullPtr) { @@ -4560,15 +4570,6 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, } QualType T = VD->getType().getNonReferenceType(); - // C++ [temp.param]p8: - // - // A non-type template-parameter of type "array of T" or - // "function returning T" is adjusted to be of type "pointer to - // T" or "pointer to function returning T", respectively. - if (ParamType->isArrayType()) - ParamType = Context.getArrayDecayedType(ParamType); - else if (ParamType->isFunctionType()) - ParamType = Context.getPointerType(ParamType); if (ParamType->isPointerType()) { // When the non-type template parameter is a pointer, take the |