From: Eli Friedman Date: Wed, 3 Feb 2010 18:21:45 +0000 (+0000) Subject: Fix for PR6220: compute the correct type for multicharacter literals. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=136b0cd75c37895ed0e00dee5b06c55c5b1d8199;p=clang Fix for PR6220: compute the correct type for multicharacter literals. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95228 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index ec57a039a8..99714aee36 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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 index 0000000000..7b65f7ee83 --- /dev/null +++ b/test/CXX/lex/lex.literal/lex.ccon/p1.cpp @@ -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;