Fix char literal types in C

L'x' is actually wchar_t

support C11 u and U char literals

llvm-svn: 148390
This commit is contained in:
Seth Cantrell 2012-01-18 12:27:06 +00:00
parent 8b2b677f39
commit 02f8605974
1 changed files with 6 additions and 8 deletions

View File

@ -2569,16 +2569,14 @@ ExprResult Sema::ActOnCharacterConstant(const Token &Tok) {
return ExprError(); return ExprError();
QualType Ty; QualType Ty;
if (!getLangOptions().CPlusPlus) if (Literal.isWide())
Ty = Context.IntTy; // 'x' and L'x' -> int in C. Ty = Context.WCharTy; // L'x' -> wchar_t in C and C++.
else if (Literal.isWide())
Ty = Context.WCharTy; // L'x' -> wchar_t in C++.
else if (Literal.isUTF16()) else if (Literal.isUTF16())
Ty = Context.Char16Ty; // u'x' -> char16_t in C++0x. Ty = Context.Char16Ty; // u'x' -> char16_t in C11 and C++11.
else if (Literal.isUTF32()) else if (Literal.isUTF32())
Ty = Context.Char32Ty; // U'x' -> char32_t in C++0x. Ty = Context.Char32Ty; // U'x' -> char32_t in C11 and C++11.
else if (Literal.isMultiChar()) else if (!getLangOptions().CPlusPlus || Literal.isMultiChar())
Ty = Context.IntTy; // 'wxyz' -> int in C++. Ty = Context.IntTy; // 'x' -> int in C, 'wxyz' -> int in C++.
else else
Ty = Context.CharTy; // 'x' -> char in C++ Ty = Context.CharTy; // 'x' -> char in C++