[PATCH] D75758: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast

2020-03-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments. Comment at: clang/lib/Sema/SemaCast.cpp:2783 +Diag = diag::ext_ms_pointer_to_int_cast; + else if (SrcType->isVoidPointerType()) +if (DestType->isEnumeralType()) A ternary operator is better here. I'll fix it.

[PATCH] D75758: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast

2020-03-07 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rG2a41b31fcdfc: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast (authored by nathanchance, committed by MaskRay). Changed prior to commit: https://reviews.llvm.org/D75758?vs=248824&id=24

[PATCH] D75758: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast

2020-03-07 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance marked an inline comment as done. nathanchance added a comment. Thanks for the review and accepting. I do not have commit rights, would you mind doing that on my behalf? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75758/new/ https:/

[PATCH] D75758: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast

2020-03-06 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance marked 2 inline comments as done. nathanchance added inline comments. Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3673 +def warn_pointer_to_enum_cast : Warning< + "cast to smaller integer type %1 from %0">, + InGroup; xbolva00 wrot

[PATCH] D75758: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast

2020-03-06 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance updated this revision to Diff 248824. nathanchance edited the summary of this revision. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75758/new/ https://reviews.llvm.org/D75758 Files: clang/include/clang/Basic/DiagnosticGroups.td cl

[PATCH] D75758: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast

2020-03-06 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments. Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3673 +def warn_pointer_to_enum_cast : Warning< + "cast to smaller integer type %1 from %0">, + InGroup; You can reuse warning text: warn_pointer_to_int_cast.Text I th

[PATCH] D75758: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast

2020-03-06 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment. Thanks, Verified that this fixes the kernel warnings in my local builds with https://gist.github.com/nathanchance/767cccf4d093c1342e1994083518815e! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75758/new/ https://review

[PATCH] D75758: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast

2020-03-06 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance created this revision. nathanchance added reviewers: Mordante, rjmccall. Herald added a project: clang. GCC does not warn on casts from pointers to enumerators, while clang currently does: https://godbolt.org/z/3DFDVG This causes a bunch of extra warnings in the Linux kernel, where c