]> granicus.if.org Git - clang/commitdiff
Fix for PR4502: add calculation of the integer conversion rank for
authorEli Friedman <eli.friedman@gmail.com>
Sun, 5 Jul 2009 23:44:27 +0000 (23:44 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sun, 5 Jul 2009 23:44:27 +0000 (23:44 +0000)
wchar_t.

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

lib/AST/ASTContext.cpp
test/SemaCXX/wchar_t.cpp

index 2877cc3b7fe77012f88ce22c7f3c6c2c43f47660..0075815300c3a9943fc3ed0e494e00fc8d40b619 100644 (file)
@@ -2245,6 +2245,9 @@ unsigned ASTContext::getIntegerRank(Type *T) {
   if (EnumType* ET = dyn_cast<EnumType>(T))
     T = ET->getDecl()->getIntegerType().getTypePtr();
 
+  if (T->isSpecificBuiltinType(BuiltinType::WChar))
+    T = getFromTargetType(Target.getWCharType()).getTypePtr();
+
   // There are two things which impact the integer rank: the width, and
   // the ordering of builtins.  The builtin ordering is encoded in the
   // bottom three bits; the width is encoded in the bits above that.
index fc258da7d1a6608c00017f5b391190d84f3f047d..cb85bc3ae729a09f7f699a3d06ec29f6fff9cdde 100644 (file)
@@ -7,3 +7,7 @@ void f(wchar_t p) {
   signed wchar_t z; // expected-warning {{'wchar_t' cannot be signed or unsigned}}
   ++x;
 }
+
+// PR4502
+wchar_t const c = L'c';
+int a[c == L'c' ? 1 : -1];