From: Chris Lattner Date: Sat, 1 Mar 2008 08:32:21 +0000 (+0000) Subject: character literals have char type in C++ and int type in C. Patch X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fc62bfd41c73c6bc555b5e37f9e25dff256e72ab;p=clang character literals have char type in C++ and int type in C. Patch by Nuno Lopes for PR2089 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47787 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index a82d0ad7e5..72bedab464 100644 --- a/Sema/SemaExpr.cpp +++ b/Sema/SemaExpr.cpp @@ -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) {