From a34267595534a72703290153a6f7e3da1adcec59 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sun, 5 Jul 2009 23:44:27 +0000 Subject: [PATCH] Fix for PR4502: add calculation of the integer conversion rank for wchar_t. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74808 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTContext.cpp | 3 +++ test/SemaCXX/wchar_t.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 2877cc3b7f..0075815300 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -2245,6 +2245,9 @@ unsigned ASTContext::getIntegerRank(Type *T) { if (EnumType* ET = dyn_cast(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. diff --git a/test/SemaCXX/wchar_t.cpp b/test/SemaCXX/wchar_t.cpp index fc258da7d1..cb85bc3ae7 100644 --- a/test/SemaCXX/wchar_t.cpp +++ b/test/SemaCXX/wchar_t.cpp @@ -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]; -- 2.40.0