From ef24b38d9c5159230669ec359f7909dd65ae321f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 1 Mar 2008 08:32:21 +0000 Subject: [PATCH] character literals have char type in C++ and int type in C. Patch by Nuno Lopes for PR2089 llvm-svn: 47787 --- clang/Sema/SemaExpr.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp index a82d0ad7e548..72bedab464f9 100644 --- a/clang/Sema/SemaExpr.cpp +++ b/clang/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) {