From 1ac02dcb60177c1c1b36526323be76a57efcc468 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 16 Mar 2009 23:35:25 +0000 Subject: [PATCH] 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 --- lib/Sema/SemaTemplateInstantiate.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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(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"); -- 2.40.0