diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-03-16 23:35:25 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-03-16 23:35:25 +0000 |
commit | 1ac02dcb60177c1c1b36526323be76a57efcc468 (patch) | |
tree | bd2e8e039d603679bc50ce66774626a3337e4586 /lib/Sema/SemaTemplateInstantiate.cpp | |
parent | 7c80bd64032e610c0dbd74fc0ef6ea334447f2fd (diff) |
Fix a problem noticed by Anders, where we were creating
IntegerLiterals during instantiation when we should be creating either
a boolean literal (CXXBoolLiteralExpr) or a character literal
(CharacterLiteral).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67061 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index fd541f3680..1c136e9f6e 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/lib/Sema/SemaTemplateInstantiate.cpp @@ -638,9 +638,22 @@ TemplateExprInstantiator::VisitDeclRefExpr(DeclRefExpr *E) { if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) { assert(NTTP->getDepth() == 0 && "No nested templates yet"); const TemplateArgument &Arg = TemplateArgs[NTTP->getPosition()]; + QualType T = Arg.getIntegralType(); + if (T->isCharType() || T->isWideCharType()) + return SemaRef.Owned(new (SemaRef.Context) CharacterLiteral( + Arg.getAsIntegral()->getZExtValue(), + T->isWideCharType(), + T, + E->getSourceRange().getBegin())); + else if (T->isBooleanType()) + return SemaRef.Owned(new (SemaRef.Context) CXXBoolLiteralExpr( + Arg.getAsIntegral()->getBoolValue(), + T, + E->getSourceRange().getBegin())); + return SemaRef.Owned(new (SemaRef.Context) IntegerLiteral( *Arg.getAsIntegral(), - Arg.getIntegralType(), + T, E->getSourceRange().getBegin())); } else assert(false && "Can't handle arbitrary declaration references"); |