summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-30 21:19:39 +0000
committerChris Lattner <sabre@nondot.org>2009-12-30 21:19:39 +0000
commitc3847ba3fa6e751759df859a07b5e013b0ab3da0 (patch)
tree94d3570ec689e844211f5099afe9bc3666541ead /clang/lib
parent92368a15f993936de684d5d25717220733708cf9 (diff)
downloadbcm5719-llvm-c3847ba3fa6e751759df859a07b5e013b0ab3da0.tar.gz
bcm5719-llvm-c3847ba3fa6e751759df859a07b5e013b0ab3da0.zip
fix PR5917, L'x' was getting the wrong type in c++ mode. Per
C++2.13.2p2: "A wide-character literal has type wchar_t" llvm-svn: 92313
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 6438faea0a0..77ddbc29dda 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1541,11 +1541,17 @@ Sema::OwningExprResult Sema::ActOnCharacterConstant(const Token &Tok) {
if (Literal.hadError())
return ExprError();
- QualType type = getLangOptions().CPlusPlus ? Context.CharTy : Context.IntTy;
+ QualType Ty;
+ if (!getLangOptions().CPlusPlus)
+ Ty = Context.IntTy; // 'x' and L'x' -> int in C.
+ else if (Literal.isWide())
+ Ty = Context.WCharTy; // L'x' -> wchar_t in C++.
+ else
+ Ty = Context.CharTy; // 'x' -> char in C++
return Owned(new (Context) CharacterLiteral(Literal.getValue(),
Literal.isWide(),
- type, Tok.getLocation()));
+ Ty, Tok.getLocation()));
}
Action::OwningExprResult Sema::ActOnNumericConstant(const Token &Tok) {
OpenPOWER on IntegriCloud