]> granicus.if.org Git - clang/commitdiff
Fix char literal types in C
authorSeth Cantrell <seth.cantrell@gmail.com>
Wed, 18 Jan 2012 12:27:06 +0000 (12:27 +0000)
committerSeth Cantrell <seth.cantrell@gmail.com>
Wed, 18 Jan 2012 12:27:06 +0000 (12:27 +0000)
L'x' is actually wchar_t

support C11 u and U char literals

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

lib/Sema/SemaExpr.cpp

index 119151a3af7857e2e940b6c19bec957d19d97970..662971f7decab7df82713791f5d11c0f11a1fd0e 100644 (file)
@@ -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++