]> granicus.if.org Git - clang/commitdiff
character literals have char type in C++ and int type in C. Patch
authorChris Lattner <sabre@nondot.org>
Sat, 1 Mar 2008 08:32:21 +0000 (08:32 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 1 Mar 2008 08:32:21 +0000 (08:32 +0000)
by Nuno Lopes for PR2089

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47787 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaExpr.cpp

index a82d0ad7e548ba223b295c322e5e92f1040e4b64..72bedab464f9d3379a943a845cf2d6069fc772c1 100644 (file)
@@ -157,8 +157,10 @@ Sema::ExprResult Sema::ActOnCharacterConstant(const Token &Tok) {
                             Tok.getLocation(), PP);
   if (Literal.hadError())
     return ExprResult(true);
-  return new CharacterLiteral(Literal.getValue(), Context.IntTy, 
-                              Tok.getLocation());
+
+  QualType type = getLangOptions().CPlusPlus ? Context.CharTy : Context.IntTy;
+
+  return new CharacterLiteral(Literal.getValue(), type, Tok.getLocation());
 }
 
 Action::ExprResult Sema::ActOnNumericConstant(const Token &Tok) {