diff options
| author | Seth Cantrell <seth.cantrell@gmail.com> | 2012-01-18 12:27:06 +0000 |
|---|---|---|
| committer | Seth Cantrell <seth.cantrell@gmail.com> | 2012-01-18 12:27:06 +0000 |
| commit | 02f860597419783c06c0e1405c1ea080a4b3366d (patch) | |
| tree | 691b24fd0cbe2cf0faa2ba5b59b5f97712221149 | |
| parent | 8b2b677f390d5181be4b99421dad4b418aa88e5f (diff) | |
| download | bcm5719-llvm-02f860597419783c06c0e1405c1ea080a4b3366d.tar.gz bcm5719-llvm-02f860597419783c06c0e1405c1ea080a4b3366d.zip | |
Fix char literal types in C
L'x' is actually wchar_t
support C11 u and U char literals
llvm-svn: 148390
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 119151a3af7..662971f7dec 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -2569,16 +2569,14 @@ ExprResult Sema::ActOnCharacterConstant(const Token &Tok) { return ExprError(); 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++. + if (Literal.isWide()) + Ty = Context.WCharTy; // L'x' -> wchar_t in C and C++. 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()) - Ty = Context.Char32Ty; // U'x' -> char32_t in C++0x. - else if (Literal.isMultiChar()) - Ty = Context.IntTy; // 'wxyz' -> int in C++. + Ty = Context.Char32Ty; // U'x' -> char32_t in C11 and C++11. + else if (!getLangOptions().CPlusPlus || Literal.isMultiChar()) + Ty = Context.IntTy; // 'x' -> int in C, 'wxyz' -> int in C++. else Ty = Context.CharTy; // 'x' -> char in C++ |

