adamcz updated this revision to Diff 305752.
adamcz added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91625/new/

https://reviews.llvm.org/D91625

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/wchar_t.cpp


Index: clang/test/SemaCXX/wchar_t.cpp
===================================================================
--- clang/test/SemaCXX/wchar_t.cpp
+++ clang/test/SemaCXX/wchar_t.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar 
-verify=allow-signed %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar 
-verify=allow-signed -DSKIP_ERROR_TESTS %s
 // allow-signed-no-diagnostics
 wchar_t x;
 
@@ -32,3 +32,10 @@
 // rdar://8040728
 wchar_t in[] = L"\x434" "\x434";  // No warning
 
+#ifndef SKIP_ERROR_TESTS
+// Verify that we do not crash when assigning wchar_t* to another pointer type.
+void assignment(wchar_t *x) {
+  char *y;
+  y = x; // expected-error {{incompatible pointer types assigning to 'char *' 
from 'wchar_t *'}}
+}
+#endif
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8722,12 +8722,14 @@
     // "unsigned char" on systems where "char" is unsigned.
     if (lhptee->isCharType())
       ltrans = S.Context.UnsignedCharTy;
-    else if (lhptee->hasSignedIntegerRepresentation())
+    else if (!lhptee->isWideCharType() &&
+             lhptee->hasSignedIntegerRepresentation())
       ltrans = S.Context.getCorrespondingUnsignedType(ltrans);
 
     if (rhptee->isCharType())
       rtrans = S.Context.UnsignedCharTy;
-    else if (rhptee->hasSignedIntegerRepresentation())
+    else if (!rhptee->isWideCharType() &&
+             rhptee->hasSignedIntegerRepresentation())
       rtrans = S.Context.getCorrespondingUnsignedType(rtrans);
 
     if (ltrans == rtrans) {


Index: clang/test/SemaCXX/wchar_t.cpp
===================================================================
--- clang/test/SemaCXX/wchar_t.cpp
+++ clang/test/SemaCXX/wchar_t.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar -verify=allow-signed %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar -verify=allow-signed -DSKIP_ERROR_TESTS %s
 // allow-signed-no-diagnostics
 wchar_t x;
 
@@ -32,3 +32,10 @@
 // rdar://8040728
 wchar_t in[] = L"\x434" "\x434";  // No warning
 
+#ifndef SKIP_ERROR_TESTS
+// Verify that we do not crash when assigning wchar_t* to another pointer type.
+void assignment(wchar_t *x) {
+  char *y;
+  y = x; // expected-error {{incompatible pointer types assigning to 'char *' from 'wchar_t *'}}
+}
+#endif
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8722,12 +8722,14 @@
     // "unsigned char" on systems where "char" is unsigned.
     if (lhptee->isCharType())
       ltrans = S.Context.UnsignedCharTy;
-    else if (lhptee->hasSignedIntegerRepresentation())
+    else if (!lhptee->isWideCharType() &&
+             lhptee->hasSignedIntegerRepresentation())
       ltrans = S.Context.getCorrespondingUnsignedType(ltrans);
 
     if (rhptee->isCharType())
       rtrans = S.Context.UnsignedCharTy;
-    else if (rhptee->hasSignedIntegerRepresentation())
+    else if (!rhptee->isWideCharType() &&
+             rhptee->hasSignedIntegerRepresentation())
       rtrans = S.Context.getCorrespondingUnsignedType(rtrans);
 
     if (ltrans == rtrans) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to