[PATCH] D75643: [Sema] Don't emit pointer to int cast warnings under -Wmicrosoft-cast
Arthur Eubanks via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 9 13:31:25 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG51d7f645448b: Don't emit pointer to int cast warnings under -Wmicrosoft-cast (authored by aeubanks).
Changed prior to commit:
https://reviews.llvm.org/D75643?vs=248306&id=249203#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75643/new/
https://reviews.llvm.org/D75643
Files:
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaCast.cpp
clang/test/Sema/MicrosoftExtensions.c
Index: clang/test/Sema/MicrosoftExtensions.c
===================================================================
--- clang/test/Sema/MicrosoftExtensions.c
+++ clang/test/Sema/MicrosoftExtensions.c
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions
-
+// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value -Wno-pointer-to-int-cast -Wmicrosoft -verify -fms-extensions
struct A
{
@@ -93,13 +92,13 @@
};
void pointer_to_integral_type_conv(char* ptr) {
- char ch = (char)ptr; // expected-warning{{cast to smaller integer type 'char' from 'char *' is a Microsoft extension}}
- short sh = (short)ptr; // expected-warning{{cast to smaller integer type 'short' from 'char *' is a Microsoft extension}}
- ch = (char)ptr; // expected-warning{{cast to smaller integer type 'char' from 'char *' is a Microsoft extension}}
- sh = (short)ptr; // expected-warning{{cast to smaller integer type 'short' from 'char *' is a Microsoft extension}}
+ char ch = (char)ptr;
+ short sh = (short)ptr;
+ ch = (char)ptr;
+ sh = (short)ptr;
- // This is valid ISO C.
- _Bool b = (_Bool)ptr;
+ // This is valid ISO C.
+ _Bool b = (_Bool)ptr;
}
typedef struct {
Index: clang/lib/Sema/SemaCast.cpp
===================================================================
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2778,9 +2778,7 @@
// is undefined. The result need not be in the range of values of any
// integer type.
unsigned Diag;
- if (Self.getLangOpts().MicrosoftExt)
- Diag = diag::ext_ms_pointer_to_int_cast;
- else if (SrcType->isVoidPointerType())
+ if (SrcType->isVoidPointerType())
Diag = DestType->isEnumeralType() ? diag::warn_void_pointer_to_enum_cast
: diag::warn_void_pointer_to_int_cast;
else if (DestType->isEnumeralType())
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3682,9 +3682,6 @@
def warn_void_pointer_to_enum_cast : Warning<
warn_void_pointer_to_int_cast.Text>,
InGroup<VoidPointerToEnumCast>;
-def ext_ms_pointer_to_int_cast : ExtWarn<
- "cast to smaller integer type %1 from %0 is a Microsoft extension">,
-InGroup<MicrosoftCast>;
def warn_attribute_ignored_for_field_of_type : Warning<
"%0 attribute ignored for field of type %1">,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75643.249203.patch
Type: text/x-patch
Size: 2584 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200309/b6d7e907/attachment.bin>
More information about the cfe-commits
mailing list