[cfe-commits] r130620 - in /cfe/trunk: lib/AST/ASTContext.cpp test/SemaCXX/short-wchar-sign.cpp

Eli Friedman eli.friedman at gmail.com
Sat Apr 30 12:24:24 PDT 2011


Author: efriedma
Date: Sat Apr 30 14:24:24 2011
New Revision: 130620

URL: http://llvm.org/viewvc/llvm-project?rev=130620&view=rev
Log:
PR9792: Make sure to use the right definition of wchar_t when the default
wchar_t is an unsigned type.


Added:
    cfe/trunk/test/SemaCXX/short-wchar-sign.cpp
Modified:
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=130620&r1=130619&r2=130620&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Apr 30 14:24:24 2011
@@ -375,7 +375,7 @@
   InitBuiltinType(UnsignedInt128Ty,    BuiltinType::UInt128);
 
   if (LangOpts.CPlusPlus) { // C++ 3.9.1p5
-    if (!LangOpts.ShortWChar)
+    if (TargetInfo::isTypeSigned(Target.getWCharType()))
       InitBuiltinType(WCharTy,           BuiltinType::WChar_S);
     else  // -fshort-wchar makes wchar_t be unsigned.
       InitBuiltinType(WCharTy,           BuiltinType::WChar_U);

Added: cfe/trunk/test/SemaCXX/short-wchar-sign.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/short-wchar-sign.cpp?rev=130620&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/short-wchar-sign.cpp (added)
+++ cfe/trunk/test/SemaCXX/short-wchar-sign.cpp Sat Apr 30 14:24:24 2011
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -fshort-wchar -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -pedantic -verify %s
+
+// Check that short wchar_t is unsigned, and that regular wchar_t is not.
+int test[(wchar_t(-1)<wchar_t(0)) == (sizeof(wchar_t) == 4) ?1:-1];





More information about the cfe-commits mailing list