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@-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));
           }
         }
       }


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@-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));
           }
         }
       }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to