[PATCH] D19056: [MSVC] Fix check for wchar_t type in case of -fno-wchar

Dmitry Polukhin via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 13 05:16:35 PDT 2016


DmitryPolukhin created this revision.
DmitryPolukhin added a reviewer: rnk.
DmitryPolukhin added a subscriber: cfe-commits.

The example below should work identically with and without compiler native wchar_t support.

void foo(wchar_t * t = L"");

http://reviews.llvm.org/D19056

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/no-wchar.cpp

Index: test/SemaCXX/no-wchar.cpp
===================================================================
--- test/SemaCXX/no-wchar.cpp
+++ test/SemaCXX/no-wchar.cpp
@@ -7,3 +7,6 @@
 void bar() {
   foo(L"wide string literal");
 }
+
+void foo1(wchar_t * t = L"");
+// expected-warning at -1 {{conversion from string literal to 'wchar_t *' (aka 'unsigned short *') is deprecated}}
Index: lib/Sema/SemaExprCXX.cpp
===================================================================
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -3040,7 +3040,8 @@
               return (ToPointeeType->getKind() == BuiltinType::Char_U ||
                       ToPointeeType->getKind() == BuiltinType::Char_S);
             case StringLiteral::Wide:
-              return ToPointeeType->isWideCharType();
+              return Context.typesAreCompatible(Context.getWideCharType(),
+                                                QualType(ToPointeeType, 0));
           }
         }
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19056.53542.patch
Type: text/x-patch
Size: 980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160413/56640977/attachment.bin>


More information about the cfe-commits mailing list