[all-commits] [llvm/llvm-project] 2a41b3: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-point...
Nathan Chancellor via All-commits
all-commits at lists.llvm.org
Sat Mar 7 16:43:53 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 2a41b31fcdfcb67ab7038fc2ffb606fd50b83a84
https://github.com/llvm/llvm-project/commit/2a41b31fcdfcb67ab7038fc2ffb606fd50b83a84
Author: Nathan Chancellor <natechancellor at gmail.com>
Date: 2020-03-07 (Sat, 07 Mar 2020)
Changed paths:
M clang/include/clang/Basic/DiagnosticGroups.td
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/lib/Sema/SemaCast.cpp
M clang/test/Sema/cast.c
Log Message:
-----------
[Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast
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
certain structs contain a void pointer to avoid using a gigantic
union for all of the various types of driver data, such as
versions.
Add a diagnostic that allows certain projects like the kernel to
disable the warning just for enums, which allows those projects to
keep full compatibility with GCC but keeps the intention of treating
casts to integers and enumerators the same by default so that other
projects have the opportunity to catch issues not noticed before (or
follow suite and disable the warning).
Link: https://github.com/ClangBuiltLinux/linux/issues/887
Reviewed By: rjmccall
Differential Revision: https://reviews.llvm.org/D75758
More information about the All-commits
mailing list