]> granicus.if.org Git - clang/commitdiff
Fix for PR6220: compute the correct type for multicharacter literals.
authorEli Friedman <eli.friedman@gmail.com>
Wed, 3 Feb 2010 18:21:45 +0000 (18:21 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Wed, 3 Feb 2010 18:21:45 +0000 (18:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95228 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/CXX/lex/lex.literal/lex.ccon/p1.cpp [new file with mode: 0644]

index ec57a039a86ed52b5e5ce4c3e83a61da1a3f93dc..99714aee36114befbdfe9f3b81281175db0fc979 100644 (file)
@@ -1668,6 +1668,8 @@ Sema::OwningExprResult Sema::ActOnCharacterConstant(const Token &Tok) {
     Ty = Context.IntTy;   // 'x' and L'x' -> int in C.
   else if (Literal.isWide())
     Ty = Context.WCharTy; // L'x' -> wchar_t in C++.
+  else if (Literal.isMultiChar())
+    Ty = Context.IntTy;   // 'wxyz' -> int in C++.
   else
     Ty = Context.CharTy;  // 'x' -> char in C++
 
diff --git a/test/CXX/lex/lex.literal/lex.ccon/p1.cpp b/test/CXX/lex/lex.literal/lex.ccon/p1.cpp
new file mode 100644 (file)
index 0000000..7b65f7e
--- /dev/null
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check types of char literals
+extern char a;
+extern __typeof('a') a;
+extern int b;
+extern __typeof('asdf') b;
+extern wchar_t c;
+extern __typeof(L'a') c;