[cfe-commits] r67061 - /cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
Douglas Gregor
dgregor at apple.com
Mon Mar 16 16:35:25 PDT 2009
Author: dgregor
Date: Mon Mar 16 18:35:25 2009
New Revision: 67061
URL: http://llvm.org/viewvc/llvm-project?rev=67061&view=rev
Log:
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).
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=67061&r1=67060&r2=67061&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Mon Mar 16 18:35:25 2009
@@ -638,9 +638,22 @@
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");
More information about the cfe-commits
mailing list